X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FSalomeApp%2FSalomeApp_Application.cxx;h=12a733584f9f9a98abad23a815311544ccee5f4e;hb=d3f84a2bd6b64ebe64b8bd639d28dd0e8c033133;hp=11d041cb7b1d981046b13b446671176f0af93d85;hpb=37049859b5c95eaefa95a6d0c8544550c15016ef;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 11d041cb7..12a733584 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -35,9 +35,10 @@ #endif #ifndef DISABLE_PYCONSOLE - #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first! - #include + #include "SalomeApp_PyInterp.h" #include "SalomeApp_NoteBook.h" + #include "LightApp_PyEditor.h" + #include "PyConsole_Console.h" #endif #include "SalomeApp_Application.h" #include "SalomeApp_Study.h" @@ -49,6 +50,7 @@ #include "SalomeApp_ExitDlg.h" #include +#include #include #include #include @@ -62,7 +64,6 @@ #include #include #include -#include #include #include #include @@ -84,6 +85,7 @@ #include #include +#include #include #include #include @@ -206,9 +208,9 @@ void SalomeApp_Application::start() QStringList pyfiles; QString loadStudy; - for (int i = 1; i < qApp->argc(); i++) { + for (int i = 1; i < qApp->arguments().size(); i++) { QRegExp rxs ("--study-hdf=(.+)"); - if ( rxs.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) { + if ( rxs.indexIn( qApp->arguments()[i] ) >= 0 && rxs.capturedTexts().count() > 1 ) { QString file = rxs.capturedTexts()[1]; QFileInfo fi ( file ); QString extension = fi.suffix().toLower(); @@ -217,7 +219,7 @@ void SalomeApp_Application::start() } else { QRegExp rxp ("--pyscript=\\[(.+)\\]"); - if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) { + if ( rxp.indexIn( qApp->arguments()[i] ) >= 0 && rxp.capturedTexts().count() > 1 ) { // pyscript QStringList dictList = rxp.capturedTexts()[1].split("},", QString::SkipEmptyParts); for (int k = 0; k < dictList.count(); ++k) { @@ -852,26 +854,6 @@ public: QCheckBox* mySaveGUIChk; }; -class DumpStudyFileValidator : public SUIT_FileValidator -{ - public: - DumpStudyFileValidator( QWidget* parent) : SUIT_FileValidator ( parent ) {}; - virtual ~DumpStudyFileValidator() {}; - virtual bool canSave( const QString& file, bool permissions ); -}; - -bool DumpStudyFileValidator::canSave(const QString& file, bool permissions) -{ - QFileInfo fi( file ); - if ( !QRegExp( "[A-Za-z_][A-Za-z0-9_]*" ).exactMatch( fi.completeBaseName() ) ) { - SUIT_MessageBox::critical( parent(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_FILE_NAME_BAD") ); - return false; - } - return SUIT_FileValidator::canSave( file, permissions); -} - /*!Private SLOT. On dump study.*/ void SalomeApp_Application::onDumpStudy( ) { @@ -893,9 +875,9 @@ void SalomeApp_Application::onDumpStudy( ) } DumpStudyFileDlg fd( desktop() ); - fd.setValidator( new DumpStudyFileValidator( &fd ) ); + fd.setValidator( new LightApp_PyFileValidator( &fd ) ); fd.setWindowTitle( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); - fd.setFilters( aFilters ); + fd.setNameFilters( aFilters ); fd.myPublishChk->setChecked( anIsPublish ); fd.myMultiFileChk->setChecked( anIsMultiFile ); fd.mySaveGUIChk->setChecked( anIsSaveGUI ); @@ -987,14 +969,6 @@ void SalomeApp_Application::onDockWindowVisibilityChanged( bool theIsVisible ) objectBrowserColumnsVisibility(); } -/*!Gets file filter. - *\retval QString "(*.hdf)" - */ -QString SalomeApp_Application::getFileFilter() const -{ - return "(*.hdf)"; -} - /*!Create window.*/ QWidget* SalomeApp_Application::createWindow( const int flag ) { @@ -1048,6 +1022,12 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) ob->setResizeOnExpandItem(resizeOnExpandItem); ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) ); + for ( int i = SalomeApp_DataObject::EntryId; i < SalomeApp_DataObject::LastId; i++ ) + { + bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i-1 ), true ); + ob->treeView()->setColumnHidden( i, !shown ); + } + // temporary commented /* for ( int i = SalomeApp_DataObject::ValueIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ ) @@ -1069,15 +1049,14 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { - PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() ); + PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" )); pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true )); + pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) ); pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) ); wid = pyCons; - //pyCons->resize( pyCons->width(), desktop()->height()/4 ); - pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } else if ( flag == WT_NoteBook ) { @@ -1314,8 +1293,14 @@ void SalomeApp_Application::moduleActionSelected( const int id ) /*!Gets CORBA::ORB_var*/ CORBA::ORB_var SalomeApp_Application::orb() { - ORB_INIT& init = *SINGLETON_::Instance(); - static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() ); + static CORBA::ORB_var _orb; + + if ( CORBA::is_nil( _orb ) ) { + Qtx::CmdLineArgs args; + ORB_INIT& init = *SINGLETON_::Instance(); + _orb = init( args.argc(), args.argv() ); + } + return _orb; } @@ -1543,6 +1528,7 @@ void SalomeApp_Application::onDblClick( SUIT_DataObject* theObj ) if ( !aSelectedIndexes.isEmpty() ) ob->treeView()->scrollTo( aSelectedIndexes.first() ); } + emit objectDoubleClicked( theObj ); } /*! @@ -2034,7 +2020,8 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript, { #ifndef DISABLE_PYCONSOLE _PTR(Study) aStudyDS = newStudy->studyDS(); - app->getNoteBook()->Init( aStudyDS ); + if ( app->getNoteBook() ) + app->getNoteBook()->Init( aStudyDS ); newStudy->updateFromNotebook(theStudyName, theIsStudySaved); newStudy->Modified(); updateDesktopTitle(); @@ -2087,7 +2074,7 @@ bool SalomeApp_Application::checkExistingDoc() PyConsole_Interp* SalomeApp_Application::createPyInterp() { - return new SalomeApp_PyInterp(); + return new SalomeApp_PyInterp; } #endif // DISABLE_PYCONSOLE