From: vsr Date: Mon, 30 Jul 2007 15:31:13 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~69 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5da79f6fa4199edafd942535f65668865bc71d67;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/LightApp/LightApp.h b/src/LightApp/LightApp.h index 3282621bd..9bbeb7763 100644 --- a/src/LightApp/LightApp.h +++ b/src/LightApp/LightApp.h @@ -16,31 +16,29 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: LightApp.h -// Created: June, 2005 -// Author: OCC team +// File : LightApp.h +// Author : OCC team +// +#ifndef LIGHTAPP_H +#define LIGHTAPP_H -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the LightApp_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// LightApp_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. #ifdef WIN32 - -#ifdef LIGHTAPP_EXPORTS -#define LIGHTAPP_EXPORT __declspec(dllexport) +# ifdef LIGHTAPP_EXPORTS +# define LIGHTAPP_EXPORT __declspec(dllexport) +# else +# define LIGHTAPP_EXPORT __declspec(dllimport) +# endif #else -#define LIGHTAPP_EXPORT __declspec(dllimport) -#endif +# define LIGHTAPP_EXPORT +#endif // WIN32 +#if defined WNT #pragma warning ( disable:4251 ) #pragma warning ( disable:4786 ) #pragma warning ( disable:4503 ) - -#else -#define LIGHTAPP_EXPORT -#endif //WIN32 +#endif #define APP_VERSION "0.1" + +#endif // LIGHTAPP_H diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 92a7c2325..08fd32ca8 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -36,12 +36,10 @@ #include "LightApp_ModuleDlg.h" #include "LightApp_AboutDlg.h" #include "LightApp_ModuleAction.h" - +#include "LightApp_Browser.h" // temporary commented //#include "LightApp_OBFilter.h" - #include "LightApp_EventFilter.h" - #include "LightApp_OBSelector.h" #include "LightApp_SelectionMgr.h" #include "LightApp_DataObject.h" @@ -64,12 +62,9 @@ #include #include #include -#include +#include #include -// temporary commented -//#include -//#include #ifndef DISABLE_GLVIEWER #include @@ -138,8 +133,7 @@ #include #include #include - -using namespace Qt; +#include #define FIRST_HELP_ID 1000000 @@ -224,39 +218,39 @@ LightApp_Application::LightApp_Application() myAccel = SUIT_Accel::getAccel(); #ifndef DISABLE_OCCVIEWER - myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() ); #endif #ifndef DISABLE_VTKVIEWER - myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() ); #endif #ifndef DISABLE_PLOT2DVIEWER - myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, Plot2d_Viewer::Type() ); - myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() ); #endif connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) ); @@ -440,7 +434,7 @@ void LightApp_Application::createActions() //! Preferences createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(), tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ), - CTRL+Key_F, desk, false, this, SLOT( onPreferences() ) ); + Qt::CTRL+Qt::Key_F, desk, false, this, SLOT( onPreferences() ) ); //! Help for modules int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); @@ -577,24 +571,24 @@ void LightApp_Application::createActions() #ifndef DISABLE_GLVIEWER - createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), ALT+Key_G ); + createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G ); #endif #ifndef DISABLE_PLOT2DVIEWER - createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), ALT+Key_P ); + createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P ); #endif #ifndef DISABLE_OCCVIEWER - createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), ALT+Key_O ); + createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O ); #endif #ifndef DISABLE_VTKVIEWER - createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), ALT+Key_K ); + createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K ); #endif #ifndef DISABLE_QXGRAPHVIEWER - createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), ALT+Key_C ); + createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C ); #endif createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), - SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) ); + Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) ); createMenu( RenameId, windowMenu, -1 ); int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); @@ -809,9 +803,8 @@ bool LightApp_Application::onOpenDoc( const QString& aName ) */ void LightApp_Application::onHelpAbout() { - LightApp_AboutDlg* dlg = new LightApp_AboutDlg( applicationName(), applicationVersion(), desktop() ); - dlg->exec(); - delete dlg; + LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() ); + dlg.exec(); } /*! @@ -1041,15 +1034,14 @@ QWidget* LightApp_Application::window( const int flag, const int studyId ) const { QWidget* wid = 0; - int sId = studyId; - if ( sId < 0 ) - { + int sId = studyId; + if ( sId < 0 ) { if ( !activeStudy() ) return 0; else sId = activeStudy()->id(); } - + if ( myWindows.contains( flag ) ) wid = myWindows[flag]->widget( sId ); @@ -1089,7 +1081,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st myWindows.insert( flag, newWC ); if ( winMap.contains( flag ) ) { //desktop()->removeDockWidget( myWindows[flag] ); - desktop()->addDockWidget( (DockWidgetArea)winMap[flag], myWindows[flag] ); + desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] ); } //myWindows[flag]->setResizeEnabled( true ); @@ -1117,7 +1109,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st f = wid->font(); myWindows[flag]->insert( sId, wid ); - wid->setFont(f); + wid->setFont( f ); setWindowShown( flag, !myWindows[flag]->isEmpty() ); } @@ -1145,7 +1137,6 @@ void LightApp_Application::removeWindow( const int flag, const int studyId ) bool anIsEmpty = !myWindows[flag]->isEmpty(); QWidget* wid = myWindows[flag]->widget( sId ); myWindows[flag]->remove( sId ); - delete wid; //setWindowShown( flag, !myWindows[flag]->isEmpty() ); setWindowShown( flag, anIsEmpty ); @@ -1206,26 +1197,17 @@ void LightApp_Application::setWindowShown( const int type, const bool on ) /*! \return Object Browser */ -// temporary commented -/*OB_Browser* LightApp_Application::objectBrowser() +LightApp_Browser* LightApp_Application::objectBrowser() { - OB_Browser* ob = 0; - QWidget* wid = window( WT_ObjectBrowser ); - if ( wid && wid->inherits( "OB_Browser" ) ) - ob = (OB_Browser*)wid; - return ob; -}*/ + return qobject_cast( window( WT_ObjectBrowser ) ); +} /*! \return Log Window */ LogWindow* LightApp_Application::logWindow() { - LogWindow* lw = 0; - QWidget* wid = getWindow( WT_LogWindow ); - if ( wid->inherits( "LogWindow" ) ) - lw = (LogWindow*)wid; - return lw; + return qobject_cast( window( WT_LogWindow ) ); } #ifndef DISABLE_PYCONSOLE @@ -1234,11 +1216,7 @@ LogWindow* LightApp_Application::logWindow() */ PyConsole_Console* LightApp_Application::pythonConsole() { - PyConsole_Console* console = 0; - QWidget* wid = getWindow( WT_PyConsole ); - if ( wid->inherits( "PyConsole_Console" ) ) - console = (PyConsole_Console*)wid; - return console; + return qobject_cast( window( WT_PyConsole ) ); } #endif @@ -1251,10 +1229,9 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels ) // update existing data models if ( updateModels ) { - // temporary commented - /*const bool isAutoUpdate = objectBrowser() ? objectBrowser()->isAutoUpdate() : true; - if( objectBrowser() ) - objectBrowser()->setAutoUpdate( false );*/ + const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true; + if ( objectBrowser() ) + objectBrowser()->setAutoUpdate( false ); LightApp_Study* study = dynamic_cast(activeStudy()); if ( study ) { @@ -1268,16 +1245,14 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels ) } } - // temporary commented - /*if( objectBrowser() ) - objectBrowser()->setAutoUpdate( isAutoUpdate );*/ + if( objectBrowser() ) + objectBrowser()->setAutoUpdate( isAutoUpdate ); } - // temporary commented - /*if ( objectBrowser() ) - { + + if ( objectBrowser() ) { objectBrowser()->updateGeometry(); objectBrowser()->updateTree( 0, false ); - }*/ + } } /*! @@ -1440,16 +1415,16 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) aRoot = theStudy->root(); //aRoot->setName( tr( "DATA_MODELS" ) ); } + getWindow( WT_ObjectBrowser ); - // temporary commented - /*if ( objectBrowser() != 0 ) - objectBrowser()->setRootObject( aRoot );*/ + + if ( objectBrowser() ) + objectBrowser()->setRoot( aRoot ); activateModule( defaultModule() ); - // temporary commented - /*if ( objectBrowser() ) - objectBrowser()->openLevels();*/ + if ( objectBrowser() ) + objectBrowser()->openLevels(); activateWindows(); } @@ -1466,16 +1441,16 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) aRoot = theStudy->root(); //aRoot->dump(); } + getWindow( WT_ObjectBrowser ); - // temporary commented - /*if ( objectBrowser() ) - objectBrowser()->setRootObject( aRoot );*/ + + if ( objectBrowser() ) + objectBrowser()->setRoot( aRoot ); activateModule( defaultModule() ); - // temporary commented - /*if ( objectBrowser() ) - objectBrowser()->openLevels();*/ + if ( objectBrowser() ) + objectBrowser()->openLevels(); activateWindows(); @@ -1640,18 +1615,20 @@ QWidget* LightApp_Application::createWindow( const int flag ) QWidget* wid = 0; if ( flag == WT_ObjectBrowser ) { - // temporary commented - /*OB_Browser* ob = new OB_Browser( desktop() ); + LightApp_Browser* ob = new LightApp_Browser( new LightApp_DataObject(), desktop() ); + ob->treeView()->setSortMenuEnabled( true ); ob->setAutoUpdate( true ); //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107 - ob->setCaption( tr( "OBJECT_BROWSER" ) ); + ob->setWindowTitle( tr( "OBJECT_BROWSER" ) ); + // temporary commented + /* OB_ListView* ob_list = dynamic_cast( const_cast( ob->listView() ) ); if( ob_list ) ob_list->setColumnMaxWidth( 0, desktop()->width()/4 ); ob->setFilter( new LightApp_OBFilter( selectionMgr() ) ); - ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) ); + */ // Create OBSelector new LightApp_OBSelector( ob, mySelMgr ); @@ -1659,7 +1636,6 @@ QWidget* LightApp_Application::createWindow( const int flag ) wid = ob; ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); - */ } #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) @@ -1800,7 +1776,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" ); pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); - pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); + pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); //pref->setItemProperty( "columns", 1, extgroup ); @@ -2025,7 +2001,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if( param=="auto_size" || param=="auto_size_first" ) { // temporary commented - /*OB_Browser* ob = objectBrowser(); + /*LightApp_Browser* ob = objectBrowser(); if( !ob ) return; @@ -2206,12 +2182,12 @@ void LightApp_Application::updateWindows() if ( !myWindows.contains( it.key() ) ) continue; - DockWidgetArea dock = desktop()->dockWidgetArea( myWindows[it.key()] ); - if ( dock != NoDockWidgetArea + Qt::DockWidgetArea dock = desktop()->dockWidgetArea( myWindows[it.key()] ); + if ( dock != Qt::NoDockWidgetArea && - dock != (DockWidgetArea)it.value() ) { + dock != (Qt::DockWidgetArea)it.value() ) { //desktop()->removeDockWidget( myWindows[it.key()] ); - desktop()->addDockWidget( (DockWidgetArea)it.value(), myWindows[it.key()] ); + desktop()->addDockWidget( (Qt::DockWidgetArea)it.value(), myWindows[it.key()] ); } } @@ -2324,13 +2300,11 @@ void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopu { CAM_Application::contextMenuPopup( type, thePopup, title ); - // temporary commented - /*OB_Browser* ob = objectBrowser(); - if ( !ob || type != ob->popupClientType() ) - return;*/ - - thePopup->addSeparator(); - thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) ); + LightApp_Browser* ob = objectBrowser(); + if ( ob && type == ob->popupClientType() ) { + thePopup->addSeparator(); + thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) ); + } } /*! @@ -2339,9 +2313,9 @@ void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopu void LightApp_Application::createEmptyStudy() { CAM_Application::createEmptyStudy(); - // temporary commented - /*if ( objectBrowser() ) - objectBrowser()->updateTree();*/ + + if ( objectBrowser() ) + objectBrowser()->updateTree(); } /*! @@ -2351,9 +2325,10 @@ void LightApp_Application::createEmptyStudy() bool LightApp_Application::activateModule( CAM_Module* mod ) { bool res = CAM_Application::activateModule( mod ); - // temporary commented - /*if ( objectBrowser() ) - objectBrowser()->updateTree();*/ + + if ( objectBrowser() ) + objectBrowser()->updateTree(); + return res; } diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 3db912538..a4b0462fe 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -32,11 +32,10 @@ #include class LogWindow; -//class OB_Browser; +class LightApp_Browser; #ifndef DISABLE_PYCONSOLE class PyConsole_Console; #endif -//class STD_Application; class LightApp_WidgetContainer; class LightApp_Preferences; class LightApp_SelectionMgr; @@ -48,7 +47,6 @@ class CAM_Module; class QString; class QWidget; class QStringList; -//class QPixmap; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -114,7 +112,7 @@ public: LightApp_SelectionMgr* selectionMgr() const; LogWindow* logWindow(); - //OB_Browser* objectBrowser(); + LightApp_Browser* objectBrowser(); #ifndef DISABLE_PYCONSOLE PyConsole_Console* pythonConsole(); #endif diff --git a/src/LightApp/LightApp_Browser.cxx b/src/LightApp/LightApp_Browser.cxx new file mode 100644 index 000000000..3617f3182 --- /dev/null +++ b/src/LightApp/LightApp_Browser.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : LightApp_Browser.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "LightApp_Browser.h" +#include +#include +#include + +/*! + \class LightApp_Browser + \brief Object browser customization. +*/ + +/*! + \brief Constructor. + \param parent parent widget +*/ +LightApp_Browser::LightApp_Browser( QWidget* parent ) +: OB_Browser( parent ) +{ + setModel( new SUIT_ProxyModel( this ) ); +} + +/*! + \brief Constructor. + \param root root data object + \param parent parent widget +*/ +LightApp_Browser::LightApp_Browser( SUIT_DataObject* root, QWidget* parent ) +: OB_Browser( parent ) +{ + setModel( new SUIT_ProxyModel( root, this ) ); + connect( treeView(), SIGNAL( sortingEnabled(bool ) ), + model(), SLOT( setSortingEnabled( bool ) ) ); +} + +/*! + \brief Get root object. + \return root object +*/ +SUIT_DataObject* LightApp_Browser::root() const +{ + SUIT_ProxyModel* m = qobject_cast( model() ); + return m ? m->root() : 0; +} + +/*! + \brief Set root object. + \param r new root object +*/ +void LightApp_Browser::setRoot( SUIT_DataObject* r ) +{ + SUIT_ProxyModel* m = qobject_cast( model() ); + if ( m ) + m->setRoot( r ); +} + +/*! + \brief Get 'auto-update tree' flag value. + \return 'auto-update tree' flag value + \sa setAutoUpdate(), updateTree() +*/ +bool LightApp_Browser::autoUpdate() const +{ + SUIT_ProxyModel* m = qobject_cast( model() ); + return m ? m->autoUpdate() : false; +} + +/*! + \brief Set 'auto-update tree' flag value. + + If this flag is set to \c true (by default), the object browser is updated + automatically when data tree is changed. + + \param on 'auto-update tree' flag value + \sa autoUpdate(), updateTree() +*/ +void LightApp_Browser::setAutoUpdate( const bool on ) +{ + SUIT_ProxyModel* m = qobject_cast( model() ); + if ( m ) + m->setAutoUpdate( on ); +} + +/*! + \brief Update object browser starting from the object \obj; + open all branches automatically if \a autoOpen is \c true. + \param obj starting object for updating + \param autoOpen if \c true automatically open branches +*/ +void LightApp_Browser::updateTree( SUIT_DataObject* obj, const bool autoOpen ) +{ + SUIT_ProxyModel* m = qobject_cast( model() ); + if ( m ) { + m->updateTree( obj ); + openLevels(); + } +} diff --git a/src/LightApp/LightApp_Browser.h b/src/LightApp/LightApp_Browser.h new file mode 100644 index 000000000..3378fd4ac --- /dev/null +++ b/src/LightApp/LightApp_Browser.h @@ -0,0 +1,49 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : LightApp_Browser.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#ifndef LIGHTAPP_BROWSER_H +#define LIGHTAPP_BROWSER_H + +#include "LightApp.h" +#include + +class SUIT_DataObject; + +class LIGHTAPP_EXPORT LightApp_Browser : public OB_Browser +{ + Q_OBJECT + +public: + LightApp_Browser( QWidget* = 0 ); + LightApp_Browser( SUIT_DataObject*, QWidget* = 0 ); + + SUIT_DataObject* root() const; + void setRoot( SUIT_DataObject* ); + + bool autoUpdate() const; + void setAutoUpdate( const bool ); + + void updateTree( SUIT_DataObject* = 0, const bool = true ); + +}; + +#endif // LIGHTAPP_BROWSER_H diff --git a/src/LightApp/LightApp_DataModel.cxx b/src/LightApp/LightApp_DataModel.cxx index 7b14e8786..b83c84abe 100644 --- a/src/LightApp/LightApp_DataModel.cxx +++ b/src/LightApp/LightApp_DataModel.cxx @@ -23,13 +23,10 @@ #include "LightApp_DataModel.h" #include "LightApp_Study.h" -#include "LightApp_RootObject.h" #include "LightApp_DataObject.h" #include "LightApp_Module.h" #include "LightApp_Application.h" - -// temporary commented -//#include +#include "LightApp_Browser.h" #include @@ -97,9 +94,8 @@ void LightApp_DataModel::build() void LightApp_DataModel::updateWidgets() { LightApp_Application* app = dynamic_cast( module()->application() ); - // temporary commented - /*if( app ) - app->objectBrowser()->updateTree( 0, false );*/ + if ( app ) + app->objectBrowser()->updateTree( 0, false ); } /*! diff --git a/src/LightApp/LightApp_DataObject.cxx b/src/LightApp/LightApp_DataObject.cxx index 378cf63b7..692dca449 100644 --- a/src/LightApp/LightApp_DataObject.cxx +++ b/src/LightApp/LightApp_DataObject.cxx @@ -16,20 +16,24 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "LightApp_DataObject.h" +// File : LightApp_DataObject.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// +#include "LightApp_DataObject.h" #include "LightApp_Study.h" -#include "LightApp_RootObject.h" - -#include "CAM_DataModel.h" -#include "CAM_Module.h" +#include +#include #include /*! - Class: LightApp_DataObject::Key - Level: Internal + \class LightApp_DataObject::Key + \brief Represents unique data object key for the LightApp_DataObject + class instances. + \internal */ + class LightApp_DataObject::Key : public SUIT_DataObjectKey { public: @@ -43,73 +47,157 @@ private: QString myEntry; }; -/*!Constructor. Initialize by \a entry.*/ +/*! + \brief Constructor. + \internal + \param entry data object entry +*/ LightApp_DataObject::Key::Key( const QString& entry ) : SUIT_DataObjectKey(), myEntry( entry ) { } -/*!Destructor. Do nothing.*/ +/*! + \brief Destructor. + \internal +*/ LightApp_DataObject::Key::~Key() { } -/*!Checks: Is current key less than \a other.*/ +/*! + \brief Compares this key with the another one. + \internal + \param other another data object key + \return \c true if this key is less than \a other. +*/ bool LightApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const { Key* that = (Key*)other; return myEntry < that->myEntry; } -/*!Checks: Is current key equal with \a other.*/ +/*! + \brief Compares this key with the another one. + \internal + \param other another data object key + \return \c true if this key is equal to the \a other. +*/ bool LightApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const { Key* that = (Key*)other; return myEntry == that->myEntry; } -/*!Constructor. Initialize by \a parent*/ +/*! + \class LightApp_DataObject + \brief Base data object class to build the data model for all the SALOME modules. +*/ + +/*! + \brief Constructor. + \param parent parent data object +*/ LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent ) -: CAM_DataObject( parent ), myCompObject( 0 ), myCompDataType( "" ) +: CAM_DataObject( parent ), + myCompObject( 0 ), + myCompDataType( "" ) { } -/*!Destructor. Do nothing.*/ +/*! + \brief Destructor. +*/ LightApp_DataObject::~LightApp_DataObject() { } -/*!Gets object ID. - *\retval QString - */ +/*! + \brief Get the number of the columns provided by the data tree. + \return number of the columns +*/ +int LightApp_DataObject::columnCount() const +{ + // add "Entry" column + return CAM_DataObject::columnCount() + 1; +} + +/*! + \brief Get column title. + \param index column index + \return title of the specified column +*/ +QString LightApp_DataObject::columnTitle( const int index ) const +{ + // add "Entry" column + return index == EntryIdx ? QObject::tr( "ENTRY_COLUMN" ) + : CAM_DataObject::columnTitle( index ); +} + +/*! + \brief Check if the column should appear in the tree view header popup menu + (to show/hide the column). + \param index column index + \return \c true if the column can be shown/hidden +*/ +bool LightApp_DataObject::appropriate( const int index ) const +{ + // add "Entry" column + return index == EntryIdx ? true : CAM_DataObject::appropriate( index ); +} + +/*! + \brief Get object string identifier. + + This method should be reimplemented in the subclasses. + Default implementation returns null string. + + \return object ID +*/ QString LightApp_DataObject::entry() const { - return QString::null; + return QString(); } -/*!Create and return new key object.*/ +/*! + \brief Get the data object unique key. + \return data object key +*/ SUIT_DataObjectKey* LightApp_DataObject::key() const { QString str = entry(); return new Key( str ); } -/*!Gets component object. - *\retval SUIT_DataObject. - */ +/*! + \brief Get object text data for the specified column. + + Column with \a index = 0 (NameIdx) is supposed to be used + to get the object name. + Column with \a index = 1 (EntryIdx) is supposed to be used + to get the object entry. + + \param index column index + \return object text data +*/ +QString LightApp_DataObject::text( const int index ) const +{ + // add "Entry" column + return index == EntryIdx ? entry() : CAM_DataObject::text( index ); +} + +/*! + \brief Get the component object. + \return component data object +*/ SUIT_DataObject* LightApp_DataObject::componentObject() const { if ( !myCompObject ) { - SUIT_DataObject* compObj = 0; // for root object - - if ( parent() && parent() == root() ) - compObj = (SUIT_DataObject*)this; // for component-level objects - else - { - compObj = parent(); // for lower level objects - while ( compObj && compObj->parent() != root() ) - compObj = compObj->parent(); + SUIT_DataObject* compObj = (SUIT_DataObject*)this; + + while ( compObj && compObj->parent() && compObj->parent() != root() ) { + compObj = compObj->parent(); } LightApp_DataObject* that = (LightApp_DataObject*)this; that->myCompObject = compObj; @@ -117,11 +205,14 @@ SUIT_DataObject* LightApp_DataObject::componentObject() const return myCompObject; } -/*!Get component type.*/ +/*! + \brief Get component type. + \return component type +*/ QString LightApp_DataObject::componentDataType() const { if ( myCompDataType.isEmpty() ) { - SUIT_DataObject* aCompObj = componentObject(); + SUIT_DataObject* aCompObj = componentObject(); LightApp_ModuleObject* anObj = dynamic_cast( aCompObj ); if ( anObj ) { CAM_DataModel* aModel = anObj->dataModel(); @@ -134,45 +225,113 @@ QString LightApp_DataObject::componentDataType() const return myCompDataType; } +/*! + \class LightApp_ModuleObject + \brief Used for optimized access to the data model from the data objects. + \sa CAM_ModuleObject class +*/ - -/*!Constructor.Initialize by \a parent.*/ +/*! + \brief Constructor. + \param parent parent data object +*/ LightApp_ModuleObject::LightApp_ModuleObject( SUIT_DataObject* parent ) -: CAM_RootObject( parent ), - CAM_DataObject( parent ) +: CAM_DataObject( parent ), + LightApp_DataObject( parent ), + CAM_ModuleObject( parent ) { } -/*!Constructor.Initialize by \a module and parent.*/ +/*! + \brief Constructor. + \param dm data model + \param parent parent data object +*/ LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent ) -: CAM_RootObject( dm, parent ), - CAM_DataObject( parent ) +: CAM_DataObject( parent ), + LightApp_DataObject( parent ), + CAM_ModuleObject( dm, parent ) { } -/*!Destructor. Do nothing.*/ +/* + \brief Destructor. +*/ LightApp_ModuleObject::~LightApp_ModuleObject() { } -/*!Returns module name */ +/*! + \brief Get module name. + \return module name +*/ QString LightApp_ModuleObject::name() const { - return CAM_RootObject::name(); + return CAM_ModuleObject::name(); } -/*!Insert new child object to the children list at specified position - *\add component in Study for this module object if it necessary*/ -void LightApp_ModuleObject::insertChild( SUIT_DataObject* theObj, int thePosition ) +/*! + \brief Insert new child object to the children list at specified position. + + Adds component in the study for this module object if it is not done yet. + + \param obj object to be inserted + \param pos position at which data object should be inserted +*/ +void LightApp_ModuleObject::insertChild( SUIT_DataObject* obj, int pos ) { - CAM_RootObject::insertChild(theObj, thePosition); + LightApp_DataObject::insertChild( obj, pos ); CAM_DataModel* aModel = dataModel(); - LightApp_RootObject* aRoot = dynamic_cast(parent()); + LightApp_RootObject* aRoot = dynamic_cast( parent() ); + + if ( aRoot ) + aRoot->study()->addComponent( aModel ); +} + +/*! + \class LightApp_RootObject + \brief Root data object for the light (without CORBA) SALOME application. + + This class is to be instanciated by only one object - the root object + of the LightApp data object tree. This object is not shown in the object browser. + The goal of this class is to provide a unified access to LightApp_Study + object from LightApp_DataObject instances. +*/ - if (aRoot) - aRoot->study()->addComponent(aModel); +/* + \brief Constructor. + \param study study +*/ +LightApp_RootObject::LightApp_RootObject( LightApp_Study* study ) +: CAM_DataObject( 0 ), + LightApp_DataObject( 0 ), + myStudy( study ) +{ +} +/* + \brief Destructor. +*/ +LightApp_RootObject::~LightApp_RootObject() +{ +} +/* + \brief Set study. + \param study pointer to the study +*/ +void LightApp_RootObject::setStudy( LightApp_Study* study ) +{ + myStudy = study; } + +/* + \brief Get study + \return pointer to the study +*/ +LightApp_Study* LightApp_RootObject::study() const +{ + return myStudy; +} diff --git a/src/LightApp/LightApp_DataObject.h b/src/LightApp/LightApp_DataObject.h index ec2469b0b..da41a7d07 100644 --- a/src/LightApp/LightApp_DataObject.h +++ b/src/LightApp/LightApp_DataObject.h @@ -16,34 +16,42 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : LightApp_DataObject.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #ifndef LIGHTAPP_DATAOBJECT_H #define LIGHTAPP_DATAOBJECT_H #include "LightApp.h" - -#include "CAM_DataObject.h" -#include "CAM_RootObject.h" +#include class CAM_DataModel; - class LightApp_Study; -/*!Description : Data Object has empty entry so it's children must redefine metod entry() and return some unique string*/ -// to do : decomment virtual inheritance class LIGHTAPP_EXPORT LightApp_DataObject : public virtual CAM_DataObject { class Key; public: - enum { CT_Value, CT_Entry, CT_IOR, CT_RefEntry }; + //! Column index + enum { + EntryIdx = NameIdx + 1 //!< entry column + }; public: LightApp_DataObject( SUIT_DataObject* = 0 ); virtual ~LightApp_DataObject(); + virtual int columnCount() const; + virtual QString columnTitle( const int = NameIdx ) const; + virtual bool appropriate( const int = NameIdx ) const; + virtual SUIT_DataObjectKey* key() const; virtual QString entry() const; + virtual QString text( const int = NameIdx ) const; + virtual SUIT_DataObject* componentObject() const; virtual QString componentDataType() const; @@ -52,22 +60,31 @@ protected: SUIT_DataObject* myCompObject; }; -/*! - * LightApp_ModuleObject - class for optimized access to DataModel from - * CAM_RootObject.h. - * In modules which will be redefine LightApp_DataObject, LightApp_ModuleObject must be children from rederined DataObject for having necessary properties and children from LightApp_ModuleObject. - */ - -class LIGHTAPP_EXPORT LightApp_ModuleObject : public CAM_RootObject +class LIGHTAPP_EXPORT LightApp_ModuleObject +: public virtual LightApp_DataObject, public CAM_ModuleObject { public: LightApp_ModuleObject( SUIT_DataObject* = 0 ); - LightApp_ModuleObject ( CAM_DataModel*, SUIT_DataObject* = 0 ); + LightApp_ModuleObject( CAM_DataModel*, SUIT_DataObject* = 0 ); virtual ~LightApp_ModuleObject(); virtual QString name() const; - virtual void insertChild( SUIT_DataObject*, int thePosition ); + virtual void insertChild( SUIT_DataObject*, int ); +}; + +class LIGHTAPP_EXPORT LightApp_RootObject : public virtual LightApp_DataObject +{ +public: + LightApp_RootObject( LightApp_Study* ); + + virtual ~LightApp_RootObject(); + + void setStudy( LightApp_Study* ); + LightApp_Study* study() const; + +private: + LightApp_Study* myStudy; }; -#endif +#endif // LIGHTAPP_DATAOBJECT_H diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index a83523f91..d67881b80 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -35,6 +35,7 @@ #include "LightApp_SwitchOp.h" #include "LightApp_UpdateFlags.h" #include "LightApp_ShowHideOp.h" +#include "LightApp_Browser.h" #include #include @@ -75,9 +76,6 @@ #endif #endif -// temporary commented -//#include - #include #include @@ -139,9 +137,8 @@ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QStr void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, SUIT_DataObject* theDataObject ) { - // temporary commented - /*bool upd = getApp()->objectBrowser()->isAutoUpdate(); - getApp()->objectBrowser()->setAutoUpdate( false );*/ + bool upd = getApp()->objectBrowser()->autoUpdate(); + getApp()->objectBrowser()->setAutoUpdate( false ); if( theIsUpdateDataModel ){ if( CAM_DataModel* aDataModel = dataModel() ){ @@ -156,9 +153,9 @@ void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, } } } - // temporary commented - /*getApp()->objectBrowser()->setAutoUpdate( upd ); - getApp()->objectBrowser()->updateTree( 0, false );*/ + + getApp()->objectBrowser()->setAutoUpdate( upd ); + getApp()->objectBrowser()->updateTree( 0, false ); } /*!NOT IMPLEMENTED*/ @@ -242,9 +239,10 @@ void LightApp_Module::update( const int theFlags ) if( LightApp_DataModel* aModel = dynamic_cast( aDataModel ) ) aModel->update( 0, dynamic_cast( getApp()->activeStudy() ) ); } - // temporary commented - /*if ( theFlags & UF_ObjBrowser ) - getApp()->objectBrowser()->updateTree( 0 );*/ + + if ( theFlags & UF_ObjBrowser ) + getApp()->objectBrowser()->updateTree( 0 ); + if ( theFlags & UF_Controls ) updateControls(); if ( theFlags & UF_Viewer ) diff --git a/src/LightApp/LightApp_RootObject.h b/src/LightApp/LightApp_RootObject.h deleted file mode 100644 index 1c1543a46..000000000 --- a/src/LightApp/LightApp_RootObject.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef LIGHTAPP_ROOTOBJECT_H -#define LIGHTAPP_ROOTOBJECT_H - -#include "LightApp.h" -#include "SUIT_DataObject.h" - -class LightApp_Study; - -/*! - LightApp_RootObject - class to be instanciated by only one object - - root object of LightApp data object tree. This object is not shown - in object browser (invisible), so it has no re-definition of name(), icon(), - etc. methods. The goal of this class is to provide a unified access - to LightApp_Study object from LightApp_DataObject instances. -*/ -class LIGHTAPP_EXPORT LightApp_RootObject : public SUIT_DataObject -{ -public: - LightApp_RootObject( LightApp_Study* study ) - : myStudy( study ) - {} - - virtual ~LightApp_RootObject() {} - - void setStudy( LightApp_Study* study ) { myStudy = study; } - LightApp_Study* study() const { return myStudy; } - -private: - LightApp_Study* myStudy; - -}; - -#endif diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index 6c3ae1bad..900f142e8 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -23,7 +23,6 @@ #include "LightApp_Application.h" #include "LightApp_DataModel.h" #include "LightApp_DataObject.h" -#include "LightApp_RootObject.h" #include "LightApp_HDFDriver.h" #include "SUIT_ResourceMgr.h" diff --git a/src/LightApp/LightApp_WidgetContainer.cxx b/src/LightApp/LightApp_WidgetContainer.cxx index c7ac53a2e..a824dcefe 100644 --- a/src/LightApp/LightApp_WidgetContainer.cxx +++ b/src/LightApp/LightApp_WidgetContainer.cxx @@ -16,137 +16,202 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : LightApp_WidgetContainer.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #include "LightApp_WidgetContainer.h" -#include #include /*! - Constructor. + \class LightApp_WidgetContainer + \brief Class which implements widget container. + + This class allows to put all the child widgets in the stack widget. + Only one widget is visible at the moment. + + Each widget can be referred by unique number identifier passed as parameter + to the insert() method. Removing of the widgets from the container is done + via remove() method. + + To raise the widget to the top (to make it visiable) use activate() method. + Current widget can be retrieved with active() method. +*/ + +/*! + \brief Constructor. + \param type widget container type + \param parent parent widget */ LightApp_WidgetContainer::LightApp_WidgetContainer( const int type, QWidget* parent ) - : QDockWidget( /*QDockWindow::InDock,*/ parent ), - myType( type ) +: QDockWidget( parent ), + myType( type ) { - setObjectName(QString("WC_%1").arg(type)); + setObjectName( QString( "WC_%1" ).arg( type ) ); setWidget( myStack = new QStackedWidget( this ) ); myStack->show(); } /*! - Destructor. + \brief Destructor. */ LightApp_WidgetContainer::~LightApp_WidgetContainer() { } /*! - Checks: is widget container is empty? + \brief Get the type of the widget container. + \return widget container type (passed as parameter to the constructor) */ -bool LightApp_WidgetContainer::isEmpty() const +int LightApp_WidgetContainer::type() const { - const QList lst = myStack->children(); - if ( lst.isEmpty() ) - return true; - - bool res = true; - QListIterator it( lst ); - while ( it.hasNext() && res ) - { - QObject* anItem = it.next(); - if ( anItem->isWidgetType() && myStack->indexOf( (QWidget*)anItem ) != -1 ) - res = false; - } - return res; + return myType; } /*! - Gets type of widget container. + \brief Insert widget \a wid with identifier \a id to the container. + + If there is already a widget with the specified identifier it is removed. + + \param id widget ID + \param wid widget being inserted + \return widget identifier or -1 on error */ -int LightApp_WidgetContainer::type() const +int LightApp_WidgetContainer::insert( const int id, QWidget* wid ) { - return myType; + if ( id == -1 || !wid ) + return -1; + + if ( widget( id ) == wid ) + return -1; + + remove( id ); + + myStack->addWidget( wid ); + if ( !myStack->currentWidget() ) + activate( wid ); + + myMap.insert( id, wid ); + + connect( wid, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); + + return id; } /*! - Checks: is container contains widget with id \a id. + \brief Remove widget with the specified identifier from the container. + \param id widget ID + \param del if \c true (default) destroy the child widget */ -bool LightApp_WidgetContainer::contains( const int id ) const +void LightApp_WidgetContainer::remove( const int id, const bool del ) { - return myStack->widget( id ) != 0; + if ( myMap.contains( id ) ) + remove( myMap[ id ], del ); } /*! - * Insert widget(\a wid with id \a id) to container.And return id of widget in stack. - *\warning remove widget with id = \a id , if it was in container. - */ -int LightApp_WidgetContainer::insert( const int id, QWidget* wid ) + \brief Remove specified widget from the container. + \param wid widget being removed + \param del if \c true (default) destroy the child widget +*/ +void LightApp_WidgetContainer::remove( QWidget* wid, const bool del ) { - if ( id == -1 || !wid ) - return -1; + if ( !wid ) + return; - if ( contains( id ) ) - remove( id ); + myStack->removeWidget( wid ); + QMutableMapIterator it( myMap ); + while ( it.hasNext() ) { + it.next(); + if ( it.value() == wid ) { + it.remove(); + break; + } + } - int stackId = myStack->insertWidget( id, wid ); - if ( !myStack->currentWidget() ) - myStack->setCurrentWidget( wid ); + disconnect( wid, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); - setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString::null ); + if ( del ) + delete wid; - return stackId; + setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString() ); } /*! - Remove widget(\a wid) from stack. + \brief Check if the container contains a widget with the + specified identifier. + \param id widget ID + \return \c true if container contains a widget */ -void LightApp_WidgetContainer::remove( const int id ) +bool LightApp_WidgetContainer::contains( const int id ) const { - remove( myStack->widget( id ) ); - - setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString::null ); + return myMap.contains( id ); } /*! - Remove widget(\a wid) from stack. + \brief Check if the container contains specified widget. + \param widget widget being checked + \return \c true if container contains a widget */ -void LightApp_WidgetContainer::remove( QWidget* wid ) +bool LightApp_WidgetContainer::contains( QWidget* wid ) const { - myStack->removeWidget( wid ); + bool found = false; + QMapIterator it( myMap ); + while ( it.hasNext() && !found ) { + it.next(); + if ( it.value() == wid ) + found = true; + } + return found; +} - setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString::null ); +/*! + \brief Check if the widget container is empty. + \return \c true if widget container does not have child widgets +*/ +bool LightApp_WidgetContainer::isEmpty() const +{ + return myMap.count() > 0; } /*! - Raise widget with id = \a id. + \brief Bring the widget with the specified identifier to the top + of the container. + \param id widget ID */ void LightApp_WidgetContainer::activate( const int id ) { - myStack->setCurrentIndex( id ); - - setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString::null ); + if ( myMap.contains( id ) ) + activate( myMap[ id ] ); } /*! - Raise widget (\a wid). + \brief Bring the specified widget to the top of the container. + \param wid widget to be activated */ void LightApp_WidgetContainer::activate( QWidget* wid ) { - myStack->setCurrentWidget( wid ); + if ( !wid || !contains( wid ) ) + return; - setWindowTitle( myStack->currentWidget() ? myStack->currentWidget()->windowTitle() : QString::null ); + myStack->setCurrentWidget( wid ); + setWindowTitle( wid ? wid->windowTitle() : QString() ); } /*! - Gets widget from container list(stack) by id = \a id. + \brief Get widget with the specified identifier. + \param id widget ID + \return widget pointer or 0 if \a id is invalid */ QWidget* LightApp_WidgetContainer::widget( const int id ) const { - return myStack->widget( id ); + return myMap.contains( id ) ? myMap[ id ] : 0; } /*! - Gets visible widget. + \brief Get currently visible widget. + \return current widget or 0 if there is no any */ QWidget* LightApp_WidgetContainer::active() const { @@ -166,3 +231,19 @@ void LightApp_WidgetContainer::setVisible ( bool visible ) QDockWidget::setVisible( visible ); emit( visibilityChanged( visible ) ); } + +/*! + \brief Called when the child widget is destroyed. + \param wid widget being destroyed +*/ +void LightApp_WidgetContainer::onDestroyed( QObject* wid ) +{ + QMutableMapIterator it( myMap ); + while ( it.hasNext() ) { + it.next(); + if ( it.value() == wid ) { + it.remove(); + break; + } + } +} diff --git a/src/LightApp/LightApp_WidgetContainer.h b/src/LightApp/LightApp_WidgetContainer.h index 23aa342a0..10208f090 100644 --- a/src/LightApp/LightApp_WidgetContainer.h +++ b/src/LightApp/LightApp_WidgetContainer.h @@ -16,19 +16,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : LightApp_WidgetContainer.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #ifndef LIGHTAPP_WIDGETCONTAINER_H #define LIGHTAPP_WIDGETCONTAINER_H #include "LightApp.h" #include +#include class QWidget; class QStackedWidget; -/*! - Class which privade widget container. -*/ class LIGHTAPP_EXPORT LightApp_WidgetContainer : public QDockWidget { Q_OBJECT @@ -37,30 +39,34 @@ public: LightApp_WidgetContainer( const int, QWidget* = 0 ); virtual ~LightApp_WidgetContainer(); - bool isEmpty() const; + int type() const; - int type() const; + int insert( const int, QWidget* ); + void remove( const int, const bool = true ); + void remove( QWidget*, const bool = true ); + bool contains( const int ) const; + bool contains( QWidget* ) const; + bool isEmpty() const; - int insert( const int, QWidget* ); - void remove( QWidget* ); - void remove( const int ); - bool contains( const int ) const; + void activate( const int ); + void activate( QWidget* ); - void activate( QWidget* ); - void activate( const int ); - - QWidget* active() const; - QWidget* widget( const int ) const; + QWidget* widget( const int ) const; + QWidget* active() const; public slots: - virtual void setVisible ( bool ); + virtual void setVisible( bool ); signals: - void visibilityChanged ( bool ); + void visibilityChanged( bool ); + +private slots: + void onDestroyed( QObject* ); private: - int myType; - QStackedWidget* myStack; + int myType; + QStackedWidget* myStack; + QMap myMap; }; -#endif +#endif // LIGHTAPP_WIDGETCONTAINER_H diff --git a/src/LightApp/Makefile.am b/src/LightApp/Makefile.am index 12e38da06..ce506cd96 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -29,6 +29,7 @@ salomeinclude_HEADERS= \ LightApp.h \ LightApp_AboutDlg.h \ LightApp_Application.h \ + LightApp_Browser.h \ LightApp_DataModel.h \ LightApp_DataObject.h \ LightApp_DataOwner.h \ @@ -51,7 +52,6 @@ salomeinclude_HEADERS= \ LightApp_SwitchOp.h \ LightApp_Preferences.h \ LightApp_PreferencesDlg.h \ - LightApp_RootObject.h \ LightApp_UpdateFlags.h \ LightApp_WidgetContainer.h @@ -72,6 +72,7 @@ endif dist_libLightApp_la_SOURCES= \ LightApp_AboutDlg.cxx \ LightApp_Application.cxx \ + LightApp_Browser.cxx \ LightApp_DataModel.cxx \ LightApp_DataObject.cxx \ LightApp_DataOwner.cxx \ @@ -113,6 +114,7 @@ endif MOC_FILES= \ LightApp_AboutDlg_moc.cxx \ LightApp_Application_moc.cxx \ + LightApp_Browser_moc.cxx \ LightApp_DataModel_moc.cxx \ LightApp_Dialog_moc.cxx \ LightApp_OBSelector_moc.cxx \ @@ -218,8 +220,8 @@ endif libLightApp_la_LIBADD= ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ ../LogWindow/libLogWindow.la $(CAS_KERNEL) \ - ../Prs/libSalomePrs.la $(HDF5_LIBS) $(KERNEL_LDFLAGS) -lSalomeHDFPersist -#../ObjBrowser/libObjBrowser.la + ../Prs/libSalomePrs.la ../ObjBrowser/libObjBrowser.la \ + $(HDF5_LIBS) $(KERNEL_LDFLAGS) -lSalomeHDFPersist if ENABLE_SALOMEOBJECT libLightApp_la_LIBADD+= ../OBJECT/libSalomeObject.la diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 50a399391..d43659692 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -26,6 +26,10 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASABOUT_VERSION Version %1 + + ENTRY_COLUMN + Entry + LightApp_Application diff --git a/src/LightApp/resources/icon_about.png b/src/LightApp/resources/icon_about.png index 6817eb407..ff65d363e 100755 Binary files a/src/LightApp/resources/icon_about.png and b/src/LightApp/resources/icon_about.png differ