QtxMainWindow::QtxMainWindow( QWidget* parent, const char* name, WFlags f )
: QMainWindow( parent, name, f ),
-myMenuBar( 0 ),
-myStatusBar( 0 )
+myMenuBar( NULL ),
+myStatusBar( NULL )
{
}
if ( !activeStudy() )
{
// if no study - open in current desktop
- createEmptyStudy();
- res = activeStudy()->openDocument( aName );
- updateDesktopTitle();
- updateCommandsStatus();
+ // jfa 21.06.2005:createEmptyStudy();
+ // jfa 21.06.2005:res = activeStudy()->openDocument( aName );
+ // jfa 21.06.2005:updateDesktopTitle();
+ // jfa 21.06.2005:updateCommandsStatus();
+ res = useFile( aName ); // jfa 21.06.2005
}
else
{
return res;
}
+bool STD_Application::onLoadDoc( const QString& aName )
+{
+ bool res = true;
+ if ( !activeStudy() )
+ {
+ // if no study - load in current desktop
+ res = useStudy( aName );
+ }
+ else
+ {
+ // if study exists - load in new desktop. Check: is the same file is loaded?
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> aAppList = aSession->applications();
+ bool isAlreadyOpen = false;
+ SUIT_Application* aApp = 0;
+ for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
+ {
+ aApp = it.current();
+ if ( aApp->activeStudy()->studyName() == aName )
+ isAlreadyOpen = true;
+ }
+ if ( !isAlreadyOpen )
+ {
+ // temporary commented because of "pure virtual method called" execution error.
+ // current state of code is not right, but works somehow.
+ // SALOMEDS::Study of the first found application is replaced by the new one,
+ // while normally the new study must be used by a new application
+ //jfa tmp:aApp = startApplication( 0, 0 );
+ if ( aApp )
+ res = aApp->useStudy( aName );
+ }
+ else
+ aApp->desktop()->setActiveWindow();
+ }
+ return res;
+}
+
void STD_Application::beforeCloseDoc( SUIT_Study* )
{
}
virtual void onOpenDoc();
virtual bool onOpenDoc( const QString& );
+ //virtual void onLoadDoc();
+ virtual bool onLoadDoc( const QString& );
+
virtual void onExit();
virtual void onCopy();
createEmptyStudy();
if ( activeStudy() )
return activeStudy()->openDocument( theFileName );
+ return false;
+}
+
+bool SUIT_Application::useStudy( const QString& theName )
+{
+ return false;
}
void SUIT_Application::createEmptyStudy()
//! Shows the application's main widget. For non GUI application must be redefined.
virtual void start();
- //! Loads document <theFileName> into active Study. If Study is empty - creates it.
- virtual bool useFile( const QString& );
+ //! Opens document <theFileName> into active Study. If Study is empty - creates it.
+ virtual bool useFile( const QString& theFileName);
+
+ //! Loads document <theName> into active Study. If Study is empty - creates it.
+ virtual bool useStudy( const QString& theName);
//! Creates new empty Study if active Study = 0
virtual void createEmptyStudy();
//! This function must return a new application instance.
extern "C"
{
- typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
+ //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
+ typedef SUIT_Application* (*APP_CREATE_FUNC)();
}
#define APP_CREATE_NAME "createApplication"
return 0;
}
- myAppLibs.insert( appName, libHandle );
+ if (!myAppLibs.contains(appName) || !myAppLibs[appName]) // jfa 22.06.2005
+ myAppLibs.insert( appName, libHandle );
APP_CREATE_FUNC crtInst = 0;
myResMgr->loadLanguage();
}
- SUIT_Application* anApp = crtInst( args, argv );
+ //jfa 22.06.2005:SUIT_Application* anApp = crtInst( args, argv );
+ SUIT_Application* anApp = crtInst();
if ( !anApp )
{
SUIT_MessageBox::warn1(0, tr( "Error" ), tr( "Can not find function %1. %2").arg( APP_CREATE_NAME ).arg( lastError() ), tr( "Ok" ) );
return res;
}
+bool SalomeApp_Application::onLoadDoc( const QString& aName )
+{
+ bool res = CAM_Application::onLoadDoc( aName );
+
+ /*jfa tmp:QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
+ {
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }*/
+ return res;
+}
+
void SalomeApp_Application::onSelection()
{
onSelectionChanged();
QApplication::restoreOverrideCursor();
}
+bool SalomeApp_Application::useStudy(const QString& theName)
+{
+ createEmptyStudy();
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ bool res = false;
+ if (aStudy)
+ res = aStudy->loadDocument( theName );
+ updateDesktopTitle();
+ updateCommandsStatus();
+ return res;
+}
+
void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
{
CAM_Application::setActiveStudy( study );
virtual CAM_Module* loadModule( const QString& );
virtual bool activateModule( const QString& );
+ virtual bool useStudy( const QString& );
+
SalomeApp_SelectionMgr* selectionMgr() const;
LogWindow* logWindow();
virtual void onOpenDoc();
virtual void onHelpAbout();
virtual bool onOpenDoc( const QString& );
+ virtual bool onLoadDoc( const QString& );
virtual void onCopy();
virtual void onPaste();
if ( aComponent->ComponentDataType() == "Interface Applicative" )
continue; // skip the magic "Interface Applicative" component
-
+
SalomeApp_DataModel::BuildTree( aComponent, root(), this );
}
// TODO: potentially unsafe call, since base study's openDocument() might try to access the file directly - to be improved
+ //bool res = true;
bool res = CAM_Study::openDocument( theStudyName );
- emit opened( this );
+ //emit opened( this );
- return res;
+ return res;
}
//=======================================================================