Salome HOME
1) remove required size calculations for each product: just read its from XML and...
[tools/install.git] / src / SALOME_InstallWizard.cxx
index 1a495012824b5a843bc2af9b956ff183b4026673..bc84ab480f6a59910c30729ba3c421b6a9ab81e1 100644 (file)
@@ -511,10 +511,10 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
   addLogo( pixmap( pxLogo ) );
 
   // set defaults
-  setVersion( "3.2.6" );
+  setVersion( "3.2.7" );
   setCaption( tr( "SALOME %1" ).arg( myVersion ) );
   setCopyright( tr( "Copyright (C) 2007 CEA" ) );
-  setLicense( tr( "All right reserved" ) );
+  setLicense( tr( "All rights reserved." ) );
 
   ___MESSAGE___( "Configuration file : " << xmlFileName.latin1() );
   ___MESSAGE___( "Target directory   : " << myTargetPath.latin1() );
@@ -907,10 +907,11 @@ void SALOME_InstallWizard::setupTypePage()
   QLabel* srcCompileLab3 = new QLabel( " " + 
                                       tr( "it is a long time operation and it can take more than 24 hours depending\n on the computer." ), 
                                       buttonGrp );
-  removeSrcBtn = new QMyCheckBox( tr( "Remove sources and temporary files after compilation" ), typePage );
+  removeSrcBtn = new QCheckBox( tr( "Remove sources and temporary files after compilation" ), typePage );
   setAboutInfo( removeSrcBtn, tr( "Check this option if you want to remove sources of the products\nwith all the temporary files after build finishing" ) );
-  removeSrcBtn->setState( QButton::Off );
+  removeSrcBtn->setChecked( false );
   removeSrcBtn->setEnabled( false );
+  rmSrcPrevState = removeSrcBtn->isChecked();
 
   srcCompileLayout->addMultiCellWidget( srcCompileBtn,  0, 0, 0, 2 );
   srcCompileLayout->addMultiCell      ( spacer6,        1, 2, 0, 0 );
@@ -930,7 +931,6 @@ void SALOME_InstallWizard::setupTypePage()
   pageLayout->addWidget( buttonGrp, 0, 0 );
   // connecting signals
   connect( buttonGrp, SIGNAL( clicked(int) ), this, SLOT ( onButtonGroup(int) ) );
-  connect( removeSrcBtn,  SIGNAL( toggled( bool ) ), this, SLOT( onRemoveSrcBtn() ) );
   // adding page
   addPage( typePage, tr( "Installation type" ) );
 }
