From 98c66abee3122ee6245e82844ae00640cf76c4db Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 25 Dec 2006 14:01:49 +0000 Subject: [PATCH] Implement features: - install and build SALOME module sources - install all products from sources --- src/SALOME_InstallWizard.cxx | 522 ++++++++++++++++++++++------------- src/SALOME_InstallWizard.hxx | 8 + src/SALOME_ProductsView.cxx | 41 ++- src/SALOME_ProductsView.hxx | 6 + src/globals.h | 2 +- 5 files changed, 382 insertions(+), 197 deletions(-) diff --git a/src/SALOME_InstallWizard.cxx b/src/SALOME_InstallWizard.cxx index acedde5..b61eb70 100644 --- a/src/SALOME_InstallWizard.cxx +++ b/src/SALOME_InstallWizard.cxx @@ -1,4 +1,4 @@ -// File : SALOME_InstallWizard.cxx +// File : SALOME_InstallWizard.cxx // Created : Thu Dec 18 12:01:00 2002 // Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com) // Project : SALOME @@ -25,13 +25,13 @@ #include #include #include -#include +#include #include -#include -#include -#include +#include +#include +#include #include -#include +#include #include #include #include @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef WNT #include @@ -80,7 +81,7 @@ public: virtual void run() { while ( hasCommands() ) { ___MESSAGE___( "ProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() ); - int result = system( myCommands[ 0 ] ) / 256; // return code is * 256 + int result = system( myCommands[ 0 ] ) / 256; // return code is * 256 ___MESSAGE___( "ProcessThread::run - Result : " << result ); QCheckListItem* item = myItems.first(); myCommands.pop_front(); @@ -110,23 +111,23 @@ class WarnDialog: public QDialog static WarnDialog* myDlg; bool myCloseFlag; - WarnDialog( QWidget* parent ) + WarnDialog( QWidget* parent ) : QDialog( parent, "WarnDialog", true, WDestructiveClose ) { setCaption( tr( "Information" ) ); myCloseFlag = false; QLabel* lab = new QLabel( tr( "Please, wait while checking native products configuration ..." ), this ); lab->setAlignment( AlignCenter ); - lab->setFrameStyle( QFrame::Box | QFrame::Plain ); + lab->setFrameStyle( QFrame::Box | QFrame::Plain ); QVBoxLayout* l = new QVBoxLayout( this ); l->setMargin( 0 ); l->add( lab ); - this->setFixedSize( lab->sizeHint().width() + 50, + this->setFixedSize( lab->sizeHint().width() + 50, lab->sizeHint().height() * 5 ); } void accept() { return; } void reject() { return; } void closeEvent( QCloseEvent* e ) - { if ( !myCloseFlag ) return; + { if ( !myCloseFlag ) return; e->accept(); QDialog::closeEvent( e ); } @@ -137,7 +138,7 @@ public: if ( !myDlg ) { myDlg = new WarnDialog( parent ); QSize sh = myDlg->size(); - myDlg->move( parent->x() + (parent->width()-sh.width())/2, + myDlg->move( parent->x() + (parent->width()-sh.width())/2, parent->y() + (parent->height()-sh.height())/2 ); myDlg->show(); } @@ -203,7 +204,7 @@ private: * Defines list of dependancies as string separated by space symbols */ // ================================================================ -static QString DefineDependeces(MapProducts& theProductsMap) +static QString DefineDependeces(MapProducts& theProductsMap) { QStringList aProducts; for ( MapProducts::Iterator mapIter = theProductsMap.begin(); mapIter != theProductsMap.end(); ++mapIter ) { @@ -223,7 +224,7 @@ static QString DefineDependeces(MapProducts& theProductsMap) #define QUOTE(arg) QString("'") + QString(arg) + QString("'") /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - T H E O L D I M P L E M E N T A T I O N + T H E O L D I M P L E M E N T A T I O N static QString DefineDependeces(MapProducts& theProductsMap, QCheckListItem* product ){ QStringList aProducts; if ( theProductsMap.contains( product ) ) { @@ -450,10 +451,10 @@ public: SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, const QString& aTargetDir, const QString& aTmpDir) - : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ), - helpWindow( NULL ), - moreMode( false ), - previousPage( 0 ), + : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ), + helpWindow( NULL ), + moreMode( false ), + previousPage( 0 ), exitConfirmed( false ) { myIWName = tr( "Installation Wizard" ); @@ -472,10 +473,10 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, setIcon( pixmap( pxIcon ) ); // enable sizegrip setSizeGripEnabled( true ); - + // add logo addLogo( pixmap( pxLogo ) ); - + // set defaults setVersion( "1.2" ); setCaption( tr( "PAL/SALOME %1" ).arg( myVersion ) ); @@ -483,9 +484,9 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, setLicense( tr( "All right reserved" ) ); setOS( "" ); - ___MESSAGE___( "Configuration file : " << xmlFileName ); - ___MESSAGE___( "Target directory : " << targetDirPath ); - ___MESSAGE___( "Temporary directory: " << tmpDirPath ); + ___MESSAGE___( "Configuration file : " << xmlFileName.latin1() ); + ___MESSAGE___( "Target directory : " << targetDirPath.latin1() ); + ___MESSAGE___( "Temporary directory: " << tmpDirPath.latin1() ); // xml reader QFile xmlfile(xmlFileName); @@ -495,7 +496,7 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, StructureParser* handler = new StructureParser( this ); reader.setContentHandler( handler ); - reader.parse( source ); + reader.parse( source ); } // create instance of class for starting shell install script @@ -511,7 +512,7 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, setupProgressPage(); // create readme page setupReadmePage(); - + // common buttons QWhatsThis::add( backButton(), tr( "Returns to the previous step of the installation procedure" ) ); QToolTip::add ( backButton(), tr( "Returns to the previous step of the installation procedure" ) ); @@ -523,7 +524,7 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, QToolTip::add ( cancelButton(), tr( "Cancels installation and quits program" ) ); QWhatsThis::add( helpButton(), tr( "Displays help information window" ) ); QToolTip::add ( helpButton(), tr( "Displays help information window" ) ); - + // common signals connections connect( this, SIGNAL( selected( const QString& ) ), this, SLOT( pageChanged( const QString& ) ) ); @@ -558,7 +559,7 @@ SALOME_InstallWizard::~SALOME_InstallWizard() script += QString::number( PID ); script += " > /dev/null"; ___MESSAGE___( "script: " << script.latin1() ); - if ( system( script.latin1() ) ) { + if ( system( script.latin1() ) ) { } } delete myThread; @@ -588,10 +589,10 @@ void SALOME_InstallWizard::closeEvent( QCloseEvent* ce ) return; } if ( !exitConfirmed ) { - if ( QMessageBox::information( this, - tr( "Exit" ), - tr( "Do you want to quit %1?" ).arg( getIWName() ), - tr( "&Yes" ), + if ( QMessageBox::information( this, + tr( "Exit" ), + tr( "Do you want to quit %1?" ).arg( getIWName() ), + tr( "&Yes" ), tr( "&No" ), QString::null, 0, @@ -615,7 +616,7 @@ void SALOME_InstallWizard::setupIntroPage() { // create page introPage = new QWidget( this, "IntroPage" ); - QGridLayout* pageLayout = new QGridLayout( introPage ); + QGridLayout* pageLayout = new QGridLayout( introPage ); pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 ); // create logo picture logoLab = new QLabel( introPage ); @@ -669,7 +670,7 @@ void SALOME_InstallWizard::setupProductsPage() { // create page productsPage = new QWidget( this, "ProductsPage" ); - QGridLayout* pageLayout = new QGridLayout( productsPage ); + QGridLayout* pageLayout = new QGridLayout( productsPage ); pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 ); // target directory QLabel* targetLab = new QLabel( tr( "Type the target directory:" ), productsPage ); @@ -735,22 +736,28 @@ void SALOME_InstallWizard::setupProductsPage() QWhatsThis::add( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) ); QToolTip::add ( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) ); // button - unselectBtn = new QPushButton( tr( "&Unselect All" ), moreBox ); + unselectBtn = new QPushButton( tr( "&Unselect All" ), moreBox ); QWhatsThis::add( unselectBtn, tr( "Unselects all products" ) ); QToolTip::add ( unselectBtn, tr( "Unselects all products" ) ); // / tri-state checkboxes - selectSrcBtn = new QMyCheckBox( tr( "SALOME sources" ), moreBox ); - selectSrcBtn->setTristate( true ); - QWhatsThis::add( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) ); - QToolTip::add ( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) ); - selectBinBtn = new QMyCheckBox( tr( "SALOME binaries" ), moreBox ); + selectBinBtn = new QMyCheckBox( tr( "SALOME binaries" ), moreBox ); selectBinBtn->setTristate( true ); QWhatsThis::add( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) ); QToolTip::add ( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) ); - QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); - btnLayout->addWidget( unselectBtn ); - btnLayout->addWidget( selectSrcBtn ); - btnLayout->addWidget( selectBinBtn ); + selectSrcBtn = new QMyCheckBox( tr( "SALOME sources" ), moreBox ); + selectSrcBtn->setTristate( true ); + QWhatsThis::add( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) ); + QToolTip::add ( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) ); + buildSrcBtn = new QMyCheckBox( tr( "Build SALOME sources" ), moreBox ); + QWhatsThis::add( buildSrcBtn, tr( "Check this box if you want to build selected SALOME sources after the installation" ) ); + QToolTip::add ( buildSrcBtn, tr( "Check this box if you want to build selected SALOME sources after the installation" ) ); + QGridLayout* btnLayout = new QGridLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); + btnLayout->addMultiCellWidget( unselectBtn, 0, 0, 0, 1 ); + btnLayout->addMultiCellWidget( selectBinBtn, 1, 1, 0, 1 ); + btnLayout->addMultiCellWidget( selectSrcBtn, 2, 2, 0, 1 ); + btnLayout->addWidget( buildSrcBtn, 3, 1 ); + btnLayout->setColSpacing( 0, 20 ); + btnLayout->setColStretch( 1, 10 ); // layouting advancet mode widgets moreBoxLayout->addMultiCellWidget( tempLab, 0, 0, 0, 2 ); moreBoxLayout->addMultiCellWidget( tempFolder, 1, 1, 0, 1 ); @@ -760,6 +767,15 @@ void SALOME_InstallWizard::setupProductsPage() moreBoxLayout->addMultiCellWidget( prerequisites,3, 3, 1, 2 ); moreBoxLayout->addMultiCellLayout( btnLayout, 4, 4, 1, 2 ); moreBoxLayout->addMultiCellLayout( sizeLayout, 5, 5, 1, 2 ); + // box + lessBox = new QWidget( productsPage ); + QGridLayout* lessBoxLayout = new QGridLayout( lessBox ); + lessBoxLayout->setMargin( 0 ); lessBoxLayout->setSpacing( 6 ); + // check box + allFromSrcBtn = new QMyCheckBox( tr( "Install all products from sources" ), lessBox ); + lessBoxLayout->addWidget( allFromSrcBtn, 0, 0 ); + lessBoxLayout->setRowStretch( 1, 10 ); + //lessBoxLayout->addItem( new QSpacerItem( 10,10, QSizePolicy::Minimum, QSizePolicy ), 1, 1 ); // button moreBtn = new QPushButton( tr( "More..." ), productsPage ); // layouting @@ -767,8 +783,10 @@ void SALOME_InstallWizard::setupProductsPage() pageLayout->addWidget ( targetFolder, 1, 0 ); pageLayout->addWidget ( targetBtn, 1, 1 ); pageLayout->addMultiCellWidget( moreBox, 2, 2, 0, 1 ); - pageLayout->addWidget ( moreBtn, 3, 1 ); + pageLayout->addMultiCellWidget( lessBox, 3, 3, 0, 1 ); + pageLayout->addWidget ( moreBtn, 4, 1 ); pageLayout->setRowStretch( 2, 5 ); + pageLayout->setRowStretch( 3, 5 ); //pageLayout->addRowSpacing( 6, 10 ); // xml reader QFile xmlfile(xmlFileName); @@ -781,7 +799,7 @@ void SALOME_InstallWizard::setupProductsPage() handler->setTargetDir(targetFolder); handler->setTempDir(tempFolder); reader.setContentHandler( handler ); - reader.parse( source ); + reader.parse( source ); } // take into account command line parameters if ( !targetDirPath.isEmpty() ) @@ -797,23 +815,29 @@ void SALOME_InstallWizard::setupProductsPage() // adding page addPage( productsPage, tr( "Installation settings" ) ); // connecting signals - connect( productsView, SIGNAL( selectionChanged() ), - this, SLOT( onSelectionChanged() ) ); - connect( productsView, SIGNAL( itemToggled( QCheckListItem* ) ), - this, SLOT( onItemToggled( QCheckListItem* ) ) ); - connect( unselectBtn, SIGNAL( clicked() ), this, SLOT( onProdBtn() ) ); - connect( selectSrcBtn, SIGNAL( stateChanged(int) ), - this, SLOT( onProdBtn() ) ); - connect( selectBinBtn, SIGNAL( stateChanged(int) ), - this, SLOT( onProdBtn() ) ); + connect( productsView, SIGNAL( selectionChanged() ), + this, SLOT( onSelectionChanged() ) ); + connect( productsView, SIGNAL( itemToggled( QCheckListItem* ) ), + this, SLOT( onItemToggled( QCheckListItem* ) ) ); + connect( unselectBtn, SIGNAL( clicked() ), + this, SLOT( onProdBtn() ) ); + connect( selectSrcBtn, SIGNAL( stateChanged(int) ), + this, SLOT( onProdBtn() ) ); + connect( selectBinBtn, SIGNAL( stateChanged(int) ), + this, SLOT( onProdBtn() ) ); + connect( buildSrcBtn, SIGNAL( stateChanged(int) ), + this, SLOT( onProdBtn() ) ); + connect( allFromSrcBtn, SIGNAL( stateChanged(int) ), + this, SLOT( onBuildAll() ) ); // connecting signals - connect( targetFolder, SIGNAL( textChanged( const QString& ) ), - this, SLOT( directoryChanged( const QString& ) ) ); - connect( targetBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) ); - connect( tempFolder, SIGNAL( textChanged( const QString& ) ), - this, SLOT( directoryChanged( const QString& ) ) ); - connect( tempBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) ); - connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) ); + connect( targetFolder, SIGNAL( textChanged( const QString& ) ), + this, SLOT( directoryChanged( const QString& ) ) ); + connect( targetBtn, SIGNAL( clicked() ), + this, SLOT( browseDirectory() ) ); + connect( tempFolder, SIGNAL( textChanged( const QString& ) ), + this, SLOT( directoryChanged( const QString& ) ) ); + connect( tempBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) ); + connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) ); // start on default - non-advanced - mode moreBox->hide(); } @@ -827,7 +851,7 @@ void SALOME_InstallWizard::setupCheckPage() { // create page prestartPage = new QWidget( this, "PrestartPage" ); - QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage ); + QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage ); pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 ); // choice text view choices = new QTextEdit( prestartPage ); @@ -856,14 +880,14 @@ void SALOME_InstallWizard::setupProgressPage() { // create page progressPage = new QWidget( this, "progressPage" ); - QGridLayout* pageLayout = new QGridLayout( progressPage ); + QGridLayout* pageLayout = new QGridLayout( progressPage ); pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 ); // top splitter splitter = new QSplitter( Vertical, progressPage ); splitter->setOpaqueResize( true ); // the parent for the widgets QWidget* widget = new QWidget( splitter ); - QGridLayout* layout = new QGridLayout( widget ); + QGridLayout* layout = new QGridLayout( widget ); layout->setMargin( 0 ); layout->setSpacing( 6 ); // installation progress view box installInfo = new InstallInfo( widget ); @@ -890,7 +914,7 @@ void SALOME_InstallWizard::setupProgressPage() layout->addRowSpacing( 3, 6 ); // the parent for the widgets widget = new QWidget( splitter ); - layout = new QGridLayout( widget ); + layout = new QGridLayout( widget ); layout->setMargin( 0 ); layout->setSpacing( 6 ); // installation results view box QLabel* resultLab = new QLabel( tr( "Installation Status:" ), widget ); @@ -920,7 +944,7 @@ void SALOME_InstallWizard::setupReadmePage() { // create page readmePage = new QWidget( this, "ReadmePage" ); - QVBoxLayout* pageLayout = new QVBoxLayout( readmePage ); + QVBoxLayout* pageLayout = new QVBoxLayout( readmePage ); pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 ); // README info text box readme = new QTextEdit( readmePage ); @@ -949,7 +973,7 @@ void SALOME_InstallWizard::setupReadmePage() QWhatsThis::add( b, tr( (*it).tootip() ) ); QToolTip::add ( b, tr( (*it).tootip() ) ); } - hLayout->addWidget( b ); + hLayout->addWidget( b ); (*it).setButton( b ); connect( b, SIGNAL( clicked() ), this, SLOT( onFinishButton() ) ); } @@ -1013,6 +1037,11 @@ void SALOME_InstallWizard::showChoiceInfo() item = (QCheckListItem*)( productsView->firstChild() ); while( item ) { if ( productsMap.contains( item ) ) { + if ( productsMap[ item ].hasContext( "salome sources" ) || + productsMap[ item ].hasContext( "salome binaries" ) ) { + item = (QCheckListItem*)( item->nextSibling() ); + continue; // skip SALOME sources and binaries + } if ( item->childCount() > 0 ) { if ( productsView->isBinaries( item ) ) { text += "
  • " + item->text() + " " + item->text(1) + " " + tr( "as binaries" ) + "
    "; @@ -1034,6 +1063,40 @@ void SALOME_InstallWizard::showChoiceInfo() text += "
  • " + tr( "none" ) + "
    "; } text += ""; + // SALOME binaries, sources, samples + QString textBin = ""; + QString textSrc = ""; + QString textBoth = ""; + item = (QCheckListItem*)( productsView->firstChild() ); + while( item ) { + if ( productsMap.contains( item ) ) { + if ( !productsMap[ item ].hasContext( "salome sources" ) && + productsMap[ item ].hasContext( "salome binaries" ) ) { + if ( ( item->childCount() > 0 && productsView->isBinaries( item ) || item->isOn() ) && item->isEnabled() ) { + textBin += "
  • " + item->text().replace( QRegExp( "(-)?bin", false ), "" ) + "
    "; + } + } + if ( productsMap[ item ].hasContext( "salome sources" ) && + !productsMap[ item ].hasContext( "salome binaries" ) ) { + if ( item->childCount() > 0 && productsView->isSources( item ) || item->isOn() ) { + textSrc += "
  • " + item->text().replace( QRegExp( "(-)?src", false ), "" ) + "
    "; + } + } + if ( productsMap[ item ].hasContext( "salome sources" ) && + productsMap[ item ].hasContext( "salome binaries" ) ) { + if ( item->childCount() > 0 && productsView->isSources( item ) || item->isOn() ) { + textBoth += "
  • " + item->text() + "
    "; + } + } + } + item = (QCheckListItem*)( item->nextSibling() ); + } + if ( !textBin.isEmpty() ) + text += tr( "SALOME binaries to be installed" ) + ":
      " + textBin + "
    "; + if ( !textSrc.isEmpty() ) + text += tr( "SALOME sources to be installed" ) + ( buildSrcBtn->isChecked() ? tr( " and build" ) : QString( "" ) ) + ":
      " + textSrc + "
    "; + if ( !textBoth.isEmpty() ) + text += tr( "Other SALOME modules to be installed" ) + ":
      " + textBoth + "
    "; text += tr( "Total disk space required:" ) + " " + QString::number( totSize ) + " Kb
    " ; text += tr( "Space for temporary files required:" ) + " " + QString::number( tempSize ) + " Kb
    " ; text += "
    "; @@ -1060,10 +1123,10 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) long totSize, tempSize; bool anySelected = checkSize( &totSize, &tempSize ); if ( !anySelected ) { - QMessageBox::warning( this, - tr( "Warning" ), - tr( "Select one or more products to install" ), - QMessageBox::Ok, + QMessageBox::warning( this, + tr( "Warning" ), + tr( "Select one or more products to install" ), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); return false; @@ -1074,62 +1137,62 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) QString tempDir = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ); // directories should differ // if (!targetDir.isEmpty() && tempDir == targetDir) { -// QMessageBox::warning( this, -// tr( "Warning" ), -// tr( "Target and temporary directories must be different"), -// QMessageBox::Ok, -// QMessageBox::NoButton, +// QMessageBox::warning( this, +// tr( "Warning" ), +// tr( "Target and temporary directories must be different"), +// QMessageBox::Ok, +// QMessageBox::NoButton, // QMessageBox::NoButton ); // return false; // } // check target directory if ( targetDir.isEmpty() ) { - QMessageBox::warning( this, - tr( "Warning" ), - tr( "Please, enter valid target directory path" ), - QMessageBox::Ok, + QMessageBox::warning( this, + tr( "Warning" ), + tr( "Please, enter valid target directory path" ), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); return false; } QFileInfo fi( QDir::cleanDirPath( targetDir ) ); if ( !fi.exists() ) { - bool toCreate = - QMessageBox::warning( this, - tr( "Warning" ), + bool toCreate = + QMessageBox::warning( this, + tr( "Warning" ), tr( "The directory %1 doesn't exist.\n" - "Create directory?" ).arg( fi.absFilePath() ), - QMessageBox::Yes, + "Create directory?" ).arg( fi.absFilePath() ), + QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::Yes; - if ( !toCreate) + if ( !toCreate) return false; if ( !makeDir( fi.absFilePath(), tmpstr ) ) { - QMessageBox::critical( this, - tr( "Error" ), - tr( "Can't create the directory\n%1").arg( fi.absFilePath() ), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::critical( this, + tr( "Error" ), + tr( "Can't create the directory\n%1").arg( fi.absFilePath() ), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } } if ( !fi.isDir() ) { - QMessageBox::warning( this, - tr( "Warning" ), + QMessageBox::warning( this, + tr( "Warning" ), tr( "%1 is not a directory.\n" - "Please, enter valid target directory path" ).arg( fi.absFilePath() ), - QMessageBox::Ok, + "Please, enter valid target directory path" ).arg( fi.absFilePath() ), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); return false; } if ( !fi.isWritable() ) { - QMessageBox::warning( this, - tr( "Warning" ), + QMessageBox::warning( this, + tr( "Warning" ), tr( "The directory %1 is not writeable.\n" - "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ), - QMessageBox::Ok, + "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); return false; @@ -1146,7 +1209,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) return false; } // check sources/binaries archives directories existance - int nbSources = 0, nbBinaries = 0; + int nbSources = 0, nbBinaries = 0; QCheckListItem* nitem = (QCheckListItem*)( productsView->firstChild() ); while( nitem ) { if ( productsMap.contains( nitem ) ) { @@ -1170,8 +1233,8 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) binDir += "/" + myOS; QFileInfo fib( QDir::cleanDirPath( binDir ) ); if ( !fib.exists() ) { - if ( QMessageBox::warning( this, - tr( "Warning" ), + if ( QMessageBox::warning( this, + tr( "Warning" ), tr( "The directory %1 doesn't exist.\n" "This directory must contain binaries archives.\n" "Continue?" ).arg( fib.absFilePath() ), @@ -1185,8 +1248,8 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) QString srcDir = "./Products/SOURCES"; QFileInfo fis( QDir::cleanDirPath( srcDir ) ); if ( !fis.exists() ) { - if ( QMessageBox::warning( this, - tr( "Warning" ), + if ( QMessageBox::warning( this, + tr( "Warning" ), tr( "The directory %1 doesn't exist.\n" "This directory must contain sources archives.\n" "Continue?" ).arg( fis.absFilePath() ), @@ -1201,26 +1264,26 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) script += fi.absFilePath(); script += "' "; script += QString( "%1" ).arg( totSize ); - ___MESSAGE___( "script = " << script ); + ___MESSAGE___( "script = " << script.latin1() ); if ( system( script ) ) { - QMessageBox::critical( this, - tr( "Out of space" ), - tr( "There is no available disk space for installing of selected products" ), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::critical( this, + tr( "Out of space" ), + tr( "There is no available disk space for installing of selected products" ), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } // check temp directory if ( tempDir.isEmpty() ) { if ( moreMode ) { - QMessageBox::warning( this, - tr( "Warning" ), - tr( "Please, enter valid temporary directory path" ), - QMessageBox::Ok, + QMessageBox::warning( this, + tr( "Warning" ), + tr( "Please, enter valid temporary directory path" ), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); - return false; + return false; } else { tempDir = "/tmp"; @@ -1229,11 +1292,11 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) } QFileInfo fit( QDir::cleanDirPath( tempDir ) ); if ( !makeDir( fit.absFilePath() + TEMPDIRNAME, tmpCreated ) ) { - QMessageBox::critical( this, - tr( "Error" ), - tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::critical( this, + tr( "Error" ), + tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } @@ -1243,13 +1306,13 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) tscript += fit.absFilePath(); tscript += "' "; tscript += QString( "%1" ).arg( tempSize ); - ___MESSAGE___( "script = " << tscript ); + ___MESSAGE___( "script = " << tscript.latin1() ); if ( system( tscript ) ) { - QMessageBox::critical( this, - tr( "Out of space" ), - tr( "There is no available disk space for the temporary files" ), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::critical( this, + tr( "Out of space" ), + tr( "There is no available disk space for the temporary files" ), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } @@ -1263,11 +1326,11 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) // VSR : 29/01/05 : Check installation script even if product is not being installed // if ( !productsView->isNone( item ) ) { if ( item->text(2).isEmpty() || item->text(2).isNull() ) { - QMessageBox::warning( this, - tr( "Error" ), - tr( "The installation script for %1 is not defined.").arg(item->text(0)), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::warning( this, + tr( "Error" ), + tr( "The installation script for %1 is not defined.").arg(item->text(0)), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); if ( !moreMode ) onMoreBtn(); @@ -1279,11 +1342,11 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) } else { QFileInfo fi( QString("./config_files/") + item->text(2) ); if ( !fi.exists() || !fi.isExecutable() ) { - QMessageBox::warning( this, - tr( "Error" ), - tr( "The script %1 required for %2 doesn't exist or doesn't have execute permissions.").arg("./config_files/" + item->text(2)).arg(item->text(0)), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::warning( this, + tr( "Error" ), + tr( "The script %1 required for %2 doesn't exist or doesn't have execute permissions.").arg("./config_files/" + item->text(2)).arg(item->text(0)), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); if ( !moreMode ) onMoreBtn(); @@ -1292,14 +1355,14 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) productsView->ensureItemVisible( item ); //productsView->setNone( item ); return false; - } + } } // } // collect native products if ( productsView->isNative( item ) ) { if ( natives.find( item->text(0) ) == natives.end() ) natives.append( item->text(0) ); - } + } else if ( productsView->isBinaries( item ) || productsView->isSources( item ) ) { QStringList dependOn = productsMap[ item ].getDependancies(); for ( int i = 0; i < (int)dependOn.count(); i++ ) { @@ -1307,14 +1370,14 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) if ( depitem ) { if ( productsView->isNative( depitem ) && natives.find( depitem->text(0) ) == natives.end() ) natives.append( depitem->text(0) ); - } + } else { - QMessageBox::warning( this, - tr( "Error" ), + QMessageBox::warning( this, + tr( "Error" ), tr( "%1 is required for %2 %3 installation.\n" - "This product is missing in the configuration file %4.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)).arg(xmlFileName), - QMessageBox::Ok, - QMessageBox::NoButton, + "This product is missing in the configuration file %4.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)).arg(xmlFileName), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } @@ -1339,12 +1402,12 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) myThread->addCommand( item, script ); } else { - QMessageBox::warning( this, - tr( "Warning" ), + QMessageBox::warning( this, + tr( "Warning" ), tr( "%The product %1 %2 required for installation.\n" "This product is missing in the configuration file %4.").arg(item->text(0)).arg(item->text(1)).arg(xmlFileName), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); return false; } @@ -1381,7 +1444,7 @@ bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize ) if ( !productsView->isNone( item ) ) nbSelected++; } - + if ( totSize ) *totSize = tots; if ( tempSize ) @@ -1409,7 +1472,7 @@ void SALOME_InstallWizard::checkProductPage() // update required size information requiredSize->setText( QString::number( tots ) + " Kb"); requiredTemp->setText( QString::number( temps ) + " Kb"); - + // update , check boxes state int totSrc = 0, selSrc = 0; int totBin = 0, selBin = 0; @@ -1435,6 +1498,14 @@ void SALOME_InstallWizard::checkProductPage() selectSrcBtn->blockSignals( false ); selectBinBtn->blockSignals( false ); + buildSrcBtn->setEnabled( selSrc > 0 ); + for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) { + if ( itProd.data().hasContext( "salome sources" ) && !itProd.data().hasContext( "salome binaries" ) ) { + productsView->setItemEnabled( productsView->findBinItem( itProd.data().getName() ) , + !buildSrcBtn->isChecked() || !productsView->isSources( itProd.key() ) ); + } + } + // enable/disable "Next" button setNextEnabled( productsPage, isAnyProductSelected && isTargetDirValid && isTempDirValid ); } @@ -1522,7 +1593,7 @@ void SALOME_InstallWizard::launchScript() } // ... sources ? else if ( productsView->isSources( item ) ) { - shellProcess->addArgument( "install_source" ); + shellProcess->addArgument( buildSrcBtn->isChecked() ? "install_source_and_build" : "install_source" ); shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() ); shellProcess->addArgument( QDir::currentDirPath() + "/Products/SOURCES" ); } @@ -1541,9 +1612,9 @@ void SALOME_InstallWizard::launchScript() // ... target folder QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ); shellProcess->addArgument( QFileInfo( tgtFolder ).absFilePath() ); - - QString depproducts = DefineDependeces(productsMap); + + QString depproducts = DefineDependeces(productsMap); ___MESSAGE___( "Dependancies"<< depproducts.latin1() ); shellProcess->addArgument( depproducts ); @@ -1565,9 +1636,9 @@ void SALOME_InstallWizard::launchScript() for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) { QCheckListItem* item = mapIter.key(); Dependancies dep = mapIter.data(); - QString depproducts = QUOTE( DefineDependeces(productsMap) ); + QString depproducts = QUOTE( DefineDependeces(productsMap) ); if ( !productsView->isNone( item ) && dep.pickUpEnvironment() ) { - ___MESSAGE___( "... for " << dep.getName() ); + ___MESSAGE___( "... for " << dep.getName().latin1() ); QString script; script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; "; script += item->text(2) + " "; @@ -1578,8 +1649,8 @@ void SALOME_InstallWizard::launchScript() script += depproducts + " "; script += item->text(0); ___MESSAGE___( "... --> " << script.latin1() ); - if ( system( script.latin1() ) ) { - ___MESSAGE___( "ERROR" ); + if ( system( script.latin1() ) ) { + ___MESSAGE___( "ERROR" ); } } } @@ -1612,10 +1683,12 @@ void SALOME_InstallWizard::onMoreBtn() { if ( moreMode ) { moreBox->hide(); + lessBox->show(); moreBtn->setText( tr( "More..." ) ); } else { moreBox->show(); + lessBox->hide(); moreBtn->setText( tr( "Less..." ) ); } qApp->processEvents(); @@ -1650,10 +1723,10 @@ void SALOME_InstallWizard::onFinishButton() script += " > /dev/null )"; ___MESSAGE___( "script: " << script.latin1() ); if ( (*it).script().isEmpty() || system( script.latin1() ) ) { - QMessageBox::warning( this, - tr( "Error" ), + QMessageBox::warning( this, + tr( "Error" ), tr( "Can't perform action!"), - QMessageBox::Ok, + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); } @@ -1676,7 +1749,7 @@ void SALOME_InstallWizard::onAbout() // ================================================================ /*! * SALOME_InstallWizard::findItem - * Searches product listview item with given symbolic name + * Searches product listview item with given symbolic name */ // ================================================================ QCheckListItem* SALOME_InstallWizard::findItem( const QString& sName ) @@ -1717,10 +1790,10 @@ void SALOME_InstallWizard::reject() { ___MESSAGE___( "REJECTED" ); if ( !exitConfirmed ) { - if ( QMessageBox::information( this, - tr( "Exit" ), - tr( "Do you want to quit %1?" ).arg( getIWName() ), - tr( "&Yes" ), + if ( QMessageBox::information( this, + tr( "Exit" ), + tr( "Do you want to quit %1?" ).arg( getIWName() ), + tr( "&Yes" ), tr( "&No" ), QString::null, 0, @@ -1762,7 +1835,7 @@ void SALOME_InstallWizard::clean(bool rmDir) script += "' "; script += QUOTE(DefineDependeces(productsMap)); script += " > /dev/null"; - ___MESSAGE___( "script = " << script ); + ___MESSAGE___( "script = " << script.latin1() ); if ( system( script.latin1() ) ) { } // VSR: then try to remove created temporary directory @@ -1772,7 +1845,7 @@ void SALOME_InstallWizard::clean(bool rmDir) script += " > /dev/null"; if ( system( script.latin1() ) ) { } - ___MESSAGE___( "script = " << script ); + ___MESSAGE___( "script = " << script.latin1() ); } } // ================================================================ @@ -1862,8 +1935,8 @@ void SALOME_InstallWizard::helpClicked() helpWindow->installEventFilter( this ); } else { - QMessageBox::warning( this, - tr( "Help file not found" ), + QMessageBox::warning( this, + tr( "Help file not found" ), tr( "Sorry, help is unavailable" ) ); } } @@ -1958,7 +2031,7 @@ void SALOME_InstallWizard::onStart() type = tr( "sources" ); else if ( productsView->isNative( item ) ) type = tr( "native" ); - else + else type = tr( "not install" ); progressView->addProduct( item->text(0), type, item->text(2) ); } @@ -2031,10 +2104,10 @@ void SALOME_InstallWizard::productInstalled( ) void SALOME_InstallWizard::tryTerminate() { if ( shellProcess->isRunning() ) { - if ( QMessageBox::information( this, - tr( "Exit" ), - tr( "Do you want to quit %1?" ).arg( getIWName() ), - tr( "&Yes" ), + if ( QMessageBox::information( this, + tr( "Exit" ), + tr( "Do you want to quit %1?" ).arg( getIWName() ), + tr( "&Yes" ), tr( "&No" ), QString::null, 0, @@ -2106,7 +2179,7 @@ void SALOME_InstallWizard::onSelectionChanged() else { text += "" + tr( "not install" ) + "" + "
    "; } - + text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " Kb
    "; text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " Kb
    "; text += "
    "; @@ -2166,7 +2239,7 @@ void SALOME_InstallWizard::onProdBtn() int selBin = 0; MapProducts::Iterator itProd1; for ( itProd1 = productsMap.begin(); itProd1 != productsMap.end(); ++itProd1 ) { - if ( itProd1.data().hasContext( "salome binaries" ) && + if ( itProd1.data().hasContext( "salome binaries" ) && !itProd1.data().hasContext( "salome sources" ) && productsView->isBinaries( itProd1.key() ) ) selBin++; @@ -2193,7 +2266,7 @@ void SALOME_InstallWizard::onProdBtn() int selSrc = 0; MapProducts::Iterator itProd1; for ( itProd1 = productsMap.begin(); itProd1 != productsMap.end(); ++itProd1 ) { - if ( itProd1.data().hasContext( "salome sources" ) && + if ( itProd1.data().hasContext( "salome sources" ) && !itProd1.data().hasContext( "salome binaries" ) && productsView->isSources( itProd1.key() ) ) selSrc++; @@ -2287,8 +2360,8 @@ void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies d * Add button for the page */ // ================================================================ -void SALOME_InstallWizard::addFinishButton( const QString& label, - const QString& tooltip, +void SALOME_InstallWizard::addFinishButton( const QString& label, + const QString& tooltip, const QString& script) { if ( !label.isEmpty() ) @@ -2331,11 +2404,11 @@ void SALOME_InstallWizard::saveLog() f.close(); } else { - QMessageBox::critical( this, - tr( "Error" ), - tr( "Can't save file %1.\nCheck path and permissions.").arg( fileName ), - QMessageBox::Ok, - QMessageBox::NoButton, + QMessageBox::critical( this, + tr( "Error" ), + tr( "Can't save file %1.\nCheck path and permissions.").arg( fileName ), + QMessageBox::Ok, + QMessageBox::NoButton, QMessageBox::NoButton ); } } @@ -2349,7 +2422,7 @@ void SALOME_InstallWizard::saveLog() void SALOME_InstallWizard::updateCaption() { QWidget* aPage = InstallWizard::currentPage(); - if ( !aPage ) + if ( !aPage ) return; InstallWizard::setCaption( tr( myCaption ) + " " + tr( getIWName() ) + " - " + @@ -2376,11 +2449,11 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data ) if ( val == 2 ) { WarnDialog::showWarnDlg( 0, false ); // when try_native returns 2 it means that native product version is higher than that is prerequisited - if ( QMessageBox::warning( this, - tr( "Warning" ), + if ( QMessageBox::warning( this, + tr( "Warning" ), tr( "You have newer version of %1 installed on your computer than that is required (%2).\nContinue?").arg(item->text(0)).arg(item->text(1)), - QMessageBox::Yes, - QMessageBox::No, + QMessageBox::Yes, + QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::No ) { myThread->clearCommands(); myWC.wakeAll(); @@ -2395,14 +2468,14 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data ) bool binMode = productsView->hasBinaries( item ); bool srcMode = productsView->hasSources( item ); QStringList buttons; - buttons.append( binMode ? tr( "Install binaries" ) : ( srcMode ? tr( "Install sources" ) : + buttons.append( binMode ? tr( "Install binaries" ) : ( srcMode ? tr( "Install sources" ) : tr( "Select manually" ) ) ); buttons.append( binMode ? ( srcMode ? tr( "Install sources" ) : tr( "Select manually" ) ) : ( srcMode ? tr( "Select manually" ) : QString::null ) ); buttons.append( binMode && srcMode ? tr( "Select manually" ) : QString::null ); - int answer = QMessageBox::warning( this, - tr( "Warning" ), - tr( "You don't have native %1 %2 on your computer.\nPlease, change your installation settings.").arg(item->text(0)).arg(item->text(1)), + int answer = QMessageBox::warning( this, + tr( "Warning" ), + tr( "You don't have native %1 %2 on your computer.\nPlease, change your installation settings.").arg(item->text(0)).arg(item->text(1)), buttons[0], buttons[1], buttons[2] ); @@ -2432,3 +2505,66 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data ) InstallWizard::processValidateEvent( val, data ); } } + +// ================================================================ +/*! + * SALOME_InstallWizard::resetToDefaultState + * Reset to default state + */ +// ================================================================ +void SALOME_InstallWizard::resetToDefaultState() +{ + productsView->blockSignals( true ); + buildSrcBtn->setChecked( false ); + MapProducts::Iterator itProd; + for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) { + QString defMode = itProd.data().getDefault(); + if ( defMode.isEmpty() ) + defMode = tr( "install binaries" ); + if ( defMode == tr( "install binaries" ) ) + productsView->setBinaries( itProd.key() ); + else if ( defMode == tr( "install sources" ) ) + productsView->setSources( itProd.key() ); + else if ( defMode == tr( "use native" ) ) + productsView->setNative( itProd.key() ); + else + productsView->setNone( itProd.key() ); + } + productsView->blockSignals( false ); +} + +// ================================================================ +/*! + * SALOME_InstallWizard::onBuildAll + * Reset to default state + */ +// ================================================================ +void SALOME_InstallWizard::onBuildAll() +{ + if ( allFromSrcBtn->isChecked() ) { + productsView->blockSignals( true ); + buildSrcBtn->setChecked( false ); + MapProducts::Iterator mapIter; + for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) + productsView->setSources( mapIter.key() ); + buildSrcBtn->setChecked( true ); + productsView->blockSignals( false ); + static bool firstTimeClicked = true; + if ( firstTimeClicked ) { + QMessageBox::warning( this, + tr( "Warning" ), + tr( "The building of all products from sources can take a lot of time\n" + "(more than 24 hours) depending on your computer performance!" ), + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton ); + firstTimeClicked = false; + } + + } + else { + resetToDefaultState(); + } + moreBtn->setEnabled( !allFromSrcBtn->isChecked() ); + checkProductPage(); +} diff --git a/src/SALOME_InstallWizard.hxx b/src/SALOME_InstallWizard.hxx index 24c4037..6621a69 100644 --- a/src/SALOME_InstallWizard.hxx +++ b/src/SALOME_InstallWizard.hxx @@ -264,10 +264,15 @@ class SALOME_InstallWizard: public InstallWizard void onProdBtn(); // button slot void onMoreBtn(); + // check box + void onBuildAll(); // page buttons slot void onFinishButton(); + // reset to default state + void resetToDefaultState(); + // button slot void onAbout(); @@ -320,8 +325,11 @@ class SALOME_InstallWizard: public InstallWizard QTextBrowser* productsInfo; // products info box QCheckBox* prerequisites; // checkbox QMyCheckBox* selectSrcBtn; // check box + QMyCheckBox* buildSrcBtn; // check box QMyCheckBox* selectBinBtn; // check box QPushButton* unselectBtn; // button + QWidget* lessBox; // container for the mode widgets + QMyCheckBox* allFromSrcBtn; // check box // --> prestart page QWidget* prestartPage; // page itself QTextEdit* choices; // choice text view diff --git a/src/SALOME_ProductsView.cxx b/src/SALOME_ProductsView.cxx index 713962c..8bb8161 100644 --- a/src/SALOME_ProductsView.cxx +++ b/src/SALOME_ProductsView.cxx @@ -128,7 +128,7 @@ void ProductsView::itemActivated( QCheckListItem* item ) { // ================================================================ bool ProductsView::isBinaries( QCheckListItem* item ) const { - if ( item->childCount() > 0 ) { + if ( item->childCount() > 0 && item->isEnabled() ) { QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); while( subItem ) { if ( subItem->isOn() ) @@ -146,7 +146,7 @@ bool ProductsView::isBinaries( QCheckListItem* item ) const // ================================================================ bool ProductsView::isSources( QCheckListItem* item ) const { - if ( item->childCount() > 0 ) { + if ( item->childCount() > 0 && item->isEnabled() ) { QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); while( subItem ) { if ( subItem->isOn() ) @@ -167,7 +167,7 @@ bool ProductsView::isSources( QCheckListItem* item ) const // ================================================================ bool ProductsView::isNative( QCheckListItem* item ) const { - if ( item->childCount() > 0 ) { + if ( item->childCount() > 0 && item->isEnabled() ) { QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); while( subItem ) { if ( subItem->isOn() ) @@ -361,3 +361,38 @@ bool ProductsView::hasNative( QCheckListItem* item ) const } return false; } + +// ================================================================ +/*! + * ProductsView::setItemEnabled + * Enable/disable item + */ +// ================================================================ +void ProductsView::setItemEnabled( QCheckListItem* item, const bool enable ) +{ + item->setEnabled( enable ); + QListViewItem* subItem = item->firstChild(); + while( subItem ) { + subItem->setEnabled( enable ); + subItem = subItem->nextSibling(); + } +} + +// ================================================================ +/*! + * ProductsView::findBinItem + * Find bin item which corresponds to the src item + */ +// ================================================================ +QCheckListItem* ProductsView::findBinItem( const QString& srcName ) +{ + QString binName = srcName.lower().replace( "src", "bin" ); + QCheckListItem* subItem = (QCheckListItem*)( firstChild() ); + while( subItem ) { + if ( subItem->text().lower() == binName ) + return subItem; + subItem = (QCheckListItem*)( subItem->nextSibling() ); + } + return 0; +} + diff --git a/src/SALOME_ProductsView.hxx b/src/SALOME_ProductsView.hxx index 3cbe49e..b0d1ac1 100644 --- a/src/SALOME_ProductsView.hxx +++ b/src/SALOME_ProductsView.hxx @@ -76,6 +76,12 @@ public: // returns true if product supports "native" installation mode bool hasNative( QCheckListItem* item ) const; + // enable/disable item + void setItemEnabled( QCheckListItem* item, const bool enable ); + + // find bin item which corresponds to the src item + QCheckListItem* findBinItem( const QString& srcName ); + signals: // emitted when checkbox or radiobutton is switched void itemToggled( QCheckListItem* item ); diff --git a/src/globals.h b/src/globals.h index 4c791bb..5701927 100644 --- a/src/globals.h +++ b/src/globals.h @@ -17,7 +17,7 @@ #define __IW_VERSION_MAJOR__ 1 #define __IW_VERSION_MINOR__ 0 -#define __IW_VERSION_PATCH__ 2 +#define __IW_VERSION_PATCH__ 3 #define __IW_VERSION__ (__IW_VERSION_MAJOR__*10000 + \ __IW_VERSION_MINOR__*100 + \ -- 2.39.2