//
#include "SUIT_SelectionMgr.h"
+#include "SUIT_Selector.h"
+#include "SUIT_SelectionFilter.h"
+
/*!\class SUIT_SelectionMgr
* Provide selection manager. Manipulate by selection filters, modes, data owners.
*/
SUIT_SelectionMgr::SUIT_SelectionMgr( const bool Feedback, QObject* p )
: QObject( p ),
myIterations( Feedback ? 1 : 0 ),
+myAutoDelFilter( false ),
myIsSelChangeEnabled( true )
{
}
/*!destructor. mySelectors auto delete.*/
SUIT_SelectionMgr::~SUIT_SelectionMgr()
{
- mySelectors.setAutoDelete( true );
+ for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
+ delete *it;
}
/*!Add selector \a sel to selectors list,if it's not exists in list.*/
/*!Remove selector \a sel from list.*/
void SUIT_SelectionMgr::removeSelector( SUIT_Selector* sel )
{
- mySelectors.remove( sel );
+ mySelectors.removeAll( sel );
}
/*!Gets selectors list to \a lst.*/
-void SUIT_SelectionMgr::selectors( QPtrList<SUIT_Selector>& lst ) const
+void SUIT_SelectionMgr::selectors( QList<SUIT_Selector*>& lst ) const
{
lst.clear();
- for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
- lst.append( it.current() );
+ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
+ lst.append( *it );
}
/*!Gets selectors list to \a lst with type \a typ.*/
-void SUIT_SelectionMgr::selectors( const QString& typ, QPtrList<SUIT_Selector>& lst ) const
+void SUIT_SelectionMgr::selectors( const QString& typ, QList<SUIT_Selector*>& lst ) const
{
lst.clear();
- for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
+ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
- if ( it.current()->type() == typ )
- lst.append( it.current() );
+ if ( (*it)->type() == typ )
+ lst.append( *it );
}
}
*/
void SUIT_SelectionMgr::setEnabled( const bool on, const QString& typ )
{
- for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
+ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
- if ( typ.isEmpty() || it.current()->type() == typ )
- it.current()->setEnabled( on );
+ if ( typ.isEmpty() || (*it)->type() == typ )
+ (*it)->setEnabled( on );
}
}
{
lst.clear();
- for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
+ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
- if ( !type.isEmpty() && it.current()->type() != type )
+ if ( !type.isEmpty() && (*it)->type() != type )
continue;
+
SUIT_DataOwnerPtrList curList;
- it.current()->selected( curList );
+ (*it)->selected( curList );
for ( SUIT_DataOwnerPtrList::const_iterator itr = curList.begin(); itr != curList.end(); ++itr )
lst.append( *itr );
}
SUIT_DataOwnerPtrList owners;
filterOwners( lst, owners );
- for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
+ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
if ( append )
{
SUIT_DataOwnerPtrList current;
- it.current()->selected( current );
+ (*it)->selected( current );
for ( SUIT_DataOwnerPtrList::const_iterator it = current.begin(); it != current.end(); ++it )
owners.append( *it );
}
- it.current()->setSelected( owners );
+ (*it)->setSelected( owners );
}
}
for ( int i = 0; i < myIterations; i++ )
{
- for ( SUIT_Selector* aSel = mySelectors.first(); aSel; aSel = mySelectors.next() )
+ for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
- // Temporary action(to avoid selection of the objects which don't pass the filters):
- //if ( aSel != sel )
- aSel->setSelected( newOwners );
+ if ( *it != sel )
+ (*it)->setSelected( newOwners );
}
}
myIsSelChangeEnabled = true;
/*! Gets selection modes to list \a vals.
*/
-void SUIT_SelectionMgr::selectionModes( QValueList<int>& vals ) const
+void SUIT_SelectionMgr::selectionModes( QList<int>& vals ) const
{
vals = mySelModes;
}
*/
void SUIT_SelectionMgr::setSelectionModes( const int mode )
{
- QValueList<int> lst;
+ QList<int> lst;
lst.append( mode );
setSelectionModes( lst );
}
/*! Sets selection modes list from \a lst.
*/
-void SUIT_SelectionMgr::setSelectionModes( const QValueList<int>& lst )
+void SUIT_SelectionMgr::setSelectionModes( const QList<int>& lst )
{
mySelModes = lst;
}
*/
void SUIT_SelectionMgr::appendSelectionModes( const int mode )
{
- QValueList<int> lst;
+ QList<int> lst;
lst.append( mode );
appendSelectionModes( lst );
}
/*! Append selection modes \a lst list.
*/
-void SUIT_SelectionMgr::appendSelectionModes( const QValueList<int>& lst )
+void SUIT_SelectionMgr::appendSelectionModes( const QList<int>& lst )
{
QMap<int, int> map;
- for ( QValueList<int>::const_iterator it = mySelModes.begin(); it != mySelModes.end(); ++it )
+ for ( QList<int>::const_iterator it = mySelModes.begin(); it != mySelModes.end(); ++it )
map.insert( *it, 0 );
- for ( QValueList<int>::const_iterator itr = lst.begin(); itr != lst.end(); ++itr )
+ for ( QList<int>::const_iterator itr = lst.begin(); itr != lst.end(); ++itr )
{
if ( !map.contains( *itr ) )
mySelModes.append( *itr );
*/
void SUIT_SelectionMgr::removeSelectionModes( const int mode )
{
- QValueList<int> lst;
+ QList<int> lst;
lst.append( mode );
removeSelectionModes( lst );
}
/*! Remove selection modea \a lst from list.
*/
-void SUIT_SelectionMgr::removeSelectionModes( const QValueList<int>& lst )
+void SUIT_SelectionMgr::removeSelectionModes( const QList<int>& lst )
{
QMap<int, int> map;
- for ( QValueList<int>::const_iterator it = mySelModes.begin(); it != mySelModes.end(); ++it )
+ for ( QList<int>::const_iterator it = mySelModes.begin(); it != mySelModes.end(); ++it )
map.insert( *it, 0 );
- for ( QValueList<int>::const_iterator itr = lst.begin(); itr != lst.end(); ++itr )
+ for ( QList<int>::const_iterator itr = lst.begin(); itr != lst.end(); ++itr )
map.remove( *itr );
mySelModes.clear();
return false;
bool ok = true;
- for ( SelFilterListIterator it( myFilters ); it.current() && ok; ++it )
- ok = it.current()->isOk( owner );
+ for ( SelFilterList::const_iterator it = myFilters.begin(); it != myFilters.end() && ok; ++it )
+ ok = (*it)->isOk( owner );
return ok;
}
*/
void SUIT_SelectionMgr::removeFilter( SUIT_SelectionFilter* f )
{
- myFilters.remove( f );
+ if ( !myFilters.contains( f ) )
+ return;
+
+ myFilters.removeAll( f );
+
+ if ( autoDeleteFilter() )
+ delete f;
}
/*! Clear filters list.
*/
void SUIT_SelectionMgr::clearFilters()
{
+ if ( autoDeleteFilter() )
+ {
+ for ( SelFilterList::const_iterator it = myFilters.begin(); it != myFilters.end(); ++it )
+ delete *it;
+ }
+
myFilters.clear();
}
*/
bool SUIT_SelectionMgr::autoDeleteFilter() const
{
- return myFilters.autoDelete();
+ return myAutoDelFilter;
}
/*! Sets auto delete filter to \a on.
*/
void SUIT_SelectionMgr::setAutoDeleteFilter( const bool on )
{
- myFilters.setAutoDelete( on );
+ myAutoDelFilter = on;
}
/*! Gets good data owners list to \a out from \a in.
#ifndef SUIT_SELECTIONMGR_H
#define SUIT_SELECTIONMGR_H
-#include "SUIT_Selector.h"
#include "SUIT_DataOwner.h"
-#include "SUIT_SelectionFilter.h"
-#include <qobject.h>
-#include <qptrlist.h>
-#include <qvaluelist.h>
+#include <QList>
+#include <QObject>
+
+class SUIT_Selector;
+class SUIT_SelectionFilter;
#ifdef WIN32
#pragma warning ( disable : 4251 )
virtual void selected( SUIT_DataOwnerPtrList&, const QString& = QString::null ) const;
virtual void setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
- void selectors( QPtrList<SUIT_Selector>& ) const;
- void selectors( const QString&, QPtrList<SUIT_Selector>& ) const;
+ void selectors( QList<SUIT_Selector*>& ) const;
+ void selectors( const QString&, QList<SUIT_Selector*>& ) const;
void setEnabled( const bool, const QString& = QString::null );
bool hasSelectionMode( const int ) const;
- void selectionModes( QValueList<int>& ) const;
+ void selectionModes( QList<int>& ) const;
void setSelectionModes( const int );
- virtual void setSelectionModes( const QValueList<int>& );
+ virtual void setSelectionModes( const QList<int>& );
void appendSelectionModes( const int );
- virtual void appendSelectionModes( const QValueList<int>& );
+ virtual void appendSelectionModes( const QList<int>& );
void removeSelectionModes( const int );
- virtual void removeSelectionModes( const QValueList<int>& );
+ virtual void removeSelectionModes( const QList<int>& );
bool isOk( const SUIT_DataOwner* ) const;
protected:
virtual void selectionChanged( SUIT_Selector* );
- typedef QPtrListIterator<SUIT_Selector> SelectorListIterator;
-
virtual void installSelector( SUIT_Selector* );
virtual void removeSelector( SUIT_Selector* );
private:
void filterOwners( const SUIT_DataOwnerPtrList&, SUIT_DataOwnerPtrList& ) const;
- typedef QPtrList<SUIT_Selector> SelectorList;
- typedef QPtrList<SUIT_SelectionFilter> SelFilterList;
- typedef QPtrListIterator<SUIT_SelectionFilter> SelFilterListIterator;
-
-protected:
- SelectorList mySelectors;
+ typedef QList<SUIT_Selector*> SelectorList;
+ typedef QList<SUIT_SelectionFilter*> SelFilterList;
private:
SelFilterList myFilters;
- QValueList<int> mySelModes;
+ QList<int> mySelModes;
+ SelectorList mySelectors;
int myIterations;
+ bool myAutoDelFilter;
bool myIsSelChangeEnabled;
friend class SUIT_Selector;
#include "SUIT_SelectionMgr.h"
+#include <QObject>
+
+/*!\class SUIT_Selector::Destroyer
+ Class provide the watching for qobject parent class of the selector.
+*/
+
+class SUIT_Selector::Destroyer : public QObject
+{
+public:
+ Destroyer( SUIT_Selector*, QObject* = 0 );
+ virtual ~Destroyer();
+
+ SUIT_Selector* selector() const;
+ void setSelector( SUIT_Selector* );
+
+private:
+ SUIT_Selector* mySelector;
+};
+
+SUIT_Selector::Destroyer::Destroyer( SUIT_Selector* s, QObject* p )
+: QObject( p ),
+ mySelector( s )
+{
+}
+
+SUIT_Selector::Destroyer::~Destroyer()
+{
+ SUIT_Selector* s = mySelector;
+ mySelector = 0;
+ if ( s )
+ delete s;
+}
+
+SUIT_Selector* SUIT_Selector::Destroyer::selector() const
+{
+ return mySelector;
+}
+
+void SUIT_Selector::Destroyer::setSelector( SUIT_Selector* s )
+{
+ mySelector = s;
+}
+
/*!\class SUIT_Selector
* Class provide selector for data owners.
*/
/*!
Constructor.
*/
-SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent ) :
-QObject( parent ),
-mySelMgr( selMgr ),
+SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent )
+: mySelMgr( selMgr ),
myBlock( false ),
myEnabled( true ),
-myAutoBlock( true )
+myAutoBlock( true ),
+myDestroyer( 0 )
{
if ( selMgr )
selMgr->installSelector( this );
+
+ if ( parent )
+ myDestroyer = new Destroyer( this, parent );
}
/*!
{
if ( selectionMgr() )
selectionMgr()->removeSelector( this );
+
+ if ( myDestroyer && myDestroyer->selector() == this )
+ {
+ myDestroyer->setSelector( 0 );
+ delete myDestroyer;
+ }
}
/*!
/*!
Puts to list \a lst selection modes from selection manager.
*/
-void SUIT_Selector::selectionModes( QValueList<int>& lst ) const
+void SUIT_Selector::selectionModes( QList<int>& lst ) const
{
if ( selectionMgr() )
selectionMgr()->selectionModes( lst );
#include "SUIT.h"
-#include <qvaluelist.h>
-#include <qobject.h>
+#include <QList>
+
+class QObject;
class SUIT_SelectionMgr;
class SUIT_DataOwnerPtrList;
(ObjectBrowser, viewers, etc)
Used by selection manager for selection synhronizing
*/
-class SUIT_EXPORT SUIT_Selector : public QObject
+
+class SUIT_EXPORT SUIT_Selector
{
- Q_OBJECT
+ class Destroyer;
+
public:
SUIT_Selector( SUIT_SelectionMgr*, QObject* = 0 );
virtual ~SUIT_Selector();
void setSelected( const SUIT_DataOwnerPtrList& );
bool hasSelectionMode( const int ) const;
- void selectionModes( QValueList<int>& ) const;
+ void selectionModes( QList<int>& ) const;
protected:
void selectionChanged();
virtual void setSelection( const SUIT_DataOwnerPtrList& ) = 0;
private:
- bool myBlock;
SUIT_SelectionMgr* mySelMgr;
+ bool myBlock;
bool myEnabled;
bool myAutoBlock;
+ Destroyer* myDestroyer;
};
#endif
//
#include "SUIT_Session.h"
+#include "SUIT_Study.h"
#include "SUIT_Tools.h"
-#include "SUIT_Desktop.h"
#include "SUIT_MessageBox.h"
-#include "SUIT_ViewWindow.h"
-#include "SUIT_ViewManager.h"
#include "SUIT_ExceptionHandler.h"
+#include "SUIT_ResourceMgr.h"
-#include <qtextcodec.h>
-#include <qmessagebox.h>
-#include <qapplication.h>
+#include <QApplication>
#ifdef WIN32
#include <windows.h>
#include <dlfcn.h>
#endif
-static bool SUIT_Session_IsPythonExecuted = false;
-static QMutex SUIT_Session_PythonMutex;
-
SUIT_Session* SUIT_Session::mySession = 0;
/*! Constructor.*/
SUIT_Session::SUIT_Session()
: QObject(),
myResMgr( 0 ),
-myHandler( 0 ),
myActiveApp( 0 ),
+myHandler( 0 ),
myExitStatus( FROM_GUI )
{
SUIT_ASSERT( !mySession )
mySession = this;
-
- myAppList.setAutoDelete( true );
}
/*!destructor. Clear applications list and set mySession to zero.*/
SUIT_Session::~SUIT_Session()
{
+ for ( AppList::iterator it = myAppList.begin(); it != myAppList.end(); ++it )
+ delete *it;
+
myAppList.clear();
- if (myResMgr) {
+ if ( myResMgr )
+ {
delete myResMgr;
myResMgr = 0;
}
Starts new application using "createApplication" function of loaded DLL.
*/
-SUIT_Application* SUIT_Session::startApplication( const QString& name, int args, char** argv )
+SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*args*/, char** /*argv*/ )
{
AppLib libHandle = 0;
APP_CREATE_FUNC crtInst = 0;
#ifdef WIN32
- crtInst = (APP_CREATE_FUNC)::GetProcAddress( libHandle, APP_CREATE_NAME );
+ crtInst = (APP_CREATE_FUNC)::GetProcAddress( (HINSTANCE)libHandle, APP_CREATE_NAME );
#else
crtInst = (APP_CREATE_FUNC)dlsym( libHandle, APP_CREATE_NAME );
#endif
return 0;
}
- anApp->setName( appName );
-
- connect( anApp, SIGNAL( applicationClosed( SUIT_Application* ) ),
- this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
- connect( anApp, SIGNAL( activated( SUIT_Application* ) ),
- this, SLOT( onApplicationActivated( SUIT_Application* ) ) );
+ anApp->setObjectName( appName );
- myAppList.append( anApp );
+ insertApplication( anApp );
if ( !myHandler )
{
APP_GET_HANDLER_FUNC crtHndlr = 0;
#ifdef WIN32
- crtHndlr = (APP_GET_HANDLER_FUNC)::GetProcAddress( libHandle, APP_GET_HANDLER_NAME );
+ crtHndlr = (APP_GET_HANDLER_FUNC)::GetProcAddress( (HINSTANCE)libHandle, APP_GET_HANDLER_NAME );
#else
crtHndlr = (APP_GET_HANDLER_FUNC)dlsym( libHandle, APP_GET_HANDLER_NAME );
#endif
/*!
Gets the list of all applications
*/
-QPtrList<SUIT_Application> SUIT_Session::applications() const
+QList<SUIT_Application*> SUIT_Session::applications() const
{
- QPtrList<SUIT_Application> apps;
- apps.setAutoDelete( false );
+ return myAppList;
+}
- for ( AppListIterator it( myAppList ); it.current(); ++it )
- apps.append( it.current() );
+void SUIT_Session::insertApplication( SUIT_Application* app )
+{
+ if ( !app || myAppList.contains( app ) )
+ return;
- return apps;
+ myAppList.append( app );
+
+ connect( app, SIGNAL( applicationClosed( SUIT_Application* ) ),
+ this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
+ connect( app, SIGNAL( activated( SUIT_Application* ) ),
+ this, SLOT( onApplicationActivated( SUIT_Application* ) ) );
}
/*!
{
emit applicationClosed( theApp );
- myAppList.remove( theApp );
+ myAppList.removeAll( theApp );
+ delete theApp;
+
if ( theApp == myActiveApp )
myActiveApp = 0;
if ( myAppList.isEmpty() )
{
printf( "Calling QApplication::exit() with exit code = %d\n", myExitStatus );
- qApp->exit( myExitStatus );
+ QApplication::instance()->exit( myExitStatus );
}
}
*/
void SUIT_Session::closeSession( int mode )
{
- while ( !myAppList.isEmpty() )
+ AppList apps = myAppList;
+ for ( AppList::const_iterator it = apps.begin(); it != apps.end(); ++it )
{
- SUIT_Application* app = myAppList.getFirst();
+ SUIT_Application* app = *it;
if ( mode == ASK && !app->isPossibleToClose() )
return;
else if ( mode == SAVE )
{
SUIT_Study* study = app->activeStudy();
if ( study->isModified() && study->isSaved() )
- study->saveDocument();
+ study->saveDocument();
}
else if ( mode == DONT_SAVE )
{
QString SUIT_Session::lastError() const
{
QString str;
-#ifdef WNT
+#ifdef WIN32
LPVOID lpMsgBuf;
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 );
- str = QString( (LPTSTR)lpMsgBuf );
+ LPTSTR msg = (LPTSTR)lpMsgBuf;
+ str = QString( SUIT_Tools::toQString( msg ) );
LocalFree( lpMsgBuf );
#else
str = QString( dlerror() );
return 0;
AppLib lib = 0;
+ QByteArray bid = libFile.toLatin1();
#ifdef WIN32
- lib = ::LoadLibrary( (char*)libFile.latin1() );
+#ifdef UNICODE
+ LPTSTR str = (LPTSTR)libFile.utf16();
+#else
+ LPTSTR str = (LPTSTR)(const char*)bid;
+#endif
+ lib = ::LoadLibrary( str );
#else
- lib = dlopen( (char*)libFile.latin1(), RTLD_LAZY | RTLD_GLOBAL );
+ lib = dlopen( (const char*)libFile.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
#endif
return lib;
}
{
myActiveApp = app;
}
-
-/*!
- \retval Return TRUE, if a command is currently executed in Python Console,
- FALSE otherwise.
-*/
-bool SUIT_Session::IsPythonExecuted()
-{
- bool ret;
- SUIT_Session_PythonMutex.lock();
- ret = SUIT_Session_IsPythonExecuted;
- SUIT_Session_PythonMutex.unlock();
- return ret;
-}
-
-/*!
- Set value of boolean flag, being returned by method \a IsPythonExecuted().
- It is supposed to set the flag to TRUE when any python command starts
- and reset it to FALSE when the command finishes.
-*/
-void SUIT_Session::SetPythonExecuted(bool isPythonExecuted)
-{
- SUIT_Session_PythonMutex.lock();
- SUIT_Session_IsPythonExecuted = isPythonExecuted;
- SUIT_Session_PythonMutex.unlock();
-}
#include "SUIT.h"
-#include "SUIT_Application.h"
-#include "SUIT_ResourceMgr.h"
+#include <SUIT_Application.h>
-#include <qmutex.h>
-#include <qobject.h>
-#include <qptrlist.h>
-#include <qptrvector.h>
-#include <qstringlist.h>
+#include <QList>
+#include <QObject>
+#include <QString>
#ifdef WIN32
#define LIB_HANDLE HINSTANCE
class SUIT_ResourceMgr;
class SUIT_ExceptionHandler;
-#ifdef WNT
+#ifdef WIN32
#pragma warning( disable:4251 )
#endif
/*!
SUIT_Application* startApplication( const QString&, int = 0, char** = 0 );
- QPtrList<SUIT_Application> applications() const;
+ QList<SUIT_Application*> applications() const;
SUIT_Application* activeApplication() const;
SUIT_ResourceMgr* resourceMgr() const;
SUIT_ExceptionHandler* handler() const;
- // To lock GUI user actions during python command execution (PAL12651)
- static bool IsPythonExecuted();
- static void SetPythonExecuted(bool isPythonExecuted);
+ void insertApplication( SUIT_Application* );
signals:
void applicationClosed( SUIT_Application* );
void onApplicationActivated( SUIT_Application* );
private:
- typedef QPtrList<SUIT_Application> AppList;
- typedef QMap<QString, AppLib> AppLibMap;
- typedef QPtrListIterator<SUIT_Application> AppListIterator;
+ typedef QList<SUIT_Application*> AppList;
+ typedef QMap<QString, AppLib> AppLibMap;
private:
QString lastError() const;
#include "SUIT_DataObject.h"
#include "SUIT_MessageBox.h"
#include "SUIT_Application.h"
-#include <qvaluevector.h>
/*!\class SUIT_Study
* Support study management. Object management. Operation management.
SUIT_Study::SUIT_Study( SUIT_Application* app )
: QObject(),
myApp( app ),
+myName( "" ),
myIsSaved( false ),
myIsModified( false ),
-myName( "" ),
myBlockChangeState( false )
{
static int _id = 0;
myId = ++_id;
myRoot = new SUIT_DataObject();
- myOperations.setAutoDelete( false );
- myOperations.setAutoDelete( false );
}
/*!Destructor.*/
*/
SUIT_Operation* SUIT_Study::activeOperation() const
{
- return myOperations.count() > 0 ? myOperations.getLast() : 0;
+ return myOperations.count() > 0 ? myOperations.last() : 0;
}
/*!
/*!
*Close document. NOT IMPLEMENTED.
*/
-void SUIT_Study::closeDocument(bool permanently)
+void SUIT_Study::closeDocument(bool /*permanently*/)
{
}
Custom document initialization to be performed \n
within onNewDoc() handler can be put here
*/
-void SUIT_Study::createDocument()
+bool SUIT_Study::createDocument( const QString& )
{
+ return true;
}
/*!
void SUIT_Study::abortAllOperations()
{
myBlockChangeState = true;
- for( SUIT_Operation* op = myOperations.first(); op; op = myOperations.next() )
- op->abort();
+ for ( Operations::iterator it = myOperations.begin(); it != myOperations.end(); ++it )
+ (*it)->abort();
myBlockChangeState = false;
myOperations.clear();
}
return 0;
Operations tmpOps( myOperations );
- SUIT_Operation* anOp = 0;
- for ( anOp = tmpOps.last(); anOp; anOp = tmpOps.prev() )
+ for ( Operations::const_iterator it = tmpOps.end(); it != tmpOps.begin(); --it )
{
+ SUIT_Operation* anOp = *it;
if ( anOp != 0 && anOp!= theOp && !anOp->isValid( theOp ) )
return anOp;
}
*/
bool SUIT_Study::start( SUIT_Operation* theOp, const bool toCheck )
{
- if ( !theOp || myOperations.find( theOp ) >= 0 )
+ if ( !theOp || myOperations.contains( theOp ) )
return false;
theOp->setExecStatus( SUIT_Operation::Rejected );
*/
bool SUIT_Study::abort( SUIT_Operation* theOp )
{
- if ( !theOp || myOperations.find( theOp ) == -1 )
+ if ( !theOp || !myOperations.contains( theOp ) )
return false;
theOp->setExecStatus( SUIT_Operation::Rejected );
*/
bool SUIT_Study::commit( SUIT_Operation* theOp )
{
- if ( !theOp || myOperations.find( theOp ) == -1 )
+ if ( !theOp || !myOperations.contains( theOp ) )
return false;
theOp->setExecStatus( SUIT_Operation::Accepted );
*/
bool SUIT_Study::suspend( SUIT_Operation* theOp )
{
- if ( !theOp || myOperations.find( theOp ) == -1 || theOp->state() == SUIT_Operation::Suspended )
+ if ( !theOp || !myOperations.contains( theOp ) || theOp->state() == SUIT_Operation::Suspended )
return false;
theOp->setState( SUIT_Operation::Suspended );
*/
bool SUIT_Study::resume( SUIT_Operation* theOp )
{
- if ( !theOp || myOperations.find( theOp ) == -1 ||
+ if ( !theOp || !myOperations.contains( theOp ) ||
theOp->state() == SUIT_Operation::Running ||
blockingOperation( theOp ) != 0 )
return false;
// Move operation at the end of list in order to sort it in the order of activation.
// As result active operation is a last operation of list, operation which was active
// before currently active operation is located before it and so on
- myOperations.remove( theOp );
+ myOperations.removeAll( theOp );
myOperations.append( theOp );
emit theOp->resumed( theOp );
void SUIT_Study::stop( SUIT_Operation* theOp )
{
theOp->setState( SUIT_Operation::Waiting );
- myOperations.remove( theOp );
+ myOperations.removeAll( theOp );
// get last operation which can be resumed
- SUIT_Operation* anOp, *aResultOp = 0;
- for ( anOp = myOperations.last(); anOp; anOp = myOperations.prev() )
+ SUIT_Operation* aResultOp = 0;
+ for ( Operations::iterator it = myOperations.end(); it != myOperations.begin(); --it )
{
+ SUIT_Operation* anOp = *it;
if ( anOp && anOp != theOp && blockingOperation( anOp ) == 0 )
{
aResultOp = anOp;
* \brief Get all started operations
* \return List of all started operations
*/
-const QPtrList<SUIT_Operation>& SUIT_Study::operations() const
+const QList<SUIT_Operation*>& SUIT_Study::operations() const
{
return myOperations;
}
/*!
* \brief Restores the study state
*/
-void SUIT_Study::restoreState(int savePoint)
+void SUIT_Study::restoreState(int /*savePoint*/)
{
}
#include "SUIT.h"
-#include "SUIT_Operation.h"
-
-#include <qobject.h>
-#include <qptrlist.h>
+#include <QList>
+#include <QObject>
class SUIT_DataObject;
class SUIT_Application;
-class QDialog;
+class SUIT_Operation;
#ifdef WIN32
#pragma warning( disable:4251 )
virtual bool isSaved() const;
virtual bool isModified() const;
- virtual void createDocument();
virtual void closeDocument( bool = true );
virtual bool openDocument( const QString& );
+ virtual bool createDocument( const QString& );
bool saveDocument();
virtual bool saveDocumentAs( const QString& );
// Operation management
SUIT_Operation* activeOperation() const;
virtual void abortAllOperations();
- const QPtrList<SUIT_Operation>& operations() const;
+ const QList<SUIT_Operation*>& operations() const;
virtual SUIT_Operation* blockingOperation( SUIT_Operation* ) const;
virtual bool commitTransaction( const QString& = QString::null );
private:
- typedef QPtrList<SUIT_Operation> Operations;
+ typedef QList<SUIT_Operation*> Operations;
void stop( SUIT_Operation* );
private:
#include "SUIT_ToolButton.h"
-#include <qpopupmenu.h>
-#include <qstyle.h>
+#include <QMenu>
/*!Constructor.*/
-SUIT_ToolButton::SUIT_ToolButton( QWidget *parent,
- const char *name,
- bool changeItemAfterClick)
- : QToolButton( parent, name ),
- myChangeItemAfterClick( changeItemAfterClick )
+SUIT_ToolButton::SUIT_ToolButton( QWidget *parent, const char* /*name*/,
+ bool changeItemAfterClick )
+: QToolButton( parent ),
+myChangeItemAfterClick( changeItemAfterClick )
{
initialize();
}
-/*!Constructor.*/
-SUIT_ToolButton::SUIT_ToolButton( const QPixmap & pm,
- const QString &textLabel,
- const QString& grouptext,
- QObject * receiver,
- const char* slot,
- QToolBar * parent,
- const char* name,
- bool changeItemAfterClick)
- :QToolButton(pm, textLabel, grouptext, receiver, slot, parent, name),
- myChangeItemAfterClick( changeItemAfterClick )
-{
- initialize();
-}
-
-
/*!Initialize tool buttons.*/
void SUIT_ToolButton::initialize()
{
- mySignal = NULL;
- myPopup = new QPopupMenu( this );
- setPopup(myPopup);
- connect( myPopup, SIGNAL(activated(int)), SLOT(OnSelectAction(int)) );
- setPopupDelay(250);
+// mySignal = NULL;
+ myPopup = new QMenu( this );
+ setMenu( myPopup );
+ connect( myPopup, SIGNAL( activated( int ) ), SLOT( OnSelectAction( int ) ) );
}
/*!drawButton is redefined to draw DownArrow*/
-void SUIT_ToolButton::drawButton( QPainter * p )
+void SUIT_ToolButton::drawButton( QPainter * /*p*/ )
{
- QToolButton::drawButton(p);
+/*
+ QToolButton::drawButton( p );
//draw DownArrow
int x, y, w, h;
style().drawPrimitive( QStyle::PE_ArrowDown,
p, QRect(x+w/2+3, y+h/2+3, w/2, h/2), //QRect(x+(w-x)/2, y+(h-y)/2, w, h)
colorGroup(), isEnabled() );
+*/
}
-
/*! Add action into popup*/
-void SUIT_ToolButton::AddAction(QAction* theAction)
+void SUIT_ToolButton::AddAction( QAction* theAction )
{
bool aIsFirst = false;
- if ( myPopup->count() == 0 )
+ if ( myPopup->actions().isEmpty() )
{
aIsFirst = true;
- setPixmap(theAction->iconSet().pixmap());
- setTextLabel(theAction->text());
- theAction->addTo( myPopup );
- QMenuItem* aItem = myPopup->findItem(myPopup->idAt(0));
- if (aItem != NULL)
- {
- mySignal = aItem->signal();
- }
+ setIcon( theAction->icon() );
+ setText( theAction->text() );
}
- else
- theAction->addTo( myPopup );
+ myPopup->addAction( theAction );
}
/*! Sets myPopup item with theIndex as current*/
-void SUIT_ToolButton::SetItem(int theIndex)
+void SUIT_ToolButton::SetItem( int theIndex )
{
- int anId = myPopup->idAt(theIndex);
- if (anId != -1)
+ QAction* a = myPopup->actions()[theIndex];
+ if ( a )
{
- // Protection against unexpected null pointers returned
- if ( myPopup->iconSet(anId) )
- setPixmap(myPopup->iconSet(anId)->pixmap());
- setTextLabel(myPopup->text(anId));
- QMenuItem* aItem = myPopup->findItem(anId);
- if (aItem != NULL)
- {
- mySignal = aItem->signal();
- }
+ setIcon( a->icon() );
+ setText( a->text() );
}
}
/*!Public SLOT.
* On select action (icon and text set with id = \a theItemID)
*/
-void SUIT_ToolButton::OnSelectAction(int theItemID)
+void SUIT_ToolButton::OnSelectAction( int /*theItemID*/ )
{
- if (myChangeItemAfterClick)
+/*
+ if ( myChangeItemAfterClick )
{
// Protection against unexpected null pointers returned
if ( myPopup->iconSet(theItemID) )
mySignal = aItem->signal();
}
}
+*/
}
-
-
/*!On mouse release event.*/
-void SUIT_ToolButton::mouseReleaseEvent ( QMouseEvent * theEvent)
+void SUIT_ToolButton::mouseReleaseEvent( QMouseEvent* theEvent )
{
- QToolButton::mouseReleaseEvent(theEvent);
- if (mySignal != NULL)
- {
+ QToolButton::mouseReleaseEvent( theEvent );
+/*
+ if ( mySignal )
mySignal->activate();
- }
+*/
}
-
-
#ifndef SUIT_TOOLBUTTON_H
#define SUIT_TOOLBUTTON_H
-#include <qtoolbutton.h>
-#include <qaction.h>
-
#include "SUIT.h"
+#include <QToolButton>
+
+class QAction;
+class QPixmap;
+class QToolBar;
+
/*! To draw down arrow on toolbutton.*/
class SUIT_EXPORT SUIT_ToolButton : public QToolButton
{
SUIT_ToolButton( QWidget *parent = 0,
const char *name = 0,
bool changeItemAfterClick = true );
- SUIT_ToolButton( const QPixmap & pm, const QString &textLabel,
- const QString& grouptext,
- QObject * receiver, const char* slot,
- QToolBar * parent, const char* name = 0,
- bool changeItemAfterClick = true );
//@}
void drawButton( QPainter * pQPainter);
private:
void initialize();
- QPopupMenu* myPopup;
- QSignal* mySignal;
- bool myChangeItemAfterClick;
+ QMenu* myPopup;
+// QSignal* mySignal;
+ bool myChangeItemAfterClick;
};
#endif
-
//
#include "SUIT_Tools.h"
-#include <qdir.h>
+#include <QDir>
#include <stdio.h>
#include <stdarg.h>
tmpPath += QString( "Salome_trace" );
FILE* pStream;
- pStream = fopen( lpszLog ? lpszLog : tmpPath.latin1(), "a" );
+ pStream = fopen( lpszLog ? lpszLog : (const char*)tmpPath.toLatin1(), "a" );
if ( pStream )
{
va_list argptr;
*/
QRect SUIT_Tools::makeRect( const int x1, const int y1, const int x2, const int y2 )
{
- return QRect( QMIN( x1, x2 ), QMIN( y1, y2 ), QABS( x2 - x1 ), QABS( y2 - y1 ) );
+ return QRect( qMin( x1, x2 ), qMin( y1, y2 ), qAbs( x2 - x1 ), qAbs( y2 - y1 ) );
}
/*!
QFont SUIT_Tools::stringToFont( const QString& fontDescription )
{
QFont font;
- if ( fontDescription.stripWhiteSpace().isEmpty() || !font.fromString( fontDescription ) )
+ if ( fontDescription.trimmed().isEmpty() || !font.fromString( fontDescription ) )
font = QFont( "Courier", 11 );
return font;
}
#include <Qtx.h>
-#include <qrect.h>
-#include <qfont.h>
-#include <qstring.h>
+#include <QRect>
+#include <QString>
+#include <QFont>
/*!
\class SUIT_Tools