X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSALOME_ProductsView.cxx;h=ccf39928502e209b70de3cc33e9ece1220569663;hb=c78011f0236881acfe030420ff0108a558c7cb06;hp=51e64bbb9382308a8c0c42124feaaffa1e892796;hpb=e655b8190e138ccdcfce1b722fb061cea68d6a60;p=tools%2Finstall.git diff --git a/src/SALOME_ProductsView.cxx b/src/SALOME_ProductsView.cxx index 51e64bb..ccf3992 100644 --- a/src/SALOME_ProductsView.cxx +++ b/src/SALOME_ProductsView.cxx @@ -1,13 +1,13 @@ // File : SALOME_ProductsView.cxx // Created : Thu Dec 18 12:01:00 2002 -// Author : Vadim SANDLER -// Project : PAL/SALOME -// Module : InstallWizard -// Copyright : 2004 CEA -// $Header$ +// Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com) +// Project : SALOME +// Module : Installation Wizard +// Copyright : 2002-2007 CEA #include "SALOME_ProductsView.hxx" #include +#include // ================================================================ /*! @@ -20,16 +20,6 @@ ProductsViewItem::ProductsViewItem( ProductsView* parent, const QString& text, T { } // ================================================================ -/*! - * ProductsViewItem::ProductsViewItem - * Constructor - */ -// ================================================================ -ProductsViewItem::ProductsViewItem( QCheckListItem* parent, const QString& text, Type tt ) - : QCheckListItem( parent, text, tt ) -{ -} -// ================================================================ /*! * ProductsViewItem::stateChange * Called when users switches item on/off @@ -40,77 +30,47 @@ void ProductsViewItem::stateChange( bool on ) { ((ProductsView*)listView())->itemActivated( (QCheckListItem*)this ); } - // ================================================================ /*! * ProductsView::ProductsView * Constructor */ // ================================================================ -ProductsView::ProductsView( QWidget* parent ) : QListView( parent ) +ProductsView::ProductsView( QWidget* parent, const char* name ) + : QListView( parent, name ) { setRootIsDecorated( false ); - addColumn( tr( "Product" ) ); - addColumn( tr( "Version" ) ); + addColumn( tr( "Module" ) ); + addColumn( tr( "Size" ) ); setResizeMode( LastColumn ); setSorting( -1, false ); } // ================================================================ /*! * ProductsView::addItem - * Adds product item(s) into the list + * Adds product item into the list */ // ================================================================ QCheckListItem* ProductsView::addItem( const QString& name, - const QString& version, - const QString& install, - const QStringList& supported, + const QString& size, const QString& script ) { QCheckListItem* item = 0; - QListViewItem* lItem = this->firstChild(); - while( lItem && lItem->nextSibling() ) - lItem = lItem->nextSibling(); - - if ( install.isNull() || install.isEmpty() ) { - item = new ProductsViewItem( this, name, QCheckListItem::CheckBox ); - item->setText( 1, version ); - item->setText( 2, script ); - item->moveItem( lItem ); - } - else { - item = new ProductsViewItem( this, name, QCheckListItem::Controller ); - item->setText( 1, version ); - item->setText( 2, script ); - - QCheckListItem* subitem = 0; - subitem = new ProductsViewItem( item, tr( "not install" ), QCheckListItem::RadioButton ); - subitem->setOn( true ); - QCheckListItem* previtem = subitem; - subitem->moveItem( previtem ); - for ( int i = 0; i < (int)supported.count(); i++ ) { - subitem = new ProductsViewItem( item, supported[ i ], QCheckListItem::RadioButton ); - if ( supported[i] == install ) - subitem->setOn( true ); - subitem->moveItem( previtem ); - previtem = subitem; - } - item->moveItem( lItem ); - item->setOpen( true ); - } + item = new ProductsViewItem( this, name, QCheckListItem::CheckBox ); + item->setText( 1, size ); + item->setText( 2, script ); + item->moveItem( this->lastItem() ); return item; } // ================================================================ /*! - * ProductsView::eventFilter - * Event filter - prevents collapsing/expanding of items + * ProductsView::renameColumn + * Sets the given text as a heading of the given column */ // ================================================================ -bool ProductsView::eventFilter( QObject* o, QEvent* e ) +void ProductsView::renameColumn( int column, const QString& label ) { - if ( o == viewport() && e->type() == QEvent::MouseButtonDblClick ) - return true; - return QListView::eventFilter( o, e ); + setColumnText( column, label ); } // ================================================================ /*! @@ -123,185 +83,34 @@ void ProductsView::itemActivated( QCheckListItem* item ) { } // ================================================================ /*! - * ProductsView::isBinaries - * Returns true if "install binaries" is on for the item + * ProductsView::setItemEnabled + * Enable/disable item */ // ================================================================ -bool ProductsView::isBinaries( QCheckListItem* item ) +void ProductsView::setItemEnabled( QCheckListItem* item, const bool enable ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - while( subItem ) { - if ( subItem->isOn() ) - return subItem->text() == tr( "install binaries" ); - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } + item->setEnabled( enable ); + QListViewItem* subItem = item->firstChild(); + while( subItem ) { + subItem->setEnabled( enable ); + subItem = subItem->nextSibling(); } - return false; } // ================================================================ /*! - * ProductsView::isSources - * Returns true if "install sources" is on for the item + * ProductsView::findBinItem + * Find bin item which corresponds to the src item */ // ================================================================ -bool ProductsView::isSources( QCheckListItem* item ) +QCheckListItem* ProductsView::findBinItem( const QString& srcName ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - while( subItem ) { - if ( subItem->isOn() ) - return subItem->text() == tr( "install sources" ); - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - } - else { - return item->isOn(); - } - return false; -} -// ================================================================ -/*! - * ProductsView::isNative - * Returns true if "use native" is on for the item - */ -// ================================================================ -bool ProductsView::isNative( QCheckListItem* item ) -{ - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - while( subItem ) { - if ( subItem->isOn() ) - return subItem->text() == tr( "use native" ); - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - } - return false; -} -// ================================================================ -/*! - * ProductsView::isNone - * Returns true if "not install" is on for the item - */ -// ================================================================ -bool ProductsView::isNone( QCheckListItem* item ) -{ - return !isBinaries( item ) && !isSources( item ) && !isNative( item ); -} -// ================================================================ -/*! - * ProductsView::setBinaries - * Sets "install binaries" on for the item; if "binaries" item - * is absent, set "install sources" on if it is present - */ -// ================================================================ -void ProductsView::setBinaries( QCheckListItem* item ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - QCheckListItem* srcItem = 0; - QCheckListItem* nativeItem = 0; - while( subItem ) { - if ( subItem->text() == tr( "install sources" ) ) - srcItem = subItem; - if ( subItem->text() == tr( "use native" ) ) - nativeItem = subItem; - if ( subItem->text() == tr( "install binaries" ) ) { - subItem->setOn( true ); - return; - } - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - if ( nativeItem ) // prefer native item - nativeItem->setOn( true ); - else if ( srcItem ) - srcItem->setOn( true ); - } - else { - item->setOn( true ); - } -} -// ================================================================ -/*! - * ProductsView::setSources - * Sets "install sources" on for the item; if "sources" item - * is absent, set "install binaries" on if it is present - */ -// ================================================================ -void ProductsView::setSources( QCheckListItem* item ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - QCheckListItem* binItem = 0; - QCheckListItem* nativeItem = 0; - while( subItem ) { - if ( subItem->text() == tr( "install binaries" ) ) - binItem = binItem; - if ( subItem->text() == tr( "use native" ) ) - nativeItem = subItem; - if ( subItem->text() == tr( "install sources" ) ) { - subItem->setOn( true ); - return; - } - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - if ( nativeItem ) // prefer native item - nativeItem->setOn( true ); - else if ( binItem ) - binItem->setOn( true ); - } - else { - item->setOn( true ); - } -} -// ================================================================ -/*! - * ProductsView::setNative - * Sets "use native" on for the item; if "sources" item - * is absent, set "install binaries" on if it is present - */ -// ================================================================ -void ProductsView::setNative( QCheckListItem* item ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - QCheckListItem* binItem = 0; - QCheckListItem* srcItem = 0; - while( subItem ) { - if ( subItem->text() == tr( "install binaries" ) ) - binItem = binItem; - if ( subItem->text() == tr( "install sources" ) ) - srcItem = subItem; - if ( subItem->text() == tr( "use native" ) ) { - subItem->setOn( true ); - return; - } - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - if ( binItem ) // prefer binaries - binItem->setOn( true ); - else if ( srcItem ) - srcItem->setOn( true ); - } - else { - item->setOn( true ); - } -} -// ================================================================ -/*! - * ProductsView::setNone - * Sets "not install" on for the item - */ -// ================================================================ -void ProductsView::setNone( QCheckListItem* item ) { - if ( item->childCount() > 0 ) { - QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() ); - while( subItem ) { - if ( subItem->text() == tr( "not install" ) ) { - subItem->setOn( true ); - return; - } - subItem = (QCheckListItem*)( subItem->nextSibling() ); - } - } - else { - item->setOn( false ); + QString binName = srcName.lower().replace( QRegExp("src"), "bin" ); + QCheckListItem* subItem = (QCheckListItem*)( firstChild() ); + while( subItem ) { + if ( subItem->text().lower() == binName ) + return subItem; + subItem = (QCheckListItem*)( subItem->nextSibling() ); } + return 0; } +