resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) );
- //no need at this action for mono-study application because study is always exists
- action( FileNewId )->setVisible( false );
createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
Qt::CTRL+Qt::Key_W, desk, false, this, SLOT( onCloseDoc() ) );
+ //no need in this action for mono-study application as it is same as NewDoc
+ action( FileCloseId )->setVisible( false );
createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIcon(),
tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
// Create tool bars
int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ), // title (language-dependant)
- QString( "SalomeStandard" ) ); // name (language-independant)
+ QString( "SalomeStandard" ) ); // name (language-independant)
// Create tool items
{
SUIT_ResourceMgr* aResMgr = resourceMgr();
if (aResMgr)
- delay = aResMgr->integerValue("notification", "timeout", 0) * 1000;
+ delay = aResMgr->integerValue("notification", "timeout", 0) * 1000;
}
uid = ntfMgr->showNotification(message, title, qMax(delay, 0));
}
//}
}*/
+namespace
+{
+ /*!
+ \brief Flag locker.
+ */
+ class MessageLocker
+ {
+ public:
+ //! Constructor. Sets passed boolean flag to \c true.
+ MessageLocker( bool& Lock ) : myPrevState( Lock ), myLock( Lock ) { myLock = true; }
+ //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
+ ~MessageLocker() { myLock = myPrevState; }
+ private:
+ bool myPrevState;
+ bool& myLock; //! External 'Lock state' boolean flag
+ };
+}
+
/*!Create new instance of SalomeApp_Application.*/
extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
{
/*!Constructor.*/
SalomeApp_Application::SalomeApp_Application()
: LightApp_Application(),
- myIsCloseFromExit( false )
+ myIsCloseFromExit( false ),
+ myToIgnoreMessages( false )
{
}
*/
void SalomeApp_Application::onExit()
{
+ //MessageLocker ml( myToIgnoreMessages );
+
bool killServers = false;
bool result = true;
}
}
+/*!SLOT. Create a document.*/
+void SalomeApp_Application::onNewDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ LightApp_Application::onNewDoc();
+}
+
/*!SLOT. Load document.*/
void SalomeApp_Application::onLoadDoc()
{
+ MessageLocker ml( myToIgnoreMessages );
+
QString studyName;
// rnv: According to the single-study approach on the server side
/*!SLOT. Parse message for desktop.*/
void SalomeApp_Application::onDesktopMessage( const QString& message )
{
+ if ( myToIgnoreMessages )
+ return; // a message from SALOMEDS is caused by GUI action
+
+ MessageLocker ml( myToIgnoreMessages );
+
if (message.indexOf("studyCreated") == 0) {
if (!activeStudy()) {
onNewDoc();
}
}
else if ( message.toLower() == "connect_to_study" ) {
- onLoadDoc();
+ if ( activeStudy() )
+ useStudy( activeStudy()->studyName() );
}
if (message.indexOf("studyNameChanged") == 0) {
updateDesktopTitle();
SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
}
+ MessageLocker ml( myToIgnoreMessages );
+
LightApp_Application::onCloseDoc( ask );
// reinitialize study to have empty data
- getStudy()->Init();
+ //getStudy()->Init();
+}
+
+/*!SLOT. Reload document from the file.*/
+bool SalomeApp_Application::onReopenDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ return LightApp_Application::onReopenDoc();
+}
+
+
+/*!SLOT. Load document.*/
+void SalomeApp_Application::onOpenDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ LightApp_Application::onOpenDoc();
+}
+
+/*!SLOT. Load document.*/
+bool SalomeApp_Application::onOpenDoc(const QString& name)
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ return LightApp_Application::onOpenDoc(name);
}
/*!Sets enable or disable some actions on selection changed.*/
this, SIGNAL(notebookVarUpdated(QString)) );
#endif
+ getStudy()->Init();
+
return aStudy;
}
virtual bool renameObject( const QString&, const QString& );
public slots:
+ virtual void onNewDoc();
virtual void onLoadDoc();
virtual void onNewWithScript();
virtual bool onLoadDoc( const QString& );
virtual void onUnloadDoc( bool ask = true);
virtual void onCloseDoc( bool ask = true);
+ virtual void onOpenDoc();
+ virtual bool onOpenDoc( const QString& );
+ virtual bool onReopenDoc();
virtual void onExit();
virtual void onCopy();
QMap<QString, QAction*> myExtActions; // Map <AttributeUserID, QAction>
bool myIsCloseFromExit; // "Close from Exit" flag
+ bool myToIgnoreMessages;// to ignore messages from SALOMEDS
+
signals:
void dumpedStudyClosed( const QString& theDumpScript,
const QString& theStudyName,
if ( myObserver ) {
PortableServer::ObjectId_var oid = myObserver->_default_POA()->servant_to_id( myObserver );
myObserver->_default_POA()->deactivate_object( oid.in() );
+ myObserver = 0;
}
}
while ( it.hasNext() )
openDataModel( studyName(), it.next() );
+ bool res = CAM_Study::openDocument( theStudyName );
+
+ //rnv: to fix the "0051779: TC7.2.0: Save operation works incorrectly for study loaded from data server"
+ // mark study as "not saved" after call openDocument( ... ) method.
+ setIsSaved(false);
+ emit opened( this ); // myRoot is set to Object Browser here
+
// this will build a SUIT_DataObject-s tree under myRoot member field
// passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
// but tree that corresponds to not-loaded data models will be updated any way.
myStudyDS->attach(myObserver->_this(),true);
#endif
- bool res = CAM_Study::openDocument( theStudyName );
-
- //rnv: to fix the "0051779: TC7.2.0: Save operation works incorrectly for study loaded from data server"
- // mark study as "not saved" after call openDocument( ... ) method.
- setIsSaved(false);
- emit opened( this );
-
bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
if ( restore ) {
std::vector<int> savePoints = getSavePoints();