2) Replace QAction class by QtxAction class throughout (workaround SIP behaviour)
SIP_FLAGS = -t WS_X11 -t $(QT_VERS) -s ".cc" -c . -I $(PYQT_SIPS)
# Sip common sources
SIP_SRC = sipSalomePyQtSalomePyQt.cc \
- sipSalomePyQtSALOME_Selection.cc
+ sipSalomePyQtSALOME_Selection.cc \
+ sipSalomePyQtQtxAction.cc
# Sip version-specific sources
ifeq ($(SIP_VERS),v4_old)
#include <qmenubar.h>
#include <qwidget.h>
#include <qpopupmenu.h>
-#include <qaction.h>
#include <qstringlist.h>
#include "SALOME_Event.hxx"
#include "SalomeApp_Study.h"
#include "SalomeApp_SelectionMgr.h"
#include "OB_Browser.h"
+#include "QtxAction.h"
using namespace std;
//====================================================================================
// SALOME_Selection class.
//====================================================================================
+static QMap<SalomeApp_Application*, SALOME_Selection*> SelMap;
+
+/*!
+ SALOME_Selection::GetSelection
+ Creates or finds the selection object (one per study).
+*/
+SALOME_Selection* SALOME_Selection::GetSelection( SalomeApp_Application* app )
+{
+ SALOME_Selection* sel = 0;
+ if ( app && SelMap.find( app ) != SelMap.end() )
+ sel = SelMap[ app ];
+ else
+ sel = SelMap[ app ] = new SALOME_Selection( app );
+ return sel;
+}
+
/*!
SALOME_Selection::SALOME_Selection
- Selection constructor. Gets an instance of selection manager.
+ Selection constructor.
*/
-SALOME_Selection::SALOME_Selection() : mySelMgr( 0 )
+SALOME_Selection::SALOME_Selection( QObject* p ) : QObject( p ), mySelMgr( 0 )
{
- if ( SalomeApp_Application* anApp = getApplication() ) {
- mySelMgr = anApp->selectionMgr();
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( p );
+ if ( app ) {
+ mySelMgr = app->selectionMgr();
connect( mySelMgr, SIGNAL( selectionChanged() ), this, SIGNAL( currentSelectionChanged() ) );
connect( mySelMgr, SIGNAL( destroyed() ), this, SLOT ( onSelMgrDestroyed() ) );
}
}
+/*!
+ SALOME_Selection::~SALOME_Selection
+ Selection destructor. Removes selection object from the map.
+*/
+SALOME_Selection::~SALOME_Selection()
+{
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( parent() );
+ if ( app && SelMap.find( app ) != SelMap.end() )
+ SelMap.remove( app );
+}
/*!
SALOME_Selection::onSelMgrDestroyed
TResult myResult;
TGetSelectionEvent() : myResult( 0 ) {}
virtual void Execute() {
- myResult = new SALOME_Selection();
+ myResult = SALOME_Selection::GetSelection( getApplication() );
}
};
SALOME_Selection* SalomePyQt::getSelection()
: myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
CrTool( const int id, const QString& tBar, const int idx )
: myCase( 2 ), myId( id ), myTbName( tBar ), myIndex( idx ) {}
- CrTool( QAction* action, const int tbId, const int id, const int idx )
+ CrTool( QtxAction* action, const int tbId, const int id, const int idx )
: myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
- CrTool( QAction* action, const QString& tBar, const int id, const int idx )
+ CrTool( QtxAction* action, const QString& tBar, const int id, const int idx )
: myCase( 4 ), myAction( action ), myTbName( tBar ), myId( id ), myIndex( idx ) {}
int execute( SALOME_PYQT_Module* module ) const
return -1;
}
private:
- int myCase;
- QString myTbName;
- int myTbId;
- QAction* myAction;
- int myId;
- int myIndex;
+ int myCase;
+ QString myTbName;
+ int myTbId;
+ QtxAction* myAction;
+ int myId;
+ int myIndex;
};
class TCreateToolEvent: public SALOME_Event {
public:
return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
}
// add action with id and index to the existing tollbar
-int SalomePyQt::createTool( QAction* a, const int tBar, const int id, const int idx )
+int SalomePyQt::createTool( QtxAction* a, const int tBar, const int id, const int idx )
{
return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
}
// add action with id and index to the existing tollbar
-int SalomePyQt::createTool( QAction* a, const QString& tBar, const int id, const int idx )
+int SalomePyQt::createTool( QtxAction* a, const QString& tBar, const int id, const int idx )
{
return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
}
: myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {}
CrMenu( const int id, const QString& menu, const int group, const int idx )
: myCase( 3 ), myId( id ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {}
- CrMenu( QAction* action, const int menu, const int id, const int group, const int idx )
+ CrMenu( QtxAction* action, const int menu, const int id, const int group, const int idx )
: myCase( 4 ), myAction( action ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
- CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
+ CrMenu( QtxAction* action, const QString& menu, const int id, const int group, const int idx )
: myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
int execute( SALOME_PYQT_Module* module ) const
return -1;
}
private:
- int myCase;
- QString myMenuName;
- int myMenuId;
- QString mySubMenuName;
- int myGroup;
- QAction* myAction;
- int myId;
- int myIndex;
+ int myCase;
+ QString myMenuName;
+ int myMenuId;
+ QString mySubMenuName;
+ int myGroup;
+ QtxAction* myAction;
+ int myId;
+ int myIndex;
};
class TCreateMenuEvent: public SALOME_Event {
public:
return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
}
-int SalomePyQt::createMenu( QAction* a, const int menu, const int id, const int group, const int idx )
+int SalomePyQt::createMenu( QtxAction* a, const int menu, const int id, const int group, const int idx )
{
return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
}
-int SalomePyQt::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx )
+int SalomePyQt::createMenu( QtxAction* a, const QString& menu, const int id, const int group, const int idx )
{
return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
}
*/
class TCreateSepEvent: public SALOME_Event {
public:
- typedef QAction* TResult;
+ typedef QtxAction* TResult;
TResult myResult;
TCreateSepEvent()
: myResult( 0 ) {}
if ( !module )
module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
if ( module )
- myResult = module->createSeparator();
+ myResult = (QtxAction*)module->createSeparator();
}
}
};
-QAction* SalomePyQt::createSeparator()
+QtxAction* SalomePyQt::createSeparator()
{
return ProcessEvent( new TCreateSepEvent() );
}
*/
class TCreateActionEvent: public SALOME_Event {
public:
- typedef QAction* TResult;
+ typedef QtxAction* TResult;
TResult myResult;
int myId;
QString myMenuText;
if ( !module )
module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
if ( module )
- myResult = module->createAction( myId, myTipText, myIcon, myMenuText, myStatusText, myKey, myToggle );
+ myResult = (QtxAction*)module->createAction( myId, myTipText, myIcon, myMenuText, myStatusText, myKey, myToggle );
}
}
};
-QAction* SalomePyQt::createAction( const int id, const QString& menuText,
- const QString& tipText, const QString& statusText,
- const QString& icon, const int key, const bool toggle )
+QtxAction* SalomePyQt::createAction( const int id, const QString& menuText,
+ const QString& tipText, const QString& statusText,
+ const QString& icon, const int key, const bool toggle )
{
return ProcessEvent( new TCreateActionEvent( id, menuText, tipText, statusText, icon, key, toggle ) );
}
*/
class TActionEvent: public SALOME_Event {
public:
- typedef QAction* TResult;
+ typedef QtxAction* TResult;
TResult myResult;
int myId;
TActionEvent( const int id )
if ( !module )
module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
if ( module )
- myResult = module->action( myId );
+ myResult = (QtxAction*)module->action( myId );
}
}
};
-QAction* SalomePyQt::action( const int id )
+QtxAction* SalomePyQt::action( const int id )
{
return ProcessEvent( new TActionEvent( id ) );
}
public:
typedef int TResult;
TResult myResult;
- const QAction* myAction;
- TActionIdEvent( const QAction* action )
+ const QtxAction* myAction;
+ TActionIdEvent( const QtxAction* action )
: myResult( -1 ), myAction( action ) {}
virtual void Execute() {
if ( SalomeApp_Application* anApp = getApplication() ) {
}
}
};
-int SalomePyQt::actionId( const QAction* a )
+int SalomePyQt::actionId( const QtxAction* a )
{
return ProcessEvent( new TActionIdEvent( a ) );
}
#include <qcolor.h>
class SalomeApp_SelectionMgr;
-class QAction;
+class SalomeApp_Application;
class QMenuBar;
class QPopupMenu;
class QWidget;
+class QtxAction;
class SALOME_Selection : public QObject
{
Q_OBJECT
public:
- SALOME_Selection();
+ ~SALOME_Selection();
+ static SALOME_Selection* GetSelection( SalomeApp_Application* );
void Clear();
void ClearIObjects();
private:
SalomeApp_SelectionMgr* mySelMgr;
+ SALOME_Selection( QObject* );
};
enum MenuName {
static bool dumpView( const QString& );
static int createTool( const QString& );
- static int createTool( const int, const int, const int = -1 );
- static int createTool( const int, const QString&, const int = -1 );
- static int createTool( QAction*, const int, const int = -1, const int = -1 );
- static int createTool( QAction*, const QString&, const int = -1, const int = -1 );
+ static int createTool( const int, const int, const int = -1 );
+ static int createTool( const int, const QString&, const int = -1 );
+ static int createTool( QtxAction*, const int, const int = -1, const int = -1 );
+ static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 );
static int createMenu( const QString&, const int = -1,
const int = -1, const int = -1 );
const int = -1, const int = -1 );
static int createMenu( const int, const QString& = QString::null,
const int = -1, const int = -1 );
- static int createMenu( QAction*, const int, const int = -1,
+ static int createMenu( QtxAction*, const int, const int = -1,
const int = -1, const int = -1 );
- static int createMenu( QAction*, const QString&, const int = -1,
+ static int createMenu( QtxAction*, const QString&, const int = -1,
const int = -1, const int = -1 );
- static QAction* createSeparator();
+ static QtxAction* createSeparator();
- static QAction* createAction( const int, const QString&,
+ static QtxAction* createAction( const int, const QString&,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const int = 0, const bool = false );
- static QAction* action( const int );
- static int actionId( const QAction* );
+ static QtxAction* action( const int );
+ static int actionId( const QtxAction* );
static void addSetting ( const QString&, const QString&, const double );
static void addSetting ( const QString&, const QString&, const int );
class SALOME_Selection : QObject
{
-
%HeaderCode
#include <SalomePyQt.h>
%End
public:
- SALOME_Selection();
-
void Clear();
void ClearIObjects();
void ClearFilters();
+private:
+ SALOME_Selection( QObject* /TransferThis/ );
+
signals:
void currentSelectionChanged();
};
Help = 7
};
-class SalomePyQt
+class QtxAction
{
+%TypeHeaderCode
+#include <QtxAction.h>
+%End
+
+public:
+ void setIconSet( const QIconSet& );
+ QIconSet iconSet() const;
+ void setText( const QString& );
+ QString text() const;
+ void setMenuText( const QString& );
+ QString menuText() const;
+ void setToolTip( const QString& );
+ QString toolTip() const;
+ void setStatusTip( const QString& );
+ QString statusTip() const;
+ void setWhatsThis( const QString& );
+ QString whatsThis() const;
+ void setAccel( const QKeySequence& );
+ QKeySequence accel() const;
+ void setToggleAction( bool );
+ bool isToggleAction() const;
+ bool isOn() const;
+ bool isEnabled() const;
+ bool isVisible() const;
+
+public slots:
+ void activate();
+ void toggle();
+ void setOn( bool );
+ void setEnabled( bool );
+ void setDisabled( bool );
+ void setVisible( bool );
+signals:
+ void activated();
+ void toggled( bool );
+
+private:
+ QtxAction(const QtxAction &);
+};
+
+class SalomePyQt
+{
%HeaderCode
#include <SalomePyQt.h>
%End
static bool dumpView( const QString& );
static int createTool( const QString& );
- static int createTool( const int, const int, int = -1 );
- static int createTool( const int, const QString&, int = -1 );
- static int createTool( QAction*, const int, int = -1, int = -1 );
- static int createTool( QAction*, const QString&, int = -1, int = -1 );
+ static int createTool( const int, const int, int = -1 );
+ static int createTool( const int, const QString&, int = -1 );
+ static int createTool( QtxAction*, const int, int = -1, int = -1 );
+ static int createTool( QtxAction*, const QString&, int = -1, int = -1 );
static int createMenu( const QString&, const int,
int = -1, int = -1 );
int = -1, int = -1 );
static int createMenu( const int, const QString&,
int = -1, int = -1 );
- static int createMenu( QAction*, const int, int = -1,
+ static int createMenu( QtxAction*, const int, int = -1,
int = -1, int = -1 );
- static int createMenu( QAction*, const QString&, int = -1,
+ static int createMenu( QtxAction*, const QString&, int = -1,
int = -1, int = -1 );
- static QAction* createSeparator();
+ static QtxAction* createSeparator();
- static QAction* createAction( const int, const QString&,
+ static QtxAction* createAction( const int, const QString&,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, int = 0, bool = false );
- static QAction* action( const int );
- static int actionId( const QAction* );
+ static QtxAction* action( const int );
+ static int actionId( const QtxAction* );
static void addSetting ( const QString&, const QString&, const double );
static void addSetting ( const QString&, const QString&, const int /Constrained/ );
%End
public:
- SALOME_Selection();
-
void Clear();
void ClearIObjects();
void ClearFilters();
+private:
+ SALOME_Selection( QObject* /TransferThis/ );
+
signals:
void currentSelectionChanged();
};
Help = 7
};
+class QtxAction
+{
+%TypeHeaderCode
+#include <QtxAction.h>
+%End
+
+public:
+ void setIconSet( const QIconSet& );
+ QIconSet iconSet() const;
+ void setText( const QString& );
+ QString text() const;
+ void setMenuText( const QString& );
+ QString menuText() const;
+ void setToolTip( const QString& );
+ QString toolTip() const;
+ void setStatusTip( const QString& );
+ QString statusTip() const;
+ void setWhatsThis( const QString& );
+ QString whatsThis() const;
+ void setAccel( const QKeySequence& );
+ QKeySequence accel() const;
+ void setToggleAction( bool );
+ bool isToggleAction() const;
+ bool isOn() const;
+ bool isEnabled() const;
+ bool isVisible() const;
+
+public slots:
+ void activate();
+ void toggle();
+ void setOn( bool );
+ void setEnabled( bool );
+ void setDisabled( bool );
+ void setVisible( bool );
+
+signals:
+ void activated();
+ void toggled( bool );
+
+private:
+ QtxAction(const QtxAction &);
+};
+
class SalomePyQt
{
%TypeHeaderCode
static bool dumpView( const QString& );
static int createTool( const QString& );
- static int createTool( const int, const int, const int = -1 );
- static int createTool( const int, const QString&, const int = -1 );
- static int createTool( QAction*, const int, const int = -1, const int = -1 );
- static int createTool( QAction*, const QString&, const int = -1, const int = -1 );
+ static int createTool( const int, const int, const int = -1 );
+ static int createTool( const int, const QString&, const int = -1 );
+ static int createTool( QtxAction*, const int, const int = -1, const int = -1 );
+ static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 );
static int createMenu( const QString&, const int,
const int = -1, const int = -1 );
const int = -1, const int = -1 );
static int createMenu( const int, const QString&,
const int = -1, const int = -1 );
- static int createMenu( QAction*, const int, const int = -1,
+ static int createMenu( QtxAction*, const int, const int = -1,
const int = -1, const int = -1 );
- static int createMenu( QAction*, const QString&, const int = -1,
+ static int createMenu( QtxAction*, const QString&, const int = -1,
const int = -1, const int = -1 );
- static QAction* createSeparator();
+ static QtxAction* createSeparator();
- static QAction* createAction( const int, const QString&,
+ static QtxAction* createAction( const int, const QString&,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const int = 0, const bool = false );
- static QAction* action( const int );
- static int actionId( const QAction* );
+ static QtxAction* action( const int );
+ static int actionId( const QtxAction* );
static void addSetting ( const QString&, const QString&, const double );
static void addSetting ( const QString&, const QString&, const int /Constrained/ );