From: Anthony Geay Date: Tue, 23 Feb 2016 08:55:04 +0000 (+0100) Subject: Step 4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17ab1f4f97865afcfdef8bff30484cdfe4c58066;p=modules%2Fgui.git Step 4 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 251f60645..b05fdbe6e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,7 +310,7 @@ INCLUDE(CMakePackageConfigHelpers) # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser - QDS qtx suitt SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData + QDS qtx SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData ImageComposer ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05d331cc1..ba919fa87 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,6 @@ # Common packages ## ADD_SUBDIRECTORY(CASCatch) -ADD_SUBDIRECTORY(SUITT) ADD_SUBDIRECTORY(Qtx) ADD_SUBDIRECTORY(HelpBrowser) ADD_SUBDIRECTORY(Style) diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index ad41a0aa8..8a6426291 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -43,6 +43,12 @@ #include #include +PyConsole_EditorBase *PyConsole_Console::PyConsole_Interp_Creator::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const +{ return new PyConsole_Editor(interp,console); } + +PyConsole_Interp *PyConsole_Console::PyConsole_Interp_Creator::createInterp( ) const +{ return new PyConsole_Interp; } + /*! \brief Constructor. @@ -51,8 +57,10 @@ \param interp python interpreter */ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp ) - : PyConsole_ConsoleBase( parent, interp ) + : PyConsole_ConsoleBase( parent, interp, 0 ) { + PyConsole_Interp_Creator crea; + defaultConstructor(interp,crea); } /** @@ -60,7 +68,8 @@ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp */ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i, PyConsole_Editor* e ) : PyConsole_ConsoleBase(parent,i,e) -{} +{ +} /*! \brief Destructor. @@ -119,6 +128,12 @@ bool PyConsole_Console::eventFilter( QObject* o, QEvent* e ) return QWidget::eventFilter( o, e ); } +PyConsole_EditorBase *PyConsole_EnhConsole::PyConsole_Interp_EnhCreator::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const +{ return new PyConsole_EnhEditor(interp,console); } + +PyConsole_Interp *PyConsole_EnhConsole::PyConsole_Interp_EnhCreator::createInterp( ) const +{ return new PyConsole_EnhInterp; } + /** * Similar to constructor of the base class but using enhanced objects. * TODO: this should really be done in a factory to avoid code duplication. @@ -128,22 +143,6 @@ bool PyConsole_Console::eventFilter( QObject* o, QEvent* e ) PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp ) : PyConsole_Console( parent, interp, 0 ) { - PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp(); - - // initialize Python interpretator - anInterp->initialize(); - - // create editor console - QVBoxLayout* lay = new QVBoxLayout( this ); - lay->setMargin( 0 ); - myEditor = new PyConsole_EnhEditor( anInterp, this ); - char* synchronous = getenv("PYTHON_CONSOLE_SYNC"); - if (synchronous && atoi(synchronous)) - { - myEditor->setIsSync(true); - } - myEditor->viewport()->installEventFilter( this ); - lay->addWidget( myEditor ); - - createActions(); + PyConsole_Interp_EnhCreator crea; + defaultConstructor(interp,crea); } diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h index 64c2e081c..1aa68a4d6 100644 --- a/src/PyConsole/PyConsole_Console.h +++ b/src/PyConsole/PyConsole_Console.h @@ -38,6 +38,14 @@ class PyConsole_Editor; class PYCONSOLE_EXPORT PyConsole_Console : public PyConsole_ConsoleBase, public SUIT_PopupClient { Q_OBJECT +public: + + struct PyConsole_Interp_Creator : public PyConsole_Interp_CreatorBase + { + virtual PyConsole_EditorBase *createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const; + virtual PyConsole_Interp *createInterp( ) const; + }; + public: PyConsole_Console( QWidget* parent, PyConsole_Interp* interp = 0 ); virtual ~PyConsole_Console(); @@ -57,6 +65,14 @@ protected: class PYCONSOLE_EXPORT PyConsole_EnhConsole : public PyConsole_Console { Q_OBJECT +public: + + struct PyConsole_Interp_EnhCreator : public PyConsole_Interp_CreatorBase + { + virtual PyConsole_EditorBase *createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const; + virtual PyConsole_Interp *createInterp( ) const; + }; + public: PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp = 0 ); virtual ~PyConsole_EnhConsole() {} diff --git a/src/PyConsoleBase/CMakeLists.txt b/src/PyConsoleBase/CMakeLists.txt index d70defa36..c19e06caa 100755 --- a/src/PyConsoleBase/CMakeLists.txt +++ b/src/PyConsoleBase/CMakeLists.txt @@ -25,7 +25,7 @@ INCLUDE(UseQtExt) INCLUDE_DIRECTORIES( ${QT_INCLUDES} ${PYTHON_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/src/SUITT + ${PROJECT_SOURCE_DIR}/src/Qtx ${PROJECT_SOURCE_DIR}/src/PyConsoleBase ${PROJECT_SOURCE_DIR}/src/Event ${PROJECT_SOURCE_DIR}/src/PyInterp @@ -35,7 +35,7 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(${QT_DEFINITIONS} ${PYTHON_DEFINITIONS}) # libraries to link to -SET(_link_LIBRARIES ${QT_LIBRARIES} ${PYTHON_LIBRARIES} PyInterp Event suitt) +SET(_link_LIBRARIES ${QT_LIBRARIES} ${PYTHON_LIBRARIES} PyInterp Event qtx) # --- headers --- @@ -49,7 +49,7 @@ SET(_moc_HEADERS # header files / no moc processing SET(_other_HEADERS PyConsoleBase.h - PyConsole_EnhInterpBase.h + PyConsole_EnhInterp.h PyConsole_Event.h PyConsole_Interp.h PyConsole_Request.h diff --git a/src/PyConsoleBase/PyConsole_ConsoleBase.cxx b/src/PyConsoleBase/PyConsole_ConsoleBase.cxx index 3e49f2f24..37d47dc75 100644 --- a/src/PyConsoleBase/PyConsole_ConsoleBase.cxx +++ b/src/PyConsoleBase/PyConsole_ConsoleBase.cxx @@ -40,6 +40,12 @@ #include #include +PyConsole_EditorBase *PyConsole_ConsoleBase::PyConsole_Interp_CreatorBase::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const +{ return new PyConsole_EditorBase(interp,console); } + +PyConsole_Interp *PyConsole_ConsoleBase::PyConsole_Interp_CreatorBase::createInterp( ) const +{ return new PyConsole_Interp; } + /*! \brief Constructor. @@ -50,7 +56,16 @@ PyConsole_ConsoleBase::PyConsole_ConsoleBase( QWidget* parent, PyConsole_Interp* interp ) : QWidget( parent ) { - PyConsole_Interp* anInterp = interp ? interp : new PyConsole_Interp(); + PyConsole_ConsoleBase::PyConsole_Interp_CreatorBase crea; + defaultConstructor(interp,crea); +} + +/*! + * MUST BE NON VIRTUAL ! (called from constructor !!!!) + */ +void PyConsole_ConsoleBase::defaultConstructor( PyConsole_Interp* interp, const PyConsole_Interp_CreatorBase& crea ) +{ + PyConsole_Interp *anInterp = interp ? interp : crea.createInterp(); // initialize Python interpretator anInterp->initialize(); @@ -58,7 +73,7 @@ PyConsole_ConsoleBase::PyConsole_ConsoleBase( QWidget* parent, PyConsole_Interp* // create editor console QVBoxLayout* lay = new QVBoxLayout( this ); lay->setMargin( 0 ); - myEditor = new PyConsole_EditorBase( anInterp, this ); + myEditor = crea.createEditor( anInterp, this ); char* synchronous = getenv("PYTHON_CONSOLE_SYNC"); if (synchronous && atoi(synchronous)) { @@ -319,6 +334,12 @@ void PyConsole_ConsoleBase::stopLog() myEditor->stopLog(); } +PyConsole_EditorBase *PyConsole_EnhConsoleBase::PyConsole_Interp_EnhCreatorBase::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const +{ return new PyConsole_EnhEditorBase(interp,console); } + +PyConsole_Interp *PyConsole_EnhConsoleBase::PyConsole_Interp_EnhCreatorBase::createInterp( ) const +{ return new PyConsole_EnhInterp; } + /** * Similar to constructor of the base class but using enhanced objects. * TODO: this should really be done in a factory to avoid code duplication. @@ -328,22 +349,6 @@ void PyConsole_ConsoleBase::stopLog() PyConsole_EnhConsoleBase::PyConsole_EnhConsoleBase( QWidget* parent, PyConsole_Interp* interp ) : PyConsole_ConsoleBase( parent, interp, 0 ) { - PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp(); - - // initialize Python interpretator - anInterp->initialize(); - - // create editor console - QVBoxLayout* lay = new QVBoxLayout( this ); - lay->setMargin( 0 ); - myEditor = new PyConsole_EnhEditorBase( anInterp, this ); - char* synchronous = getenv("PYTHON_CONSOLE_SYNC"); - if (synchronous && atoi(synchronous)) - { - myEditor->setIsSync(true); - } - myEditor->viewport()->installEventFilter( this ); - lay->addWidget( myEditor ); - - createActions(); + PyConsole_Interp_EnhCreatorBase crea; + defaultConstructor(interp,crea); } diff --git a/src/PyConsoleBase/PyConsole_ConsoleBase.h b/src/PyConsoleBase/PyConsole_ConsoleBase.h index 615400d41..b7e29523a 100644 --- a/src/PyConsoleBase/PyConsole_ConsoleBase.h +++ b/src/PyConsoleBase/PyConsole_ConsoleBase.h @@ -38,6 +38,14 @@ class PYCONSOLEBASE_EXPORT PyConsole_ConsoleBase : public QWidget { Q_OBJECT +public: + + struct PyConsole_Interp_CreatorBase + { + virtual PyConsole_EditorBase *createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const; + virtual PyConsole_Interp *createInterp( ) const; + }; + public: //! Context popup menu actions flags enum @@ -82,7 +90,8 @@ public: protected: void createActions(); void updateActions(); - + //! MUST BE NON VIRTUAL ! (called from constructor !!!!) + void defaultConstructor( PyConsole_Interp* interp, const PyConsole_Interp_CreatorBase& crea ); PyConsole_ConsoleBase( QWidget* parent, PyConsole_Interp*, PyConsole_EditorBase*); PyConsole_EditorBase* myEditor; //!< python console editor widget @@ -97,6 +106,13 @@ protected: class PYCONSOLEBASE_EXPORT PyConsole_EnhConsoleBase : public PyConsole_ConsoleBase { Q_OBJECT +public: + + struct PyConsole_Interp_EnhCreatorBase : public PyConsole_Interp_CreatorBase + { + virtual PyConsole_EditorBase *createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const; + virtual PyConsole_Interp *createInterp( ) const; + }; public: PyConsole_EnhConsoleBase( QWidget* parent, PyConsole_Interp* interp = 0 ); diff --git a/src/PyConsoleBase/PyConsole_EditorBase.cxx b/src/PyConsoleBase/PyConsole_EditorBase.cxx index cf95a290d..d83452714 100644 --- a/src/PyConsoleBase/PyConsole_EditorBase.cxx +++ b/src/PyConsoleBase/PyConsole_EditorBase.cxx @@ -95,9 +95,7 @@ #include "PyInterp_Dispatcher.h" #include "PyConsole_Request.h" -#include "SUIT_FileValidator.h" -#include "SUIT_MessageBox.h" -#include "Qtxx.h" +#include #include #include @@ -169,7 +167,7 @@ PyConsole_EditorBase::PyConsole_EditorBase( PyConsole_Interp* theInterp, myIsSuppressOutput( false ) { QString fntSet( "" ); - QFont aFont ( Qtxx::stringToFont(fntSet) ); + QFont aFont ( Qtx::stringToFont(fntSet) ); setFont( aFont ); setUndoRedoEnabled( false ); diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index f43ec8504..2fb381888 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -2095,6 +2095,17 @@ QString Qtx::qtDir( const QString& context ) return qtPath; } +/*! + Creates font from string description +*/ +QFont Qtx::stringToFont( const QString& fontDescription ) +{ + QFont font; + if ( fontDescription.trimmed().isEmpty() || !font.fromString( fontDescription ) ) + font = QFont( "Courier", 11 ); + return font; +} + #ifndef WIN32 #include diff --git a/src/Qtx/Qtx.h b/src/Qtx/Qtx.h index 423735c56..3d997d5a5 100755 --- a/src/Qtx/Qtx.h +++ b/src/Qtx/Qtx.h @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -262,6 +263,8 @@ public: static QString qtDir( const QString& = QString()); + static QFont stringToFont( const QString& fontDescription ); + #ifndef WIN32 static void* getDisplay(); static Qt::HANDLE getVisual(); diff --git a/src/SUIT/SUIT_Tools.cxx b/src/SUIT/SUIT_Tools.cxx index 11a8ddb92..2d5ab0162 100755 --- a/src/SUIT/SUIT_Tools.cxx +++ b/src/SUIT/SUIT_Tools.cxx @@ -62,17 +62,6 @@ QRect SUIT_Tools::makeRect( const int x1, const int y1, const int x2, const int return QRect( qMin( x1, x2 ), qMin( y1, y2 ), qAbs( x2 - x1 ), qAbs( y2 - y1 ) ); } -/*! - Creates font from string description -*/ -QFont SUIT_Tools::stringToFont( const QString& fontDescription ) -{ - QFont font; - if ( fontDescription.trimmed().isEmpty() || !font.fromString( fontDescription ) ) - font = QFont( "Courier", 11 ); - return font; -} - /*! Creates font's string description */ diff --git a/src/SUIT/SUIT_Tools.h b/src/SUIT/SUIT_Tools.h index dbb64a7da..40da4718a 100755 --- a/src/SUIT/SUIT_Tools.h +++ b/src/SUIT/SUIT_Tools.h @@ -42,7 +42,6 @@ public: static QRect makeRect( const int x1, const int y1, const int x2, const int y2 ); static QString fontToString( const QFont& font ); - static QFont stringToFont( const QString& fontDescription ); static void centerWidget( QWidget* src, const QWidget* ref ); }; diff --git a/src/SUITT/CMakeLists.txt b/src/SUITT/CMakeLists.txt deleted file mode 100644 index fcff36a2c..000000000 --- a/src/SUITT/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright (C) 2012-2015 CEA/DEN, EDF R&D, OPEN CASCADE -# -# 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, or (at your option) any later version. -# -# 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 -# - -INCLUDE(UseQtExt) - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${QT_INCLUDES} -) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS(${QT_DEFINITIONS}) -IF(ENABLE_TESTRECORDER) - ADD_DEFINITIONS("-DENABLE_TESTRECORDER ${TESTRECORDER_DEFINITIONS}") -ENDIF() - -# libraries to link to -SET(_link_LIBRARIES ${PLATFORM_LIBS} ${QT_LIBRARIES} qtx ObjBrowser) -IF(ENABLE_TESTRECORDER) - LIST(APPEND _link_LIBRARIES ${TESTRECORDER_LIBS}) -ENDIF() - -# --- headers --- - -# header files / to be processed by moc -SET(_moc_HEADERS - SUIT_MessageBox.h -) - -# header files / no moc processing -SET(_other_HEADERS - SUIT_OverrideCursor.h - SUIT_FileValidator.h - Qtxx.h - SUIT.h -) - -# header files / to install -SET(suitt_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) - -# --- resources --- - -# resource files / to be processed by lrelease - -# resource files / static -SET(_other_RESOURCES - resources/icon_visibility_on.png - resources/icon_visibility_off.png - resources/view_sync.png -) - -# --- sources --- - -# sources / moc wrappings -QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS}) - -# sources / static -SET(_other_SOURCES - SUIT_OverrideCursor.cxx - SUIT_MessageBox.cxx - SUIT_FileValidator.cxx - Qtxx.cxx -) - -# sources / to compile -SET(suitt_SOURCES ${_other_SOURCES} ${_moc_SOURCES}) - -# --- rules --- - -ADD_LIBRARY(suitt ${suitt_SOURCES}) -TARGET_LINK_LIBRARIES(suitt ${_link_LIBRARIES}) -INSTALL(TARGETS suitt EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - -INSTALL(FILES ${suitt_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) - -INSTALL(FILES ${_other_RESOURCES} DESTINATION ${SALOME_GUI_INSTALL_RES_DATA}) - diff --git a/src/SUITT/Qtxx.cxx b/src/SUITT/Qtxx.cxx deleted file mode 100755 index 3186a1148..000000000 --- a/src/SUITT/Qtxx.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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: Qtxx.cxx -// Author: Sergey TELKOV -// -#include "Qtxx.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/*! - \brief Return directory part of the file path. - - If the file path does not include directory part (the file is in the - current directory), null string is returned. - - \param path file path - \param abs if true (default) \a path parameter is treated as absolute file path - \return directory part of the file path -*/ -QString Qtxx::dir( const QString& path, const bool abs ) -{ - QDir aDir = QFileInfo( path ).dir(); - QString dirPath = abs ? aDir.absolutePath() : aDir.path(); - if ( dirPath == QString( "." ) ) - dirPath = QString(); - return dirPath; -} - -/*! - Creates font from string description -*/ -QFont Qtxx::stringToFont( const QString& fontDescription ) -{ - QFont font; - if ( fontDescription.trimmed().isEmpty() || !font.fromString( fontDescription ) ) - font = QFont( "Courier", 11 ); - return font; -} diff --git a/src/SUITT/Qtxx.h b/src/SUITT/Qtxx.h deleted file mode 100755 index 5d31747db..000000000 --- a/src/SUITT/Qtxx.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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: Qtx.h -// Author: Sergey TELKOV -// -#ifndef QTXX_H -#define QTXX_H - -#if defined WIN32 -# if defined QTXX_EXPORTS || defined qtxx_EXPORTS -# define QTX_EXPORT _declspec( dllexport ) -# else -# define QTX_EXPORT _declspec( dllimport ) -# endif -#else -# define QTX_EXPORT -#endif - -#if defined SOLARIS -#define bool int -#define false 0 -#define true 1 -#endif - -#include -#include -#include -#include -#include -#include - -class QObject; -class QWidget; -class QCompleter; - -typedef QList QIntList; //!< list of int values -typedef QList QShortList; //!< list of short int values -typedef QList QDoubleList; //!< list of double values -typedef QList QColorList; //!< list of colors - -class QTX_EXPORT Qtxx -{ -public: - static QString dir( const QString&, const bool = true ); - static QFont stringToFont( const QString& fontDescription ); -}; - -#endif diff --git a/src/SUITT/SUIT.h b/src/SUITT/SUIT.h deleted file mode 100755 index 392e98719..000000000 --- a/src/SUITT/SUIT.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 : SUIT.h -// Author : -// -#ifndef SUIT_H -#define SUIT_H - -#if defined WIN32 -# if defined SUIT_EXPORTS || defined suit_EXPORTS -# define SUIT_EXPORT __declspec( dllexport ) -# else -# define SUIT_EXPORT __declspec( dllimport ) -# endif -#else -# define SUIT_EXPORT -#endif - -#if defined SOLARIS -#define bool int -#define false 0 -#define true 1 -#endif - -#if defined WIN32 -#pragma warning ( disable: 4251 ) -#endif - -#if defined ( _DEBUG ) || defined ( DEBUG ) -#include -#define SUIT_VERIFY(x) assert( x ); -#define SUIT_ASSERT(x) assert( x ); -#else -#define SUIT_VERIFY(x) x -#define SUIT_ASSERT(x) -#endif - -#endif // SUIT_H diff --git a/src/SUITT/SUIT_FileValidator.cxx b/src/SUITT/SUIT_FileValidator.cxx deleted file mode 100755 index 1fc1b402a..000000000 --- a/src/SUITT/SUIT_FileValidator.cxx +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 : SUIT_FileValidator.cxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// -#include "SUIT_FileValidator.h" -#include "SUIT_MessageBox.h" -#include "Qtxx.h" -#include - -/*! - \class SUIT_FileValidator - \brief Provides functionality to check the file or directory - existance and permissions. - \sa SUIT_FileDlg class -*/ - -/*! - \brief Constructor. - \param parent parent widget (used as parent when displaying - information message boxes) -*/ -SUIT_FileValidator::SUIT_FileValidator( QWidget* parent ) -: myParent( parent ) -{ -} - -/*! - \brief Check if the specified file exists and (optionally) can be read. - - If file does not exists or can not be read (if \a checkPermission is \c true) - and parent() is not null, shows error message box. - - \param fileName file path - \param checkPermission if \c true (default) check also file permissions - \return \c false if file does not exist or if it does not have - read permissions (if \a checkPermission is \c true) -*/ -bool SUIT_FileValidator::canOpen( const QString& fileName, bool checkPermission ) -{ - if ( !QFile::exists( fileName ) ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( fileName ) ); - return false; - } - if ( checkPermission && !QFileInfo( fileName ).isReadable() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_OPEN_PERMISSION_DENIED" ).arg( fileName ) ); - return false; - } - return true; -} - -/*! - \brief Check if the specified file can be written. - - If file already exists and parent() is not null, prompts - question message box to the user to confirm file overwriting. - - If file can not be written (if \a checkPermission is \c true) - and parent() is not null, shows error message box. - - \param fileName file path - \param checkPermission if \c true (default) check also file permissions - \return \c false if file exists and user rejects file overwriting - or if file does not have write permissions (if \a checkPermission is \c true) -*/ -bool SUIT_FileValidator::canSave( const QString& fileName, bool checkPermission ) -{ - if ( QFile::exists( fileName ) ) { - if ( parent() ) - if ( SUIT_MessageBox::question( parent(), QObject::tr( "WRN_WARNING" ), - QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( fileName ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No, - SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) - return false; - - if ( checkPermission && !QFileInfo( fileName ).isWritable() ) { - if ( parent() ) - SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); - return false; - } - } - else { - QString dirName = Qtxx::dir( fileName ); - if ( !QFile::exists( dirName ) ) { - SUIT_MessageBox::critical( parent(), QObject::tr( "WRN_WARNING" ), - QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); - return false; - } - if ( checkPermission && !QFileInfo( dirName ).isWritable() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); - return false; - } - } - return true; -} - -/*! - \brief Check if the specified directory exists and (optionally) can be read. - - If directory does not exists or can not be read (if \a checkPermission is \c true) - and parent() is not null, shows error message box. - - \param dirName directory path - \param checkPermission if \c true (default) check also directory permissions - \return \c false if directory does not exist or if it does not have - read permissions (if \a checkPermission is \c true) -*/ -bool SUIT_FileValidator::canReadDir( const QString& dirName, bool checkPermission ) -{ - QFileInfo info( dirName ); - if ( !info.exists() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); - return false; - } - if ( !info.isDir() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); - return false; - } - if ( checkPermission && !info.isReadable() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_READ_PERMISSION_DENIED" ).arg( dirName ) ); - return false; - } - return true; -} - -/*! - \brief Check if the specified directory can be written. - - If directory does not exists or can not be modified (if \a checkPermission is \c true) - and parent() is not null, shows error message box. - - \param dirName directory path - \param checkPermission if \c true (default) check also directory permissions - \return \c false if directory does not exist or if it does not have - write permissions (if \a checkPermission is \c true) -*/ -bool SUIT_FileValidator::canWriteDir( const QString& dirName, bool checkPermission ) -{ - QFileInfo info( dirName ); - if ( !info.exists() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); - return false; - } - if ( !info.isDir() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); - return false; - } - if ( checkPermission && !info.isWritable() ) { - if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_WRITE_PERMISSION_DENIED" ).arg( dirName ) ); - return false; - } - return true; -} - -/*! - \brief Get parent widget. - \return parent widget -*/ -QWidget* SUIT_FileValidator::parent() const -{ - return myParent; -} diff --git a/src/SUITT/SUIT_FileValidator.h b/src/SUITT/SUIT_FileValidator.h deleted file mode 100755 index 4c59b02d3..000000000 --- a/src/SUITT/SUIT_FileValidator.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 : SUIT_FileValidator.h -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// -#ifndef SUIT_FILEVALIDATOR_H -#define SUIT_FILEVALIDATOR_H - -#include "SUIT.h" - -class QWidget; -class QString; - -class SUIT_EXPORT SUIT_FileValidator -{ -public: - SUIT_FileValidator( QWidget* = 0 ); - - virtual bool canOpen( const QString&, bool = true ); - virtual bool canSave( const QString&, bool = true ); - - virtual bool canReadDir( const QString&, bool = true ); - virtual bool canWriteDir( const QString&, bool = true ); - - QWidget* parent() const; - -private: - QWidget* myParent; -}; - -#endif // SUIT_FILEVALIDATOR_H diff --git a/src/SUITT/SUIT_MessageBox.cxx b/src/SUITT/SUIT_MessageBox.cxx deleted file mode 100755 index 348d8a864..000000000 --- a/src/SUITT/SUIT_MessageBox.cxx +++ /dev/null @@ -1,1131 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 -// - -#include "SUIT_MessageBox.h" - -#include "SUIT_OverrideCursor.h" - -#include -#include -#include -#include - -#include - -/*! - \class SUIT_MessageBox - \brief Message dialog box for SUIT-based application - - The class provides a modal dialog with a short message, an icon, - and buttons laid out depending on the current style. - - Message boxes are used to provide informative messages and to ask - simple questions. - - The easiest way to pop up a message box is to call one of the static - functions information(), question(), critical(), and warning(). - - The class provides the static functions to show message boxes with - standard buttons (like \c Ok, \c Cancel, \c Apply, \c Close, \c Yes, - \c No, \c Abort, \c Retry, etc). These methods accept ORed buttons - flags as one of the parameters. The buttons layouting type and order - is system-dependant and defined by the current style. In addition, - these methods allow to define default button (where input focus is - set by default and which is clicked when user presses \c Enter key). - - Another set of static functions allows to show message boxes with - up to four user-defined buttons. It is possible to define default - and escape buttons using additional parameters. - - And finally, the last group of static functions allow displaying - the message boxes with an arbitrary number of buttons. - - For example: - \code - // show question message box with two standard buttons - int result = SUIT_MessageBox::question(desktop(), "Error", - "File already exists? Overwrite?", - SUIT_MessageBox::Yes | SUIT_MessageBox::No, - SUIT_MessageBox::No ); - if ( result == SUIT_MessageBox::Yes ) - overwriteFileFunction(); - - // show critical message box with user-defined buttons - // default is second button and escape is third button - int result = SUIT_MessageBox::critical(desktop(), "Hazard!", - "The situation is critical! What to do?", - "Hide", "Run Away", "Stand still", 1, 2); - switch ( result ) - { - case 0: - hideMyself(); break; - case 1: - runAwayFromHere(); break; - case 2: - sitDownAndPray(); break; - default: - break; - } - - // show message box with 6 buttons - // both default and escape buttons are set to first button ("Zero") - int result = SUIT_MessageBox::information(desktop(), "Question", - "Select your favourite number", - 0, 0, - "Zero", "One", "Two", "Three", "Four", "Five"); - useMyFavouriteNumberSomewhere( result ); - \endcode -*/ - -/*! - \brief Constructor. - \param parent parent widget -*/ -SUIT_MessageBox::SUIT_MessageBox( QWidget* parent ) -: QMessageBox( parent ) -{ -} - -/*! - \brief Constructor. - \param icon message box icon (QMessageBox::Icon) - \param title message box title - \param text message box text - \param buttons ORed message box standard buttons (QMessageBox::StandardButton) - \param parent parent widget - \param f window flags -*/ -SUIT_MessageBox::SUIT_MessageBox( Icon icon, const QString& title, const QString& text, - StandardButtons buttons, QWidget* parent, Qt::WindowFlags f ) -: QMessageBox( icon, title, text, buttons, parent, f ) -{ -} - -/*! - \brief Destructor. -*/ -SUIT_MessageBox::~SUIT_MessageBox() -{ -} - -/*! - \brief Get the standard button text. - \param btn standard button id - \return button text -*/ -QString SUIT_MessageBox::buttonText( StandardButton btn ) const -{ - QString res; - QAbstractButton* b = button( btn ); - if ( b ) - res = b->text(); - return res; -} - -/*! - \brief Set the standard button text. - \param btn standard button id - \param text new button text -*/ -void SUIT_MessageBox::setButtonText( StandardButton btn, const QString& text ) -{ - QAbstractButton* b = button( btn ); - if ( b ) - b->setText( text ); -} - -/*! - \brief Show critical message box with specified standard buttons. - \param parent parent widget - \param title message box title - \param text message box text - \param buttons ORed message box buttons (QMessageBox::StandardButton) - \param defaultButton default button (QMessageBox::StandardButton) - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -SUIT_MessageBox::StandardButton SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons, StandardButton defaultButton ) -{ - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - return QMessageBox::critical( parent, title, text, buttons, defaultButton ); -} - -/*! - \brief Show warning message box with specified standard buttons. - \param parent parent widget - \param title message box title - \param text message box text - \param buttons ORed message box buttons (QMessageBox::StandardButton) - \param defaultButton default button (QMessageBox::StandardButton) - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -SUIT_MessageBox::StandardButton SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - SUIT_MessageBox::StandardButtons buttons, StandardButton defaultButton ) -{ - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - return QMessageBox::warning( parent, title, text, buttons, defaultButton ); -} - -/*! - \brief Show information message box with specified standard buttons. - \param parent parent widget - \param title message box title - \param text message box text - \param buttons ORed message box buttons (QMessageBox::StandardButton) - \param defaultButton default button (QMessageBox::StandardButton) - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -SUIT_MessageBox::StandardButton SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons, StandardButton defaultButton ) -{ - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - return QMessageBox::information( parent, title, text, buttons, defaultButton ); -} - -/*! - \brief Show question message box with specified standard buttons. - \param parent parent widget - \param title message box title - \param text message box text - \param buttons ORed message box buttons (QMessageBox::StandardButton) - \param defaultButton default button (QMessageBox::StandardButton) - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -SUIT_MessageBox::StandardButton SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons, StandardButton defaultButton ) -{ - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - return QMessageBox::question( parent, title, text, buttons, defaultButton ); -} - -/*! - \brief Show critical message box with one custom button. - - Specified button becomes "default" button and "escape" button, i.e. - pressing \c Return or \c Enter and \c Escape keys is equivalent to clicking - this button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button button text - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const QString& button ) -{ - ButtonInfos lst; - lst.append( ButtonInfo( 0, button ) ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst ); -} - -/*! - \brief Show warning message box with one custom button. - - Specified button becomes "default" button and "escape" button, i.e. - pressing \c Return or \c Enter and \c Escape keys is equivalent to clicking - this button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button button text - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const QString& button ) -{ - ButtonInfos lst; - lst.append( ButtonInfo( 0, button ) ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst ); -} - -/*! - \brief Show information message box with one custom button. - - Specified button becomes "default" button and "escape" button, i.e. - pressing \c Return or \c Enter and \c Escape keys is equivalent to clicking - this button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button button text - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const QString& button ) -{ - ButtonInfos lst; - lst.append( ButtonInfo( 0, button ) ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, lst ); -} - -/*! - \brief Show question message box with one custom button. - - \warning This function does not make a lot of sense because it provides - message box with only one button, i.e. it is impossible to give several - answers for the question (at least 'yes'/'no'). - This function is implemented only for completeness. - - Specified button becomes "default" button and "escape" button, i.e. - pressing \c Return or \c Enter and \c Escape keys is equivalent to clicking - this button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button button text - \return button id clicked by the user (QMessageBox::StandardButton) -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const QString& button ) -{ - ButtonInfos lst; - lst.append( ButtonInfo( 0, button ) ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, lst ); -} - -/*! - \brief Show critical message box with two custom buttons. - - Parameters \a button1 and \a button2 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the second one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show warning message box with two custom buttons. - - Parameters \a button1 and \a button2 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the second one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show information message box with two custom buttons. - - Parameters \a button1 and \a button2 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the second one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show question message box with two custom buttons. - - Parameters \a button1 and \a button2 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the second one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show critical message box with three custom buttons. - - Parameters \a button1, \a button2 and \a button3 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show warning message box with three custom buttons. - - Parameters \a button1, \a button2 and \a button3 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show information message box with three custom buttons. - - Parameters \a button1, \a button2 and \a button3 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show question message box with three custom buttons. - - Parameters \a button1, \a button2 and \a button3 specify the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show critical message box with four custom buttons. - - Parameters \a button1, \a button2, \a button3 and \a button4 specify - the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param button4 fourth button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - lst.append( ButtonInfo( id++, button4 ) ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show warning message box with four custom buttons. - - Parameters \a button1, \a button2, \a button3 and \a button4 specify - the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param button4 fourth button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - lst.append( ButtonInfo( id++, button4 ) ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show information message box with four custom buttons. - - Parameters \a button1, \a button2, \a button3 and \a button4 specify - the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param button4 fourth button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - lst.append( ButtonInfo( id++, button4 ) ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show question message box with four custom buttons. - - Parameters \a button1, \a button2, \a button3 and \a button4 specify - the buttons text. - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param button1 first button text - \param button2 second button text - \param button3 third button text - \param button4 fourth button text - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - lst.append( ButtonInfo( id++, button1 ) ); - lst.append( ButtonInfo( id++, button2 ) ); - lst.append( ButtonInfo( id++, button3 ) ); - lst.append( ButtonInfo( id++, button4 ) ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show critical message box with arbitrary number of user-specified - buttons. - - List of buttons to be shown is specified via \a buttons parameter. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param buttons list of buttons to be shown - \return button used button id -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - Q_FOREACH( QString button, buttons ) - lst.append( ButtonInfo( id++, button ) ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show warning message box with arbitrary number of user-specified - buttons. - - List of buttons to be shown is specified via \a buttons parameter. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param buttons list of buttons to be shown - \return button used button id -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - Q_FOREACH( QString button, buttons ) - lst.append( ButtonInfo( id++, button ) ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show information message box with arbitrary number of user-specified - buttons. - - List of buttons to be shown is specified via \a buttons parameter. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param buttons list of buttons to be shown - \return button used button id -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - Q_FOREACH( QString button, buttons ) - lst.append( ButtonInfo( id++, button ) ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show question message box with arbitrary number of user-specified - buttons. - - List of buttons to be shown is specified via \a buttons parameter. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param buttons list of buttons to be shown - \return button used button id -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton, const int escapeButton ) -{ - ButtonInfos lst; - int id = 0; - Q_FOREACH( QString button, buttons ) - lst.append( ButtonInfo( id++, button ) ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, lst, - defaultButton, escapeButton ); -} - -/*! - \brief Show critical message box with arbitrary number of user-specified - buttons. - - The function accepts arbitrary number of parameters. Each parameter starting - from \a btn should be of type const char* to specify the button text. - After the last button parameter and additional 0 (zero) value should be - specified. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param btn first button text - \return button used button id -*/ -int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char* btn, ... ) -{ - va_list args; - va_start( args, btn ); - return messageBox( SUIT_MessageBox::Critical, parent, title, text, - messageList( btn, args ), - defaultButton, escapeButton ); -} - -/*! - \brief Show warning message box with arbitrary number of user-specified - buttons. - - The function accepts arbitrary number of parameters. Each parameter starting - from \a btn should be of type const char* to specify the button text. - After the last button parameter and additional 0 (zero) value should be - specified. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param btn first button text - \return button used button id -*/ -int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char* btn, ... ) -{ - va_list args; - va_start( args, btn ); - return messageBox( SUIT_MessageBox::Warning, parent, title, text, - messageList( btn, args ), - defaultButton, escapeButton ); -} - -/*! - \brief Show information message box with arbitrary number of user-specified - buttons. - - The function accepts arbitrary number of parameters. Each parameter starting - from \a btn should be of type const char* to specify the button text. - After the last button parameter and additional 0 (zero) value should be - specified. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param btn first button text - \return button used button id -*/ -int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char* btn, ... ) -{ - va_list args; - va_start( args, btn ); - return messageBox( SUIT_MessageBox::Information, parent, title, text, - messageList( btn, args ), - defaultButton, escapeButton ); -} - -/*! - \brief Show question message box with arbitrary number of user-specified - buttons. - - The function accepts arbitrary number of parameters. Each parameter starting - from \a btn should be of type const char* to specify the button text. - After the last button parameter and additional 0 (zero) value should be - specified. - - The function returns clicked button id. The identifiers for the buttons - are assigned automatically. The first button is identified as 0, the - second one as 1, etc. - - The \a defaultButton parameter allows to specify the button which is assigned - for the \c Return or \c Enter key. Similarly, \a escapeButton parameter - allows specifing the button which is assigned for \c Escape key. - If these parameters are not specified (-1 by default), the first button - is set as default button and the last one is defined as escape button. - - \param parent parent widget - \param title message box title - \param text message box text - \param defaultButton default button - \param escapeButton escape button - \param btn first button text - \return button used button id -*/ -int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char* btn, ... ) -{ - va_list args; - va_start( args, btn ); - return messageBox( SUIT_MessageBox::Question, parent, title, text, - messageList( btn, args ), - defaultButton, escapeButton ); -} - -/*! - \brief Parse arbitrary arguments list. - - The last parameter in a sequence should be 0 (zero) value. - - \param txt first argument which starts arbitrary sequence - \param args arguments list from the stack - \return list of buttons infos -*/ -SUIT_MessageBox::ButtonInfos SUIT_MessageBox::messageList( char* txt, va_list& args ) -{ - int i = 0; - ButtonInfos lst; - char* cur = txt; - while ( cur ) - { - lst.append( ButtonInfo( i++, cur ) ); - cur = va_arg( args, char* ); - } - - va_end( args ); - - return lst; -} - -/*! - \brief Create and show the message box. - \param icon icon type - \param parent parent widget - \param title message box title - \param text message box text - \param lst list of buttons infos - \param defaultButton default button - \param escapeButton escape button - \return button used button id -*/ -int SUIT_MessageBox::messageBox( Icon icon, QWidget* parent, - const QString& title, const QString& text, - const ButtonInfos& lst, - const int defaultButton, - const int escapeButton ) -{ - SUIT_MessageBox msgBox( icon, title, text, NoButton, parent ); - - QMap bm; - for ( int i = 0; i < lst.count(); i++ ) - { - int btn = lst[i].id(); - QString txt = lst[i].text(); - ButtonRole role = lst[i].role(); - - QPushButton* pb = msgBox.addButton( txt, role ); - bm.insert( pb, btn ); - - if ( ( defaultButton == -1 && i == 0 ) || btn == defaultButton ) - msgBox.setDefaultButton( pb ); - if ( ( escapeButton == -1 && i == lst.count() - 1 ) || btn == escapeButton ) - msgBox.setEscapeButton( pb ); - } - - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - int res = msgBox.exec(); - if ( res != -1 ) - res = bm[msgBox.clickedButton()]; - - QApplication::processEvents(); - - return res; -} - diff --git a/src/SUITT/SUIT_MessageBox.h b/src/SUITT/SUIT_MessageBox.h deleted file mode 100755 index b00040ceb..000000000 --- a/src/SUITT/SUIT_MessageBox.h +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 SUIT_MESSAGEBOX_H -#define SUIT_MESSAGEBOX_H - -#include "SUIT.h" - -#include -#include -#include - -class SUIT_EXPORT SUIT_MessageBox : public QMessageBox -{ - Q_OBJECT -public: - // construction/destruction - SUIT_MessageBox( QWidget* = 0 ); - SUIT_MessageBox( Icon, const QString&, const QString&, StandardButtons buttons = NoButton, - QWidget* = 0, Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint ); - ~SUIT_MessageBox(); - - // customize the standard buttons text - QString buttonText( StandardButton ) const; - void setButtonText( StandardButton, const QString& ); - - // message box with standard buttons - static StandardButton critical( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); - static StandardButton warning( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); - static StandardButton information( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); - static StandardButton question( QWidget* parent, const QString& title, const QString& text, - StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); - - // message boxes with one custom button - static int critical( QWidget* parent, const QString& title, const QString& text, - const QString& button ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const QString& button ); - static int information( QWidget* parent, const QString& title, const QString& text, - const QString& button ); - static int question( QWidget* parent, const QString& title, const QString& text, - const QString& button ); - - // message boxes with two custom buttons - static int critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton = -1, const int escapeButton = -1 ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton = -1, const int escapeButton = -1 ); - static int information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton = -1, const int escapeButton = -1 ); - static int question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const int defaultButton = -1, const int escapeButton = -1 ); - - // message boxes with three custom buttons - static int critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, const QString& button3, - const int defaultButton = -1, const int escapeButton = -1 ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, const QString& button3, - const int defaultButton = -1, const int escapeButton = -1 ); - static int information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, const QString& button3, - const int defaultButton = -1, const int escapeButton = -1 ); - static int question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, const QString& button3, - const int defaultButton = -1, const int escapeButton = -1 ); - - // message boxes with four custom buttons - static int critical( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton = -1, const int escapeButton = -1 ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton = -1, const int escapeButton = -1 ); - static int information( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton = -1, const int escapeButton = -1 ); - static int question( QWidget* parent, const QString& title, const QString& text, - const QString& button1, const QString& button2, - const QString& button3, const QString& button4, - const int defaultButton = -1, const int escapeButton = -1 ); - - // message boxes with arbitrary number of buttons - static int critical( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton = -1, const int escapeButton = -1 ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton = -1, const int escapeButton = -1 ); - static int information( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton = -1, const int escapeButton = -1 ); - static int question( QWidget* parent, const QString& title, const QString& text, - const QStringList& buttons, - const int defaultButton = -1, const int escapeButton = -1 ); - - static int critical( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char*, ... ); - static int warning( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char*, ... ); - static int information( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char*, ... ); - static int question( QWidget* parent, const QString& title, const QString& text, - const int defaultButton, const int escapeButton, - char*, ... ); - -private: - class ButtonInfo - { - public: - ButtonInfo( const int id, - const QString& text, - const ButtonRole role = ActionRole ) - : myId( id ), myText( text ), myRole( role ) {} - int id() const { return myId; } - QString text() const { return myText; } - ButtonRole role() const { return myRole; } - private: - int myId; //!< button id - QString myText; //!< button text - ButtonRole myRole; //!< button role - }; - - typedef QList ButtonInfos; - -private: - static int messageBox( SUIT_MessageBox::Icon icon, QWidget* parent, - const QString& title, const QString& text, - const ButtonInfos& lst, - const int defaultButton = -1, - const int escapeButton = -1 ); - static ButtonInfos messageList( char*, va_list& ); -}; - -#endif diff --git a/src/SUITT/SUIT_OverrideCursor.cxx b/src/SUITT/SUIT_OverrideCursor.cxx deleted file mode 100755 index aaf50903a..000000000 --- a/src/SUITT/SUIT_OverrideCursor.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 -// - -#include "SUIT_OverrideCursor.h" - -#include - -/*!Constructor. Initialize wait cursor.*/ -SUIT_OverrideCursor::SUIT_OverrideCursor() -{ - QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); -} - -/*!Copy constructor.*/ -SUIT_OverrideCursor::SUIT_OverrideCursor( const QCursor& cursor ) -{ - QApplication::setOverrideCursor( cursor ); -} - -/*!Destructor. restoring override cursor.*/ -SUIT_OverrideCursor::~SUIT_OverrideCursor() -{ - QApplication::restoreOverrideCursor(); -} - -/*! Check cursors is empty */ -bool SUIT_OverrideCursor::isActive() const -{ - return myCursors.isEmpty(); -} - -/*!Suspend cursors.*/ -void SUIT_OverrideCursor::suspend() -{ - if ( !isActive() ) - return; - - while ( QApplication::overrideCursor() ) - { - myCursors.prepend( *QApplication::overrideCursor() ); - QApplication::restoreOverrideCursor(); - } -} - -/*!Resume cursors.*/ -void SUIT_OverrideCursor::resume() -{ - if ( isActive() ) - return; - - for ( QList::const_iterator it = myCursors.begin(); it != myCursors.end(); ++it ) - QApplication::setOverrideCursor( *it ); - - myCursors.clear(); -} diff --git a/src/SUITT/SUIT_OverrideCursor.h b/src/SUITT/SUIT_OverrideCursor.h deleted file mode 100755 index d5f4d5b70..000000000 --- a/src/SUITT/SUIT_OverrideCursor.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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, or (at your option) any later version. -// -// 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 SUIT_OVERRIDECURSOR_H -#define SUIT_OVERRIDECURSOR_H - -#include "SUIT.h" - -#include -#include - -/*! \brief Class used for management cursors.*/ -class SUIT_EXPORT SUIT_OverrideCursor -{ -public: - SUIT_OverrideCursor(); - SUIT_OverrideCursor( const QCursor& ); - virtual ~SUIT_OverrideCursor(); - - bool isActive() const; - void suspend(); - void resume(); - -private: - QList myCursors; -}; - -#endif