bool allowResize, const int f, WFlags wf )
: QtxDialog( parent, name, modal, allowResize, f, wf ),
myIsExclusive( true ),
- myIsAutoResumed( false )
+ myIsBusy( false )
{
setObjectPixmap( "SalomeApp", tr( "ICON_SELECT" ) );
}
return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown();
}
+//=======================================================================
+// name : setObjectEnabled
+// Purpose :
+//=======================================================================
+void SalomeApp_Dialog::setObjectEnabled( const int id, const bool en )
+{
+ if( myObjects.contains( id ) && isObjectEnabled( id )!=en )
+ {
+ Object& obj = myObjects[ id ];
+ obj.myEdit->setEnabled( en );
+ obj.myBtn->setEnabled( en );
+ obj.myLabel->setEnabled( en );
+ if( !en )
+ ( ( QToolButton* )obj.myBtn )->setOn( false );
+ }
+}
+
+//=======================================================================
+// name : isObjectEnabled
+// Purpose :
+//=======================================================================
+bool SalomeApp_Dialog::isObjectEnabled( const int id ) const
+{
+ return myObjects.contains( id ) && myObjects[ id ].myEdit->isEnabled();
+}
+
//=======================================================================
// name : selectObject
// Purpose :
aLast = myObjects.end();
for( ; anIt!=aLast; anIt++ )
if( anIt.data().myBtn->isOn() )
- {
- QStringList names = _names, ids = _ids;
- TypesList types = _types;
-
- filterTypes( anIt.key(), names, types, ids );
-
- anIt.data().myEdit->setText( selectionDescription( names, types, anIt.data().myNI ) );
- anIt.data().myTypes = types;
- anIt.data().myIds = ids;
- anIt.data().myNames = names;
-
- emit selectionChanged( anIt.key() );
- }
+ selectObject( anIt.key(), _names, _types, _ids );
}
//=======================================================================
QLineEdit* ne = new QLineEdit( parent );
ne->setReadOnly( true );
ne->setMinimumWidth( 150 );
+ connect( ne, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
myObjects[ nid ].myEdit = ne;
myObjects[ nid ].myNI = OneNameOrCount;
for( ; anIt!=aLast; anIt++ )
{
anIt.data().myNI = ni;
+ setReadOnly( anIt.key(), isReadOnly( anIt.key() ) );
aNext = anIt; aNext++;
updateObject( anIt.key(), aNext==aLast );
}
else if( myObjects.contains( id ) )
{
myObjects[ id ].myNI = ni;
+ setReadOnly( id, isReadOnly( id ) );
updateObject( id, true );
}
}
if( names.count()!=types.count() )
return "SalomeApp_Dialog::selectionDescription(): Error!!!";
+ if( names.isEmpty() )
+ return QString::null;
+
switch( ni )
{
case OneName:
break;
case ListOfNames:
- return names.join( ", " );
+ return names.join( " " );
break;
case Count:
btn->setOn( false );
}
}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void SalomeApp_Dialog::selectObject( const int id, const QString& name, const int type, const QString& selid )
+{
+ QStringList names; names.append( name );
+ TypesList types; types.append( type );
+ QStringList ids; ids.append( selid );
+ selectObject( id, names, types, ids );
+}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void SalomeApp_Dialog::selectObject( const int id, const QStringList& _names, const TypesList& _types,
+ const QStringList& _ids )
+{
+ if( !myObjects.contains( id ) )
+ return;
+
+ QStringList names = _names, ids = _ids;
+ TypesList types = _types;
+
+ filterTypes( id, names, types, ids );
+
+ Object& obj = myObjects[ id ];
+ obj.myEdit->setText( selectionDescription( names, types, obj.myNI ) );
+ obj.myTypes = types;
+ obj.myIds = ids;
+ obj.myNames = names;
+
+ emit selectionChanged( id );
+}
+
+//=======================================================================
+// name : setReadOnly
+// Purpose :
+//=======================================================================
+void SalomeApp_Dialog::setReadOnly( const int id, const bool ro )
+{
+ if( myObjects.contains( id ) )
+ myObjects[ id ].myEdit->setReadOnly( nameIndication( id )==ListOfNames || nameIndication( id )==OneName ? ro : true );
+}
+
+//=======================================================================
+// name : isReadOnly
+// Purpose :
+//=======================================================================
+bool SalomeApp_Dialog::isReadOnly( const int id ) const
+{
+ if( myObjects.contains( id ) )
+ return myObjects[ id ].myEdit->isReadOnly();
+ else
+ return true;
+}
+
+//=======================================================================
+// name : onTextChanged
+// Purpose :
+//=======================================================================
+void SalomeApp_Dialog::onTextChanged( const QString& text )
+{
+ if( myIsBusy )
+ return;
+
+ myIsBusy = true;
+
+ if( sender() && sender()->inherits( "QLineEdit" ) )
+ {
+ QLineEdit* edit = ( QLineEdit* )sender();
+ int id = -1;
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data().myEdit == edit )
+ id = anIt.key();
+
+ if( id>=0 && !isReadOnly( id ) )
+ {
+ QStringList list = QStringList::split( " ", text );
+ emit objectChanged( id, list );
+ }
+ }
+
+ myIsBusy = false;
+}
//! Check the shown state
bool isObjectShown( const int ) const;
+ //! Change the enabled state of widgets corresponding to id
+ void setObjectEnabled( const int, const bool );
+
+ //! Check the enabled state
+ bool isObjectEnabled( const int ) const;
+
//! Pass to all active widgets name, type and id of selected object
void selectObject( const QString&, const int, const QString& );
*/
void selectObject( const QStringList&, const TypesList&, const QStringList& );
+ //! Select in certain widget avoiding check if there is active widget
+ void selectObject( const int, const QString&, const int, const QString& );
+ void selectObject( const int, const QStringList&, const TypesList&, const QStringList& );
+
//! Check if certain widget has selection
bool hasSelection( const int ) const;
//! selection in certain widget is off
void objectDeactivated( int );
+
+ /*
+ text representation of selection is changed
+ it is emitted only if "read only" state of line edit is false
+ */
+ void objectChanged( int, const QStringList& );
protected:
//! Finds and returns resource manager
SUIT_ResourceMgr* resMgr() const;
-
+
/*! Create label, button and line edit for object selection
* If passed id is negative, then id will be calculated automatically (first free id)
* Returns the same id (if id>=0) or calculated
//! Check using name indication if multiple selection in possible
bool multipleSelection( const int ) const;
+ //! Set the "read only" state of object selection line edit
+ //! The "read only" will be false only if name indication is ListOfNames
+ void setReadOnly( const int, const bool );
+
+ //! Check the "read only" state of object selection line edit
+ bool isReadOnly( const int ) const;
+
private slots:
//! emits if the object selection button changes state
void onToggled( bool );
+ //! text in some line edit is changed
+ void onTextChanged( const QString& );
+
private:
/*!
If buttons are exclusive, set to "off" all buttons except one with id
private:
ObjectMap myObjects;
QMap<int,QString> myTypeNames;
- bool myIsExclusive, myIsAutoResumed;
+ bool myIsExclusive, myIsBusy;
QPixmap myPixmap;
};