void CAM_Module::initialize( CAM_Application* app )
{
myApp = app;
- if (myApp) {
+ if ( myApp )
+ {
SUIT_Session* aSession = SUIT_Session::session();
- connect(aSession, SIGNAL( applicationClosed( SUIT_Application* ) ),
- this, SLOT( onApplicationClosed( SUIT_Application* ) ));
+ connect( aSession, SIGNAL( applicationClosed( SUIT_Application* ) ),
+ this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
+
+ connect( myApp, SIGNAL( infoChanged( QString ) ), this, SLOT( onInfoChanged( QString ) ) );
}
}
{
}
+/*!Return true if module is active.*/
+bool CAM_Module::isActiveModule() const
+{
+ return application() ? application()->activeModule() == this : false;
+}
+
+/*!
+ Put the message into the status bar of the desktop. Message will be displayed
+ during specified \amscec milliseconds. If parameter \amsec is negative then
+ message will be persistently displayed when module is active.
+*/
+void CAM_Module::putInfo( const QString& msg, const int msec )
+{
+ if ( application() )
+ application()->putInfo( msg, msec );
+
+ if ( msec < 0 )
+ myInfo = msg;
+}
+
+/*!
+ Restore persistently displayed info string when previos information status string erasing
+ if module is active.
+*/
+void CAM_Module::onInfoChanged( QString txt )
+{
+ if ( txt.isEmpty() && isActiveModule() && !myInfo.isEmpty() && application() )
+ application()->putInfo( myInfo );
+}
+
/*!Public slot, nullify application pointer if the application was closed.*/
void CAM_Module::onApplicationClosed( SUIT_Application* theApp )
{
- if (myApp == theApp)
+ if ( myApp == theApp )
myApp = NULL;
}
CAM_DataModel* dm = it.current()->dataModel();
if( it.current() == this && !camStudy->containsDataModel( dm ) )
{
- if( prev )
- camStudy->insertDataModel( it.current()->dataModel(), prev );
+ if ( prev )
+ camStudy->insertDataModel( it.current()->dataModel(), prev );
else
- camStudy->insertDataModel( it.current()->dataModel(), 0 );
+ camStudy->insertDataModel( it.current()->dataModel(), 0 );
}
prev = dm;
}
virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
virtual void updateCommandsStatus() {};
+ virtual void putInfo( const QString&, const int = -1 );
+
+ bool isActiveModule() const;
+
/** @name Set Menu Shown*/
//@{
virtual void setMenuShown( const bool );
virtual void onApplicationClosed( SUIT_Application* );
+private slots:
+ void onInfoChanged( QString );
+
protected:
virtual CAM_DataModel* createDataModel();
CAM_Application* myApp;
QString myName;
QPixmap myIcon;
+ QString myInfo;
CAM_DataModel* myDataModel;
QMap<int, QAction*> myActionMap;
#pragma warning( default: 4251 )
#endif
-extern "C" {
+extern "C"
+{
typedef CAM_Module* (*GET_MODULE_FUNC)();
}
\param msg - text of message
\param msec - time in milliseconds, after that the status label will be cleared
*/
-void SUIT_Application::putInfo ( const QString& msg, const int msec )
+void SUIT_Application::putInfo( const QString& msg, const int msec )
{
if ( !desktop() )
return;
myStatusLabel->show();
}
+ QString prev = myStatusLabel->text();
+
myStatusLabel->setText( msg );
if ( msec != -1 )
- QTimer::singleShot( msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, myStatusLabel, SLOT( clear() ) );
+ QTimer::singleShot( msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, this, SLOT( onInfoClear() ) );
+
+ if ( prev != msg )
+ emit infoChanged( msg );
+}
+
+/*!
+ Clear the information label in status bar after delay.
+*/
+void SUIT_Application::onInfoClear()
+{
+ if ( !myStatusLabel )
+ return;
+
+ bool changed = !myStatusLabel->text().isEmpty();
+ myStatusLabel->clear();
+ if ( changed )
+ emit infoChanged( QString::null );
}
/*!