Salome HOME
Update pre-requisites for SALOME 7.4.0
[tools/install.git] / src / SALOME_ProductsView.cxx
index 5268830d2d86ddcebfbec7de780f90e708db73a2..412974e4e58b8b70b13b534e0df3c5ba1253a00d 100644 (file)
@@ -3,7 +3,7 @@
 //  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
 //  Project   : SALOME
 //  Module    : Installation Wizard
-//  Copyright : 2002-2007 CEA
+//  Copyright : 2002-2014 CEA
 
 #include "SALOME_ProductsView.hxx"
 #include <qstringlist.h>
@@ -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 );
 }
 // ================================================================
 /*!
@@ -121,248 +81,6 @@ bool ProductsView::eventFilter( QObject* o, QEvent* e )
 void ProductsView::itemActivated( QCheckListItem* item ) {
   emit itemToggled( item );
 }
-// ================================================================
-/*!
- *  ProductsView::isBinaries
- *  Returns true if "install binaries" is on for the item
- */
-// ================================================================
-bool ProductsView::isBinaries( QCheckListItem* item ) const
-{
-  if ( item->childCount() > 0 && item->isEnabled() ) {
-    QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() );
-    while( subItem ) {
-      if ( subItem->isOn() )
-       return subItem->text() == tr( "install binaries" );
-      subItem = (QCheckListItem*)( subItem->nextSibling() );
-    }
-  }
-  return false;
-}
-// ================================================================
-/*!
- *  ProductsView::isSources
- *  Returns true if "install sources" is on for the item
- */
-// ================================================================
-bool ProductsView::isSources( QCheckListItem* item ) const
-{
-  if ( item->childCount() > 0 && item->isEnabled() ) {
-    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 ) const
-{
-  if ( item->childCount() > 0 && item->isEnabled() ) {
-    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 ) const
-{
-  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 );
-  }
-}
-
-// ================================================================
-/*!
- *  ProductsView::hasBinaries
- *  Returns true if product supports "binaries" installation mode
- */
-// ================================================================
-bool ProductsView::hasBinaries( QCheckListItem* item ) const
-{
-  if ( item->childCount() > 0 ) {
-    QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() );
-    while( subItem ) {
-      if ( subItem->text() == tr( "install binaries" ) )
-        return true;
-      subItem = (QCheckListItem*)( subItem->nextSibling() );
-    }
-  }
-  return false;
-}
-
-// ================================================================
-/*!
- *  ProductsView::hasSources
- *  Returns true if product supports "sources" installation mode
- */
-// ================================================================
-bool ProductsView::hasSources( QCheckListItem* item ) const
-{
-  if ( item->childCount() > 0 ) {
-    QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() );
-    while( subItem ) {
-      if ( subItem->text() == tr( "install sources" ) )
-        return true;
-      subItem = (QCheckListItem*)( subItem->nextSibling() );
-    }
-  }
-  return false;
-}
-
-// ================================================================
-/*!
- *  ProductsView::hasNative
- *  Returns true if product supports "native" installation mode
- */
-// ================================================================
-bool ProductsView::hasNative( QCheckListItem* item ) const
-{
-  if ( item->childCount() > 0 ) {
-    QCheckListItem* subItem = (QCheckListItem*)( item->firstChild() );
-    while( subItem ) {
-      if ( subItem->text() == tr( "use native" ) )
-        return true;
-      subItem = (QCheckListItem*)( subItem->nextSibling() );
-    }
-  }
-  return false;
-}
-
 // ================================================================
 /*!
  *  ProductsView::setItemEnabled
@@ -378,7 +96,6 @@ void ProductsView::setItemEnabled( QCheckListItem* item, const bool enable )
     subItem = subItem->nextSibling();
   }
 }
-  
 // ================================================================
 /*!
  *  ProductsView::findBinItem