}
//! MRU
- QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
- connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
+ static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
+ connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onOpenDoc( const QString& ) ) );
registerAction( MRUId, mru );
// default icon for neutral point ('SALOME' module)
*/
bool LightApp_Application::onOpenDoc( const QString& aName )
{
+#ifdef SWITCH_OFF
bool isAlreadyOpen = false;
// Look among opened studies
}
}
}
+#endif
bool res = CAM_Application::onOpenDoc( aName );
- QAction* a = action( MRUId );
- if ( a && a->inherits( "QtxMRUAction" ) )
+ QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
+ if ( mru )
{
- QtxMRUAction* mru = (QtxMRUAction*)a;
if ( res )
mru->insert( aName );
else
emit preferenceChanged( modName, section, param );
}
-/*!Private SLOT. On open document with name \a aName.*/
-void LightApp_Application::onMRUActivated( QString aName )
-{
- onOpenDoc( aName );
-}
-
/*!Remove all windows from study.*/
void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
{
if ( !aResMgr )
return;
+ static bool mru_load = true;
+ if ( mru_load )
+ {
+ QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
+ if ( mru )
+ mru->loadLinks( aResMgr, "MRU" );
+ mru_load = false;
+ }
+
myWinGeom.clear();
QStringList mods = aResMgr->parameters( "windows_geometry" );
for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
saveDockWindowsState();
- if ( !resourceMgr() )
+ SUIT_ResourceMgr* aResMgr = resourceMgr();
+
+ if ( !aResMgr )
return;
+ QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
+ if ( mru )
+ mru->saveLinks( aResMgr, "MRU" );
+
for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
- resourceMgr()->setValue( "windows_geometry", it.key(), it.value() );
+ aResMgr->setValue( "windows_geometry", it.key(), it.value() );
for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
- resourceMgr()->setValue( "windows_visibility", itr.key(), itr.value() );
+ aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
if ( desktop() )
- resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
+ aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
- resourceMgr()->save();
+ aResMgr->save();
}
/*!
Updates desktop title
*/
-void LightApp_Application::updateDesktopTitle() {
+void LightApp_Application::updateDesktopTitle()
+{
QString aTitle = applicationName();
QString aVer = applicationVersion();
if ( !aVer.isEmpty() )
return false;
}
+
+int LightApp_Application::openChoice( const QString& aName )
+{
+ int choice = CAM_Application::openChoice( aName );
+
+ if ( choice == OpenExist ) // The document is already open.
+ {
+ // Do you want to reload it?
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
+ choice = OpenReload;
+ }
+
+ return choice;
+}
+
+bool LightApp_Application::openAction( const int choice, const QString& aName )
+{
+ bool res = false;
+ switch ( choice )
+ {
+ case OpenReload:
+ {
+ STD_Application* app = 0;
+ SUIT_Session* session = SUIT_Session::session();
+ QList<SUIT_Application*> appList = session->applications();
+ for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
+ {
+ if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
+ app = ::qobject_cast<STD_Application*>( *it );
+ }
+
+ if ( app )
+ {
+ app->onCloseDoc( false );
+ appList = session->applications();
+ STD_Application* other = 0;
+ for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
+ other = ::qobject_cast<STD_Application*>( *it );
+
+ if ( other )
+ res = other->onOpenDoc( aName );
+ }
+ }
+ break;
+ default:
+ res = CAM_Application::openAction( choice, aName );
+ break;
+ }
+
+ return res;
+}
enum { MenuWindowId = 6 };
- enum { RenameId = CAM_Application::UserID,
-
-#ifndef DISABLE_GLVIEWER
- NewGLViewId ,
-#endif
-
-#ifndef DISABLE_PLOT2DVIEWER
- NewPlot2dId,
-#endif
-
-#ifndef DISABLE_OCCVIEWER
- NewOCCViewId,
-#endif
-
-#ifndef DISABLE_VTKVIEWER
- NewVTKViewId,
-#endif
-
-#ifndef DISABLE_QXGRAPHVIEWER
- NewQxGraphViewId,
-#endif
-
- PreferencesId, MRUId, ModulesListId, UserID };
+ enum { RenameId = CAM_Application::UserID, PreferencesId, MRUId, ModulesListId,
+ NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId, UserID };
protected:
enum { NewStudyId = 1, OpenStudyId };
void onSelection();
void onRefresh();
void onPreferences();
- void onMRUActivated( QString );
void onPreferenceChanged( QString&, QString&, QString& );
void onRenameWindow();
QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
+ virtual int openChoice( const QString& );
+ virtual bool openAction( const int, const QString& );
+
protected:
typedef QPointer<QWidget> WinPtr;
typedef QMap<int, WinPtr> WinMap;
typedef QMap<QString, QByteArray> WinVis;
typedef QMap<QString, QByteArray> WinGeom;
+ enum { OpenReload = CAM_Application::OpenExist + 1 };
+
protected:
LightApp_Preferences* myPrefs;
LightApp_SelectionMgr* mySelMgr;
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
QtxMRUAction::QtxMRUAction( QObject* parent )
: QtxAction( "Most Recently Used", "Most Recently Used", 0, parent ),
myVisCount( 5 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
setMenu( new QMenu( 0 ) );
QtxMRUAction::QtxMRUAction( const QString& text, const QString& menuText, QObject* parent )
: QtxAction( text, menuText, 0, parent ),
myVisCount( 5 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
setMenu( new QMenu( 0 ) );
QtxMRUAction::QtxMRUAction( const QString& text, const QIcon& icon,
const QString& menuText, QObject* parent )
: QtxAction( text, icon, menuText, 0, parent ),
-myVisCount( 5 ),
-myInsertMode( MoveFirst )
+ myVisCount( 5 ),
+ myLinkType( LinkAuto ),
+ myInsertMode( MoveFirst )
{
setMenu( new QMenu( 0 ) );
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
myInsertMode = mode;
}
+/*!
+ \brief Get the type of link menu name.
+ \return link type (QtxMRUAction::LinkType)
+*/
+int QtxMRUAction::linkType() const
+{
+ return myLinkType;
+}
+
+/*!
+ \brief Set the type of link menu name.
+ \param link type (QtxMRUAction::LinkType)
+*/
+void QtxMRUAction::setLinkType( const int type )
+{
+ myLinkType = type;
+}
+
/*!
\brief Get number of MRU items.
\return number of MRU items
/*!
\brief Set number of visible MRU items.
-
+
This method sets the maximum number of MRU items
to be displayed in the popup menu (5 by default).
/*!
\brief Prepare MRU items popup menu.
-
+
This method is called when the parent menu is shown.
Enables or disables sub menu item according to the number of MRU items.
*/
if ( !a )
return;
- QString link = a->text();
+ QString link = a->data().toString();
if ( !link.isEmpty() && myLinks.contains( link ) )
emit activated( link );
}
pm->clear();
+ QStringList links;
+ QMap<QString, int> map;
int count = visibleCount() < 0 ? myLinks.count() : visibleCount();
for ( QStringList::const_iterator it = myLinks.begin(); it != myLinks.end() && count > 0; ++it, count-- )
- pm->addAction( *it, this, SLOT( onActivated() ) );
+ {
+ links.append( *it );
+ if ( linkType() == LinkAuto )
+ {
+ QString shortName = Qtx::file( *it );
+ if ( map.contains( shortName ) )
+ map[shortName]++;
+ else
+ map.insert( shortName, 0 );
+ }
+ }
+
+ int i = 0;
+ for ( QStringList::const_iterator it = links.begin(); it != links.end(); ++it, i++ )
+ {
+ QString linkName;
+ switch( linkType() )
+ {
+ case LinkAuto:
+ linkName = Qtx::file( *it );
+ if ( map.contains( linkName ) && map[linkName] )
+ linkName = *it;
+ break;
+ case LinkShort:
+ linkName = Qtx::file( *it );
+ break;
+ case LinkFull:
+ default:
+ linkName = *it;
+ break;
+ }
+
+ if ( links.count() < 10 )
+ linkName = QString( "&%1 %2" ).arg( i ).arg( linkName );
+
+ pm->addAction( linkName, this, SLOT( onActivated() ) )->setData( *it );
+ }
+
+ if ( pm->isEmpty() )
+ pm->addAction( tr( "<Empty>" ) )->setEnabled( false );
}
/*!
AddLast //!< if specified item doesn't exist, add it to the end
} InsertionMode;
+ typedef enum { LinkAuto, //!< put the full path of link into the menu if link file names of severals link are same
+ LinkShort, //!< put the only file name of link into the menu
+ LinkFull //!< put the full path of link into the menu
+ } LinkType;
+
public:
QtxMRUAction( QObject* = 0 );
QtxMRUAction( const QString&, const QString&, QObject* = 0 );
int insertMode() const;
void setInsertMode( const int );
+ int linkType() const;
+ void setLinkType( const int );
+
int count() const;
bool isEmpty() const;
private:
QStringList myLinks; //!< most recent used items
int myVisCount; //!< number of visible MRU items
+ int myLinkType; //!< type of link names in menu
int myInsertMode; //!< items insertion policy
};
{
QApplication::setOverrideCursor( Qt::WaitCursor );
- bool res = true;
- if ( !activeStudy() )
- {
- // if no study - open in current desktop
- res = useFile( aName );
- }
- else
- {
- // if study exists - open in new desktop. Check: is the same file is opened?
- SUIT_Session* aSession = SUIT_Session::session();
- QList<SUIT_Application*> aAppList = aSession->applications();
- bool isAlreadyOpen = false;
- SUIT_Application* aApp = 0;
- for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it )
- {
- aApp = *it;
- if ( aApp->activeStudy()->studyName() == aName )
- isAlreadyOpen = true;
- }
- if ( !isAlreadyOpen )
- {
- aApp = startApplication( 0, 0 );
- if ( aApp )
- res = aApp->useFile( aName );
- if ( !res )
- aApp->closeApplication();
- }
- else
- aApp->desktop()->activateWindow();
- }
-
+ bool res = openAction( openChoice( aName ), aName );
+
QApplication::restoreOverrideCursor();
return res;
return res;
}
+int STD_Application::openChoice( const QString& aName )
+{
+ SUIT_Session* aSession = SUIT_Session::session();
+
+ bool isAlreadyOpen = false;
+ QList<SUIT_Application*> aAppList = aSession->applications();
+ for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it )
+ isAlreadyOpen = (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName;
+ return isAlreadyOpen ? OpenExist : OpenNew;
+}
+
+bool STD_Application::openAction( const int choice, const QString& aName )
+{
+ bool res = true;
+ switch ( choice )
+ {
+ case OpenExist:
+ {
+ SUIT_Application* aApp = 0;
+ SUIT_Session* aSession = SUIT_Session::session();
+ QList<SUIT_Application*> aAppList = aSession->applications();
+ for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !aApp; ++it )
+ {
+ if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
+ aApp = *it;
+ }
+ if ( aApp )
+ aApp->desktop()->activateWindow();
+ else
+ res = false;
+ }
+ break;
+ case OpenNew:
+ if ( !activeStudy() )
+ res = useFile( aName );
+ else
+ {
+ SUIT_Application* aApp = startApplication( 0, 0 );
+ if ( aApp )
+ res = aApp->useFile( aName );
+ if ( !res )
+ aApp->closeApplication();
+ }
+ break;
+ case OpenCancel:
+ default:
+ res = false;
+ }
+
+ return res;
+}
+
/*!Save document if all ok, else error message.*/
void STD_Application::onSaveDoc()
{
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
void viewManagers( const QString&, ViewManagerList& ) const;
virtual QString getFileFilter() const { return QString(); }
- virtual QString getFileName( bool open, const QString& initial, const QString& filters,
+ virtual QString getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent );
QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
MenuHelpId = 7
};
+ enum { OpenCancel, OpenNew, OpenExist };
enum { CloseCancel, CloseSave, CloseDiscard };
protected:
virtual void setActiveViewManager( SUIT_ViewManager* );
- virtual bool closeAction( const int, bool& );
+ virtual int openChoice( const QString& );
+ virtual bool openAction( const int, const QString& );
+
virtual int closeChoice( const QString& );
+ virtual bool closeAction( const int, bool& );
private:
ViewManagerList myViewMgrs;
{
SUIT_FileDlg fd( parent, open, showQuickDir, true );
- fd.setFileMode( ExistingFile );
+ fd.setFileMode( open ? ExistingFile : AnyFile );
if ( filters.isEmpty() )
fd.setFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
SalomeApp_DataObject* SAObj = dynamic_cast<SalomeApp_DataObject*>( theObj );
if( !SAObj )
return;
-
+
_PTR(SObject) SObj = SAObj->object();
if( !SObj )
return;
theItem->setSelectable( aAttrSel->IsSelectable() );
}
// Expandable
- if ( SObj->FindAttribute(anAttr, "AttributeExpandable") )
+ if ( SObj->FindAttribute(anAttr, "AttributeExpandable") )
{
_PTR(AttributeExpandable) aAttrExpand = anAttr;
theItem->setExpandable( aAttrExpand->IsExpandable() );
}
// Opened
//this attribute is not supported in the version of SALOME 3.x
- //if ( SObj->FindAttribute(anAttr, "AttributeOpened") )
+ //if ( SObj->FindAttribute(anAttr, "AttributeOpened") )
//{
// _PTR(AttributeOpened) aAttrOpen = anAttr;
// theItem->setOpen( aAttrOpen->IsOpened() );
SalomeApp_Application::SalomeApp_Application()
: LightApp_Application()
{
- connect( desktop(), SIGNAL( message( const QString& ) ),
+ connect( desktop(), SIGNAL( message( const QString& ) ),
this, SLOT( onDesktopMessage( const QString& ) ) );
}
LightApp_Application::createActions();
SUIT_Desktop* desk = desktop();
-
+
//! Save GUI state
// "Save GUI State" command is moved to VISU module
// createAction( SaveGUIStateId, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIcon(),
// tr( "MEN_DESK_FILE_SAVE_GUI_STATE" ), tr( "PRP_DESK_FILE_SAVE_GUI_STATE" ),
// 0, desk, false, this, SLOT( onSaveGUIState() ) );
-
+
//! Dump study
createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIcon(),
tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) );
-
+
//! Load script
createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(),
tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
- // "Save GUI State" command is renamed to "Save VISU State" and
+ // "Save GUI State" command is renamed to "Save VISU State" and
// creation of menu item is moved to VISU
- // createMenu( SaveGUIStateId, fileMenu, 10, -1 );
+ // createMenu( SaveGUIStateId, fileMenu, 10, -1 );
createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
createMenu( separator(), toolsMenu, -1, 15, -1 );
}
-/*! Purpose : SLOT. Open new document with \a aName.*/
-bool SalomeApp_Application::onOpenDoc( const QString& aName )
-{
- bool res = false, toOpen = true, isAlreadyOpen = false;
-
- // Look among opened studies
- if (activeStudy()) { // at least one study is opened
- SUIT_Session* aSession = SUIT_Session::session();
- QList<SUIT_Application*> aAppList = aSession->applications();
- QListIterator<SUIT_Application*> it (aAppList);
- SUIT_Application* aApp = 0;
- // iterate on all applications
- while ( it.hasNext() && !isAlreadyOpen ) {
- aApp = it.next();
-
- if (aApp && aApp->activeStudy()->studyName() == aName) {
- isAlreadyOpen = true; // Already opened, ask user what to do
-
- // The document ... is already open.
- // Do you want to reload it?
- int aAnswer = SUIT_MessageBox::question(desktop(), tr("WRN_WARNING"),
- tr("QUE_DOC_ALREADYOPEN").arg(aName),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::No);
- if (aAnswer == SUIT_MessageBox::Yes) { // reload
- if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
- // Opened in THIS (active) application.
- STD_Application* app1 = (STD_Application*)aAppList.at(0);
- STD_Application* app2 = (STD_Application*)aAppList.at(1);
- if (!app1 || !app2) {
- // Error
- return false;
- }
- if (app1->activeStudy()->studyName() == aName) {
- // app1 is this application, we need another one
- app1 = app2;
- }
- // Close document of this application. This application will be destroyed.
- onCloseDoc(/*ask = */false);
- // Open the file with another application, as this one will be destroyed.
- return app1->onOpenDoc(aName);
- } else {
- // Opened in another application.
- STD_Application* app = (STD_Application*)aApp;
- if (app)
- app->onCloseDoc(/*ask = */false);
- }
- } else { // do not reload
- // OK, the study will not be reloaded, but we call
- // CAM_Application::onOpenDoc( aName ) all the same.
- // It will activate a desktop of the study <aName>.
- }
- }
- }
- }
-
- // Look among unloaded studies
- if (!isAlreadyOpen) {
- std::vector<std::string> List = studyMgr()->GetOpenStudies();
-
- QString studyName;
- for (unsigned int ind = 0; ind < List.size() && !isAlreadyOpen; ind++) {
- studyName = List[ind].c_str();
- if (aName == studyName) {
- // Already exists unloaded, ask user what to do
- isAlreadyOpen = true;
-
- // The document ... already exists in the study manager.
- // Do you want to reload it?
- int aAnswer = SUIT_MessageBox::question(desktop(), tr("WRN_WARNING"),
- tr("QUE_DOC_ALREADYEXIST").arg(aName),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::No);
- if (aAnswer == SUIT_MessageBox::Yes) {
- _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.toStdString());
- if (aStudy)
- studyMgr()->Close(aStudy);
- } else {
- toOpen = false;
- }
- }
- }
- }
-
- if (toOpen)
- res = CAM_Application::onOpenDoc( aName );
-
- QAction* a = action( MRUId );
- if ( a && a->inherits( "QtxMRUAction" ) )
- {
- QtxMRUAction* mru = (QtxMRUAction*)a;
- if ( res )
- mru->insert( aName );
- else
- mru->remove( aName );
- }
- return res;
-}
-
/*!
\brief Close application.
*/
result = dlg.exec() == QDialog::Accepted;
killServers = dlg.isServersShutdown();
}
-
+
if ( result )
SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers );
}
QListIterator<SUIT_Application*> it( aAppList );
while ( it.hasNext() && !isAlreadyOpen ) {
SUIT_Application* aApp = it.next();
- if( !aApp || !aApp->activeStudy() )
+ if( !aApp || !aApp->activeStudy() )
continue;
- if ( aApp->activeStudy()->studyName() == studyName )
+ if ( aApp->activeStudy()->studyName() == studyName )
isAlreadyOpen = true;
}
- if ( !isAlreadyOpen )
+ if ( !isAlreadyOpen )
unloadedStudies << studyName;
}
return;
#ifndef WIN32
- // this code replaces marker of windows drive and path become invalid therefore
+ // this code replaces marker of windows drive and path become invalid therefore
// defines placed there
studyName.replace( QRegExp(":"), "/" );
#endif
QList<SUIT_Application*> aAppList = aSession->applications();
bool isAlreadyOpen = false;
SalomeApp_Application* aApp = 0;
- for ( QList<SUIT_Application*>::iterator it = aAppList.begin();
+ for ( QList<SUIT_Application*>::iterator it = aAppList.begin();
it != aAppList.end() && !isAlreadyOpen; ++it ) {
aApp = dynamic_cast<SalomeApp_Application*>( *it );
if ( aApp && aApp->activeStudy()->studyName() == aName )
SALOME_ListIO list;
LightApp_SelectionMgr* mgr = selectionMgr();
mgr->selectedObjects(list);
-
+
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if(study == NULL) return;
-
+
_PTR(Study) stdDS = study->studyDS();
if(!stdDS) return;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if (study != NULL) {
- _PTR(Study) stdDS = study->studyDS();
+ _PTR(Study) stdDS = study->studyDS();
if(stdDS && stdDS->IsStudyLocked()) {
if ( SUIT_MessageBox::question( desktop(),
QObject::tr( "WRN_WARNING" ),
QObject::tr( "CLOSE_LOCKED_STUDY" ),
SUIT_MessageBox::Yes | SUIT_MessageBox::No,
SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
-
+
}
}
/*!
\class DumpStudyFileDlg
- Private class used in Dump Study operation. Consists 2 check boxes:
+ Private class used in Dump Study operation. Consists 2 check boxes:
"Publish in study" and "Save GUI parameters"
*/
class DumpStudyFileDlg : public SUIT_FileDlg
{
public:
- DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true )
+ DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true )
{
QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
if ( grid )
QWidget *hB = new QWidget( this );
myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY") );
mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE") );
-
+
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(myPublishChk);
layout->addWidget(mySaveGUIChk);
hB->setLayout(layout);
-
- QPushButton* pb = new QPushButton(this);
+
+ QPushButton* pb = new QPushButton(this);
int row = grid->rowCount();
grid->addWidget( new QLabel("", this), row, 0 );
grid->addWidget( hB, row, 1, 1, 3 );
grid->addWidget( pb, row, 5 );
-
- pb->hide();
+
+ pb->hide();
}
}
QCheckBox* myPublishChk;
if(ip->isDumpPython(appStudy->studyDS())) ip->setDumpPython(appStudy->studyDS()); //Unset DumpPython flag.
if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
ip->setDumpPython(appStudy->studyDS());
- savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point
+ savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point
}
- bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toStdString(),
+ bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toStdString(),
aFileInfo.baseName().toStdString(), toPublish);
- if ( toSaveGUI )
+ if ( toSaveGUI )
appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point.
if ( !res )
SUIT_MessageBox::warning( desktop(),
if ( flag == WT_ObjectBrowser )
{
SUIT_DataBrowser* ob = qobject_cast<SUIT_DataBrowser*>( wid );
- if ( ob ) {
+ if ( ob ) {
// temporary commented
//ob->setUpdater( new SalomeApp_Updater() );
return res;
}
+int SalomeApp_Application::openChoice( const QString& aName )
+{
+ int choice = LightApp_Application::openChoice( aName );
+
+ if ( choice == OpenNew ) // The document isn't already open.
+ {
+ bool exist = false;
+ std::vector<std::string> lst = studyMgr()->GetOpenStudies();
+ for ( uint i = 0; i < lst.size() && !exist; i++ )
+ {
+ if ( aName == QString( lst[i].c_str() ) )
+ exist = true;
+ }
+
+ // The document already exists in the study manager.
+ // Do you want to reload it?
+ if ( exist )
+ {
+ int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYEXIST" ).arg( aName ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No );
+ if ( answer == SUIT_MessageBox::Yes )
+ choice = OpenRefresh;
+ else
+ choice = OpenCancel;
+ }
+ }
+
+ return choice;
+}
+
+bool SalomeApp_Application::openAction( const int aChoice, const QString& aName )
+{
+ bool res = false;
+ int choice = aChoice;
+ switch ( choice )
+ {
+ case OpenRefresh:
+ {
+ _PTR(Study) aStudy = studyMgr()->GetStudyByName( aName.toStdString() );
+ if ( aStudy )
+ {
+ studyMgr()->Close( aStudy );
+ choice = OpenNew;
+ }
+ }
+ default:
+ res = LightApp_Application::openAction( choice, aName );
+ break;
+ }
+
+ return res;
+}
+
/*!
- \brief Get map of the operations which can be performed
+ \brief Get map of the operations which can be performed
on the module activation.
-
+
The method should return the map of the kind \c {<id>:<name>}
where \c <id> is an integer identifier of the operation and
- \c <name> is a title for the button to be added to the
+ \c <name> is a title for the button to be added to the
dialog box. After user selects the required operation by the
clicking the corresponding button in the dialog box, its identifier
is passed to the moduleActionSelected() method to process
from "Activate module" dialog box.
Performs the required operation according to the user choice.
-
+
\param id operation identifier
\sa activateModuleActions()
*/
mgr->selectedObjects( aList, QString(), false );
// add GUI state commands: restore, rename
- if ( aList.Extent() == 1 && aList.First()->hasEntry() &&
+ if ( aList.Extent() == 1 && aList.First()->hasEntry() &&
QString( aList.First()->getEntry() ).startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
thePopup->addSeparator();
thePopup->addAction( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) );
_PTR(Study) stdDS = study->studyDS();
if( stdDS )
{
- for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
+ for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
{
_PTR(SComponent) aComponent ( it->Value() );
void SalomeApp_Application::onRestoreGUIState()
{
int savePoint = ::getSelectedSavePoint( selectionMgr() );
- if ( savePoint == -1 )
- return;
+ if ( savePoint == -1 )
+ return;
SalomeApp_VisualState( this ).restoreState( savePoint );
}
void SalomeApp_Application::onRenameGUIState()
{
int savePoint = ::getSelectedSavePoint( selectionMgr() );
- if ( savePoint == -1 )
- return;
+ if ( savePoint == -1 )
+ return;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( !study )
+ if ( !study )
return;
QString newName = LightApp_NameDlg::getName( desktop(), study->getNameOfSavePoint( savePoint ) );
void SalomeApp_Application::onDeleteGUIState()
{
int savePoint = ::getSelectedSavePoint( selectionMgr() );
- if ( savePoint == -1 )
- return;
+ if ( savePoint == -1 )
+ return;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( !study )
+ if ( !study )
return;
-
+
study->removeSavePoint( savePoint );
updateSavePointDataObjects( study );
}
// find GUI states root object
SUIT_DataObject* guiRootObj = 0;
- DataObjectList ch;
- study->root()->children( ch );
+ DataObjectList ch;
+ study->root()->children( ch );
DataObjectList::const_iterator it = ch.begin(), last = ch.end();
for ( ; it != last ; ++it ) {
if ( dynamic_cast<SalomeApp_SavePointRootObject*>( *it ) ) {
// store data objects in a map id-to-DataObject
QMap<int,SalomeApp_SavePointObject*> mapDO;
- ch.clear();
- guiRootObj->children( ch );
+ ch.clear();
+ guiRootObj->children( ch );
for( it = ch.begin(), last = ch.end(); it != last ; ++it ) {
SalomeApp_SavePointObject* dobj = dynamic_cast<SalomeApp_SavePointObject*>( *it );
if ( dobj )
}
// iterate new save points. if DataObject with such ID not found in map - create DataObject
- // if in the map - remove it from map.
+ // if in the map - remove it from map.
for ( int i = 0; i < savePoints.size(); i++ )
if ( !mapDO.contains( savePoints[i] ) )
new SalomeApp_SavePointObject( guiRootObj, savePoints[i], study );
void SalomeApp_Application::onDesktopMessage( const QString& message )
{
// update object browser
- if ( message.toLower() == "updateobjectbrowser" ||
+ if ( message.toLower() == "updateobjectbrowser" ||
message.toLower() == "updateobjbrowser" )
updateObjectBrowser();
}
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID };
protected:
- enum { CloseUnload = CloseDiscard + 1 };
- enum { LoadStudyId = OpenStudyId + 1 };
+ enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
+ enum { CloseUnload = LightApp_Application::CloseDiscard + 1 };
+ enum { LoadStudyId = LightApp_Application::OpenStudyId + 1 };
public:
SalomeApp_Application();
SUIT_ViewManager* newViewManager(const QString&);
void updateSavePointDataObjects( SalomeApp_Study* );
-
+
virtual bool isPossibleToClose( bool& );
virtual bool useStudy( const QString& );
public slots:
- virtual bool onOpenDoc( const QString& );
virtual void onLoadDoc();
virtual bool onLoadDoc( const QString& );
+ virtual void onCloseDoc( bool ask = true);
+
virtual void onExit();
virtual void onCopy();
virtual void onPaste();
void onSaveGUIState();// called from VISU
- virtual void onCloseDoc( bool ask = true);
protected slots:
void onStudySaved( SUIT_Study* );
virtual bool closeAction( const int, bool& );
virtual int closeChoice( const QString& );
-
+
+ virtual int openChoice( const QString& );
+ virtual bool openAction( const int, const QString& );
+
virtual QMap<int, QString> activateModuleActions() const;
virtual void moduleActionSelected( const int );
void onDblClick( QListViewItem* );
void onProperties();
void onDumpStudy();
- void onLoadScript();
+ void onLoadScript();
- void onDeleteGUIState();
+ void onDeleteGUIState();
void onRestoreGUIState();
void onRenameGUIState();