//
// 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
#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"
#include <QtxMRUAction.h>
#include <QtxDockAction.h>
#include <QtxToolBar.h>
-#include <QProcess>
+#include <QtxTreeView.h>
#include <LogWindow.h>
-// temporary commented
-//#include <OB_Browser.h>
-//#include <OB_ListView.h>
#ifndef DISABLE_GLVIEWER
#include <GLViewer_Viewer.h>
#include <QIcon>
#include <QByteArray>
#include <QMenu>
-
-using namespace Qt;
+#include <QProcess>
#define FIRST_HELP_ID 1000000
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() ) );
//! 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 );
#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 );
*/
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();
}
/*!
{
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 );
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 );
f = wid->font();
myWindows[flag]->insert( sId, wid );
- wid->setFont(f);
+ wid->setFont( f );
setWindowShown( flag, !myWindows[flag]->isEmpty() );
}
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 );
/*!
\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<LightApp_Browser*>( 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<LogWindow*>( window( WT_LogWindow ) );
}
#ifndef DISABLE_PYCONSOLE
*/
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<PyConsole_Console*>( window( WT_PyConsole ) );
}
#endif
// 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<LightApp_Study*>(activeStudy());
if ( study ) {
}
}
- // temporary commented
- /*if( objectBrowser() )
- objectBrowser()->setAutoUpdate( isAutoUpdate );*/
+ if( objectBrowser() )
+ objectBrowser()->setAutoUpdate( isAutoUpdate );
}
- // temporary commented
- /*if ( objectBrowser() )
- {
+
+ if ( objectBrowser() ) {
objectBrowser()->updateGeometry();
objectBrowser()->updateTree( 0, false );
- }*/
+ }
}
/*!
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();
}
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();
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<OB_ListView*>( const_cast<QListView*>( 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 );
wid = ob;
ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- */
}
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
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 );
if( param=="auto_size" || param=="auto_size_first" )
{
// temporary commented
- /*OB_Browser* ob = objectBrowser();
+ /*LightApp_Browser* ob = objectBrowser();
if( !ob )
return;
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()] );
}
}
{
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() ) );
+ }
}
/*!
void LightApp_Application::createEmptyStudy()
{
CAM_Application::createEmptyStudy();
- // temporary commented
- /*if ( objectBrowser() )
- objectBrowser()->updateTree();*/
+
+ if ( objectBrowser() )
+ objectBrowser()->updateTree();
}
/*!
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;
}
#include <CAM_Application.h>
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;
class QString;
class QWidget;
class QStringList;
-//class QPixmap;
#ifdef WIN32
#pragma warning( disable:4251 )
LightApp_SelectionMgr* selectionMgr() const;
LogWindow* logWindow();
- //OB_Browser* objectBrowser();
+ LightApp_Browser* objectBrowser();
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pythonConsole();
#endif
--- /dev/null
+// 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 <SUIT_DataObject.h>
+#include <SUIT_TreeModel.h>
+#include <QtxTreeView.h>
+
+/*!
+ \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<SUIT_ProxyModel*>( 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<SUIT_ProxyModel*>( 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<SUIT_ProxyModel*>( 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<SUIT_ProxyModel*>( 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<SUIT_ProxyModel*>( model() );
+ if ( m ) {
+ m->updateTree( obj );
+ openLevels();
+ }
+}
--- /dev/null
+// 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 <OB_Browser.h>
+
+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
#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 <OB_Browser.h>
+#include "LightApp_Browser.h"
#include <SUIT_DataObject.h>
void LightApp_DataModel::updateWidgets()
{
LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
- // temporary commented
- /*if( app )
- app->objectBrowser()->updateTree( 0, false );*/
+ if ( app )
+ app->objectBrowser()->updateTree( 0, false );
}
/*!
//
// 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 <CAM_DataModel.h>
+#include <CAM_Module.h>
#include <SUIT_DataObjectKey.h>
/*!
- 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:
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;
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<LightApp_ModuleObject*>( aCompObj );
if ( anObj ) {
CAM_DataModel* aModel = anObj->dataModel();
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<LightApp_RootObject*>(parent());
+ LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( 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;
+}
//
// 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 <CAM_DataObject.h>
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;
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
#include "LightApp_SwitchOp.h"
#include "LightApp_UpdateFlags.h"
#include "LightApp_ShowHideOp.h"
+#include "LightApp_Browser.h"
#include <SUIT_Study.h>
#include <SUIT_DataObject.h>
#endif
#endif
-// temporary commented
-//#include <OB_Browser.h>
-
#include <QtxPopupMgr.h>
#include <QVariant>
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() ){
}
}
}
- // temporary commented
- /*getApp()->objectBrowser()->setAutoUpdate( upd );
- getApp()->objectBrowser()->updateTree( 0, false );*/
+
+ getApp()->objectBrowser()->setAutoUpdate( upd );
+ getApp()->objectBrowser()->updateTree( 0, false );
}
/*!NOT IMPLEMENTED*/
if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
aModel->update( 0, dynamic_cast<LightApp_Study*>( 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 )
+++ /dev/null
-// 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
#include "LightApp_Application.h"
#include "LightApp_DataModel.h"
#include "LightApp_DataObject.h"
-#include "LightApp_RootObject.h"
#include "LightApp_HDFDriver.h"
#include "SUIT_ResourceMgr.h"
//
// 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 <QList>
#include <QStackedWidget>
/*!
- 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<QObject*> lst = myStack->children();
- if ( lst.isEmpty() )
- return true;
-
- bool res = true;
- QListIterator<QObject*> 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<int, QWidget*> 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<int, QWidget*> 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
{
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<int, QWidget*> it( myMap );
+ while ( it.hasNext() ) {
+ it.next();
+ if ( it.value() == wid ) {
+ it.remove();
+ break;
+ }
+ }
+}
//
// 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 <QDockWidget>
+#include <QMap>
class QWidget;
class QStackedWidget;
-/*!
- Class which privade widget container.
-*/
class LIGHTAPP_EXPORT LightApp_WidgetContainer : public QDockWidget
{
Q_OBJECT
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<int, QWidget*> myMap;
};
-#endif
+#endif // LIGHTAPP_WIDGETCONTAINER_H
LightApp.h \
LightApp_AboutDlg.h \
LightApp_Application.h \
+ LightApp_Browser.h \
LightApp_DataModel.h \
LightApp_DataObject.h \
LightApp_DataOwner.h \
LightApp_SwitchOp.h \
LightApp_Preferences.h \
LightApp_PreferencesDlg.h \
- LightApp_RootObject.h \
LightApp_UpdateFlags.h \
LightApp_WidgetContainer.h
dist_libLightApp_la_SOURCES= \
LightApp_AboutDlg.cxx \
LightApp_Application.cxx \
+ LightApp_Browser.cxx \
LightApp_DataModel.cxx \
LightApp_DataObject.cxx \
LightApp_DataOwner.cxx \
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 \
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
<source>ABOUT_VERSION</source>
<translation>Version %1</translation>
</message>
+ <message>
+ <source>ENTRY_COLUMN</source>
+ <translation>Entry</translation>
+ </message>
</context>
<context>
<name>LightApp_Application</name>