"....................",
"...................."};
+int LightApp_Application::lastStudyId = 0;
+
+int LightApp_Application::studyId()
+{
+ return LightApp_Application::lastStudyId;
+}
+
/*!Create new instance of LightApp_Application.*/
extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
{
//=======================================================================
SUIT_Study* LightApp_Application::createNewStudy()
{
+ LightApp_Application::lastStudyId++;
+
LightApp_Study* aStudy = new LightApp_Study( this );
// Set up processing of major study-related events
if ( !aVer.isEmpty() )
aTitle += QString( " " ) + aVer;
+ if ( activeStudy() ) {
+ QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
+ aTitle += QString( " - [%1]" ).arg( sName );
+ }
+
desktop()->setCaption( aTitle );
}
/*!Update windows.*/
void LightApp_Application::updateWindows()
{
+ if ( !activeStudy() )
+ return;
+
QMap<int, int> winMap;
currentWindows( winMap );
return false;
}
+/*! default name for an active study */
+void LightApp_Application::setDefaultStudyName( const QString& theName )
+{
+ QStringList anInfoList;
+ modules( anInfoList, false );
+
+ LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
+ if( anInfoList.count() == 1 && // to avoid a conflict between different modules
+ !aStudy->isSaved() )
+ {
+ aStudy->setStudyName( theName );
+ updateDesktopTitle();
+ }
+}
//
// See http://www.salome-platform.org/
//
-#ifndef LIGHTAPP_STUDY_H\r
-#define LIGHTAPP_STUDY_H\r
-\r
-#include <LightApp.h>\r
-#include <LightApp_Driver.h>\r
-\r
-#include <CAM_Study.h>\r
-#include <CAM_DataModel.h>\r
-#include <SUIT_Study.h>\r
-\r
-#include "string"\r
-#include "vector"\r
-\r
-class SUIT_Application;\r
-class CAM_DataModel;\r
-\r
-class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study\r
-{\r
- Q_OBJECT\r
-\r
-public:\r
- LightApp_Study( SUIT_Application* );\r
- virtual ~LightApp_Study();\r
-\r
- virtual void createDocument();\r
- virtual bool openDocument( const QString& );\r
- virtual bool loadDocument( const QString& ); \r
-\r
- virtual bool saveDocument();\r
- virtual bool saveDocumentAs( const QString& );\r
-\r
- virtual void closeDocument(bool permanently = true);\r
-\r
- virtual bool isSaved() const;\r
- virtual bool isModified() const;\r
-\r
- virtual void addComponent ( const CAM_DataModel* dm);\r
-\r
- virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile );\r
-\r
- virtual QString componentDataType( const QString& ) const;\r
- virtual QString referencedToEntry( const QString& ) const;\r
- virtual bool isComponent( const QString& ) const;\r
- virtual void children( const QString&, QStringList& ) const;\r
- virtual void components( QStringList& ) const;\r
-\r
-protected:\r
- virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );\r
- virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles );\r
- virtual bool saveStudyData ( const QString& theFileName );\r
- virtual bool openStudyData ( const QString& theFileName );\r
-\r
- virtual std::vector<std::string> GetListOfFiles ( const char* theModuleName ) const;\r
- virtual void SetListOfFiles ( const char* theModuleName,\r
- const std::vector<std::string> theListOfFiles );\r
-\r
- virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const;\r
-\r
-protected:\r
- virtual bool openDataModel ( const QString&, CAM_DataModel* );\r
-\r
-signals:\r
- void saved ( SUIT_Study* );\r
- void opened ( SUIT_Study* );\r
- void closed ( SUIT_Study* );\r
- void created( SUIT_Study* );\r
-\r
-\r
-private:\r
- LightApp_Driver* myDriver;\r
-};\r
-\r
-#endif \r
+#ifndef LIGHTAPP_STUDY_H
+#define LIGHTAPP_STUDY_H
+
+#include <LightApp.h>
+#include <LightApp_Driver.h>
+
+#include <CAM_Study.h>
+#include <CAM_DataModel.h>
+#include <SUIT_Study.h>
+
+#include "string"
+#include "vector"
+
+class SUIT_Application;
+class CAM_DataModel;
+
+class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study
+{
+ Q_OBJECT
+
+public:
+ LightApp_Study( SUIT_Application* );
+ virtual ~LightApp_Study();
+
+ virtual void createDocument();
+ virtual bool openDocument( const QString& );
+ virtual bool loadDocument( const QString& );
+
+ virtual bool saveDocument();
+ virtual bool saveDocumentAs( const QString& );
+
+ virtual void closeDocument(bool permanently = true);
+
+ virtual bool isSaved() const;
+ virtual bool isModified() const;
+
+ virtual void addComponent ( const CAM_DataModel* dm);
+
+ virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile );
+
+ virtual QString componentDataType( const QString& ) const;
+ virtual QString referencedToEntry( const QString& ) const;
+ virtual bool isComponent( const QString& ) const;
+ virtual void children( const QString&, QStringList& ) const;
+ virtual void components( QStringList& ) const;
+
+protected:
+ virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );
+ virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles );
+ virtual bool saveStudyData ( const QString& theFileName );
+ virtual bool openStudyData ( const QString& theFileName );
+
+ virtual std::vector<std::string> GetListOfFiles ( const char* theModuleName ) const;
+ virtual void SetListOfFiles ( const char* theModuleName,
+ const std::vector<std::string> theListOfFiles );
+
+ virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const;
+
+protected:
+ virtual bool openDataModel ( const QString&, CAM_DataModel* );
+
+signals:
+ void saved ( SUIT_Study* );
+ void opened ( SUIT_Study* );
+ void closed ( SUIT_Study* );
+ void created( SUIT_Study* );
+
+
+private:
+ LightApp_Driver* myDriver;
+
+ friend class LightApp_Application;
+};
+
+#endif
#include <qdockarea.h>
#include <qdockwindow.h>
#include <qmainwindow.h>
+#include <qobjectlist.h>
#include <qapplication.h>
/*!
if ( !mw )
return;
- lst = mw->dockWindows();
+ QObjectList* objs = mw->queryList( "QDockWindow" );
+ if ( objs )
+ {
+ for ( QObjectListIt it( *objs ); it.current(); ++it )
+ {
+ QDockWindow* dockWin = ::qt_cast<QDockWindow*>( it.current() );
+ if ( dockWin && dockMainWindow( mw, dockWin ) )
+ lst.append( dockWin );
+ }
+ }
+ delete objs;
+}
+
+bool QtxDockAction::dockMainWindow( QMainWindow* mw, QObject* win ) const
+{
+ if ( !mw || !win )
+ return false;
+
+ while ( win )
+ {
+ if ( win->parent() && win->parent() == mw )
+ return true;
+
+ if ( ::qt_cast<QMainWindow*>( win->parent() ) )
+ return false;
+
+ win = win->parent();
+ }
+
+ return false;
}
/*!
if ( !myInfo.contains( dw ) )
return;
+ QMainWindow* mw = mainWindow();
+ if ( !mw )
+ return;
+
+ QObject* p = dw->parent();
+ if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) )
+ return;
+
QString winName = myInfo[dw].name;
if ( winName.isEmpty() || !myGeom.contains( winName ) )
return;
QMap<QString, QDockWindow*> nameMap;
for ( QPtrListIterator<QDockWindow> itr( lst ); itr.current(); ++itr )
{
+ QObject* p = itr.current()->parent();
+ if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) )
+ continue;
+
QString name;
if ( myInfo.contains( itr.current() ) )
name = myInfo[itr.current()].name;