From: vsr Date: Mon, 14 May 2007 11:50:32 +0000 (+0000) Subject: Porting to Qt4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=734a274ef53bafab2d5c88f5574b768eaece6ea7;p=modules%2Fgui.git Porting to Qt4 --- diff --git a/src/SUIT/Makefile.am b/src/SUIT/Makefile.am index a87d39fae..f91816226 100755 --- a/src/SUIT/Makefile.am +++ b/src/SUIT/Makefile.am @@ -25,94 +25,103 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libsuit.la -salomeinclude_HEADERS= \ - SUIT.h \ - SUIT_ActionOperation.h \ - SUIT_Application.h \ - SUIT_Convertor.h \ - SUIT_DataObject.h \ - SUIT_DataObjectIterator.h \ - SUIT_DataObjectKey.h \ - SUIT_DataOwner.h \ - SUIT_Desktop.h \ - SUIT_ExceptionHandler.h \ - SUIT_FileDlg.h \ - SUIT_FileValidator.h \ - SUIT_MessageBox.h \ - SUIT_Operation.h \ - SUIT_OverrideCursor.h \ - SUIT_ParserSettings.h \ - SUIT_PopupClient.h \ - SUIT_ResourceMgr.h \ - SUIT_SelectionMgr.h \ - SUIT_Selector.h \ - SUIT_Session.h \ - SUIT_SmartPtr.h \ - SUIT_Study.h \ - SUIT_ToolButton.h \ - SUIT_Tools.h \ - SUIT_ViewManager.h \ - SUIT_ViewModel.h \ - SUIT_ViewWindow.h \ - SUIT_SelectionFilter.h \ - SUIT_Accel.h \ - SUIT_TreeSync.h +#VSR: already migrated to Qt4 files +salomeinclude_HEADERS= \ + SUIT.h \ + SUIT_Accel.h \ + SUIT_ActionOperation.h \ + SUIT_Application.h \ + SUIT_DataObject.h \ + SUIT_DataObjectIterator.h \ + SUIT_DataObjectKey.h \ + SUIT_DataOwner.h \ + SUIT_Desktop.h \ + SUIT_ExceptionHandler.h \ + SUIT_FileDlg.h \ + SUIT_FileValidator.h \ + SUIT_MessageBox.h \ + SUIT_Operation.h \ + SUIT_OverrideCursor.h \ + SUIT_PopupClient.h \ + SUIT_ResourceMgr.h \ + SUIT_SelectionFilter.h \ + SUIT_SelectionMgr.h \ + SUIT_Selector.h \ + SUIT_Session.h \ + SUIT_SmartPtr.h \ + SUIT_Study.h \ + SUIT_ToolButton.h \ + SUIT_Tools.h \ + SUIT_TreeSync.h \ + SUIT_ViewManager.h \ + SUIT_ViewModel.h \ + SUIT_ViewWindow.h -dist_libsuit_la_SOURCES= \ - SUIT_ActionOperation.cxx \ - SUIT_Application.cxx \ - SUIT_DataObject.cxx \ - SUIT_DataObjectIterator.cxx \ - SUIT_DataObjectKey.cxx \ - SUIT_DataOwner.cxx \ - SUIT_Desktop.cxx \ - SUIT_ExceptionHandler.cxx \ - SUIT_FileDlg.cxx \ - SUIT_FileValidator.cxx \ - SUIT_MessageBox.cxx \ - SUIT_Operation.cxx \ - SUIT_OverrideCursor.cxx \ - SUIT_ParserSettings.cxx \ - SUIT_PopupClient.cxx \ - SUIT_ResourceMgr.cxx \ - SUIT_SelectionMgr.cxx \ - SUIT_Selector.cxx \ - SUIT_Session.cxx \ - SUIT_Study.cxx \ - SUIT_ToolButton.cxx \ - SUIT_Tools.cxx \ - SUIT_ViewManager.cxx \ - SUIT_ViewModel.cxx \ - SUIT_ViewWindow.cxx \ - SUIT_SelectionFilter.cxx \ - SUIT_Accel.cxx +#VSR: not yet migrated to Qt4 files +# \ + SUIT_Convertor.h \ + SUIT_ParserSettings.h + +#VSR: already migrated to Qt4 files +dist_libsuit_la_SOURCES= \ + SUIT_Accel.cxx \ + SUIT_ActionOperation.cxx \ + SUIT_Application.cxx \ + SUIT_DataObject.cxx \ + SUIT_DataObjectIterator.cxx \ + SUIT_DataObjectKey.cxx \ + SUIT_DataOwner.cxx \ + SUIT_Desktop.cxx \ + SUIT_ExceptionHandler.cxx \ + SUIT_FileDlg.cxx \ + SUIT_FileValidator.cxx \ + SUIT_MessageBox.cxx \ + SUIT_Operation.cxx \ + SUIT_OverrideCursor.cxx \ + SUIT_PopupClient.cxx \ + SUIT_ResourceMgr.cxx \ + SUIT_SelectionFilter.cxx \ + SUIT_SelectionMgr.cxx \ + SUIT_Selector.cxx \ + SUIT_Session.cxx \ + SUIT_Study.cxx \ + SUIT_ToolButton.cxx \ + SUIT_Tools.cxx \ + SUIT_ViewManager.cxx \ + SUIT_ViewModel.cxx \ + SUIT_ViewWindow.cxx + +#VSR: not yet migrated to Qt4 files +# \ + SUIT_ParserSettings.cxx + +MOC_FILES= \ + SUIT_Accel_moc.cxx \ + SUIT_ActionOperation_moc.cxx \ + SUIT_Application_moc.cxx \ + SUIT_DataObject_moc.cxx \ + SUIT_Desktop_moc.cxx \ + SUIT_FileDlg_moc.cxx \ + SUIT_Operation_moc.cxx \ + SUIT_PopupClient_moc.cxx \ + SUIT_SelectionMgr_moc.cxx \ + SUIT_Selector_moc.cxx \ + SUIT_Session_moc.cxx \ + SUIT_Study_moc.cxx \ + SUIT_ToolButton_moc.cxx \ + SUIT_ViewManager_moc.cxx \ + SUIT_ViewModel_moc.cxx \ + SUIT_ViewWindow_moc.cxx -MOC_FILES= \ - SUIT_ActionOperation_moc.cxx \ - SUIT_Application_moc.cxx \ - SUIT_DataObject_moc.cxx \ - SUIT_Desktop_moc.cxx \ - SUIT_FileDlg_moc.cxx \ - SUIT_Operation_moc.cxx \ - SUIT_PopupClient_moc.cxx \ - SUIT_Session_moc.cxx \ - SUIT_Study_moc.cxx \ - SUIT_ToolButton_moc.cxx \ - SUIT_ViewModel_moc.cxx \ - SUIT_ViewWindow_moc.cxx \ - SUIT_ViewManager_moc.cxx \ - SUIT_SelectionMgr_moc.cxx \ - SUIT_Selector_moc.cxx \ - SUIT_Accel_moc.cxx nodist_libsuit_la_SOURCES=$(MOC_FILES) -dist_salomeres_DATA = \ - resources/cascade.png \ - resources/htile.png \ +dist_salomeres_DATA = \ + resources/cascade.png \ + resources/htile.png \ resources/vtile.png -nodist_salomeres_DATA = \ - SUIT_images.qm \ +nodist_salomeres_DATA = \ + SUIT_images.qm \ SUIT_msg_en.qm libsuit_la_CPPFLAGS=$(QT_INCLUDES) -I$(srcdir)/../Qtx diff --git a/src/SUIT/SUIT.h b/src/SUIT/SUIT.h index 82940286a..151fba4d1 100755 --- a/src/SUIT/SUIT.h +++ b/src/SUIT/SUIT.h @@ -20,13 +20,13 @@ #define SUIT_H #if defined SUIT_EXPORTS -#if defined WNT +#if defined WIN32 #define SUIT_EXPORT __declspec( dllexport ) #else #define SUIT_EXPORT #endif #else -#if defined WNT +#if defined WIN32 #define SUIT_EXPORT __declspec( dllimport ) #else #define SUIT_EXPORT @@ -39,7 +39,7 @@ #define true 1 #endif -#if defined WNT +#if defined WIN32 #pragma warning ( disable: 4251 ) #endif diff --git a/src/SUIT/SUIT.pro b/src/SUIT/SUIT.pro new file mode 100644 index 000000000..34eb8aaf5 --- /dev/null +++ b/src/SUIT/SUIT.pro @@ -0,0 +1,87 @@ +TEMPLATE = lib +TARGET = suit +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH += ../../include ../Qtx +LIBS += -L../../lib -lqtx + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += SUIT_EXPORTS + +HEADERS = SUIT.h +HEADERS += SUIT_Accel.h +HEADERS += SUIT_ActionOperation.h +HEADERS += SUIT_Application.h +HEADERS += SUIT_DataObject.h +HEADERS += SUIT_DataObjectIterator.h +HEADERS += SUIT_DataObjectKey.h +HEADERS += SUIT_DataOwner.h +HEADERS += SUIT_Desktop.h +HEADERS += SUIT_ExceptionHandler.h +HEADERS += SUIT_FileDlg.h +HEADERS += SUIT_FileValidator.h +HEADERS += SUIT_MessageBox.h +HEADERS += SUIT_Operation.h +HEADERS += SUIT_OverrideCursor.h +HEADERS += SUIT_PopupClient.h +HEADERS += SUIT_ResourceMgr.h +HEADERS += SUIT_SelectionFilter.h +HEADERS += SUIT_SelectionMgr.h +HEADERS += SUIT_Selector.h +HEADERS += SUIT_Session.h +HEADERS += SUIT_SmartPtr.h +HEADERS += SUIT_Study.h +HEADERS += SUIT_ToolButton.h +HEADERS += SUIT_Tools.h +HEADERS += SUIT_TreeSync.h +HEADERS += SUIT_ViewManager.h +HEADERS += SUIT_ViewModel.h +HEADERS += SUIT_ViewWindow.h +#HEADERS += SUIT_Convertor.h +#HEADERS += SUIT_ParserSettings.h + +SOURCES = SUIT_Accel.cxx +SOURCES += SUIT_ActionOperation.cxx +SOURCES += SUIT_Application.cxx +SOURCES += SUIT_DataObject.cxx +SOURCES += SUIT_DataObjectIterator.cxx +SOURCES += SUIT_DataObjectKey.cxx +SOURCES += SUIT_DataOwner.cxx +SOURCES += SUIT_Desktop.cxx +SOURCES += SUIT_ExceptionHandler.cxx +SOURCES += SUIT_FileDlg.cxx +SOURCES += SUIT_FileValidator.cxx +SOURCES += SUIT_MessageBox.cxx +SOURCES += SUIT_Operation.cxx +SOURCES += SUIT_OverrideCursor.cxx +SOURCES += SUIT_PopupClient.cxx +SOURCES += SUIT_ResourceMgr.cxx +SOURCES += SUIT_SelectionFilter.cxx +SOURCES += SUIT_SelectionMgr.cxx +SOURCES += SUIT_Selector.cxx +SOURCES += SUIT_Session.cxx +SOURCES += SUIT_Study.cxx +SOURCES += SUIT_ToolButton.cxx +SOURCES += SUIT_Tools.cxx +SOURCES += SUIT_ViewManager.cxx +SOURCES += SUIT_ViewModel.cxx +SOURCES += SUIT_ViewWindow.cxx +#SOURCES += SUIT_ParserSettings.cxx + +TRANSLATIONS = resources/SUIT_images.ts \ + resources/SUIT_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/SUIT/SUIT_Accel.cxx b/src/SUIT/SUIT_Accel.cxx index 7bc7b5167..28dd85e9e 100644 --- a/src/SUIT/SUIT_Accel.cxx +++ b/src/SUIT/SUIT_Accel.cxx @@ -19,22 +19,27 @@ // SUIT_Accel.cxx: implementation of the SUIT_Accel class. #include "SUIT_Accel.h" + #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" #include "SUIT_ViewModel.h" -#include -#include -#include +#include +#include +#include +/*! + \class SUIT_Accel + \brief Manager of keyboard accelerator bindings. +*/ SUIT_Accel* SUIT_Accel::myself = 0; /*! Constructor [private].*/ SUIT_Accel::SUIT_Accel() - : QObject( qApp, "SUIT_Accel" ) +: QObject( QCoreApplication::instance() ) { - qApp->installEventFilter( this ); + QCoreApplication::instance()->installEventFilter( this ); } /*! getAccel() : public interface for SUIT_Accel object. Only one instance is created and returned. */ @@ -61,10 +66,12 @@ void SUIT_Accel::setActionKey( const int action, const int key, const QString& t /*! unsetActionKey() : unregister a certain key accelerator */ void SUIT_Accel::unsetActionKey( const int key, const QString& type ) { - if ( myMap.contains( type ) ) { + if ( myMap.contains( type ) ) + { IdActionMap idActionMap = myMap[type]; - if ( idActionMap.contains( key ) ) { - idActionMap.erase( key ); + if ( idActionMap.contains( key ) ) + { + idActionMap.remove( key ); myMap[type] = idActionMap; } } @@ -73,7 +80,8 @@ void SUIT_Accel::unsetActionKey( const int key, const QString& type ) /*! getParentViewWindow() : returns given object or any of its parents-grandparents-.. if it is a SUIT_ViewWindow */ SUIT_ViewWindow* getParentViewWindow( const QObject* obj ) { - if ( obj ) { + if ( obj ) + { if ( obj->inherits( "SUIT_ViewWindow" ) ) return (SUIT_ViewWindow*)obj; else @@ -83,22 +91,25 @@ SUIT_ViewWindow* getParentViewWindow( const QObject* obj ) } /*! getKey() : returns integer key code (with modifiers) made of key pressed 'inside' given event */ -int getKey( QKeyEvent *keyEvent ) +int getKey( QKeyEvent* keyEvent ) { - int key = keyEvent->key(), - state = keyEvent->state(); - if ( state & Qt::ShiftButton ) + int key = keyEvent->key(), state = keyEvent->modifiers(); + if ( state & Qt::ShiftModifier ) key += Qt::SHIFT; - if ( state & Qt::ControlButton ) + if ( state & Qt::ControlModifier ) key += Qt::CTRL; - if ( state & Qt::AltButton ) + if ( state & Qt::AltModifier ) key += Qt::ALT; - if ( state & Qt::MetaButton ) + if ( state & Qt::MetaModifier ) key += Qt::META; return key; } -/*! getAccelKey() : returns key pressed if 1) event was KeyPress 2) pressed key is a registered accelerator */ +/*! + Returns key pressed if + -# event was KeyPress + -# pressed key is a registered accelerator +*/ int SUIT_Accel::getAccelKey( QEvent *event ) { if ( event && event->type() == QEvent::KeyPress ) { diff --git a/src/SUIT/SUIT_Accel.h b/src/SUIT/SUIT_Accel.h index fdc9cd384..ed7dd4671 100644 --- a/src/SUIT/SUIT_Accel.h +++ b/src/SUIT/SUIT_Accel.h @@ -18,19 +18,15 @@ // // SUIT_Accel.h: interface for the SUIT_Accel class. -#ifndef SUIT_Accel_h -#define SUIT_Accel_h +#ifndef SUIT_ACELL_H +#define SUIT_ACELL_H #include "SUIT.h" -#include -#include -#include +#include +#include +#include -/*! - \class SUIT_Accel - Manager of keyboard accelerator bindings -*/ class SUIT_EXPORT SUIT_Accel: public QObject { Q_OBJECT @@ -63,15 +59,16 @@ protected: private: SUIT_Accel(); - int getAccelKey( QEvent* ); // returns key pressed if 1) event was KeyPress - // 2) pressed key is a registered accelerator + int getAccelKey( QEvent* ); - typedef QMap IdActionMap; // key - to - action_id map - typedef QMap ViewerTypeIdActionMap; // viewer_type - to - IdActionMap - ViewerTypeIdActionMap myMap; + typedef QMap IdActionMap; //!< maps key to action id + typedef QMap + ViewerTypeIdActionMap; //!< maps viewer type to IdActionMap + ViewerTypeIdActionMap myMap; //!< viewer actions map - QMap myOptMap; // key - to - map, used for optimazation. all registered keys (accelerators) - // are stored in this map. + //! Maps key to flag map, used for optimization. + //! All registered keys (accelerators) are stored in this map. + QMap myOptMap; static SUIT_Accel* myself; }; diff --git a/src/SUIT/SUIT_ActionOperation.cxx b/src/SUIT/SUIT_ActionOperation.cxx index d56f01705..5c7b4711b 100644 --- a/src/SUIT/SUIT_ActionOperation.cxx +++ b/src/SUIT/SUIT_ActionOperation.cxx @@ -49,20 +49,20 @@ QtxAction* SUIT_ActionOperation::action() const /*!Set action. * Create new instance of QtxAction and set. */ -void SUIT_ActionOperation::setAction( const QString& text, const QIconSet& icon, - const QString& menuText, QKeySequence accel, - QObject* parent, const char* name, bool toggle ) +void SUIT_ActionOperation::setAction( const QString& text, const QIcon& icon, + const QString& menuText, QKeySequence accel, + QObject* parent, bool toggle ) { - setAction( new QtxAction( text, icon, menuText, accel, parent, name, toggle ) ); + setAction( new QtxAction( text, icon, menuText, accel, parent, 0, toggle ) ); } /*!Set action. * Create new instance of QtxAction and set. */ void SUIT_ActionOperation::setAction( const QString& text, const QString& menuText, - QKeySequence accel, QObject* parent, const char* name, bool toggle ) + QKeySequence accel, QObject* parent, bool toggle ) { - setAction( new QtxAction(text, menuText, accel, parent, name, toggle ) ); + setAction( new QtxAction( text, menuText, accel, parent, 0, toggle ) ); } /*!Set action. diff --git a/src/SUIT/SUIT_ActionOperation.h b/src/SUIT/SUIT_ActionOperation.h index bed11e318..89d9b1f25 100644 --- a/src/SUIT/SUIT_ActionOperation.h +++ b/src/SUIT/SUIT_ActionOperation.h @@ -16,43 +16,46 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #ifndef SUIT_ACTIONOPERATION_H #define SUIT_ACTIONOPERATION_H #include "SUIT_Operation.h" -class QtxAction; +#include + +class QIcon; class QString; -class QIconSet; -class QKeySequence; class QWidget; +class QtxAction; + /*!Provide support QtxAction*/ class SUIT_EXPORT SUIT_ActionOperation : public SUIT_Operation { Q_OBJECT public: - SUIT_ActionOperation( SUIT_Application* theApp ); + SUIT_ActionOperation( SUIT_Application* ); virtual ~SUIT_ActionOperation(); QtxAction* action() const; /** @name GUI management*/ //@{ - virtual void setAction( const QString& text, const QIconSet& icon, const QString& menuText, - QKeySequence accel, QObject* parent, const char* name = 0, bool toggle = false ); + virtual void setAction( const QString& text, const QIcon& icon, const QString& menuText, + QKeySequence accel, QObject* parent, bool toggle = false ); - virtual void setAction( const QString& text, const QString& menuText, QKeySequence accel, - QObject* parent, const char* name = 0, bool toggle = false ); + virtual void setAction( const QString& text, const QString& menuText, + QKeySequence accel, QObject* parent, bool toggle = false ); virtual void setAction( QtxAction* theAction ); bool addTo( QWidget* theWidget ); bool addTo( QWidget* theWidget, int thePos ); - + void setStatusTip( const QString& theTip ); //@} - + private: QtxAction* myAction;