//
#include "SUIT_Application.h"
+#include "SUIT_Study.h"
#include "SUIT_Session.h"
#include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h"
-#include <qlabel.h>
-#include <qtimer.h>
-#include <qstatusbar.h>
+#include <QTimer>
+#include <QLabel>
+#include <QStatusBar>
#include <QtxAction.h>
#include <QtxActionMenuMgr.h>
myStudy( 0 ),
myDesktop( 0 ),
myStatusLabel( 0 )
-{
+{
+ if ( SUIT_Session::session() )
+ SUIT_Session::session()->insertApplication( this );
}
/*!
Opens other study into active Study. If Study is empty - creates it.
\param theName - name of study
*/
-bool SUIT_Application::useStudy( const QString& theName )
+bool SUIT_Application::useStudy( const QString& /*theName*/ )
{
return false;
}
*/
SUIT_Application* SUIT_Application::startApplication( int argc, char** argv ) const
{
- return startApplication( name(), argc, argv );
+ return startApplication( objectName(), argc, argv );
}
/*!
*/
void SUIT_Application::setMenuShown( QAction* a, const bool on )
{
- setMenuShown( actionId( a ), on );
+ if ( !a || !desktop() )
+ return;
+
+ QtxActionMenuMgr* mMgr = desktop()->menuMgr();
+ if ( mMgr )
+ mMgr->setShown( mMgr->actionId( a ), on );
}
/*!
*/
void SUIT_Application::setMenuShown( const int id, const bool on )
{
- if ( desktop() && desktop()->menuMgr() )
- desktop()->menuMgr()->setShown( id, on );
+ setMenuShown( action( id ), on );
}
/*!
*/
void SUIT_Application::setToolShown( QAction* a, const bool on )
{
- setToolShown( actionId( a ), on );
+ if ( !a || !desktop() )
+ return;
+
+ QtxActionToolMgr* tMgr = desktop()->toolMgr();
+ if ( tMgr )
+ tMgr->setShown( tMgr->actionId( a ), on );
}
/*!
*/
void SUIT_Application::setToolShown( const int id, const bool on )
{
- if ( desktop() && desktop()->toolMgr() )
- desktop()->toolMgr()->setShown( id, on );
+ setToolShown( action( id ), on );
}
/*!
int SUIT_Application::actionId( const QAction* a ) const
{
int id = -1;
- for ( QMap<int, QAction*>::ConstIterator it = myActionMap.begin();
- it != myActionMap.end() && id == -1;
- ++it ) {
- if ( it.data() == a )
+ for ( QMap<int, QAction*>::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && id == -1; ++it )
+ {
+ if ( it.value() == a )
id = it.key();
}
return id;
\param reciever - object that contains slot
\param member - slot to be called when action is activated
*/
-QAction* SUIT_Application::createAction( const int id, const QString& text, const QIconSet& icon,
+QAction* SUIT_Application::createAction( const int id, const QString& text, const QIcon& icon,
const QString& menu, const QString& tip, const int key,
QObject* parent, const bool toggle, QObject* reciever, const char* member )
{
a->setStatusTip( tip );
if ( reciever && member )
- connect( a, SIGNAL( activated() ), reciever, member );
+ connect( a, SIGNAL( triggered( bool ) ), reciever, member );
registerAction( id, a );
#define SUIT_APPLICATION_H
#include "SUIT.h"
-#include "SUIT_Study.h"
-#include <qobject.h>
-#include <qwidget.h>
+#include <QObject>
+#include <QMap>
+class QIcon;
class QLabel;
class QString;
class QAction;
-class QIconSet;
+class QWidget;
+
class SUIT_Desktop;
-class SUIT_Convertor;
class SUIT_ViewModel;
class SUIT_ResourceMgr;
+class SUIT_Study;
#ifdef WIN32
#pragma warning ( disable:4251 )
SUIT_ResourceMgr* resourceMgr() const;
- /*! Returns instance of data object Convertor class according to given Viewer.
- If convertation is not supported returns 0. */
- virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
-
//! Puts the message to the status bar
void putInfo ( const QString&, const int = 0 );
QAction* action( const int ) const;
int actionId( const QAction* ) const;
int registerAction( const int, QAction* );
- QAction* createAction( const int, const QString&, const QIconSet&, const QString&,
+ QAction* createAction( const int, const QString&, const QIcon&, const QString&,
const QString&, const int, QObject* = 0,
const bool = false, QObject* = 0, const char* = 0 );
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "SUIT_DataObject.h"
-#include <qobject.h>
+#include "SUIT_DataObject.h"
#include "SUIT_DataObjectKey.h"
SUIT_DataObject::SUIT_DataObject( SUIT_DataObject* p )
: myParent( 0 ),
- mySignal( 0 ),
- myOpen( false ),
- myCheck( false )
+myOpen( false ),
+myCheck( false ),
+mySignal( 0 ),
+myAutoDel( true )
{
- myChildren.setAutoDelete( true );
-
setParent( p );
}
mySignal->setOwner( 0 );
}
- for ( QPtrListIterator<SUIT_DataObject> it( myChildren ); it.current(); ++it )
- it.current()->myParent = 0;
+ for ( DataObjectList::iterator it = myChildren.begin(); it != myChildren.end(); ++it )
+ (*it)->myParent = 0;
+
+ if ( autoDeleteChildren() )
+ {
+ for ( DataObjectList::iterator itr = myChildren.begin(); itr != myChildren.end(); ++itr )
+ delete *itr;
+ }
delete mySignal;
}
{
SUIT_DataObject* child = 0;
if ( !myChildren.isEmpty() )
- child = myChildren.getFirst();
+ child = myChildren.first();
return child;
}
{
SUIT_DataObject* child = 0;
if ( !myChildren.isEmpty() )
- child = myChildren.getLast();
+ child = myChildren.last();
return child;
}
int res = -1;
int i = 0;
- for ( DataObjectListIterator it( myChildren ); it.current() && res == -1; ++it, i++ )
+ for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end() && res == -1; ++it, i++ )
{
- if ( it.current() == obj )
+ if ( *it == obj )
res = i;
}
bool SUIT_DataObject::autoDeleteChildren() const
{
- return myChildren.autoDelete();
+ return myAutoDel;
}
/*!
void SUIT_DataObject::setAutoDeleteChildren( const bool on )
{
- myChildren.setAutoDelete( on );
+ myAutoDel = on;
}
/*!
void SUIT_DataObject::children( DataObjectList& lst, const bool rec ) const
{
- for ( DataObjectListIterator it( myChildren ); it.current(); ++it )
+ for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end(); ++it )
{
- lst.append( it.current() );
+ lst.append( *it );
if ( rec )
- it.current()->children( lst, rec );
+ (*it)->children( lst, rec );
}
}
void SUIT_DataObject::insertChild( SUIT_DataObject* theObj, int thePosition )
{
- if ( !theObj || myChildren.find( theObj ) != -1 )
+ if ( !theObj || myChildren.contains( theObj ) )
return;
int pos = thePosition < 0 ? myChildren.count() : thePosition;
- myChildren.insert( QMIN( pos, (int)myChildren.count() ), theObj );
+ myChildren.insert( qMin( pos, (int)myChildren.count() ), theObj );
theObj->setParent( this );
}
if ( !theObj )
return;
- bool ad = myChildren.autoDelete();
- myChildren.setAutoDelete( false );
-
- if ( myChildren.remove( theObj ) )
+ if ( myChildren.removeAll( theObj ) )
theObj->setParent( 0 );
-
- myChildren.setAutoDelete( ad );
}
/*!
DataObjectList lst;
obj->children( lst );
- for ( DataObjectListIterator it( lst ); it.current(); ++it )
- it.current()->setParent( this );
+ for ( DataObjectList::iterator it = lst.begin(); it != lst.end(); ++it )
+ (*it)->setParent( this );
}
/*!
void SUIT_DataObject::dump( const int indent ) const
{
QString strIndent = QString().fill( ' ', indent ); // indentation string
- printf( "%s%s\n", strIndent.latin1(), name().latin1() );
- for ( DataObjectListIterator it( myChildren ); it.current(); ++it ) // iterate all children
- it.current()->dump( indent + 2 ); // dump every child with indent + 2 spaces
+ printf( "%s%s\n", strIndent.toLatin1().data(), name().toLatin1().data() );
+ for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end(); ++it )
+ (*it)->dump( indent + 2 );
}
/*!
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#ifndef SUIT_DATAOBJECT_H
#define SUIT_DATAOBJECT_H
-#include <qobject.h>
-#include <qstring.h>
-#include <qpixmap.h>
-#include <qptrlist.h>
-
#include "SUIT.h"
+#include <QList>
+#include <QObject>
+#include <QString>
+#include <QPixmap>
+
class SUIT_DataObject;
class SUIT_DataObjectKey;
-typedef QPtrList<SUIT_DataObject> DataObjectList;
-typedef QPtrListIterator<SUIT_DataObject> DataObjectListIterator;
+typedef QList<SUIT_DataObject*> DataObjectList;
#ifdef WIN32
#pragma warning( disable:4251 )
void dump( const int indent = 2 ) const; // dump to cout
private:
+ SUIT_DataObject* myParent;
bool myOpen;
bool myCheck;
Signal* mySignal;
- SUIT_DataObject* myParent;
+ bool myAutoDel;
DataObjectList myChildren;
friend class SUIT_DataObject::Signal;