myIsExclusive( true )
{
setObjectPixmap( "SalomeApp", tr( "ICON_SELECT" ) );
- setNameIndication( OneNameOrCount );
}
SalomeApp_Dialog::~SalomeApp_Dialog()
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() );
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();
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();
}
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 );
}
}
QLineEdit* ne = new QLineEdit( parent );
ne->setReadOnly( true );
myObjects[ nid ].myEdit = ne;
+
+ myObjects[ nid ].myNI = OneNameOrCount;
}
return nid;
}
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;
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
aLast = myObjects.end();
for( ; anIt!=aLast; anIt++ )
anIt.data().myBtn->setIconSet( p );
-}
+}
void SalomeApp_Dialog::setObjectPixmap( const QString& section, const QString& file )
{
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();
typedef QMap<int,QStringList> 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 "<count> <type>" is shown
+ ListOfNames, //! list of all names is shown
+ Count //! In every case "<count> <type>" is shown
} NameIndication;
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 "<count> <type>" 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;
QMap<int,QString> myTypeNames;
bool myIsExclusive;
QPixmap myPixmap;
- NameIndication myNI;
};
#endif
#include <SalomeApp_Application.h>
#include <SalomeApp_Operation.h>
#include <SalomeApp_DataOwner.h>
+#include <SalomeApp_DataSubOwner.h>
#include <SalomeApp_SelectionMgr.h>
#include <SUIT_Desktop.h>
for( ; anIt!=aLast; anIt++ )
{
SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
+ SalomeApp_DataSubOwner* subowner = dynamic_cast<SalomeApp_DataSubOwner*>( (*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();