@@ -1323,11 +1323,6 @@ void SALOME_InstallWizard::showChoiceInfo()
   item = (QCheckListItem*)( prereqsView->firstChild() );
   while( item ) {
     if ( productsMap.contains( item ) ) {
-      if ( productsMap[ item ].hasType( "salome sources" ) || 
-          productsMap[ item ].hasType( "salome binaries" ) ) {
-       item = (QCheckListItem*)( item->nextSibling() );
-       continue; // skip SALOME sources and binaries
-      }
       if ( item->isOn() ) {
        text += "<li><b>" + item->text() + " " + productsMap[ item ].getVersion() + "</b><br>";
        nbProd++;
@@ -1493,7 +1488,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
     // ########## check if any products are selected to be installed
     long totSize, tempSize;
     bool anySelected = checkSize( &totSize, &tempSize );
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On ) {
+    if ( installType == Compile && removeSrcBtn->isOn() ) {
       totSize += tempSize;
     }
     if ( !anySelected ) {
@@ -1626,17 +1621,14 @@ bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
     Dependancies dep = mapIter.data();
     if ( !item->isOn() )
       continue;
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
-      tots += dep.getSize( Binaries );
-    else
-      tots += dep.getSize( installType );
+    tots += ( QStringList::split( " ", item->text(1) )[0] ).toLong();
     maxSrcTmp = max( maxSrcTmp, dep.getSize( Compile ) - dep.getSize( Binaries ) );
     temps += dep.getTempSize( installType );
     nbSelected++;
   }
 
   if ( totSize )
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
+    if ( installType == Compile && removeSrcBtn->isOn() )
       temps += maxSrcTmp;
     *totSize = tots;
   if ( tempSize )
@@ -1662,19 +1654,18 @@ void SALOME_InstallWizard::updateAvailableSpace()
 // ================================================================
 void SALOME_InstallWizard::checkFLibResult()
 {
-  cout << "RESULT is " << checkFLibProc->exitStatus() << endl;
   if ( checkFLibProc->normalExit() && checkFLibProc->exitStatus() == 1 ) {
-    cout << "Some libs are absent" << endl;
-    QString notFoundLibs;
+    QStringList notFoundLibsList;
+    QString record = "";
     while ( checkFLibProc->canReadLineStdout() ) {
-      notFoundLibs.append( checkFLibProc->readLineStdout() );
-      if ( checkFLibProc->canReadLineStdout() )
-       notFoundLibs.append( "\n" );
+      record = checkFLibProc->readLineStdout();
+      if ( !record.isEmpty() && !notFoundLibsList.contains( record ) )
+       notFoundLibsList.append( record );
     }
     QMessageBox::warning( this,
                          tr( "Warning" ),
                          tr( "The following libraries are absent on current system:\n"
-                         "%1").arg( notFoundLibs ),
+                         "%1").arg( notFoundLibsList.join( "\n" ) ),
                          QMessageBox::Ok,
                          QMessageBox::NoButton,
                          QMessageBox::NoButton );
@@ -1683,6 +1674,44 @@ void SALOME_InstallWizard::checkFLibResult()
   completeInstallation();
 }
 // ================================================================
+/*!
+ *  SALOME_InstallWizard::updateSizeColumn
+ *  Sets required size for each product according to 
+ *  installation type and 'Remove SRC & TMP' checkbox state
+ */
+// ================================================================
+void SALOME_InstallWizard::updateSizeColumn()
+{
+  long prodSize = 0;
+  bool removeSrc = removeSrcBtn->isChecked();
+  MapProducts::Iterator mapIter;
+  for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
+    QCheckListItem* item = mapIter.key();
+    Dependancies dep = mapIter.data();
+    // get required size for current product
+    long binSize = dep.getSize( Binaries );
+    long srcSize = dep.getSize( Sources );
+    long bldSize = dep.getSize( Compile );
+    InstallationType instType = getInstType();
+    if ( instType == Binaries ) {
+      if ( dep.getType() == "component" )
+       prodSize = binSize + srcSize;
+      else
+       prodSize = ( binSize != 0 ? binSize : srcSize );
+    }
+    else if ( instType == Sources )
+      prodSize = srcSize;
+    else
+      if ( removeSrc )
+       prodSize = ( binSize != 0 ? binSize : srcSize );
+      else {
+       prodSize = ( bldSize != 0 ? bldSize : srcSize );
+      }
+    // fill in 'Size' field
+    item->setText( 1, QString::number( prodSize )+" KB" );
+  }
+}
+// ================================================================
 /*!
  *  SALOME_InstallWizard::checkProductPage
  *  Checks products page validity (directories and products selection) and
@@ -1793,7 +1822,6 @@ void SALOME_InstallWizard::unsetPrerequisites( QCheckListItem* item )
        if ( itProd1.data().getType() == "prerequisite" ) {
          MapProducts::Iterator itProd2;
          for ( itProd2 = productsMap.begin(); itProd2 != productsMap.end(); ++itProd2 ) {
-           //      if ( itProd2.data().getType() == "component" ) {
            if ( itProd2.key()->isOn() ) {
              QStringList prereqsList = productsMap[ itProd2.key() ].getDependancies();
              for ( int k = 0; k < (int)prereqsList.count(); k++ ) {
@@ -1902,7 +1930,7 @@ void SALOME_InstallWizard::launchScript()
     // ... sources directory
     shellProcess->addArgument( QDir::cleanDirPath( getSrcPath() ) );
     // ... remove sources and tmp files or not?
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
+    if ( installType == Compile && removeSrcBtn->isOn() )
       shellProcess->addArgument( "TRUE" );
     else 
       shellProcess->addArgument( "FALSE" );
@@ -2023,7 +2051,8 @@ void SALOME_InstallWizard::onInstallGuiBtn()
       }
       else {
        QString itemName = itProd.data().getName();
-       if ( itemName != "KERNEL" && itemName != "MED" && itemName != "SAMPLES" ) {
+       if ( itemName != "KERNEL" && itemName != "MED" && 
+            itemName != "SAMPLES" && itemName != "DOCUMENTATION" ) {
          itProd.key()->setOn( false );
          itProd.key()->setEnabled( false );
        }
@@ -2232,7 +2261,7 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
     if ( buttonGrp->id( buttonGrp->selected() ) == -1 )
       binBtn->animateClick(); // set default installation type
   }
-  if ( aPage == platformsPage ) {
+  else if ( aPage == platformsPage ) {
     // installation platforms page
     MapXmlFiles::Iterator it;
     if ( previousPage == typePage ) {
@@ -2269,6 +2298,8 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
       if ( tempFolder->text().isEmpty() )
        parser->setTempDir( tempFolder );
       parser->readXmlFile( xmlFileName );
+      // update required size for each product
+      updateSizeColumn();
       // take into account command line parameters
       if ( !myTargetPath.isEmpty() )
        targetFolder->setText( myTargetPath );
@@ -2280,6 +2311,11 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
       if ( modulesView->childCount() > 0 && !modulesView->selectedItem() )
        modulesView->setSelected( modulesView->firstChild(), true );
       stateChanged = false;
+    } 
+    else if ( rmSrcPrevState != removeSrcBtn->isChecked() ) {
+      // only update required size for each product
+      updateSizeColumn();
+      rmSrcPrevState = removeSrcBtn->isChecked();
     }
   }
   else if ( aPage == productsPage ) {
@@ -2352,7 +2388,7 @@ void SALOME_InstallWizard::onButtonGroup( int rbIndex )
   else if ( aPage == platformsPage ) {
     refPlatform = platBtnGrp->find( rbIndex )->name();
     xmlFileName = platformsMap[ refPlatform ];
-    cout << xmlFileName << endl;
+//     cout << xmlFileName << endl;
     setNextEnabled( platformsPage, true );
   }
   if ( prevType != installType || 
@@ -2425,7 +2461,6 @@ void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
 // ================================================================
 void SALOME_InstallWizard::onStart()
 {
-  cout << "" << endl;
   if ( nextButton()->text() == tr( "&Stop" ) ) {
     statusLab->setText( tr( "Aborting installation..." ) );
     shellProcess->kill();
@@ -2477,6 +2512,7 @@ void SALOME_InstallWizard::onStart()
       statusLab->setText( tr( "Check Fortran compiler..." ) );
       // check Fortran compiler.
       QString script = "./config_files/checkFortran.sh find_compilers";
+      script += " " + QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() );
       ___MESSAGE___( "script = " << script.latin1() );
       if ( system( script ) ) {
        QMessageBox::critical( this,
@@ -2694,6 +2730,7 @@ void SALOME_InstallWizard::onCancel()
 /*!
  *  SALOME_InstallWizard::onSelectionChanged
  *  Called when selection is changed in the products list view
+ *  to fill in the 'Information about product' text box
  */
 // ================================================================
 void SALOME_InstallWizard::onSelectionChanged()
@@ -2702,11 +2739,9 @@ void SALOME_InstallWizard::onSelectionChanged()
   QListViewItem* item = modulesView->selectedItem();
   if ( snd == prereqsView )
     item = prereqsView->selectedItem();
-  else if ( snd != modulesView )
-    return;
-  productInfo->clear();
   if ( !item )
     return;
+  productInfo->clear();
   QCheckListItem* anItem = (QCheckListItem*)item;
   if ( !productsMap.contains( anItem ) )
     return;
@@ -2718,14 +2753,13 @@ void SALOME_InstallWizard::onSelectionChanged()
   if ( !dep.getDescription().isEmpty() ) {
     text += "<i>" + dep.getDescription() + "</i><br><br>";
   }
-  long totSize = 0, tempSize = 0;
-  if ( installType == Compile && removeSrcBtn->state() == QButton::On )
-    totSize = dep.getSize( Binaries );
-  else
-    totSize = dep.getSize( installType );
-  tempSize = dep.getTempSize( installType );
-  text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " KB<br>";
-  text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " KB<br>";
+  /* AKL: 07/08/28 - hide required disk space for tmp files for each product ==>
+     long tempSize = 0;
+     tempSize = dep.getTempSize( installType );
+     text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " KB<br>";
+     AKL: 07/08/28 - hide required disk space for tmp files for each product <==
+  */
+  text += tr( "Disk space required" ) + ": " + item->text(1) + "<br>";
   text += "<br>";
   QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
   text +=  tr( "Prerequisites" ) + ": " + req;