From: asl Date: Mon, 4 Jul 2005 03:57:01 +0000 (+0000) Subject: Comments are added X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8780523bbff0ad3062dd8f4cb6319ad1fdabf8c0;p=modules%2Fgui.git Comments are added + minor changes --- diff --git a/src/SalomeApp/SalomeApp_Dialog.cxx b/src/SalomeApp/SalomeApp_Dialog.cxx index 054857981..dc3039c41 100644 --- a/src/SalomeApp/SalomeApp_Dialog.cxx +++ b/src/SalomeApp/SalomeApp_Dialog.cxx @@ -14,7 +14,6 @@ SalomeApp_Dialog::SalomeApp_Dialog( QWidget* parent, const char* name, bool moda myIsExclusive( true ) { setObjectPixmap( "SalomeApp", tr( "ICON_SELECT" ) ); - setNameIndication( OneNameOrCount ); } SalomeApp_Dialog::~SalomeApp_Dialog() @@ -88,31 +87,31 @@ bool SalomeApp_Dialog::isObjectShown( const int id ) const return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown(); } -void SalomeApp_Dialog::selectObject( const QString& name, const int type, const QString& entry ) +void SalomeApp_Dialog::selectObject( const QString& name, const int type, const QString& id ) { QStringList names; names.append( name ); TypesList types; types.append( type ); - QStringList entries; entries.append( entry ); - selectObject( names, types, entries ); + QStringList ids; ids.append( id ); + selectObject( names, types, ids ); } void SalomeApp_Dialog::selectObject( const QStringList& _names, const TypesList& _types, - const QStringList& _entries ) + const QStringList& _ids ) { ObjectMap::iterator anIt = myObjects.begin(), aLast = myObjects.end(); for( ; anIt!=aLast; anIt++ ) if( anIt.data().myBtn->isOn() ) { - QStringList names, entries; - TypesList types; + QStringList names = _names, ids = _ids; + TypesList types = _types; - filterTypes( anIt.key(), names, types, entries ); + filterTypes( anIt.key(), names, types, ids ); - anIt.data().myEdit->setText( selectionDescription( names, types ) ); + anIt.data().myEdit->setText( selectionDescription( names, types, anIt.data().myNI ) ); anIt.data().myTypes = types; - anIt.data().myEntries = entries; + anIt.data().myIds = ids; anIt.data().myNames = names; emit selectionChanged( anIt.key() ); @@ -121,14 +120,14 @@ void SalomeApp_Dialog::selectObject( const QStringList& _names, bool SalomeApp_Dialog::hasSelection( const int id ) const { - return myObjects.contains( id ) && !myObjects[ id ].myEntries.isEmpty(); + return myObjects.contains( id ) && !myObjects[ id ].myIds.isEmpty(); } void SalomeApp_Dialog::clearSelection( const int id ) { if( myObjects.contains( id ) ) { - myObjects[ id ].myEntries.clear(); + myObjects[ id ].myIds.clear(); myObjects[ id ].myTypes.clear(); myObjects[ id ].myNames.clear(); @@ -140,7 +139,7 @@ void SalomeApp_Dialog::clearSelection( const int id ) void SalomeApp_Dialog::selectedObject( const int id, QStringList& list ) const { if( myObjects.contains( id ) ) - list = myObjects[ id ].myEntries; + list = myObjects[ id ].myIds; //else // list.clear(); } @@ -152,10 +151,10 @@ void SalomeApp_Dialog::objectSelection( SelectedObjects& objs ) const aLast = myObjects.end(); for( ; anIt!=aLast; anIt++ ) { - QStringList entries; - selectedObject( anIt.key(), entries ); - if( !entries.isEmpty() ) - objs.insert( anIt.key(), entries ); + QStringList ids; + selectedObject( anIt.key(), ids ); + if( !ids.isEmpty() ) + objs.insert( anIt.key(), ids ); } } @@ -178,6 +177,8 @@ int SalomeApp_Dialog::createObject( const QString& label, QWidget* parent, const QLineEdit* ne = new QLineEdit( parent ); ne->setReadOnly( true ); myObjects[ nid ].myEdit = ne; + + myObjects[ nid ].myNI = OneNameOrCount; } return nid; } @@ -338,14 +339,14 @@ void SalomeApp_Dialog::updateObject( const int id, bool emit_signal ) if( hasSelection( id ) ) { Object& obj = myObjects[ id ]; - filterTypes( id, obj.myNames, obj.myTypes, obj.myEntries ); - obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes ) ); + filterTypes( id, obj.myNames, obj.myTypes, obj.myIds ); + obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes, obj.myNI ) ); if( emit_signal ) emit selectionChanged( id ); } } -void SalomeApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& entries ) const +void SalomeApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& ids ) const { if( !myObjects.contains( id ) ) return; @@ -354,26 +355,26 @@ void SalomeApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& if( obj.myPossibleTypes.isEmpty() ) return; - QStringList new_names, new_entries; + QStringList new_names, new_ids; TypesList new_types; TypesList::const_iterator anIt1 = types.begin(), aLast = types.end(); QStringList::const_iterator anIt2 = names.begin(), - anIt3 = entries.begin(); + anIt3 = ids.begin(); for( ; anIt1!=aLast; anIt1++, anIt2++, anIt3++ ) if( obj.myPossibleTypes.contains( *anIt1 ) ) { - if( new_types.count()==1 && !multipleSelection() ) + if( new_types.count()==1 && !multipleSelection( id ) ) break; new_names.append( *anIt2 ); new_types.append( *anIt1 ); - new_entries.append( *anIt3 ); + new_ids.append( *anIt3 ); } names = new_names; types = new_types; - entries = new_entries; + ids = new_ids; } SUIT_ResourceMgr* SalomeApp_Dialog::resMgr() const @@ -388,7 +389,7 @@ void SalomeApp_Dialog::setObjectPixmap( const QPixmap& p ) aLast = myObjects.end(); for( ; anIt!=aLast; anIt++ ) anIt.data().myBtn->setIconSet( p ); -} +} void SalomeApp_Dialog::setObjectPixmap( const QString& section, const QString& file ) { @@ -397,35 +398,46 @@ void SalomeApp_Dialog::setObjectPixmap( const QString& section, const QString& f setObjectPixmap( mgr->loadPixmap( section, file ) ); } -bool SalomeApp_Dialog::multipleSelection() const +bool SalomeApp_Dialog::multipleSelection( const int id ) const { - return nameIndication()==OneName; + return nameIndication( id )==OneName; } -SalomeApp_Dialog::NameIndication SalomeApp_Dialog::nameIndication() const +SalomeApp_Dialog::NameIndication SalomeApp_Dialog::nameIndication( const int id ) const { - return myNI; + if( myObjects.contains( id ) ) + return myObjects[ id ].myNI; + else + return OneNameOrCount; } -void SalomeApp_Dialog::setNameIndication( const NameIndication ni ) +void SalomeApp_Dialog::setNameIndication( const int id, const NameIndication ni ) { - myNI = ni; - ObjectMap::const_iterator anIt = myObjects.begin(), - aNext, - aLast = myObjects.end(); - for( ; anIt!=aLast; anIt++ ) + if( id==-1 ) + { + ObjectMap::iterator anIt = myObjects.begin(), + aNext, + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + anIt.data().myNI = ni; + aNext = anIt; aNext++; + updateObject( anIt.key(), aNext==aLast ); + } + } + else if( myObjects.contains( id ) ) { - aNext = anIt; aNext++; - updateObject( anIt.key(), aNext==aLast ); + myObjects[ id ].myNI = ni; + updateObject( id, true ); } } -QString SalomeApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types ) const +QString SalomeApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types, const NameIndication ni ) const { if( names.count()!=types.count() ) return "SalomeApp_Dialog::selectionDescription: Error!!!"; - switch( nameIndication() ) + switch( ni ) { case OneName: return names.first(); diff --git a/src/SalomeApp/SalomeApp_Dialog.h b/src/SalomeApp/SalomeApp_Dialog.h index d53aff3bf..9ea446862 100644 --- a/src/SalomeApp/SalomeApp_Dialog.h +++ b/src/SalomeApp/SalomeApp_Dialog.h @@ -26,10 +26,10 @@ public: typedef QMap SelectedObjects; typedef enum { - OneName, - OneNameOrCount, - ListOfNames, - Count + OneName, //! only one object can be selected and it's name is shown + OneNameOrCount, //! if one object is selected, it's name is shown otherwise " " is shown + ListOfNames, //! list of all names is shown + Count //! In every case " " is shown } NameIndication; @@ -39,71 +39,150 @@ public: virtual ~SalomeApp_Dialog(); virtual void show(); - + + //! Check if buttons is exclusive (as radiobuttons) bool isExclusive() const; + + //! Set exclusive state void setExclusive( const bool ); + //! Show widgets corresponding to id void showObject( const int ); + + //! Hide widgets corresponding to id void hideObject( const int ); + + //! Change the shown state of widgets corresponding to id void setObjectShown( const int, const bool ); + + //! Check the shown state bool isObjectShown( const int ) const; - + + //! Pass to all active widgets name, type and id of selected object void selectObject( const QString&, const int, const QString& ); + + /*! + Pass to all active widgets list of names, types and ids of selected object + Every active widget filters list and accept only objects with possible types + */ void selectObject( const QStringList&, const TypesList&, const QStringList& ); + + //! Check if widgets has selection bool hasSelection( const int ) const; + + //! Clear selection in widgets void clearSelection( const int = -1 ); + + //! Get ids list of object selected in widgets void selectedObject( const int, QStringList& ) const; + + //! Get map "widget id -> ids list" void objectSelection( SelectedObjects& ) const; signals: + //! selection in certain widget is changed void selectionChanged ( int ); + + //! selection in certain widget is on void objectActivated ( int ); + + //! selection in certain widget is off void objectDeactivated( int ); protected: SUIT_ResourceMgr* resMgr() const; + //! Create label, button and line edit for object selection int createObject ( const QString&, QWidget*, const int = -1 ); + + //! Set pixmap as icon for all selection buttons void setObjectPixmap ( const QPixmap& ); + + //! Load pixmap with section, name using resource manager and set as icon for all selection buttons void setObjectPixmap ( const QString&, const QString& ); + + //! Change label void renameObject ( const int, const QString& ); + + //! Set possible types for certain id. The list of arguments must be finished by negative integer void setObjectType ( const int, const int, ... ); + + //! Set list as possible types for object selection void setObjectType ( const int, const TypesList& ); + + /*! + Add types to list of possible types + The list of arguments must be finished by negative integer + */ void addObjectType ( const int, const int, const int, ... ); + + //! Add types to list of possible types void addObjectType ( const int, const TypesList& ); + + //! Add type to list of possible types void addObjectType ( const int, const int ); + + //! Clear list of possible types (it means, that all types are welcome) void removeObjectType( const int ); + + //! Remove types in list from list of possible types void removeObjectType( const int, const TypesList& ); + + //! Remove a type from list of possible types void removeObjectType( const int, const int ); + + //! Check if list of possible types contains this one bool hasObjectType ( const int, const int ) const; - void objectTypes ( const int, TypesList& ) const; + //! Return list of possible types + void objectTypes ( const int, TypesList& ) const; + + //!Change and get type name for indicating in selection widget QString& typeName( const int ); const QString& typeName( const int ) const; - - virtual QString selectionDescription( const QStringList&, const TypesList& ) const; + + //! Create string contains selection list by list of names, list of types and current name indication state + virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const; + + //! Create string with pattern " " for current list of types virtual QString countOfTypes( const TypesList& ) const; - NameIndication nameIndication() const; - void setNameIndication( const NameIndication ); - bool multipleSelection() const; + //! Get and set name indication + NameIndication nameIndication( const int ) const; + void setNameIndication( const int, const NameIndication ); + + //! Check using name indication if multiple selection in possible + bool multipleSelection( const int ) const; private slots: + //! emits if the object selection button changes state void onToggled( bool ); private: + /*! + If buttons are exclusive, set to "off" all buttons except one with id + If id=-1, then all buttons, except first with "on" state, will be set to "off" + */ void updateButtons( const int = -1 ); + + /*! + Filter types and update selection string in line edit + If bool is true, then signal is emitted + */ void updateObject( const int, bool = true ); + + //! Remove from list not possible types and remove from names and ids lists the corresponding items void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const; private: typedef struct { - QLineEdit* myEdit; - QPushButton* myBtn; - QLabel* myLabel; - QStringList myNames, myEntries; - TypesList myTypes, myPossibleTypes; + QLineEdit* myEdit; + QPushButton* myBtn; + QLabel* myLabel; + QStringList myNames, myIds; + TypesList myTypes, myPossibleTypes; + NameIndication myNI; } Object; @@ -114,7 +193,6 @@ private: QMap myTypeNames; bool myIsExclusive; QPixmap myPixmap; - NameIndication myNI; }; #endif diff --git a/src/SalomeApp/SalomeApp_Operation.cxx b/src/SalomeApp/SalomeApp_Operation.cxx index add111a67..87be9e786 100755 --- a/src/SalomeApp/SalomeApp_Operation.cxx +++ b/src/SalomeApp/SalomeApp_Operation.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -228,6 +229,16 @@ void SalomeApp_Operation::selected( QStringList& names, SalomeApp_Dialog::TypesL for( ; anIt!=aLast; anIt++ ) { SalomeApp_DataOwner* owner = dynamic_cast( (*anIt).operator->() ); + SalomeApp_DataSubOwner* subowner = dynamic_cast( (*anIt).operator->() ); + + if( subowner ) + { + QString entry = QString( "%1#%2" ).arg( subowner->entry() ).arg( subowner->index() ); + entries.append( entry ); + types.append( type( entry ) ); + names.append( QString( "%1" ).arg( subowner->index() ) ); + } + if( owner ) { QString entry = owner->entry();