From: mkr Date: Fri, 22 Jun 2007 14:03:41 +0000 (+0000) Subject: Porting to Qt4. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc451abe6cb78f8946e67bee1987e3ea8ef30f68;p=modules%2Fgui.git Porting to Qt4. --- diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index cb09b74f1..5c554f9a1 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -127,7 +127,8 @@ void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e ) return; } - if ( !isPossibleToClose() ) + bool closePermanently; + if ( !isPossibleToClose( closePermanently ) ) { e->ignore(); return; @@ -396,7 +397,9 @@ void STD_Application::afterCloseDoc() /*!Close document, if it's possible.*/ void STD_Application::onCloseDoc( bool ask ) { - if ( ask && !isPossibleToClose() ) + bool closePermanently = true; + + if ( ask && !isPossibleToClose( closePermanently ) ) return; SUIT_Study* study = activeStudy(); @@ -404,9 +407,7 @@ void STD_Application::onCloseDoc( bool ask ) beforeCloseDoc( study ); if ( study ) - study->closeDocument(); -// TODO: myClosePermanently move to SalomeApp -// study->closeDocument( myClosePermanently ); + study->closeDocument( closePermanently ); clearViewManagers(); @@ -438,17 +439,15 @@ void STD_Application::onCloseDoc( bool ask ) /*!Check the application on closing. * \retval true if possible, else false */ -bool STD_Application::isPossibleToClose() +bool STD_Application::isPossibleToClose( bool& closePermanently ) { -// TODO: myClosePermanently move to SalomeApp -// myClosePermanently = true; if ( activeStudy() ) { activeStudy()->abortAllOperations(); if ( activeStudy()->isModified() ) { QString sName = activeStudy()->studyName().trimmed(); - return closeAction( closeChoice( sName ) ); + return closeAction( closeChoice( sName ), closePermanently ); } } return true; @@ -469,7 +468,7 @@ int STD_Application::closeChoice( const QString& docName ) return res; } -bool STD_Application::closeAction( const int choice ) +bool STD_Application::closeAction( const int choice, bool& closePermanently ) { bool res = true; switch( choice ) @@ -482,11 +481,6 @@ bool STD_Application::closeAction( const int choice ) break; case CloseDiscard: break; -/* - case 3: - myClosePermanently = false; - break; -*/ case CloseCancel: default: res = false; diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 7177a9a6b..3ff6d57bc 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -61,7 +61,7 @@ public: virtual QString applicationName() const; - virtual bool isPossibleToClose(); + virtual bool isPossibleToClose( bool& ); virtual bool useFile( const QString& ); virtual void createEmptyStudy(); @@ -158,7 +158,7 @@ protected: virtual void setActiveViewManager( SUIT_ViewManager* ); - virtual bool closeAction( const int ); + virtual bool closeAction( const int, bool& ); virtual int closeChoice( const QString& ); private: @@ -168,7 +168,6 @@ private: private: bool myExitConfirm; bool myEditEnabled; -// bool myClosePermanently; TODO: Move into SalomeApp_Application }; #if defined WIN32 diff --git a/src/STD/resources/STD_msg_en.po b/src/STD/resources/STD_msg_en.po index eef69e683..7956e4586 100755 --- a/src/STD/resources/STD_msg_en.po +++ b/src/STD/resources/STD_msg_en.po @@ -344,15 +344,6 @@ msgstr "Saving study " msgid "STD_Application::INF_DOC_SAVING_FAILS" msgstr "Can't save file \"%1\".\nPossible reason is permission denied or disc full.\nTry to use another file name." -msgid "CLOSE_DLG_SAVE_CLOSE" -msgstr "&Save&&Close" - -msgid "CLOSE_DLG_CLOSE" -msgstr "C&lose w/o saving" - -msgid "CLOSE_DLG_UNLOAD" -msgstr "&Unload" - msgid "TOT_DESK_FILE_LOAD" msgstr "Load document" @@ -362,12 +353,6 @@ msgstr "Load a document" msgid "MEN_DESK_FILE_LOAD" msgstr "Conn&ect..." -msgid "CLOSE_DLG_CAPTION" -msgstr "Close active study" - -msgid "CLOSE_DLG_DESCRIPTION" -msgstr "Do you want to close or only unload the study" - msgid "DLG_LOAD_STUDY_CAPTION" msgstr "Load Study" diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index 0f01076b0..a5e545230 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -67,7 +67,7 @@ SUIT_Desktop* SUIT_Application::desktop() \return FALSE if application can not be closed (because of non saved data for example). This method called by SUIT_Session whin closing of application was requested. */ -bool SUIT_Application::isPossibleToClose() +bool SUIT_Application::isPossibleToClose( bool& closePermanently ) { return true; } diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 597932673..710d3b2d5 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -64,7 +64,7 @@ public: /*! Returns FALSE if application can not be closed (because of non saved data for example). This method called by SUIT_Session whin closing of application was requested. */ - virtual bool isPossibleToClose(); + virtual bool isPossibleToClose( bool& ); /*! Performs some finalization of life cycle of this application. For instance, the application can force its documents(s) to close. */ diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 000786bb2..891c20b8f 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -243,7 +243,8 @@ void SUIT_Session::closeSession( int mode ) for ( AppList::const_iterator it = apps.begin(); it != apps.end(); ++it ) { SUIT_Application* app = *it; - if ( mode == ASK && !app->isPossibleToClose() ) + bool closePermanently; + if ( mode == ASK && !app->isPossibleToClose( closePermanently ) ) return; else if ( mode == SAVE ) { diff --git a/src/SalomeApp/Makefile.am b/src/SalomeApp/Makefile.am index f8a49cf22..4299c0858 100755 --- a/src/SalomeApp/Makefile.am +++ b/src/SalomeApp/Makefile.am @@ -92,17 +92,17 @@ libSalomeApp_la_CPPFLAGS=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) \ -I$(srcdir)/../LightApp -I$(srcdir)/../CAM -I$(srcdir)/../Qtx \ -I$(srcdir)/../SUIT -I$(srcdir)/../OBJECT -I$(srcdir)/../SVTK \ -I$(srcdir)/../STD -I$(srcdir)/../VTKViewer -I$(srcdir)/../ObjBrowser \ - -I$(srcdir)/../PythonConsole -I$(srcdir)/../TOOLSGUI \ + -I$(srcdir)/../PyConsole -I$(srcdir)/../TOOLSGUI \ -I$(srcdir)/../PyInterp -I$(srcdir)/../Session -I$(top_builddir)/idl \ -I$(srcdir)/../Event \ -I$(top_builddir)/salome_adm/unix @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ libSalomeApp_la_LDFLAGS=$(PYTHON_LIBS) $(QT_MT_LIBS) libSalomeApp_la_LIBADD= $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient \ - ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la ../ObjBrowser/libObjBrowser.la \ + ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ #../ObjBrowser/libObjBrowser.la \ ../Prs/libSalomePrs.la ../SPlot2d/libSPlot2d.la ../GLViewer/libGLViewer.la \ ../OCCViewer/libOCCViewer.la ../VTKViewer/libVTKViewer.la ../OBJECT/libSalomeObject.la \ ../SVTK/libSVTK.la ../SOCC/libSOCC.la ../PyInterp/libPyInterp.la \ - ../PythonConsole/libPythonConsole.la ../LogWindow/libLogWindow.la \ + ../PyConsole/libPyConsole.la ../LogWindow/libLogWindow.la \ ../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la $(CAS_KERNEL) EXTRA_DIST+=SalomeApp_PyInterp.h diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index fa94bedc6..61c7bb715 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -32,45 +32,46 @@ #include "SalomeApp_VisualState.h" #include "SalomeApp_StudyPropertiesDlg.h" +#include "SalomeApp_LoadStudiesDlg.h" #include "LightApp_Application.h" #include "LightApp_Preferences.h" -#include "LightApp_WidgetContainer.h" #include "LightApp_SelectionMgr.h" #include "LightApp_NameDlg.h" -#include "SalomeApp_LoadStudiesDlg.h" +#include "CAM_Module.h" #include #include +#include #include -#include -#include +// temporary commented +//#include +//#include -#include +#include #include #include #include -#include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "SALOMEDSClient_ClientFactory.hxx" -#include "SALOMEDSClient_IParameters.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIO.hxx" @@ -78,11 +79,11 @@ #include "ToolsGUI_CatalogGeneratorDlg.h" #include "ToolsGUI_RegWidget.h" -#include - #include + /*!Internal class that updates object browser item properties */ -class SalomeApp_Updater : public OB_Updater +// temporary commented +/*class SalomeApp_Updater : public OB_Updater { public: SalomeApp_Updater() : OB_Updater(){}; @@ -123,7 +124,7 @@ void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem ) // _PTR(AttributeOpened) aAttrOpen = anAttr; // theItem->setOpen( aAttrOpen->IsOpened() ); //} -} +}*/ /*!Create new instance of SalomeApp_Application.*/ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() @@ -164,17 +165,17 @@ void SalomeApp_Application::start() for (int i = 1; i < qApp->argc(); i++) { QRegExp rxs ("--study-hdf=(.+)"); - if ( rxs.search( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) { + if ( rxs.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) { QString file = rxs.capturedTexts()[1]; QFileInfo fi ( file ); - QString extension = fi.extension( false ).lower(); + QString extension = fi.suffix().toLower(); if ( extension == "hdf" && fi.exists() ) - hdffile = fi.absFilePath(); + hdffile = fi.absoluteFilePath(); } else { QRegExp rxp ("--pyscript=(.+)"); - if ( rxp.search( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) { - QStringList files = QStringList::split(",",rxp.capturedTexts()[1],false); + if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) { + QStringList files = rxp.capturedTexts()[1].split(",",QString::SkipEmptyParts); pyfiles += files; } } @@ -193,12 +194,12 @@ void SalomeApp_Application::start() if ( !aStudy->GetProperties()->IsLocked() ) { for (uint j = 0; j < pyfiles.count(); j++ ) { QFileInfo fi ( pyfiles[j] ); - PythonConsole* pyConsole = pythonConsole(); + PyConsole_Console* pyConsole = pythonConsole(); if ( pyConsole ) { - QString extension = fi.extension( false ).lower(); + QString extension = fi.suffix().toLower(); if ( extension == "py" && fi.exists() ) { // execute python script - QString command = QString( "execfile(\"%1\")" ).arg( fi.absFilePath() ); + QString command = QString( "execfile(\"%1\")" ).arg( fi.absoluteFilePath() ); pyConsole->exec( command ); } else { @@ -224,40 +225,40 @@ void SalomeApp_Application::createActions() //! Save GUI state // "Save GUI State" command is moved to VISU module - // createAction( SaveGUIStateId, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIconSet(), + // 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" ), QIconSet(), + createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIcon(), tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), - CTRL+Key_D, desk, false, this, SLOT( onDumpStudy() ) ); + Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) ); //! Load script - createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(), + createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(), tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), - CTRL+Key_T, desk, false, this, SLOT( onLoadScript() ) ); + Qt::CTRL+Qt::Key_T, desk, false, this, SLOT( onLoadScript() ) ); //! Properties - createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(), + createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIcon(), tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ), - CTRL+Key_P, desk, false, this, SLOT( onProperties() ) ); + Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onProperties() ) ); //! Catalog Generator - createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(), + createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIcon(), tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ), - SHIFT+Key_G, desk, false, this, SLOT( onCatalogGen() ) ); + Qt::SHIFT+Qt::Key_G, desk, false, this, SLOT( onCatalogGen() ) ); //! Registry Display - createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(), + createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIcon(), tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ), - /*SHIFT+Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) ); + /*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) ); //SRN: BugID IPAL9021, add an action "Load" createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ), resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ), tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ), - CTRL+Key_L, desk, false, this, SLOT( onLoadDoc() ) ); + Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) ); //SRN: BugID IPAL9021: End @@ -290,12 +291,14 @@ bool SalomeApp_Application::onOpenDoc( const QString& aName ) // Look among opened studies if (activeStudy()) { // at least one study is opened SUIT_Session* aSession = SUIT_Session::session(); - QPtrList aAppList = aSession->applications(); - QPtrListIterator it (aAppList); + QList aAppList = aSession->applications(); + QListIterator it (aAppList); SUIT_Application* aApp = 0; // iterate on all applications - for (; (aApp = it.current()) && !isAlreadyOpen; ++it) { - if (aApp->activeStudy()->studyName() == aName) { + 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. @@ -354,7 +357,7 @@ bool SalomeApp_Application::onOpenDoc( const QString& aName ) SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No); if (aAnswer == SUIT_MessageBox::Yes) { - _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.latin1()); + _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.toStdString()); if (aStudy) studyMgr()->Close(aStudy); } else { @@ -389,25 +392,26 @@ void SalomeApp_Application::onLoadDoc() std::vector List = studyMgr()->GetOpenStudies(); SUIT_Session* aSession = SUIT_Session::session(); - QPtrList aAppList = aSession->applications(); + QList aAppList = aSession->applications(); SUIT_Application* aApp = 0; for (unsigned int ind = 0; ind < List.size(); ind++) { studyname = List[ind].c_str(); //Add to list only unloaded studies bool isAlreadyOpen = false; - for ( QPtrListIterator it( aAppList ); it.current() && !isAlreadyOpen; ++it ) + QListIterator it( aAppList ); + while ( it.hasNext() && !isAlreadyOpen ) { - aApp = it.current(); + aApp = it.next(); if(!aApp || !aApp->activeStudy()) continue; if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true; } - if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname ); + if ( !isAlreadyOpen ) aDlg.ListComponent->addItem( studyname ); } int retVal = aDlg.exec(); - studyname = aDlg.ListComponent->currentText(); + studyname = aDlg.ListComponent->currentItem()->text(); if (retVal == QDialog::Rejected) return; @@ -497,6 +501,14 @@ void SalomeApp_Application::onPaste() } } +/*!Check the application on closing. + * \retval true if possible, else false + */ +bool SalomeApp_Application::isPossibleToClose( bool& closePermanently ) +{ + return LightApp_Application::isPossibleToClose( closePermanently ); +} + /*! Check if the study is locked */ void SalomeApp_Application::onCloseDoc( bool ask ) { @@ -580,7 +592,7 @@ void SalomeApp_Application::onDeleteInvalidReferences() /*!Private SLOT. */ void SalomeApp_Application::onOpenWith() { - QApplication::setOverrideCursor( Qt::waitCursor ); + QApplication::setOverrideCursor( Qt::WaitCursor ); SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(aList); @@ -653,12 +665,27 @@ class DumpStudyFileDlg : public SUIT_FileDlg public: DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true ) { - QHBox* hB = new QHBox( this ); - myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY"), hB ); - mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE"), hB ); - QPushButton* pb = new QPushButton(this); - addWidgets( new QLabel("", this), hB, pb ); - pb->hide(); + QGridLayout* grid = ::qobject_cast( 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); + + 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(); + } } QCheckBox* myPublishChk; QCheckBox* mySaveGUIChk; @@ -675,7 +702,7 @@ void SalomeApp_Application::onDumpStudy( ) aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); DumpStudyFileDlg* fd = new DumpStudyFileDlg( desktop() ); - fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); + fd->setWindowTitle( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); fd->setFilters( aFilters ); fd->myPublishChk->setChecked( true ); fd->mySaveGUIChk->setChecked( true ); @@ -695,7 +722,8 @@ void SalomeApp_Application::onDumpStudy( ) ip->setDumpPython(appStudy->studyDS()); savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point } - bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish); + bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toStdString(), + aFileInfo.baseName().toStdString(), toPublish); if ( toSaveGUI ) appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point. if ( !res ) @@ -729,7 +757,7 @@ void SalomeApp_Application::onLoadScript( ) { QString command = QString("execfile(\"%1\")").arg(aFile); - PythonConsole* pyConsole = pythonConsole(); + PyConsole_Console* pyConsole = pythonConsole(); if ( pyConsole ) pyConsole->exec( command ); @@ -743,7 +771,8 @@ void SalomeApp_Application::onSaveGUIState() if ( study ) { SalomeApp_VisualState( this ).storeState(); updateSavePointDataObjects( study ); - objectBrowser()->updateTree( study->root() ); + // temporary commented + //objectBrowser()->updateTree( study->root() ); } updateActions(); } @@ -766,25 +795,28 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) if ( flag == WT_ObjectBrowser ) { - OB_Browser* ob = (OB_Browser*)wid; + // temporary commented + /*OB_Browser* ob = (OB_Browser*)wid; ob->setUpdater( new SalomeApp_Updater() ); - connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) ); + connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );*/ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ), autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) { - ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); + // temporary commented + /*ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser", - QString().sprintf( "visibility_column_%d", i ), true ) ); + QString().sprintf( "visibility_column_%d", i ), true ) );*/ } - ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); + // temporary commented + /*ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual ); - ob->resize( desktop()->width()/3, ob->height() ); + ob->resize( desktop()->width()/3, ob->height() );*/ } else if ( flag == WT_PyConsole ) { - PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() ); - pyCons->setCaption( tr( "PYTHON_CONSOLE" ) ); + PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new SalomeApp_PyInterp() ); + pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); wid = pyCons; pyCons->resize( pyCons->width(), desktop()->height()/4 ); //pyCons->connectPopupRequest(this, SLOT(onConnectPopupRequest(SUIT_PopupClient*, QContextMenuEvent*))); @@ -805,7 +837,7 @@ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab ); for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) { - pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols, + pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ).toLatin1() ), defCols, LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) ); } pref->setItemProperty( defCols, "columns", 1 ); @@ -825,7 +857,7 @@ void SalomeApp_Application::updateDesktopTitle() { if ( activeStudy() ) { - QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false ); + QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false ); if ( !sName.isEmpty() ) { SalomeApp_Study* study = dynamic_cast(activeStudy()); if ( study ) { @@ -841,7 +873,48 @@ void SalomeApp_Application::updateDesktopTitle() { } } - desktop()->setCaption( aTitle ); + desktop()->setWindowTitle( aTitle ); +} + +int SalomeApp_Application::closeChoice( const QString& docName ) +{ + int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "APPCLOSE_DESCRIPTION" ).arg( docName ), + tr ("APPCLOSE_SAVE"), tr ("APPCLOSE_CLOSE"), + tr ("APPCLOSE_UNLOAD"), tr ("APPCLOSE_CANCEL"), 1 ); + + int res = CloseCancel; + if ( answer == 1 ) + res = CloseSave; + else if ( answer == 2 ) + res = CloseDiscard; + else if ( answer == 3 ) + res = CloseUnload; + + return res; +} + +bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently ) +{ + bool res = true; + switch( choice ) + { + case CloseSave: + if ( activeStudy()->isSaved() ) + onSaveDoc(); + else if ( !onSaveAsDoc() ) + res = false; + break; + case CloseDiscard: + break; + case CloseUnload: + closePermanently = false; + break; + case CloseCancel: + default: + res = false; + } + + return res; } /*!Gets CORBA::ORB_var*/ @@ -911,13 +984,14 @@ void SalomeApp_Application::onProperties() } /*!Insert items in popup, which necessary for current application*/ -void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title ) +void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title ) { LightApp_Application::contextMenuPopup( type, thePopup, title ); - OB_Browser* ob = objectBrowser(); + // temporary commented + /*OB_Browser* ob = objectBrowser(); if ( !ob || type != ob->popupClientType() ) - return; + return;*/ // Get selected objects SALOME_ListIO aList; @@ -927,10 +1001,10 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t // add GUI state commands: restore, rename if ( aList.Extent() == 1 && aList.First()->hasEntry() && QString( aList.First()->getEntry() ).startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) { - thePopup->insertSeparator(); - thePopup->insertItem( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) ); - thePopup->insertItem( tr( "MEN_RENAME_VS" ), this, SLOT( onRenameGUIState() ) ); - thePopup->insertItem( tr( "MEN_DELETE_VS" ), this, SLOT( onDeleteGUIState() ) ); + thePopup->addSeparator(); + thePopup->addAction( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) ); + thePopup->addAction( tr( "MEN_RENAME_VS" ), this, SLOT( onRenameGUIState() ) ); + thePopup->addAction( tr( "MEN_DELETE_VS" ), this, SLOT( onDeleteGUIState() ) ); } // "Delete reference" item should appear only for invalid references @@ -955,8 +1029,8 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t // Add "Delete reference" item to popup if ( isInvalidRefs ) { - thePopup->insertSeparator(); - thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); + thePopup->addSeparator(); + thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); return; } @@ -977,7 +1051,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t if (currentModule && currentModule->moduleName() == aModuleTitle) return; if ( !aModuleTitle.isEmpty() ) - thePopup->insertItem( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) ); + thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) ); } /*!Update obect browser: @@ -1000,11 +1074,13 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) if ( aComponent->ComponentDataType() == "Interface Applicative" ) continue; // skip the magic "Interface Applicative" component - OB_Browser* ob = static_cast( getWindow( WT_ObjectBrowser )); + // temporary commented + /*OB_Browser* ob = static_cast( getWindow( WT_ObjectBrowser )); const bool isAutoUpdate = ob->isAutoUpdate(); - ob->setAutoUpdate( false ); + ob->setAutoUpdate( false );*/ SalomeApp_DataModel::synchronize( aComponent, study ); - ob->setAutoUpdate( isAutoUpdate ); + // temporary commented + /*ob->setAutoUpdate( isAutoUpdate );*/ //SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true ); } } @@ -1031,13 +1107,14 @@ void SalomeApp_Application::onRegDisplay() ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" ); regWnd->show(); regWnd->raise(); - regWnd->setActiveWindow(); + regWnd->activateWindow(); } /*!find original object by double click on item */ void SalomeApp_Application::onDblClick( QListViewItem* it ) { - OB_ListItem* item = dynamic_cast( it ); + // temporary commented + /*OB_ListItem* item = dynamic_cast( it ); SalomeApp_Study* study = dynamic_cast( activeStudy() ); if( study && item ) @@ -1074,7 +1151,7 @@ void SalomeApp_Application::onDblClick( QListViewItem* it ) break; } } - } + }*/ } /*! @@ -1125,7 +1202,8 @@ void SalomeApp_Application::onRenameGUIState() if ( !newName.isNull() && !newName.isEmpty() ) { study->setNameOfSavePoint( savePoint, newName ); updateSavePointDataObjects( study ); - objectBrowser()->updateTree( study->root() ); + // temporary commented + //objectBrowser()->updateTree( study->root() ); } } @@ -1149,10 +1227,11 @@ void SalomeApp_Application::onStudySaved( SUIT_Study* study ) { LightApp_Application::onStudySaved( study ); - if ( objectBrowser() ) { + // temporary commented + /*if ( objectBrowser() ) { updateSavePointDataObjects( dynamic_cast( study ) ); objectBrowser()->updateTree( study->root() ); - } + }*/ } /*!Called on Open study operation*/ @@ -1160,35 +1239,20 @@ void SalomeApp_Application::onStudyOpened( SUIT_Study* study ) { LightApp_Application::onStudyOpened( study ); - if ( objectBrowser() ) { + // temporary commented + /*if ( objectBrowser() ) { updateSavePointDataObjects( dynamic_cast( study ) ); objectBrowser()->updateTree( study->root() ); - } -} - -/*! utility function. returns true if list view item that correspond to given SUIT_DataObject is open. - only first level items are traversed */ -bool isListViewItemOpen( QListView* lv, const SUIT_DataObject* dobj ) -{ - if ( !lv || !dobj ) - return false; - - QListViewItem* item = lv->firstChild(); - while ( item ) { - OB_ListItem* ob_item = dynamic_cast( item ); - if ( ob_item && ob_item->dataObject() == dobj ) - return ob_item->isOpen(); - item = item->nextSibling(); - } - return false; + }*/ } /*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study ) { - OB_Browser* ob = objectBrowser(); + // temporary commented + //OB_Browser* ob = objectBrowser(); - if ( !study || !ob ) + if ( !study /*|| !ob */) // temporary commented return; // find GUI states root object @@ -1243,7 +1307,7 @@ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study ) // delete DataObjects that are still in the map -- their IDs were not found in data model for ( QMap::Iterator it = mapDO.begin(); it != mapDO.end(); ++it ) - delete it.data(); + delete it.value(); } /*! Check data object */ @@ -1259,8 +1323,8 @@ bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj) void SalomeApp_Application::onDesktopMessage( const QString& message ) { // update object browser - if ( message.lower() == "updateobjectbrowser" || - message.lower() == "updateobjbrowser" ) + if ( message.toLower() == "updateobjectbrowser" || + message.toLower() == "updateobjbrowser" ) updateObjectBrowser(); } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 09ece677d..0b9c15f66 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -31,8 +31,6 @@ #include "SalomeApp.h" #include -#include - #include #include @@ -41,17 +39,12 @@ #include "SALOMEDSClient.hxx" -class QAction; -class QComboBox; -class QDockWindow; - class LightApp_Preferences; -class SalomeApp_Module; class SalomeApp_Study; class SALOME_LifeCycleCORBA; -class QListViewItem; +class QListViewItem;//? waiting for object browser porting #ifdef WIN32 #pragma warning( disable:4251 ) @@ -70,6 +63,7 @@ public: enum { MenuToolsId = 5 }; enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID }; + enum { CloseUnload = STD_Application::CloseCancel+1 }; public: SalomeApp_Application(); @@ -81,7 +75,7 @@ public: virtual void start(); - virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); virtual bool checkDataObject(LightApp_DataObject* theObj); @@ -93,6 +87,8 @@ public: SUIT_ViewManager* newViewManager(const QString&); void updateSavePointDataObjects( SalomeApp_Study* ); + + virtual bool isPossibleToClose( bool& ); public slots: virtual bool onOpenDoc( const QString& ); @@ -118,6 +114,9 @@ protected: virtual void createPreferences( LightApp_Preferences* ); virtual void updateDesktopTitle(); + + virtual bool closeAction( const int, bool& ); + virtual int closeChoice( const QString& ); private slots: void onDeleteInvalidReferences(); @@ -133,7 +132,6 @@ private slots: void onCatalogGen(); void onRegDisplay(); void onOpenWith(); - }; #ifdef WIN32 diff --git a/src/SalomeApp/SalomeApp_CheckFileDlg.cxx b/src/SalomeApp/SalomeApp_CheckFileDlg.cxx index a62a33d47..866e06fbb 100644 --- a/src/SalomeApp/SalomeApp_CheckFileDlg.cxx +++ b/src/SalomeApp/SalomeApp_CheckFileDlg.cxx @@ -18,9 +18,10 @@ // #include "SalomeApp_CheckFileDlg.h" -#include -#include -#include +#include +#include +#include +#include /*! Constructor @@ -28,11 +29,20 @@ Constructor SalomeApp_CheckFileDlg::SalomeApp_CheckFileDlg( QWidget* parent, bool open, const QString& theCheckBoxName, bool showQuickDir, bool modal) : SUIT_FileDlg( parent, open, showQuickDir, modal ) { - myCheckBox = new QCheckBox( theCheckBoxName, this ); - QLabel* label = new QLabel("", this); - QPushButton* pb = new QPushButton(this); - addWidgets( label, myCheckBox, pb ); - pb->hide(); + QGridLayout* grid = ::qobject_cast( layout() ); + if ( grid ) + { + myCheckBox = new QCheckBox( theCheckBoxName, this ); + QLabel* label = new QLabel("", this); + QPushButton* pb = new QPushButton(this); + + int row = grid->rowCount(); + grid->addWidget( label, row, 0 ); + grid->addWidget( myCheckBox, row, 1 ); + grid->addWidget( pb, row, 2 ); + + pb->hide(); + } } /*! diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 742a75e35..8c5ca74ac 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -26,15 +26,11 @@ #include "SalomeApp_DataObject.h" #include "SalomeApp_Module.h" #include "SalomeApp_Application.h" -#include "SalomeApp_Engine_i.hxx" #include "LightApp_RootObject.h" #include -#include -#include -#include #include #include @@ -58,8 +54,8 @@ public: bool isEqual( const kerPtr&, const suitPtr& ) const; kerPtr nullSrc() const; suitPtr nullTrg() const; - void children( const kerPtr&, QValueList& ) const; - void children( const suitPtr&, QValueList& ) const; + void children( const kerPtr&, QList& ) const; + void children( const suitPtr&, QList& ) const; suitPtr parent( const suitPtr& ) const; bool isCorrect( const kerPtr& ) const; void updateItem( const kerPtr&, const suitPtr& ) const; @@ -119,7 +115,7 @@ suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so, { DataObjectList ch; parent->children( ch ); - int pos = ch.find( after ); + int pos = ch.indexOf( after ); if( pos>=0 ) parent->insertChild( nitem, pos+1 ); else @@ -188,7 +184,7 @@ suitPtr SalomeApp_DataModelSync::nullTrg() const \param obj - kernel object \param ch - list to be filled */ -void SalomeApp_DataModelSync::children( const kerPtr& obj, QValueList& ch ) const +void SalomeApp_DataModelSync::children( const kerPtr& obj, QList& ch ) const { ch.clear(); _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) ); @@ -201,15 +197,16 @@ void SalomeApp_DataModelSync::children( const kerPtr& obj, QValueList& c \param p - SUIT object \param ch - list to be filled */ -void SalomeApp_DataModelSync::children( const suitPtr& p, QValueList& ch ) const +void SalomeApp_DataModelSync::children( const suitPtr& p, QList& ch ) const { DataObjectList l; if( p ) { p->children( l ); ch.clear(); - for( SUIT_DataObject* o = l.first(); o; o = l.next() ) - ch.append( o ); + QListIterator it( ch ); + while ( it.hasNext() ) + ch.append( it.next() ); } } @@ -244,7 +241,7 @@ void showTree( SUIT_DataObject* root ) { QString marg; marg.fill( ' ', 3*it.depth() ); QString nnn = "%1 '%2'"; - qDebug( nnn.arg( marg ).arg( it.current()->name() ) ); + qDebug( nnn.arg( marg ).arg( it.current()->name() ).toLatin1() ); } } @@ -277,7 +274,7 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study, QStringLi return true; // Probably nothing to load _PTR(Study) aStudy ( aDoc->studyDS() ); // shared_ptr cannot be used here - _PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.latin1() ) ) ); + _PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.toLatin1() ) ) ); if ( aSComp ) updateTree( aSComp, aDoc ); @@ -312,7 +309,7 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) QString anId = getRootEntry( aSStudy ); if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing _PTR(Study) aStudy ( aSStudy->studyDS() ); - sobj = aStudy->FindComponentID( std::string( anId.latin1() ) ); + sobj = aStudy->FindComponentID( std::string( anId.toLatin1() ) ); } } } @@ -323,7 +320,7 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) if ( aSStudy ) { _PTR(Study) aStudy ( aSStudy->studyDS() ); // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon - sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) ); + sobj = aStudy->FindComponentID( std::string( modelRoot->entry().toLatin1() ) ); } } } @@ -408,7 +405,7 @@ QString SalomeApp_DataModel::getRootEntry( SalomeApp_Study* study ) const anEntry = anObj->entry(); } else if ( study && study->studyDS() ) { // this works even if is null - _PTR(SComponent) aSComp( study->studyDS()->FindComponent( module()->name() ) ); + _PTR(SComponent) aSComp( study->studyDS()->FindComponent( module()->name().toStdString() ) ); if ( aSComp ) anEntry = aSComp->GetID().c_str(); } diff --git a/src/SalomeApp/SalomeApp_DataModel.h b/src/SalomeApp/SalomeApp_DataModel.h index 9c2bff16a..bccc327e6 100644 --- a/src/SalomeApp/SalomeApp_DataModel.h +++ b/src/SalomeApp/SalomeApp_DataModel.h @@ -35,7 +35,8 @@ class SalomeApp_Module; class SalomeApp_Study; -class SalomeApp_DataObject; +class SUIT_DataObject; +class LightApp_DataObject; // Class : SalomeApp_DataModel /// Description : Base class of data model diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 1f1c6ae5a..d9ab722e6 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -25,15 +25,8 @@ #include #include -#include -#include - -#include -#include -#include -#include -#include +#include /*!Constructor. Initialize by \a parent*/ SalomeApp_DataObject::SalomeApp_DataObject( SUIT_DataObject* parent ) diff --git a/src/SalomeApp/SalomeApp_EventFilter.cxx b/src/SalomeApp/SalomeApp_EventFilter.cxx index 493d690c8..02af6ce0a 100755 --- a/src/SalomeApp/SalomeApp_EventFilter.cxx +++ b/src/SalomeApp/SalomeApp_EventFilter.cxx @@ -18,9 +18,9 @@ // #include "SalomeApp_EventFilter.h" -#include +#include -#include +#include SalomeApp_EventFilter* SalomeApp_EventFilter::myFilter = NULL; @@ -45,9 +45,9 @@ bool SalomeApp_EventFilter::eventFilter( QObject* o, QEvent* e ) { if ( e->type() == SALOME_EVENT ) { - SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data(); + SALOME_Event* aSE = (SALOME_Event*)((SALOME_CustomEvent*)e)->data(); processEvent(aSE); - ((QCustomEvent*)e)->setData( 0 ); + ((SALOME_CustomEvent*)e)->setData( 0 ); return true; } return QObject::eventFilter( o, e ); diff --git a/src/SalomeApp/SalomeApp_EventFilter.h b/src/SalomeApp/SalomeApp_EventFilter.h index 8edb2102c..dea5cad73 100755 --- a/src/SalomeApp/SalomeApp_EventFilter.h +++ b/src/SalomeApp/SalomeApp_EventFilter.h @@ -20,7 +20,7 @@ #define SALOMEAPP_EVENTFILTER_H #include "SalomeApp.h" -#include +#include #if defined WIN32 #pragma warning( disable: 4251 ) diff --git a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx index 9fd7d40c6..e1b871274 100644 --- a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx +++ b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx @@ -24,7 +24,7 @@ #include #include -#include +#include #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 #include diff --git a/src/SalomeApp/SalomeApp_ListView.cxx b/src/SalomeApp/SalomeApp_ListView.cxx index e2c354eaa..6fcc0e80e 100644 --- a/src/SalomeApp/SalomeApp_ListView.cxx +++ b/src/SalomeApp/SalomeApp_ListView.cxx @@ -29,18 +29,22 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include #include #include -#include "utilities.h" - using namespace std; +using namespace Qt; + /*! Used for resizing editing widget */ @@ -49,19 +53,19 @@ void computeEditGeometry(SalomeApp_ListViewItem* theItem, { if (!theItem) return; - QListView* aListView = theItem->listView(); + QTreeWidget* aListView = theItem->treeWidget(); int anEditColumn = theItem->getEditedColumn(); if (anEditColumn < 0) return; int aX = 0, aY = 0, aW = 0, aH = 0; - QRect aRect = aListView->itemRect(theItem); - aListView->contentsToViewport(aListView->header()->sectionPos(anEditColumn), 0, aX, aY); + QRect aRect = aListView->visualItemRect(theItem); + aX = aListView->header()->sectionViewportPosition(anEditColumn); if (aX < 0) aX = 0; // THIS CAN BE REMOVED QSize aSize = theWidget->getControl()->sizeHint(); - aH = QMAX(aSize.height() , aRect.height() ); + aH = qMax(aSize.height() , aRect.height() ); aY = aRect.y() - ((aH - aRect.height()) / 2); //aW = aListView->columnWidth(anEditColumn); // CAN SUBSTITUTE NEXT 3 ROWS aW = aListView->viewport()->width() - aX; @@ -74,23 +78,22 @@ void computeEditGeometry(SalomeApp_ListViewItem* theItem, Constructor */ SalomeApp_ListView::SalomeApp_ListView( QWidget* parent ) -: QtxListView( parent ) + : QTreeWidget/*QtxListView*/( parent ) { myMouseEnabled = true; myEditingEnabled = false; - setSelectionMode(Single); - setSorting(-1); + setSelectionMode(QAbstractItemView::SingleSelection); setRootIsDecorated(false); setAllColumnsShowFocus(false); // header()->setClickEnabled(false); - header()->setMovingEnabled(false); + header()->setMovable(false); myEditedItem = 0; myEdit = 0; viewport()->installEventFilter(this); - connect(this, SIGNAL(selectionChanged()), + connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged())); connect(header(), SIGNAL(sizeChange(int, int, int)), this, SLOT(onHeaderSizeChange(int, int, int))); @@ -115,13 +118,14 @@ void SalomeApp_ListView::updateViewer() { // temporary disconnecting selection changed SIGNAL blockSignals(true); - SalomeApp_ListViewItem* aRoot = (SalomeApp_ListViewItem*)firstChild(); + QTreeWidgetItemIterator it( this ); + SalomeApp_ListViewItem* aRoot = (SalomeApp_ListViewItem*)(*it); if (aRoot) aRoot->updateAllLevels(); - updateContents(); + update( contentsRect() );//updateContents(); // connecting again selection changed SIGNAL blockSignals(false); - emit selectionChanged(); + emit itemSelectionChanged(); } /*! @@ -131,13 +135,13 @@ void SalomeApp_ListView::updateSelected() { // temporary disconnecting selection changed SIGNAL blockSignals(true); - SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)selectedItem(); + SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(selectedItems().first()); if (aChild) aChild->updateAllLevels(); - updateContents(); + update( contentsRect() );//updateContents(); // connecting again selection changed SIGNAL blockSignals(false); - emit selectionChanged(); + emit itemSelectionChanged(); } /*! @@ -151,7 +155,7 @@ QString SalomeApp_ListView::popupClientType() const /*! Fills popup menu with items */ -void SalomeApp_ListView::contextMenuPopup( QPopupMenu* aPopup ) +void SalomeApp_ListView::contextMenuPopup( QMenu* aPopup ) { if (aPopup) { // add items here... @@ -168,7 +172,7 @@ void SalomeApp_ListView::clear() myEdit = 0; myEditedItem = 0; } - QListView::clear(); + QTreeWidget::clear(); } /*! @@ -199,7 +203,7 @@ bool SalomeApp_ListView::eventFilter(QObject* object, QEvent* event) !isMouseEnabled()) return true; else - return QListView::eventFilter(object, event); + return QTreeWidget::eventFilter(object, event); } /*! @@ -244,14 +248,14 @@ void SalomeApp_ListView::onSelectionChanged() myEdit = 0; if (myEditedItem && !myEditedItem->isAccepted()) { delete myEditedItem; - updateContents(); + update( contentsRect() );//updateContents(); } myEditedItem = 0; } // editing is allowed in Single Selection Mode only - if (selectionMode() != Single || !isEnableEditing()) + if (selectionMode() != QAbstractItemView::SingleSelection || !isEnableEditing()) return; - SalomeApp_ListViewItem* anItem = (SalomeApp_ListViewItem*)selectedItem(); + SalomeApp_ListViewItem* anItem = (SalomeApp_ListViewItem*)(selectedItems().first()); if (anItem) { if (!anItem->isEditable()) return; @@ -271,12 +275,12 @@ void SalomeApp_ListView::onSelectionChanged() */ void SalomeApp_ListView::resizeEvent( QResizeEvent * e) { - QListView::resizeEvent(e); - int aW = columnWidth(columns()-1); - int aX = header()->sectionPos(columns()-1); + QTreeWidget::resizeEvent(e); + int aW = columnWidth(columnCount()-1); + int aX = header()->sectionPosition(columnCount()-1); if (aW < width() - frameWidth() * 2 - aX - 1) - setColumnWidth(columns()-1, width() - frameWidth() * 2 - aX - 1); - updateContents(); + setColumnWidth(columnCount()-1, width() - frameWidth() * 2 - aX - 1); + update( contentsRect() );//updateContents(); } /*! @@ -284,10 +288,10 @@ void SalomeApp_ListView::resizeEvent( QResizeEvent * e) */ void SalomeApp_ListView::onHeaderSizeChange(int, int, int) { - int aW = columnWidth(columns()-1); - int aX = header()->sectionPos(columns()-1); + int aW = columnWidth(columnCount()-1); + int aX = header()->sectionPosition(columnCount()-1); if (aW < width() - frameWidth() * 2 - aX - 1) - setColumnWidth(columns()-1, width() - frameWidth() * 2 - aX - 1); + setColumnWidth(columnCount()-1, width() - frameWidth() * 2 - aX - 1); } /*! @@ -295,7 +299,7 @@ void SalomeApp_ListView::onHeaderSizeChange(int, int, int) */ void SalomeApp_ListView::viewportPaintEvent(QPaintEvent* e) { - QListView::viewportPaintEvent(e); + QTreeWidget::paintEvent(e); if (myEditedItem && myEdit) { computeEditGeometry(myEditedItem, myEdit); } @@ -386,14 +390,14 @@ UpdateType SalomeApp_ListView::finishEditing(bool ok) \retval valid rect in success */ QRect SalomeApp_ListView::tip(QPoint aPos, - QString& aText, - QRect& dspRect, - QFont& dspFnt) const + QString& aText, + QRect& dspRect, + QFont& dspFnt) const { QRect result( -1, -1, -1, -1 ); SalomeApp_ListViewItem* aItem = (SalomeApp_ListViewItem*)itemAt( aPos ); if ( aItem ) { - for (int i = 0; i < columns(); i++) { + for (int i = 0; i < columnCount(); i++) { QRect aItemRect = aItem->itemRect(i); QRect aTextRect = aItem->textRect(i); if ( !aItem->text(i).isEmpty() && @@ -420,17 +424,7 @@ QRect SalomeApp_ListView::tip(QPoint aPos, Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent) : -QListViewItem( parent ) -{ - init(); -} - -/*! - Constructor -*/ -SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent, - SalomeApp_ListViewItem* after) : -QListViewItem( parent, after ) +QTreeWidgetItem( parent ) { init(); } @@ -439,22 +433,19 @@ QListViewItem( parent, after ) Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent, - const QString& theName, - const bool theEditable) : -QListViewItem(parent, theName) + SalomeApp_ListViewItem* after) : +QTreeWidgetItem( parent, after ) { init(); - setEditable(theEditable); } /*! Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent, - const QString& theName, - const QString& theValue, - const bool theEditable) : -QListViewItem(parent, theName, theValue) + const QStringList& theStrings, + const bool theEditable) : +QTreeWidgetItem(parent, theStrings) { init(); setEditable(theEditable); @@ -464,9 +455,9 @@ QListViewItem(parent, theName, theValue) Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent, - const QString& theName, - const bool theEditable) : -QListViewItem(parent, theName) + const QStringList& theString, + const bool theEditable) : +QTreeWidgetItem(parent, theString) { init(); setEditable(theEditable); @@ -476,11 +467,12 @@ QListViewItem(parent, theName) Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent, - SalomeApp_ListViewItem* after, - const QString& theName, - const bool theEditable) : -QListViewItem(parent, after, theName) + SalomeApp_ListViewItem* after, + const QString& theName, + const bool theEditable) : +QTreeWidgetItem(parent, after) { + setData(0,Qt::DisplayRole,QVariant(theName)); init(); setEditable(theEditable); } @@ -489,40 +481,28 @@ QListViewItem(parent, after, theName) Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent, - SalomeApp_ListViewItem* after, - const QString& theName, - const bool theEditable) : -QListViewItem(parent, after, theName) -{ - init(); - setEditable(theEditable); -} - - -/*! - Constructor -*/ -SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent, - const QString& theName, - const QString& theValue, - const bool theEditable) : -QListViewItem(parent, theName, theValue) + SalomeApp_ListViewItem* after, + const QString& theName, + const bool theEditable) : +QTreeWidgetItem(parent, after) { + setData(0,Qt::DisplayRole,QVariant(theName)); init(); setEditable(theEditable); } - /*! Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent, - SalomeApp_ListViewItem* after, - const QString& theName, - const QString& theValue, - const bool theEditable) : -QListViewItem(parent, after, theName, theValue) -{ + SalomeApp_ListViewItem* after, + const QString& theName, + const QString& theValue, + const bool theEditable) : +QTreeWidgetItem(parent, after) +{ + setData(0,Qt::DisplayRole,QVariant(theName)); + setData(1,Qt::DisplayRole,QVariant(theValue)); init(); setEditable(theEditable); } @@ -531,12 +511,14 @@ QListViewItem(parent, after, theName, theValue) Constructor */ SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView* parent, - SalomeApp_ListViewItem* after, - const QString& theName, - const QString& theValue, - const bool theEditable) : -QListViewItem(parent, after, theName, theValue) -{ + SalomeApp_ListViewItem* after, + const QString& theName, + const QString& theValue, + const bool theEditable) : +QTreeWidgetItem(parent, after) +{ + setData(0,Qt::DisplayRole,QVariant(theName)); + setData(1,Qt::DisplayRole,QVariant(theValue)); init(); setEditable(theEditable); } @@ -561,12 +543,26 @@ void SalomeApp_ListViewItem::init() myUserType = -1; } +/*! + Returns the depth of this item +*/ +int SalomeApp_ListViewItem::depth() const +{ + int aDepth = 0; + QTreeWidgetItem* aParent = parent(); + while ( aParent ) { + aParent = aParent->parent(); + aDepth++; + } + return aDepth; +} + /*! \return text in the first column */ QString SalomeApp_ListViewItem::getName() const { - return ( listView()->columns() > 0 ) ? text(0) : QString(""); + return ( treeWidget()->columnCount() > 0 ) ? text(0) : QString(""); } /*! @@ -575,7 +571,7 @@ QString SalomeApp_ListViewItem::getName() const UpdateType SalomeApp_ListViewItem::setName(const QString& theName) { UpdateType aNeedsUpdate = utCancel; - if (listView()->columns() > 0) { + if (treeWidget()->columnCount() > 0) { setText(0, theName); aNeedsUpdate = utNone; } @@ -587,7 +583,7 @@ UpdateType SalomeApp_ListViewItem::setName(const QString& theName) */ QString SalomeApp_ListViewItem::getValue() const { - return ( listView()->columns() > 1 ) ? text(1) : QString(""); + return ( treeWidget()->columnCount() > 1 ) ? text(1) : QString(""); } /*! @@ -596,7 +592,7 @@ QString SalomeApp_ListViewItem::getValue() const UpdateType SalomeApp_ListViewItem::setValue(const QString& theValue) { UpdateType aNeedsUpdate = utCancel; - if (listView()->columns() > 1) { + if (treeWidget()->columnCount() > 1) { setText(1, theValue); aNeedsUpdate = utNone; } @@ -622,11 +618,13 @@ QString SalomeApp_ListViewItem::fullName() */ void SalomeApp_ListViewItem::openAllLevels() { - setOpen(true); - SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)firstChild(); + setExpanded(true); + QTreeWidgetItemIterator it( this ); + SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(*it); while( aChild ) { aChild->openAllLevels(); - aChild = (SalomeApp_ListViewItem*)(aChild->nextSibling()); + ++it; + aChild = (SalomeApp_ListViewItem*)(*it); } } @@ -635,10 +633,12 @@ void SalomeApp_ListViewItem::openAllLevels() */ void SalomeApp_ListViewItem::updateAllLevels() { - SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)firstChild(); + QTreeWidgetItemIterator it( this ); + SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(*it); while( aChild ) { aChild->updateAllLevels(); - aChild = (SalomeApp_ListViewItem*)(aChild->nextSibling()); + ++it; + aChild = (SalomeApp_ListViewItem*)(*it); } } @@ -701,7 +701,7 @@ void SalomeApp_ListViewItem::setEditingType(const int type) */ int SalomeApp_ListViewItem::getEditedColumn() { - return listView()->columns()-1; + return treeWidget()->columnCount()-1; } /*! @@ -760,7 +760,7 @@ void SalomeApp_ListViewItem::setButtons(const int buttons) SalomeApp_EntityEdit* SalomeApp_ListViewItem::startEditing() { SalomeApp_EntityEdit* aWidget = 0; - QListView* aListView = listView(); + QTreeWidget* aListView = treeWidget(); if (aListView) { if (!isEditable()) return 0; @@ -825,14 +825,14 @@ UpdateType SalomeApp_ListViewItem::finishEditing(SalomeApp_EntityEdit* theWidget QRect SalomeApp_ListViewItem::tipRect() { QRect aRect = QRect(-1, -1, -1, -1); - QRect aItemRect = listView()->itemRect(this); + QRect aItemRect = treeWidget()->visualItemRect(this); if ( !aItemRect.isValid() ) return aItemRect; QString aTip = tipText(); if (!aTip.isEmpty()) { QRect aRect0 = textRect(0); - QFont aFont(listView()->font()); + QFont aFont(treeWidget()->font()); QFontMetrics fm(aFont); int iw = fm.width(aTip); aRect = QRect(QPoint(aRect0.x() < 0 ? 0 : aRect0.x(), @@ -859,33 +859,33 @@ QString SalomeApp_ListViewItem::tipText() */ QRect SalomeApp_ListViewItem::textRect(const int column) const { - QRect aItemRect = listView()->itemRect( this ); + QRect aItemRect = treeWidget()->visualItemRect( this ); if ( !aItemRect.isValid() ) return aItemRect; - QFont aFont(listView()->font()); + QFont aFont(treeWidget()->font()); QFontMetrics fm(aFont); - int decorWidth = ( listView()->rootIsDecorated() ) ? - ( listView()->treeStepSize() * (depth() + 1) ) : - ( listView()->treeStepSize() * depth() ); - int pixmapWidth = ( pixmap(column) ) ? - pixmap(column)->width() + listView()->itemMargin() * 2 : - listView()->itemMargin(); + int decorWidth = ( treeWidget()->rootIsDecorated() ) ? + ( treeWidget()->indentation() * (depth() + 1) ) : + ( treeWidget()->indentation() * depth() ); + int pixmapWidth = ( !icon(column).isNull() ) ? + treeWidget()->iconSize().width() + 2 : + 1; int prevWidth = 0; for (int i = 0; i < column; i++) - prevWidth += listView()->header()->sectionSize(i); + prevWidth += treeWidget()->header()->sectionSize(i); int ix = prevWidth + pixmapWidth + ((column == 0) ? decorWidth : 0); int iy = aItemRect.y(); int iw = fm.width(text(column)); int ih = aItemRect.height(); - if (pixmap(column)) { - iy += listView()->itemMargin(); - ih -= listView()->itemMargin() * 2; + if (!icon(column).isNull()) { + iy += 1; + ih -= 2; } - ix -= listView()->contentsX(); + ix -= treeWidget()->contentsRect().left(); QRect theResult(QPoint(ix, iy), QSize(iw, ih)); return theResult; @@ -896,30 +896,30 @@ QRect SalomeApp_ListViewItem::textRect(const int column) const */ QRect SalomeApp_ListViewItem::itemRect(const int column) const { - QRect aItemRect = listView()->itemRect( this ); + QRect aItemRect = treeWidget()->visualItemRect( this ); if ( !aItemRect.isValid() ) return aItemRect; - QFont aFont(listView()->font()); + QFont aFont(treeWidget()->font()); QFontMetrics fm(aFont); - int decorWidth = ( listView()->rootIsDecorated() ) ? - ( listView()->treeStepSize() * (depth() + 1) ) : - ( listView()->treeStepSize() * depth() ); - int pixmapWidth = ( pixmap(column) ) ? - pixmap(column)->width() + listView()->itemMargin() * 2 : + int decorWidth = ( treeWidget()->rootIsDecorated() ) ? + ( treeWidget()->indentation() * (depth() + 1) ) : + ( treeWidget()->indentation() * depth() ); + int pixmapWidth = ( !icon(column).isNull() ) ? + treeWidget()->iconSize().width() + 2 : 0; int prevWidth = 0; for (int i = 0; i < column; i++) - prevWidth += listView()->header()->sectionSize(i); + prevWidth += treeWidget()->header()->sectionSize(i); int ix = prevWidth; int iy = aItemRect.y(); int iw = pixmapWidth + - listView()->itemMargin() * 2 + + 2 + ((column == 0) ? decorWidth : 0) + fm.width(text(column)); int ih = aItemRect.height(); - ix -= listView()->contentsX(); + ix -= treeWidget()->contentsRect().left(); QRect theResult(QPoint(ix, iy), QSize(iw, ih)); return theResult; @@ -950,8 +950,10 @@ void SalomeApp_EditBox::keyPressEvent( QKeyEvent *e ) Constructor */ SalomeApp_ComboBox::SalomeApp_ComboBox(bool rw, QWidget* parent, const char* name) : -QComboBox(rw, parent, name) +QComboBox(parent) { + setEditable( rw ); + setObjectName( name ); } /*! @@ -960,7 +962,7 @@ QComboBox(rw, parent, name) int SalomeApp_ComboBox::findItem(const QString& theText) { for (int i = 0; i < count(); i++) - if (text(i) == theText) + if (itemText(i) == theText) return i; return -1; } @@ -969,10 +971,10 @@ int SalomeApp_ComboBox::findItem(const QString& theText) Adds item in combo box */ void SalomeApp_ComboBox::insertItem(const QString& theValue, - int theIndex) + int theIndex) { if (duplicatesEnabled() || findItem(theValue) < 0) - QComboBox::insertItem(theValue, theIndex); + QComboBox::insertItem(theIndex, theValue); } /*! @@ -992,10 +994,10 @@ void SalomeApp_ComboBox::insertItem(const int theValue) int aNum; bool bOk; for (int i = 0; i < count(); i++) { - aNum = text(i).toInt(&bOk); + aNum = itemText(i).toInt(&bOk); if (bOk) { if (aNum > theValue || (aNum == theValue && duplicatesEnabled())) { - insertItem(QString::number(theValue), i); + insertItem(QString::number(theValue),i); return; } } @@ -1020,7 +1022,7 @@ void SalomeApp_ComboBox::insertItem(const double theValue) double aNum; bool bOk; for (int i = 0; i < count(); i++) { - aNum = text(i).toDouble(&bOk); + aNum = itemText(i).toDouble(&bOk); if (bOk) { if (aNum > theValue || (aNum == theValue && duplicatesEnabled())) { insertItem(QString::number(theValue), i); @@ -1077,7 +1079,7 @@ myCancelBtn(0) myCombo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); // no insertions - myCombo->setInsertionPolicy(QComboBox::NoInsertion); + myCombo->setInsertPolicy(QComboBox::NoInsert); // no duplicates enabled by default myCombo->setDuplicatesEnabled(false); aTopLayout->addWidget(myCombo); @@ -1112,7 +1114,7 @@ myCancelBtn(0) if( mgr ) anIcon = mgr->loadPixmap( "STD", tr( "ICON_APPLY" ), false ); - myApplyBtn->setPixmap(anIcon); + myApplyBtn->setIcon(anIcon); myApplyBtn->setEnabled(false); myApplyBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); myApplyBtn->setMinimumSize(16, 16); @@ -1126,7 +1128,7 @@ myCancelBtn(0) QPixmap anIcon; if( mgr ) anIcon = mgr->loadPixmap( "STD", tr( "ICON_CANCEL" ), false ); - myCancelBtn->setPixmap(anIcon); + myCancelBtn->setIcon(anIcon); myCancelBtn->setEnabled(false); myCancelBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); myCancelBtn->setMinimumSize(16, 16); @@ -1178,7 +1180,7 @@ void SalomeApp_EntityEdit::setText(const QString& theText) if (myCombo) { int aFound = myCombo->findItem(theText); if (aFound >= 0) { - myCombo->setCurrentItem(aFound); + myCombo->setCurrentIndex(aFound); onTextChanged(theText); } } @@ -1196,11 +1198,11 @@ void SalomeApp_EntityEdit::insertItem(const QString& theValue, if (theOrder == atTop) aIndexAt = 0; else if (theOrder == atBeforeCurrent && myCombo->count() > 0) - aIndexAt = myCombo->currentItem(); + aIndexAt = myCombo->currentIndex(); else if (theOrder == atAfterCurrent && myCombo->count() > 0 && - myCombo->currentItem() < myCombo->count()-1) - aIndexAt = myCombo->currentItem() + 1; + myCombo->currentIndex() < myCombo->count()-1) + aIndexAt = myCombo->currentIndex() + 1; myCombo->insertItem(theValue, aIndexAt); } if (theSetCurrent) @@ -1303,7 +1305,7 @@ void SalomeApp_EntityEdit::setFocus() myEdit->setFocus(); //myEdit->selectAll(); } - else if (myCombo && myCombo->editable()) { + else if (myCombo && myCombo->isEditable()) { myCombo->setFocus(); //myCombo->lineEdit()->selectAll(); } diff --git a/src/SalomeApp/SalomeApp_ListView.h b/src/SalomeApp/SalomeApp_ListView.h index ef6ebc99b..df4e3d792 100644 --- a/src/SalomeApp/SalomeApp_ListView.h +++ b/src/SalomeApp/SalomeApp_ListView.h @@ -25,19 +25,20 @@ #ifndef SALOMEAPP_LISTVIEW_H #define SALOMEAPP_LISTVIEW_H -#include +//#include -#include -#include -#include -#include -#include -#include +#include -#include -#include +#include +#include +#include +#include +#include -#include +class QToolButton; + +class TColStd_ListOfInteger; +class TColStd_ListOfReal; // enumeration for ListView updating mode enum UpdateType { @@ -56,7 +57,7 @@ class SalomeApp_EntityEdit; \class SalomeApp_ListView parent class for Data Viewer and Properties Viewer */ -class SalomeApp_ListView : public QtxListView , public SUIT_PopupClient { +class SalomeApp_ListView : public QTreeWidget/*QtxListView*/ , public SUIT_PopupClient { Q_OBJECT @@ -73,7 +74,7 @@ public: // fills popup with items virtual QString popupClientType() const; - virtual void contextMenuPopup( QPopupMenu* ); + virtual void contextMenuPopup( QMenu* ); // setting editing of items availbale/not available void enableEditing(bool theFlag); @@ -235,21 +236,17 @@ private: QString myString; }; -class SalomeApp_ListViewItem : public QListViewItem +class SalomeApp_ListViewItem : public QTreeWidgetItem { public: SalomeApp_ListViewItem( SalomeApp_ListView* ); SalomeApp_ListViewItem( SalomeApp_ListView*, SalomeApp_ListViewItem* ); SalomeApp_ListViewItem( SalomeApp_ListView*, - const QString&, - const bool = false ); - SalomeApp_ListViewItem( SalomeApp_ListView*, - const QString& theName, - const QString& theValue, + const QStringList&, const bool = false ); - SalomeApp_ListViewItem( SalomeApp_ListViewItem* theParent, - const QString&, + SalomeApp_ListViewItem( SalomeApp_ListViewItem*, + const QStringList&, const bool = false ); SalomeApp_ListViewItem( SalomeApp_ListView*, SalomeApp_ListViewItem*, @@ -259,10 +256,6 @@ public: SalomeApp_ListViewItem*, const QString&, const bool = false); - SalomeApp_ListViewItem( SalomeApp_ListViewItem*, - const QString& theName, - const QString& theValue, - const bool = false); SalomeApp_ListViewItem( SalomeApp_ListView*, SalomeApp_ListViewItem*, const QString& theName, @@ -335,6 +328,7 @@ public: protected: // initialization void init(); + int depth() const; private: bool myEditable; diff --git a/src/SalomeApp/SalomeApp_LoadStudiesDlg.cxx b/src/SalomeApp/SalomeApp_LoadStudiesDlg.cxx index 1cf810ea0..9105ab16f 100644 --- a/src/SalomeApp/SalomeApp_LoadStudiesDlg.cxx +++ b/src/SalomeApp/SalomeApp_LoadStudiesDlg.cxx @@ -18,10 +18,10 @@ // #include "SalomeApp_LoadStudiesDlg.h" -#include -#include -#include -#include +#include +#include +#include +#include #define SPACING_SIZE 6 #define MARGIN_SIZE 11 @@ -35,18 +35,22 @@ * \param f style flags */ -SalomeApp_LoadStudiesDlg::SalomeApp_LoadStudiesDlg( QWidget* parent, bool modal, WFlags fl ) -: QDialog( parent, "SalomeApp_LoadStudiesDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SalomeApp_LoadStudiesDlg::SalomeApp_LoadStudiesDlg( QWidget* parent, bool modal, Qt::WindowFlags fl ) +: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) { + setObjectName( "SalomeApp_LoadStudiesDlg" ); + setModal( modal ); + resize( 321, 181 ); - setCaption( tr("DLG_LOAD_STUDY_CAPTION") ); + setWindowTitle( tr("DLG_LOAD_STUDY_CAPTION") ); setSizeGripEnabled( TRUE ); QGridLayout* aTopLayout = new QGridLayout(this); aTopLayout->setMargin(MARGIN_SIZE); aTopLayout->setSpacing(SPACING_SIZE); - TextLabel1 = new QLabel( this, "TextLabel1" ); + TextLabel1 = new QLabel( this ); + TextLabel1->setObjectName( "TextLabel1" ); TextLabel1->setGeometry( QRect( 11, 12, 297, 16 ) ); TextLabel1->setText( tr( "MEN_STUDIES_CHOICE" ) ); @@ -54,12 +58,14 @@ SalomeApp_LoadStudiesDlg::SalomeApp_LoadStudiesDlg( QWidget* parent, bool modal aBtnLayout->setSpacing( SPACING_SIZE ); aBtnLayout->setMargin( 0 ); - buttonOk = new QPushButton( this, "buttonOk" ); + buttonOk = new QPushButton( this ); + buttonOk->setObjectName( "buttonOk" ); buttonOk->setText( tr( "BUT_OK" ) ); buttonOk->setAutoDefault( true ); buttonOk->setDefault( true ); - buttonCancel = new QPushButton( this, "buttonCancel" ); + buttonCancel = new QPushButton( this ); + buttonCancel->setObjectName( "buttonCancel" ); buttonCancel->setText( tr( "BUT_CANCEL" ) ); buttonCancel->setAutoDefault( true ); @@ -67,11 +73,11 @@ SalomeApp_LoadStudiesDlg::SalomeApp_LoadStudiesDlg( QWidget* parent, bool modal aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); aBtnLayout->addWidget( buttonCancel ); - ListComponent = new QListBox( this, "ListComponent" ); - ListComponent->setVScrollBarMode(QListBox::AlwaysOn); + ListComponent = new QListWidget( this ); + ListComponent->setObjectName( "ListComponent" ); ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT); ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - ListComponent->setSelectionMode(QListBox::Single); + ListComponent->setSelectionMode(QAbstractItemView::SingleSelection); aTopLayout->addWidget(TextLabel1, 0, 0); aTopLayout->addWidget(ListComponent, 1, 0); diff --git a/src/SalomeApp/SalomeApp_LoadStudiesDlg.h b/src/SalomeApp/SalomeApp_LoadStudiesDlg.h index 0fe64394d..a523d034e 100644 --- a/src/SalomeApp/SalomeApp_LoadStudiesDlg.h +++ b/src/SalomeApp/SalomeApp_LoadStudiesDlg.h @@ -21,16 +21,11 @@ #include -#include -#include +#include class QLabel; -class QListBox; +class QListWidget; class QPushButton; -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QListBoxItem; /*!\class SalomeApp_LoadStudiesDlg * \brief Describes a dialog box that gives a list of opened studies. @@ -41,7 +36,7 @@ class STD_EXPORT SalomeApp_LoadStudiesDlg : public QDialog Q_OBJECT public: - SalomeApp_LoadStudiesDlg( QWidget* parent = 0, bool modal = FALSE, WFlags fl = 0 ); + SalomeApp_LoadStudiesDlg( QWidget* parent = 0, bool modal = FALSE, Qt::WindowFlags fl = 0 ); ~SalomeApp_LoadStudiesDlg() {} /*!\var TextLabel1 @@ -62,7 +57,7 @@ public: /*!\var ListComponent * \brief stores a dialog list compoent */ - QListBox* ListComponent; + QListWidget* ListComponent; }; diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 332441a65..918c514ac 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -27,32 +27,19 @@ #include "SalomeApp_Study.h" #include "LightApp_Selection.h" -#include "LightApp_Operation.h" -#include "LightApp_Preferences.h" -//#include "LightApp_Displayer.h" #include "CAM_DataModel.h" -#include "OB_Browser.h" +// temporary commented +//#include "OB_Browser.h" #include #include #include -//#include #include -#include -#include -//#include -//#include -//#include - -#include -#include - -//#include -//#include +#include /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) @@ -78,9 +65,9 @@ CAM_DataModel* SalomeApp_Module::createDataModel() } /*!Create and return instance of LightApp_Selection.*/ -LightApp_Selection* SalomeApp_Module::createSelection() const +LightApp_Selection* SalomeApp_Module::createSelection( const QString& client, LightApp_SelectionMgr* mgr ) const { - return LightApp_Module::createSelection(); + return LightApp_Module::createSelection( client, mgr ); } /*! @@ -121,7 +108,7 @@ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_Li val = valSO->GetName().c_str(); Handle( SALOME_InteractiveObject ) new_obj = - new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() ); + new SALOME_InteractiveObject( id.toLatin1(), comp.toLatin1(), val.toLatin1() ); dest.Append( new_obj ); } anIter->Next(); diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 87ca5aad7..1231c2678 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -30,7 +30,6 @@ class CAM_DataModel; class SalomeApp_Application; -class LightApp_Operation; class LightApp_Selection; class SALOME_ListIO; class QString; @@ -59,7 +58,7 @@ public: virtual void storeVisualParameters(int savePoint); virtual void restoreVisualParameters(int savePoint); - virtual LightApp_Selection* createSelection() const; + virtual LightApp_Selection* createSelection( const QString&, LightApp_SelectionMgr* ) const; protected: virtual CAM_DataModel* createDataModel(); diff --git a/src/SalomeApp/SalomeApp_PyInterp.cxx b/src/SalomeApp/SalomeApp_PyInterp.cxx index 2f9e02040..cf59e8438 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.cxx +++ b/src/SalomeApp/SalomeApp_PyInterp.cxx @@ -31,12 +31,8 @@ #include #include -#include -#include +#include "PyInterp.h" // this include must be first (see PyInterp_base.h)! -#include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! - -#include using namespace std; /*! @@ -45,7 +41,7 @@ using namespace std; * initstate & initcontext redefined here. */ SalomeApp_PyInterp::SalomeApp_PyInterp(): - PythonConsole_PyInterp(), myFirstRun( true ) + PyConsole_Interp(), myFirstRun( true ) { } @@ -82,7 +78,7 @@ bool SalomeApp_PyInterp::initContext() * It is the caller responsability caller to acquire the GIL * It will still be held on initContext output */ - if ( !PythonConsole_PyInterp::initContext() ) + if ( !PyConsole_Interp::initContext() ) return false; // Import special module to change the import mechanism diff --git a/src/SalomeApp/SalomeApp_PyInterp.h b/src/SalomeApp/SalomeApp_PyInterp.h index c704482a4..735be4420 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.h +++ b/src/SalomeApp/SalomeApp_PyInterp.h @@ -29,9 +29,9 @@ #ifndef _SalomeApp_PYINTERP_H_ #define _SalomeApp_PYINTERP_H_ -#include // this include must be first (see PyInterp_base.h)! +#include // this include must be first (see PyInterp_base.h)! -class SalomeApp_PyInterp : public PythonConsole_PyInterp +class SalomeApp_PyInterp : public PyConsole_Interp { public: SalomeApp_PyInterp(); @@ -41,7 +41,7 @@ public: protected: virtual bool initContext(); - virtual bool beforeRun(); + virtual int beforeRun(); private: bool myFirstRun; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 1fb4d0bdd..ec8a6b893 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -20,32 +20,22 @@ #include "SalomeApp_Module.h" #include "SalomeApp_DataModel.h" -#include "SalomeApp_DataObject.h" #include "SalomeApp_Application.h" #include "SalomeApp_Engine_i.hxx" #include "SalomeApp_VisualState.h" #include "LightApp_RootObject.h" -#include +// temporary commented +//#include #include -#include -#include -#include - #include "utilities.h" -#include -#include -#include - -#include #include "SALOMEDS_Tool.hxx" #include "SALOMEDSClient_ClientFactory.hxx" -#include "SALOMEDSClient_IParameters.hxx" #include #include CORBA_SERVER_HEADER(SALOME_Exception) @@ -89,15 +79,15 @@ _PTR(Study) SalomeApp_Study::studyDS() const /*! Create document. */ -void SalomeApp_Study::createDocument() +bool SalomeApp_Study::createDocument( const QString& theStr ) { MESSAGE( "openDocument" ); // initialize myStudyDS, read HDF file QString aName = newStudyName(); - _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.latin1() ) ); + _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.toStdString() ) ); if ( !study ) - return; + return false; setStudyDS( study ); setStudyName( aName ); @@ -105,8 +95,10 @@ void SalomeApp_Study::createDocument() // create myRoot setRoot( new LightApp_RootObject( this ) ); - CAM_Study::createDocument(); + bool aRet = CAM_Study::createDocument( theStr ); emit created( this ); + + return aRet; } /*! @@ -118,7 +110,7 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) MESSAGE( "openDocument" ); // initialize myStudyDS, read HDF file - _PTR(Study) study ( SalomeApp_Application::studyMgr()->Open( (char*) theFileName.latin1() ) ); + _PTR(Study) study ( SalomeApp_Application::studyMgr()->Open( (char*) theFileName.toStdString().c_str() ) ); if ( !study ) return false; @@ -129,8 +121,9 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) // update loaded data models: call open() and update() on them. ModelList dm_s; dataModels( dm_s ); - for ( ModelListIterator it( dm_s ); it.current(); ++it ) - openDataModel( studyName(), it.current() ); + QListIterator it( dm_s ); + while ( it.hasNext() ) + openDataModel( studyName(), it.next() ); // 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 @@ -161,7 +154,7 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) MESSAGE( "loadDocument" ); // obtain myStudyDS from StudyManager - _PTR(Study) study ( SalomeApp_Application::studyMgr()->GetStudyByName( (char*) theStudyName.latin1() ) ); + _PTR(Study) study ( SalomeApp_Application::studyMgr()->GetStudyByName( (char*) theStudyName.toStdString().c_str() ) ); if ( !study ) return false; @@ -175,8 +168,9 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) ModelList dm_s; dataModels( dm_s ); - for ( ModelListIterator it( dm_s ); it.current(); ++it ) - openDataModel( studyName(), it.current() ); + QListIterator it( dm_s ); + while ( it.hasNext() ) + openDataModel( studyName(), it.next() ); // 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 @@ -210,13 +204,15 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) ModelList list; dataModels( list ); - SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + QListIterator it( list ); QStringList listOfFiles; - for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) { - listOfFiles.clear(); - aModel->saveAs( theFileName, this, listOfFiles ); - if ( !listOfFiles.isEmpty() ) - saveModuleData(aModel->module()->name(), listOfFiles); + while ( it.hasNext() ) { + if ( SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)it.next() ) { + listOfFiles.clear(); + aModel->saveAs( theFileName, this, listOfFiles ); + if ( !listOfFiles.isEmpty() ) + saveModuleData(aModel->module()->name(), listOfFiles); + } } // save SALOMEDS document @@ -227,8 +223,8 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false ); bool res = (isAscii ? - SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) : - SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile )) + SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.toStdString(), studyDS(), isMultiFile ) : + SalomeApp_Application::studyMgr()->SaveAs ( theFileName.toStdString(), studyDS(), isMultiFile )) && CAM_Study::saveDocumentAs( theFileName ); res = res && saveStudyData(theFileName); @@ -250,13 +246,15 @@ bool SalomeApp_Study::saveDocument() ModelList list; dataModels( list ); - SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + QListIterator it( list ); QStringList listOfFiles; - for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) { - listOfFiles.clear(); - aModel->save(listOfFiles); - if ( !listOfFiles.isEmpty() ) - saveModuleData(aModel->module()->name(), listOfFiles); + while ( it.hasNext() ) { + if ( SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)it.next() ) { + listOfFiles.clear(); + aModel->save(listOfFiles); + if ( !listOfFiles.isEmpty() ) + saveModuleData(aModel->module()->name(), listOfFiles); + } } // save SALOMEDS document @@ -336,10 +334,10 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theList for ( QStringList::Iterator it = theListOfFiles.begin(); it != theListOfFiles.end(); ++it ) { if ( (*it).isEmpty() ) continue; - aListOfFiles[anIndex] = (*it).latin1(); + aListOfFiles[anIndex] = (*it).toStdString(); anIndex++; } - SetListOfFiles(theModuleName, aListOfFiles); + SetListOfFiles(theModuleName.toStdString().c_str(), aListOfFiles); } /*! @@ -349,7 +347,7 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theList */ void SalomeApp_Study::openModuleData( QString theModuleName, QStringList& theListOfFiles ) { - std::vector aListOfFiles = GetListOfFiles( theModuleName ); + std::vector aListOfFiles = GetListOfFiles( theModuleName.toStdString().c_str() ); int i, aLength = aListOfFiles.size() - 1; if ( aLength < 0 ) @@ -368,10 +366,11 @@ void SalomeApp_Study::openModuleData( QString theModuleName, QStringList& theLis bool SalomeApp_Study::saveStudyData( const QString& theFileName ) { ModelList list; dataModels( list ); - SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + QListIterator it( list ); std::vector listOfFiles(0); - for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) - SetListOfFiles(aModel->module()->name(), listOfFiles); + while ( it.hasNext() ) + if ( SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)it.next() ) + SetListOfFiles(aModel->module()->name().toStdString().c_str(), listOfFiles); return true; } @@ -396,7 +395,7 @@ void SalomeApp_Study::setStudyDS( const _PTR(Study)& s ) */ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) { - MESSAGE("SalomeApp_Study::dataModelInserted() : module name() = " << dm->module()->name()); + MESSAGE("SalomeApp_Study::dataModelInserted() : module name() = " << dm->module()->name().toStdString()); CAM_Study::dataModelInserted(dm); @@ -415,20 +414,20 @@ void SalomeApp_Study::addComponent(const CAM_DataModel* dm) _PTR(Study) aStudy = studyDS(); if (!aStudy) return; - _PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name()); + _PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name().toStdString()); if (!aComp) { // Create SComponent _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); - aComp = aBuilder->NewComponent(dm->module()->name()); - aBuilder->SetName(aComp, dm->module()->moduleName().latin1()); + aComp = aBuilder->NewComponent(dm->module()->name().toStdString()); + aBuilder->SetName(aComp, dm->module()->moduleName().toStdString()); QString anIconName = dm->module()->iconName(); if (!anIconName.isEmpty()) { _PTR(AttributePixMap) anAttr = aBuilder->FindOrCreateAttribute(aComp, "AttributePixMap"); if (anAttr) - anAttr->SetPixMap(anIconName.latin1()); + anAttr->SetPixMap(anIconName.toStdString()); } // Set default engine IOR - aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1()); + aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().toStdString()); //SalomeApp_DataModel::BuildTree( aComp, root(), this, /*skipExisitng=*/true ); SalomeApp_DataModel::synchronize( aComp, this ); } @@ -451,7 +450,7 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm // 1. aModule == 0 means that this is a light module (no CORBA enigine) if (!aModule) { anEngine = SalomeApp_Application::defaultEngineIOR(); - aSComp = aStudy->FindComponent(dm->module()->name()); + aSComp = aStudy->FindComponent(dm->module()->name().toStdString()); } else { SalomeApp_DataModel* aDM = dynamic_cast( dm ); @@ -462,14 +461,14 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm anEngine = aDM->getModule()->engineIOR(); if ( anEngine.isEmpty() ) return false; - aSComp = aStudy->FindComponentID( std::string( anId.latin1() ) ); + aSComp = aStudy->FindComponentID( std::string( anId.toLatin1() ) ); } } if ( aSComp ) { _PTR(StudyBuilder) aBuilder( aStudy->NewBuilder() ); if ( aBuilder ) { try { - aBuilder->LoadWith( aSComp, std::string( anEngine.latin1() ) ); + aBuilder->LoadWith( aSComp, std::string( anEngine.toLatin1() ) ); } catch( const SALOME::SALOME_Exception& ) { // Oops, something went wrong while loading -> return an error @@ -489,7 +488,7 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm // Remove the files and temporary directory, created // for this module by LightApp_Engine_i::Load() bool isMultiFile = false; // TODO: decide, how to access this parameter - RemoveTemporaryFiles( dm->module()->name(), isMultiFile ); + RemoveTemporaryFiles( dm->module()->name().toStdString().c_str(), isMultiFile ); // Something has been read -> create data model tree LightApp_DataModel* aDM = dynamic_cast( dm ); @@ -511,7 +510,7 @@ QString SalomeApp_Study::newStudyName() const while ( newName.isEmpty() ){ curName = prefix.arg( i ); for ( j = 0 ; j < n; j++ ){ - if ( !strcmp( studies[j].c_str(), curName.latin1() ) ) + if ( !strcmp( studies[j].c_str(), curName.toLatin1() ) ) break; } if ( j == n ) @@ -606,7 +605,7 @@ void SalomeApp_Study::deleteReferencesTo( _PTR( SObject ) obj ) */ QString SalomeApp_Study::referencedToEntry( const QString& entry ) const { - _PTR(SObject) obj = studyDS()->FindObjectID( entry.latin1() ); + _PTR(SObject) obj = studyDS()->FindObjectID( entry.toStdString() ); _PTR(SObject) refobj; if( obj && obj->ReferencedObject( refobj ) ) @@ -619,7 +618,7 @@ QString SalomeApp_Study::referencedToEntry( const QString& entry ) const */ QString SalomeApp_Study::componentDataType( const QString& entry ) const { - _PTR(SObject) obj( studyDS()->FindObjectID( entry.latin1() ) ); + _PTR(SObject) obj( studyDS()->FindObjectID( entry.toStdString() ) ); if ( !obj ) return LightApp_Study::componentDataType( entry ); return obj->GetFatherComponent()->ComponentDataType().c_str(); @@ -630,7 +629,7 @@ QString SalomeApp_Study::componentDataType( const QString& entry ) const */ bool SalomeApp_Study::isComponent( const QString& entry ) const { - _PTR(SObject) obj( studyDS()->FindObjectID( entry.latin1() ) ); + _PTR(SObject) obj( studyDS()->FindObjectID( entry.toStdString() ) ); return obj && QString( obj->GetID().c_str() ) == obj->GetFatherComponent()->GetID().c_str(); } @@ -639,7 +638,7 @@ bool SalomeApp_Study::isComponent( const QString& entry ) const */ void SalomeApp_Study::children( const QString& entry, QStringList& child_entries ) const { - _PTR(SObject) SO = studyDS()->FindObjectID( entry.latin1() ); + _PTR(SObject) SO = studyDS()->FindObjectID( entry.toStdString() ); _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( SO ) ); anIter->InitEx( true ); while( anIter->More() ) @@ -716,7 +715,7 @@ void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSav { _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); _PTR(IParameters) ip = ClientFactory::getIParameters(AP); - ip->setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.latin1()); + ip->setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.toStdString()); } /*! diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index ef5c127fd..8de53b5f8 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -22,7 +22,6 @@ #include "SalomeApp.h" #include -#include #ifdef WIN32 #pragma warning( disable:4251 ) @@ -40,7 +39,7 @@ public: virtual int id() const; - virtual void createDocument(); + virtual bool createDocument( const QString& ); virtual bool openDocument( const QString& ); virtual bool loadDocument( const QString& ); diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx index 5f637cece..5fece2786 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx @@ -31,17 +31,13 @@ #include #include -// OCCT Includes -#include -#include - // CORBA Headers #include #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) // QT Includes -#include -#include +#include +#include using namespace std; @@ -59,7 +55,7 @@ public: const QString theName, const bool theEditable, const int theUserType) : - SalomeApp_ListViewItem( parent, theName, theEditable ) + SalomeApp_ListViewItem( parent, QStringList(theName), theEditable ) { setUserType(theUserType); } @@ -141,24 +137,29 @@ public: /*!Constructor. Initialize study properties dialog.*/ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) - : QDialog(parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myChanged( false ) { - setCaption(tr("TLT_STUDY_PROPERTIES")); + setObjectName( "" ); + setModal( TRUE ); + + setWindowTitle(tr("TLT_STUDY_PROPERTIES")); setSizeGripEnabled( true ); - clearWFlags(Qt::WStyle_ContextHelp); + //clearWFlags(Qt::WindowContextHelpButtonHint); QGridLayout* mainLayout = new QGridLayout(this); mainLayout->setMargin(DEFAULT_MARGIN); mainLayout->setSpacing(DEFAULT_SPACING); myPropList = new SalomeApp_ListView(this); - myPropList->addColumn(""); - myPropList->addColumn(""); + myPropList->setColumnCount(2); + QStringList aLabels; + aLabels << "" << ""; + myPropList->setHeaderLabels( aLabels ); myPropList->enableEditing(TRUE); myPropList->setMinimumSize(MIN_LIST_WIDTH, MIN_LIST_HEIGHT); - mainLayout->addMultiCellWidget(myPropList, 0, 0, 0, 2); + mainLayout->addWidget(myPropList, 0, 0, 1, 3); myOKBtn = new QPushButton(tr("BUT_OK"), this); mainLayout->addWidget(myOKBtn, 1, 0); @@ -290,15 +291,15 @@ void SalomeApp_StudyPropertiesDlg::onOK() _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties(); //myChanged = propChanged(); if ( propAttr /*&& myChanged*/ ) { - QListViewItemIterator it( myPropList ); + QTreeWidgetItemIterator it( myPropList ); // iterate through all items of the listview - for ( ; it.current(); ++it ) { - SalomeApp_PropItem* item = (SalomeApp_PropItem*)(it.current()); + while (*it) { + SalomeApp_PropItem* item = (SalomeApp_PropItem*)(*it); switch (item->getUserType()) { case prpAuthorId: - if (QString(propAttr->GetUserName().c_str()) != item->getValue().stripWhiteSpace()) { + if (QString(propAttr->GetUserName().c_str()) != item->getValue().trimmed()) { if (!propAttr->IsLocked()) { - propAttr->SetUserName(item->getValue().stripWhiteSpace().latin1()); + propAttr->SetUserName(item->getValue().trimmed().toStdString()); myChanged = true; } else { SUIT_MessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), @@ -308,7 +309,7 @@ void SalomeApp_StudyPropertiesDlg::onOK() } break; //case prpModeId: - // propAttr->SetCreationMode(item->getValue().stripWhiteSpace().latin1()); + // propAttr->SetCreationMode(item->getValue().trimmed().latin1()); // break; case prpLockedId: { @@ -322,6 +323,7 @@ void SalomeApp_StudyPropertiesDlg::onOK() default: break; } + ++it; } } accept(); @@ -335,18 +337,19 @@ bool SalomeApp_StudyPropertiesDlg::propChanged() { _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties(); if (propAttr) { - QListViewItemIterator it (myPropList); + QTreeWidgetItemIterator it (myPropList); + // iterate through all items of the listview - for (; it.current(); ++it) { - SalomeApp_PropItem* item = (SalomeApp_PropItem*)(it.current()); + while (*it) { + SalomeApp_PropItem* item = (SalomeApp_PropItem*)(*it); switch (item->getUserType()) { case prpAuthorId: - if ( QString( propAttr->GetUserName().c_str() ) != item->getValue().stripWhiteSpace() ) { + if ( QString( propAttr->GetUserName().c_str() ) != item->getValue().trimmed() ) { return true; } break; //case prpModeId: - // if ( QString( propAttr->GetCreationMode().c_str() ) != item->getValue().stripWhiteSpace() ) { + // if ( QString( propAttr->GetCreationMode().c_str() ) != item->getValue().trimmed() ) { // return true; // } // break; @@ -361,6 +364,7 @@ bool SalomeApp_StudyPropertiesDlg::propChanged() default: break; } + ++it; } } return false; diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h index 4abedf932..6991488fe 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h @@ -24,11 +24,8 @@ #define SALOMEAPP_STUDY_PROPERTIES_DLG_H #include "SalomeApp.h" -#include -#include -#include -#include -#include + +#include #include #include CORBA_SERVER_HEADER(SALOMEDS) @@ -37,7 +34,6 @@ class SalomeApp_ListView; class QPushButton; -class QToolButton; class SALOMEAPP_EXPORT SalomeApp_StudyPropertiesDlg : public QDialog { diff --git a/src/SalomeApp/SalomeApp_Tools.cxx b/src/SalomeApp/SalomeApp_Tools.cxx index 39989f6a6..893629e9d 100644 --- a/src/SalomeApp/SalomeApp_Tools.cxx +++ b/src/SalomeApp/SalomeApp_Tools.cxx @@ -24,6 +24,11 @@ #include +#include +#include + +#include + /*! Convert QColor to Quantity_Color, if QColor is valid. */ diff --git a/src/SalomeApp/SalomeApp_Tools.h b/src/SalomeApp/SalomeApp_Tools.h index a6f1e06dc..c288ef12f 100644 --- a/src/SalomeApp/SalomeApp_Tools.h +++ b/src/SalomeApp/SalomeApp_Tools.h @@ -23,10 +23,10 @@ #include -#include -#include +class QColor; +class QString; -#include +class Quantity_Color; #include #include CORBA_CLIENT_HEADER(SALOME_Exception) diff --git a/src/SalomeApp/SalomeApp_TypeFilter.cxx b/src/SalomeApp/SalomeApp_TypeFilter.cxx index c82912207..2a8d2fb8a 100644 --- a/src/SalomeApp/SalomeApp_TypeFilter.cxx +++ b/src/SalomeApp/SalomeApp_TypeFilter.cxx @@ -50,11 +50,11 @@ bool SalomeApp_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const _PTR(Study) aStudy = aDoc->studyDS(); QString entry = owner->entry(); - _PTR(SObject) aSObj( aStudy->FindObjectID( entry.latin1() ) ); + _PTR(SObject) aSObj( aStudy->FindObjectID( entry.toStdString() ) ); if (aSObj) { _PTR(SComponent) aComponent(aSObj->GetFatherComponent()); - if ( aComponent && (aComponent->ComponentDataType() == myKind.latin1()) ) + if ( aComponent && (aComponent->ComponentDataType() == myKind.toStdString()) ) return true; } } diff --git a/src/SalomeApp/SalomeApp_TypeFilter.h b/src/SalomeApp/SalomeApp_TypeFilter.h index 533ea7269..fa18adf95 100644 --- a/src/SalomeApp/SalomeApp_TypeFilter.h +++ b/src/SalomeApp/SalomeApp_TypeFilter.h @@ -19,7 +19,7 @@ #ifndef SALOMEAPP_TYPEFILTER_H #define SALOMEAPP_TYPEFILTER_H -#include +#include #include "SalomeApp_Filter.h" diff --git a/src/SalomeApp/SalomeApp_VisualState.cxx b/src/SalomeApp/SalomeApp_VisualState.cxx index dab9a907e..a5af64fdd 100644 --- a/src/SalomeApp/SalomeApp_VisualState.cxx +++ b/src/SalomeApp/SalomeApp_VisualState.cxx @@ -22,20 +22,22 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include +//#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include //? +#include //? -#include -#include +#include //? +#include //? /*! Constructor. @@ -64,28 +66,33 @@ SalomeApp_VisualState::~SalomeApp_VisualState() */ void nameViewWindows( const ViewManagerList& lst ) { - QDict viewersCounter; // map viewerType - to - index_of_this_viewer_type - viewersCounter.setAutoDelete( true ); - for ( QPtrListIterator it(lst); it.current(); ++it) { - int view_count = it.current()->getViewsCount(); - QString vType = it.current()->getType(); + QMultiHash viewersCounter; // map viewerType - to - index_of_this_viewer_type + QListIterator it(lst); + SUIT_ViewManager* aVM = 0; + while ( it.hasNext() ) { + aVM = it.next(); + if ( !aVM ) continue; + + int view_count = aVM->getViewsCount(); + QString vType = aVM->getType(); if ( !view_count ) continue; //No views is opened in the viewer - int* viewerID = viewersCounter[ vType ]; + int viewerID = viewersCounter.value( vType ); if ( !viewerID ) { - viewerID = new int( 0 ); + viewerID = 0; viewersCounter.insert( vType, viewerID ); } else - ++(*viewerID); + ++viewerID; - QPtrVector views = it.current()->getViews(); + QVector views = aVM->getViews(); for ( int i = 0; i < view_count; i++ ) { - QString vName = QString( "%1_%2_%3" ).arg( vType ).arg( *viewerID ).arg( i ); - views[i]->setName( vName ); + QString vName = QString( "%1_%2_%3" ).arg( vType ).arg( viewerID ).arg( i ); + views[i]->setObjectName( vName ); } } + viewersCounter.clear(); } /*! @@ -117,23 +124,26 @@ int SalomeApp_VisualState::storeState() // store active window's name SUIT_ViewWindow* win = myApp->desktop()->activeWindow(); if ( win ) - ip->setProperty("AP_ACTIVE_VIEW", win->name() ); + ip->setProperty("AP_ACTIVE_VIEW", win->objectName().toStdString() ); int viewerID = 0; SUIT_ViewManager* vm = 0; - for (QPtrListIterator it( lst ); it.current(); ++it ) { - vm = it.current(); + QListIterator it( lst ); + while ( it.hasNext() ) { + vm = it.next(); + if ( !vm ) continue; + int view_count = vm->getViewsCount(); if ( !view_count ) continue; //No views is opened in the viewer - std::string viewerEntry = QString( "%1_%2" ).arg( vm->getType() ).arg( ++viewerID ).latin1(); + std::string viewerEntry = QString( "%1_%2" ).arg( vm->getType() ).arg( ++viewerID ).toStdString(); ip->append("AP_VIEWERS_LIST", viewerEntry); - QPtrVector views = vm->getViews(); + QVector views = vm->getViews(); for(int i = 0; iappend( viewerEntry, views[i]->caption().latin1() ); - ip->append( viewerEntry, views[i]->getVisualParameters().latin1() ); + ip->append( viewerEntry, views[i]->windowTitle().toStdString() ); + ip->append( viewerEntry, views[i]->getVisualParameters().toStdString() ); } } @@ -142,20 +152,24 @@ int SalomeApp_VisualState::storeState() QtxWorkstack* workstack = ((STD_TabDesktop*)myApp->desktop())->workstack(); QString workstackInfo; (*workstack) >> workstackInfo; - ip->setProperty( "AP_WORKSTACK_INFO", workstackInfo.latin1() ); + ip->setProperty( "AP_WORKSTACK_INFO", workstackInfo.toStdString() ); } //Save a name of the active module if ( CAM_Module* activeModule = myApp->activeModule() ) - ip->setProperty( "AP_ACTIVE_MODULE", activeModule->moduleName().latin1() ); + ip->setProperty( "AP_ACTIVE_MODULE", activeModule->moduleName().toStdString() ); //Store visual parameters of the modules - QPtrList mlist; + QList mlist; myApp->modules( mlist ); + QListIterator itM( mlist ); CAM_Module* module = 0; - for ( module = mlist.first(); module; module = mlist.next() ) { + while ( itM.hasNext() ) { + module = itM.next(); + if ( !module ) continue; + if ( SalomeApp_Module* sModule = dynamic_cast( module ) ) { - ip->append( "AP_MODULES_LIST", sModule->moduleName().latin1() ); + ip->append( "AP_MODULES_LIST", sModule->moduleName().toStdString() ); sModule->storeVisualParameters( savePoint ); } } @@ -181,8 +195,9 @@ void SalomeApp_VisualState::restoreState(int savePoint) //Remove all already existent veiwers and their views ViewManagerList lst; myApp->viewManagers( lst ); - for ( QPtrListIterator it(lst); it.current(); ++it ) { - myApp->removeViewManager( it.current() ); + QListIterator it(lst); + while ( it.hasNext() ) { + myApp->removeViewManager( it.next() ); qApp->processEvents(); } //Restore the viewers and view windows @@ -216,7 +231,7 @@ void SalomeApp_VisualState::restoreState(int savePoint) } //Resize the views, set their captions and apply visual parameters. - QPtrVector views = vm->getViews(); + QVector views = vm->getViews(); for (int i = 0, j = 0; iisVisible() ) qApp->processEvents(); - viewWin->setCaption(ip->getValue(viewerEntry, j).c_str()); + viewWin->setWindowTitle(ip->getValue(viewerEntry, j).c_str()); // printf ( "VP for viewWin \"%s\": %s\n", viewerEntry.c_str(), ip->getValue(viewerEntry, j+1).c_str() ); viewersParameters[ viewWin ] = ip->getValue(viewerEntry, j+1).c_str(); @@ -246,14 +261,18 @@ void SalomeApp_VisualState::restoreState(int savePoint) // so here we store their visual parameters for later restoring.. lst.clear(); myApp->viewManagers(lst); - QPtrListIterator it( lst ); - for ( ; it.current(); ++it ) { - int view_count = it.current()->getViewsCount(); - QPtrVector views = it.current()->getViews(); + QListIterator itVM( lst ); + SUIT_ViewManager* aVM = 0; + while ( itVM.hasNext() ) { + aVM = itVM.next(); + if ( !aVM ) continue; + + int view_count = aVM->getViewsCount(); + QVector views = aVM->getViews(); for ( int i = 0; i < view_count; i++ ) { if ( !viewersParameters.contains( views[i] ) ) { viewersParameters[ views[i] ] = views[i]->getVisualParameters(); - // printf ( "store VP for viewWin \"%s\": %s\n", views[i]->name(), views[i]->getVisualParameters().latin1() ); + // printf ( "store VP for viewWin \"%s\": %s\n", views[i]->name(), views[i]->getVisualParameters().toLatin1().constData() ); } } } @@ -280,8 +299,8 @@ void SalomeApp_VisualState::restoreState(int savePoint) std::string activeViewName = ip->getProperty("AP_ACTIVE_VIEW"); QMap::Iterator mapIt; for ( mapIt = viewersParameters.begin(); mapIt != viewersParameters.end(); ++mapIt ) { - mapIt.key()->setVisualParameters( mapIt.data() ); - if ( activeViewName == mapIt.key()->name() ) + mapIt.key()->setVisualParameters( mapIt.value() ); + if ( activeViewName == mapIt.key()->objectName().toStdString() ) mapIt.key()->setFocus(); } diff --git a/src/SalomeApp/resources/SalomeApp_images.ts b/src/SalomeApp/resources/SalomeApp_images.ts new file mode 100644 index 000000000..4eb9e1878 --- /dev/null +++ b/src/SalomeApp/resources/SalomeApp_images.ts @@ -0,0 +1,2 @@ + + diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index f6db22171..445306db7 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -246,3 +246,24 @@ msgstr "Rename" msgid "SalomeApp_Application::MEN_DELETE_VS" msgstr "Delete" + +//======================================================================================= + +msgid "APPCLOSE_SAVE" +msgstr "&Save&&Close" + +msgid "APPCLOSE_CLOSE" +msgstr "&Close w/o saving" + +msgid "APPCLOSE_UNLOAD" +msgstr "&Unload" + +msgid "APPCLOSE_CANCEL" +msgstr "&Cancel" + +msgid "APPCLOSE_CAPTION" +msgstr "Close active study" + +msgid "APPCLOSE_DESCRIPTION" +msgstr "Do you want to close or only unload the study" +