From: vsr Date: Mon, 14 May 2007 13:23:14 +0000 (+0000) Subject: Porting to Qt4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=05b0763ceebce932d82787e9177628ebf92154ce;p=modules%2Fgui.git Porting to Qt4 --- diff --git a/src/SUIT/SUIT_ExceptionHandler.cxx b/src/SUIT/SUIT_ExceptionHandler.cxx index 7a5083c91..ef0047ab7 100755 --- a/src/SUIT/SUIT_ExceptionHandler.cxx +++ b/src/SUIT/SUIT_ExceptionHandler.cxx @@ -20,7 +20,7 @@ #include "SUIT_MessageBox.h" -#include +#include /*!\class SUIT_ExceptionHandler * Show exception message on error handler. @@ -53,5 +53,5 @@ void SUIT_ExceptionHandler::showMessage( const QString& title, const QString& ms while ( QApplication::overrideCursor() ) QApplication::restoreOverrideCursor(); - SUIT_MessageBox::error1( qApp->mainWidget(), title, msg, "OK" ); + SUIT_MessageBox::error1( 0, title, msg, "OK" ); } diff --git a/src/SUIT/SUIT_FileDlg.cxx b/src/SUIT/SUIT_FileDlg.cxx index 7fb1ee7c6..89887fbb5 100755 --- a/src/SUIT/SUIT_FileDlg.cxx +++ b/src/SUIT/SUIT_FileDlg.cxx @@ -66,19 +66,18 @@ #include "SUIT_Tools.h" #include "SUIT_Session.h" -#include "SUIT_Desktop.h" #include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" #include "SUIT_FileValidator.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define MIN_COMBO_SIZE 100 @@ -90,39 +89,50 @@ const bool IGNORE_NON_MATCHING_EXTENSION = true; QString SUIT_FileDlg::myLastVisitedPath; /*! Constructor */ -SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool modal ) : -QFileDialog( parent, 0, modal ), +SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool modal ) +: QFileDialog( parent ), +myOpen( open ), myValidator( 0 ), -myQuickCombo( 0 ), myQuickButton( 0 ), myQuickLab( 0 ), -myOpen( open )//, +myQuickLab( 0 ), +myQuickCombo( 0 ), +myQuickButton( 0 )//, //myAccepted( false ) -{ - const QObjectList* child = children(); - QObjectList::const_iterator anIt = child->begin(), aLast = child->end(); - for( ; anIt!=aLast; anIt++ ) - if( (*anIt)->inherits( "QPushButton" ) ) +{ + setModal( modal ); + + const QObjectList& child = children(); + for ( QObjectList::const_iterator anIt = child.begin(); anIt != child.end(); ++anIt ) + { + QPushButton* pb = ::qobject_cast( *anIt ); + if ( pb ) { - QPushButton* bt = ( QPushButton* )( *anIt ); - bt->setDefault( false ); - bt->setAutoDefault( false ); + pb->setDefault( false ); + pb->setAutoDefault( false ); } + } - if ( parent->icon() ) - setIcon( *parent->icon() ); + if ( parent ) + setWindowIcon( parent->windowIcon() ); setSizeGripEnabled( true ); - if ( showQuickDir ) { + QGridLayout* grid = ::qobject_cast( layout() ); + if ( showQuickDir && grid ) + { // inserting quick dir combo box - myQuickLab = new QLabel(tr("LAB_QUICK_PATH"), this); - myQuickCombo = new QComboBox(false, this); - myQuickCombo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - myQuickCombo->setMinimumSize(MIN_COMBO_SIZE, 0); + myQuickLab = new QLabel( tr( "LAB_QUICK_PATH" ), this ); + myQuickCombo = new QComboBox( this ); + myQuickCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myQuickCombo->setMinimumSize( MIN_COMBO_SIZE, 0 ); - myQuickButton = new QPushButton(tr("BUT_ADD_PATH"), this); + myQuickButton = new QPushButton( tr( "BUT_ADD_PATH" ), this ); + + connect( myQuickCombo, SIGNAL( activated( const QString& ) ), this, SLOT( quickDir( const QString& ) ) ); + connect( myQuickButton, SIGNAL( clicked() ), this, SLOT( addQuickDir() ) ); - connect(myQuickCombo, SIGNAL(activated(const QString&)), this, SLOT(quickDir(const QString&))); - connect(myQuickButton, SIGNAL(clicked()), this, SLOT(addQuickDir())); - addWidgets(myQuickLab, myQuickCombo, myQuickButton); + int row = grid->rowCount(); + grid->addWidget( myQuickLab, row, 0 ); + grid->addWidget( myQuickCombo, row, 1, 1, 3 ); + grid->addWidget( myQuickButton, row, 5 ); // getting dir list from settings QString dirs; @@ -130,27 +140,29 @@ myOpen( open )//, if ( resMgr ) dirs = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) ); - QStringList dirList = QStringList::split(';', dirs, false); - if (dirList.count() > 0) { - for (unsigned i = 0; i < dirList.count(); i++) - myQuickCombo->insertItem(dirList[i]); - } - else { - myQuickCombo->insertItem(QDir::homeDirPath()); + QStringList dirList = dirs.split( ';' ); + if ( dirList.count() > 0 ) + { + for ( int i = 0; i < dirList.count(); i++ ) + myQuickCombo->addItem( dirList[i] ); } + else + myQuickCombo->addItem( QDir::homePath() ); } - setMode( myOpen ? ExistingFile : AnyFile ); - setCaption( myOpen ? tr( "INF_DESK_DOC_OPEN" ) : tr( "INF_DESK_DOC_SAVE" ) ); + setAcceptMode( myOpen ? AcceptOpen: AcceptSave ); + setWindowTitle( myOpen ? tr( "INF_DESK_DOC_OPEN" ) : tr( "INF_DESK_DOC_SAVE" ) ); // If last visited path doesn't exist -> switch to the first preferred path - if ( !myLastVisitedPath.isEmpty() ) { + if ( !myLastVisitedPath.isEmpty() ) + { if ( !processPath( myLastVisitedPath ) && showQuickDir ) - processPath( myQuickCombo->text( 0 ) ); + processPath( myQuickCombo->itemText( 0 ) ); } - else { + else + { if ( showQuickDir ) - processPath(myQuickCombo->text( 0 ) ); - } + processPath( myQuickCombo->itemText( 0 ) ); + } // set default file validator myValidator = new SUIT_FileValidator(this); @@ -162,11 +174,22 @@ SUIT_FileDlg::~SUIT_FileDlg() setValidator( 0 ); } +bool SUIT_FileDlg::event( QEvent* e ) +{ + bool res = QFileDialog::event( e ); + + if ( e->type() == QEvent::Polish ) + polish(); + + return res; +} + /*! Redefined from QFileDialog.*/ void SUIT_FileDlg::polish() { - QFileDialog::polish(); - if ( myQuickButton && myQuickLab ) { +/* + if ( myQuickButton && myQuickLab ) + { // the following is a workaround for proper layouting of custom widgets QValueList buttonList; QValueList labelList; @@ -198,6 +221,7 @@ void SUIT_FileDlg::polish() (*lListIt)->setFixedWidth( maxLabWidth ); } } +*/ } /*! Sets validator for file names to open/save @@ -236,13 +260,19 @@ void SUIT_FileDlg::accept() * (e.g. permission denied) */ // if ( !myAccepted ) { - if ( mode() != ExistingFiles ) { - mySelectedFile = QFileDialog::selectedFile(); + if ( acceptMode() != AcceptOpen ) + { + QString fn; + QStringList lst = QFileDialog::selectedFiles(); + if ( !lst.isEmpty() ) + fn = lst.first(); + mySelectedFile = fn; addExtension(); } - if ( acceptData() ) { - myLastVisitedPath = dirPath(); + if ( acceptData() ) + { + myLastVisitedPath = directory().path(); QFileDialog::accept(); // myAccepted = true; } @@ -268,7 +298,7 @@ bool SUIT_FileDlg::acceptData() { if ( isOpenDlg() ) { - if ( mode() == ExistingFiles ) + if ( acceptMode() == AcceptOpen ) { QStringList fileNames = selectedFiles(); for ( int i = 0; i < (int)fileNames.count(); i++ ) @@ -296,11 +326,11 @@ bool SUIT_FileDlg::acceptData() void SUIT_FileDlg::addExtension() { // check if file name entered is empty - if ( mySelectedFile.stripWhiteSpace().isEmpty() ) + if ( mySelectedFile.trimmed().isEmpty() ) return; // current file extension - QString anExt = "." + SUIT_Tools::extension( mySelectedFile.stripWhiteSpace() ).stripWhiteSpace(); + QString anExt = "." + SUIT_Tools::extension( mySelectedFile.trimmed() ).trimmed(); // If the file already has extension and it does not match the filter there are two choices: // - to leave it 'as is' @@ -309,14 +339,8 @@ void SUIT_FileDlg::addExtension() if ( anExt != "." && !IGNORE_NON_MATCHING_EXTENSION ) return; - // get selected file filter -#if QT_VERSION < 0x030000 - QRegExp r( QString::fromLatin1("(?[a-zA-Z0-9.*? +;#|]*)?$") ); - int len, index = r.match( selectedFilter().stripWhiteSpace(), 0, &len ); -#else QRegExp r( QString::fromLatin1("\\(?[a-zA-Z0-9.*? +;#|]*\\)?$") ); - int index = r.search( selectedFilter().stripWhiteSpace() ); -#endif + int index = r.indexIn( selectedFilter().trimmed() ); if ( index >= 0 ) { // Create wildcard regular expression basing on selected filter @@ -324,23 +348,20 @@ void SUIT_FileDlg::addExtension() // Due to transformations from the filter list (*.txt *.*xx *.c++ SUIT*.* ) we // will have the pattern (\.txt|\..*xx|\.c\+\+|\..*) (as we validate extension only, // we remove everything except extension mask from the pattern -#if QT_VERSION < 0x030000 - QString wildcard = selectedFilter().mid( index, len ).stripWhiteSpace(); -#else - QString wildcard = selectedFilter().mid( index, r.matchedLength() ).stripWhiteSpace(); -#endif + QString wildcard = selectedFilter().mid( index, r.matchedLength() ).trimmed(); // replace '|' and ';' separators by space symbol and also brackets if there are some wildcard.replace( QRegExp( "[\\|;|(|)]" )," " ); - QString aPattern = wildcard.replace( QRegExp( "(^| )(\\s*)[0-9a-zA-Z*_?]*\\."), " \\." ).stripWhiteSpace(). + QString aPattern = wildcard.replace( QRegExp( "(^| )(\\s*)[0-9a-zA-Z*_?]*\\."), " \\." ).trimmed(). replace( QRegExp( "\\s+" ), "|" ).replace( QRegExp( "[?]" ),".?" ). replace( QRegExp( "[*]" ),".*" ).replace( QRegExp( "[+]" ),"\\+" ); // now we get the list of all extension masks and remove all which does not contain wildcard symbols - QStringList extList = QStringList::split( "|",aPattern ); - for( int i = extList.count() - 1; i >= 0; i-- ) { + QStringList extList = aPattern.split( "|", QString::SkipEmptyParts ); + for ( int i = extList.count() - 1; i >= 0; i-- ) + { if ( !extList[i].contains( "." ) ) - extList.remove( extList.at( i ) ); + extList.removeAt( i ); } aPattern = extList.join( "|" ); @@ -348,19 +369,19 @@ void SUIT_FileDlg::addExtension() QRegExp anExtRExp( "^("+ aPattern + ")$" ); // Check if the current file extension matches the pattern - if ( anExtRExp.match( anExt ) < 0 ) + if ( !anExtRExp.exactMatch( anExt ) ) { // find first appropriate extension in the selected filter // (it should be without wildcard symbols) for ( int i = 0; i < (int)extList.count(); i++ ) { QString newExt = extList[i].replace( QRegExp( "[\\\\][+]" ),"+" ); - int res = newExt.findRev( '.' ); + int res = newExt.lastIndexOf( '.' ); if ( res >= 0 ) newExt = newExt.mid( res + 1 ); - if ( newExt.find( QRegExp("[*|?]" ) ) < 0 ) + if ( newExt.indexOf( QRegExp("[*|?]" ) ) < 0 ) { - mySelectedFile.stripWhiteSpace(); + mySelectedFile.trimmed(); mySelectedFile += mySelectedFile.endsWith(".") ? newExt : QString(".") + newExt; break; } @@ -372,20 +393,24 @@ void SUIT_FileDlg::addExtension() /*! Processes selection : tries to set given path or filename as selection */ bool SUIT_FileDlg::processPath( const QString& path ) { - if ( !path.isNull() ) { + if ( !path.isNull() ) + { QFileInfo fi( path ); - if ( fi.exists() ) { + if ( fi.exists() ) + { if ( fi.isFile() ) - setSelection( path ); + selectFile( path ); else if ( fi.isDir() ) - setDir( path ); + setDirectory( path ); return true; } - else { - if ( QFileInfo( fi.dirPath() ).exists() ) { - setDir( fi.dirPath() ); - setSelection( path ); - return true; + else + { + if ( QFileInfo( SUIT_Tools::dir( path ) ).exists() ) + { + setDirectory( SUIT_Tools::dir( path ) ); + selectFile( path ); + return true; } } } @@ -395,8 +420,9 @@ bool SUIT_FileDlg::processPath( const QString& path ) void SUIT_FileDlg::quickDir(const QString& dirPath) { QString aPath = dirPath; - if ( !QDir(aPath).exists() ) { - aPath = QDir::homeDirPath(); + if ( !QDir(aPath).exists() ) + { + aPath = QDir::homePath(); SUIT_MessageBox::error1(this, tr("ERR_ERROR"), tr("ERR_DIR_NOT_EXIST").arg(dirPath), @@ -411,129 +437,115 @@ void SUIT_FileDlg::quickDir(const QString& dirPath) */ void SUIT_FileDlg::addQuickDir() { - QString dp = dirPath(); - if ( !dp.isEmpty() ) { + QString dp = directory().path(); + if ( !dp.isEmpty() ) + { QDir dir( dp ); // getting dir list from settings QString dirs; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if ( resMgr ) dirs = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) ); - QStringList dirList = QStringList::split(';', dirs, false); + QStringList dirList = dirs.split( ';', QString::SkipEmptyParts ); bool found = false; bool emptyAndHome = false; - if ( dirList.count() > 0 ) { - for ( unsigned i = 0; i < dirList.count(); i++ ) { - QDir aDir( dirList[i] ); - if ( aDir.canonicalPath().isNull() && dirList[i] == dir.absPath() || - !aDir.canonicalPath().isNull() && aDir.exists() && aDir.canonicalPath() == dir.canonicalPath() ) { - found = true; - break; - } + if ( dirList.count() > 0 ) + { + for ( int i = 0; i < dirList.count(); i++ ) + { + QDir aDir( dirList[i] ); + if ( aDir.canonicalPath().isNull() && dirList[i] == dir.absolutePath() || + !aDir.canonicalPath().isNull() && aDir.exists() && aDir.canonicalPath() == dir.canonicalPath() ) + { + found = true; + break; + } } } - else { - emptyAndHome = dir.canonicalPath() == QDir(QDir::homeDirPath()).canonicalPath(); - } - if ( !found ) { + else + emptyAndHome = dir.canonicalPath() == QDir( QDir::homePath() ).canonicalPath(); + + if ( !found ) + { dirList.append( dp ); - resMgr->setValue( "FileDlg", QString( "QuickDirList" ), dirList.join(";") ); + resMgr->setValue( "FileDlg", QString( "QuickDirList" ), dirList.join( ";" ) ); if ( !emptyAndHome ) - myQuickCombo->insertItem( dp ); + myQuickCombo->addItem( dp ); } } } /*! Returns the file name for Open/Save [ static ] */ -QString SUIT_FileDlg::getFileName( QWidget* parent, - const QString& initial, - const QStringList& filters, - const QString& caption, - bool open, - bool showQuickDir, - SUIT_FileValidator* validator ) +QString SUIT_FileDlg::getFileName( QWidget* parent, const QString& initial, const QStringList& filters, + const QString& caption, bool open, bool showQuickDir, + SUIT_FileValidator* validator ) { SUIT_FileDlg* fd = new SUIT_FileDlg( parent, open, showQuickDir, true ); if ( !caption.isEmpty() ) - fd->setCaption( caption ); - if ( !initial.isEmpty() ) { + fd->setWindowTitle( caption ); + if ( !initial.isEmpty() ) fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug - } - fd->setFilters( filters ); + + fd->setFilters( filters ); if ( validator ) fd->setValidator( validator ); + fd->exec(); + QString filename = fd->selectedFile(); delete fd; - qApp->processEvents(); + + QApplication::processEvents(); + return filename; } - /*! Returns the list of files to be opened [ static ] */ -QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, - const QString& initial, - const QStringList& filters, - const QString& caption, - bool showQuickDir, - SUIT_FileValidator* validator ) +QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters, + const QString& caption, bool showQuickDir, SUIT_FileValidator* validator ) { SUIT_FileDlg* fd = new SUIT_FileDlg( parent, true, showQuickDir, true ); - fd->setMode( ExistingFiles ); + fd->setFileMode( ExistingFiles ); if ( !caption.isEmpty() ) - fd->setCaption( caption ); - if ( !initial.isEmpty() ) { + fd->setWindowTitle( caption ); + if ( !initial.isEmpty() ) fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug - } + fd->setFilters( filters ); if ( validator ) fd->setValidator( validator ); + fd->exec(); QStringList filenames = fd->selectedFiles(); delete fd; - qApp->processEvents(); + + QApplication::processEvents(); return filenames; } /*! Existing directory selection dialog [ static ] */ -QString SUIT_FileDlg::getExistingDirectory( QWidget* parent, - const QString& initial, - const QString& caption, - bool showQuickDir ) +QString SUIT_FileDlg::getExistingDirectory( QWidget* parent, const QString& initial, + const QString& caption, bool showQuickDir ) { - SUIT_FileDlg* fd = new SUIT_FileDlg( parent, true, showQuickDir, true); + SUIT_FileDlg* fd = new SUIT_FileDlg( parent, true, showQuickDir, true ); if ( !caption.isEmpty() ) - fd->setCaption( caption ); - if ( !initial.isEmpty() ) { + fd->setWindowTitle( caption ); + if ( !initial.isEmpty() ) fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug - } - fd->setMode( DirectoryOnly ); - fd->setFilters(tr("INF_DIRECTORIES_FILTER")); + + fd->setFileMode( DirectoryOnly ); + fd->setFilters( QStringList( tr( "INF_DIRECTORIES_FILTER" ) ) ); + fd->exec(); + QString dirname = fd->selectedFile(); delete fd; - qApp->processEvents(); - return dirname; - -} - -/*! - QFileDialog::dirPath() has a bug on Linux Debian (1 level up from correct - directory is returned). This function fixes the bug. -*/ -QString SUIT_FileDlg::dirPath() const -{ - if ( !mySelectedFile.isNull() ) - return QFileInfo( mySelectedFile ).dirPath(); - const QDir* aDir = dir(); - if ( aDir->exists() ) - return aDir->absPath(); - - return QFileDialog::dirPath(); + QApplication::processEvents(); + return dirname; } diff --git a/src/SUIT/SUIT_FileDlg.h b/src/SUIT/SUIT_FileDlg.h index 044188003..c2d7e4c44 100755 --- a/src/SUIT/SUIT_FileDlg.h +++ b/src/SUIT/SUIT_FileDlg.h @@ -21,7 +21,7 @@ #include "SUIT.h" -#include +#include class QLabel; class QComboBox; @@ -45,9 +45,6 @@ public: void setValidator( SUIT_FileValidator* ); - QString dirPath() const; // QFileDialog::dirPath() has a bug on Linux Debian (1 level up from correct - // directory is returned). This redefinition fixes the bug. - static QString getFileName( QWidget* parent, const QString& initial, const QStringList& filters, const QString& caption, const bool open, const bool showQuickDir = true, SUIT_FileValidator* validator = 0 ); @@ -57,10 +54,8 @@ public: static QString getExistingDirectory( QWidget* parent, const QString& initial, const QString& caption, const bool showQuickDir = true ); -public slots: - void polish(); - private: + void polish(); bool acceptData(); void addExtension(); bool processPath( const QString& path ); @@ -71,6 +66,9 @@ protected slots: void quickDir( const QString& ); void addQuickDir(); +protected: + virtual bool event( QEvent* ); + protected: bool myOpen; //!< open/save selector QString mySelectedFile; //!< selected filename diff --git a/src/SUIT/SUIT_FileValidator.cxx b/src/SUIT/SUIT_FileValidator.cxx index ab09fc665..9cafdd513 100755 --- a/src/SUIT/SUIT_FileValidator.cxx +++ b/src/SUIT/SUIT_FileValidator.cxx @@ -16,18 +16,12 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// File : SUIT_FileValidator.cxx -// Module : SALOME -// $Header$ - #include "SUIT_FileValidator.h" + #include "SUIT_MessageBox.h" -#include "SUIT_Session.h" -#include -#include +#include +#include /*! constructor */ SUIT_FileValidator::SUIT_FileValidator(QWidget* parent) : @@ -79,17 +73,19 @@ bool SUIT_FileValidator::canSave( const QString& file ) return false; } } - else { + else + { // if file doesn't exist - try to create it QFile qf( file ); - if ( !qf.open( IO_WriteOnly ) ) { - SUIT_MessageBox::error1( myParent, - QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), - QObject::tr( "BUT_OK" ) ); + if ( !qf.open( QFile::WriteOnly ) ) + { + SUIT_MessageBox::error1( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), + QObject::tr( "BUT_OK" ) ); return false; } - else { + else + { // remove just created file qf.close(); qf.remove(); @@ -97,4 +93,3 @@ bool SUIT_FileValidator::canSave( const QString& file ) } return true; } - diff --git a/src/SUIT/SUIT_FileValidator.h b/src/SUIT/SUIT_FileValidator.h index 197f6a2ab..9142c381d 100755 --- a/src/SUIT/SUIT_FileValidator.h +++ b/src/SUIT/SUIT_FileValidator.h @@ -18,15 +18,14 @@ // // SALOME SALOMEGUI : implementation of desktop and GUI kernel // -// File : SUIT_FileValidator.h -// Module : SALOME - #ifndef SUIT_FILEVALIDATOR_H #define SUIT_FILEVALIDATOR_H -#include #include "SUIT.h" +class QWidget; +class QString; + /*! \class SUIT_FileValidator Provides functionality to check file diff --git a/src/SUIT/SUIT_MessageBox.cxx b/src/SUIT/SUIT_MessageBox.cxx index e80ff74f0..a6e7829a5 100755 --- a/src/SUIT/SUIT_MessageBox.cxx +++ b/src/SUIT/SUIT_MessageBox.cxx @@ -25,23 +25,22 @@ */ #include "SUIT_MessageBox.h" + #include "SUIT_OverrideCursor.h" -#include -#include +#include +#include /*! Shows info message box with one button [ static ] */ -int SUIT_MessageBox::info1( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0 ) +int SUIT_MessageBox::info1( QWidget* parent, const QString& caption, + const QString& text, const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); int ret = QMessageBox::information( parent, caption, text, textButton0, QString::null, QString::null, 0, 0 ); - qApp->processEvents(); + QApplication::processEvents(); return ret; } @@ -53,10 +52,10 @@ int SUIT_MessageBox::warn1( QWidget* parent, const QString& text, const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); int ret = QMessageBox::warning( parent, caption, text, textButton0, QString::null, QString::null, 0, 0 ); - qApp->processEvents(); + QApplication::processEvents(); return ret; } @@ -68,10 +67,10 @@ int SUIT_MessageBox::error1( QWidget* parent, const QString& text, const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); int ret = QMessageBox::critical( parent, caption, text, textButton0, QString::null, QString::null, 0, 0 ); - qApp->processEvents(); + QApplication::processEvents(); return ret; } @@ -83,10 +82,10 @@ int SUIT_MessageBox::question1( QWidget* parent, const QString& text, const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); int ret = QMessageBox::question( parent, caption, text, textButton0, QString::null, QString::null, 0, 0 ); - qApp->processEvents(); + QApplication::processEvents(); return ret; } @@ -101,7 +100,7 @@ int SUIT_MessageBox::info2( QWidget* parent, const QString& textButton1, int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; else if ( idDefault == idButton1 ) @@ -111,7 +110,7 @@ int SUIT_MessageBox::info2( QWidget* parent, int ret = QMessageBox::information( parent, caption, text, textButton0, textButton1, QString::null, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); return ( ret == 0 ? idButton0 : idButton1 ); } @@ -126,7 +125,7 @@ int SUIT_MessageBox::warn2( QWidget* parent, const QString& textButton1, int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -137,7 +136,7 @@ int SUIT_MessageBox::warn2( QWidget* parent, int ret = QMessageBox::warning( parent, caption, text, textButton0, textButton1, QString::null, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); return ( ret == 0 ? idButton0 : idButton1 ); } @@ -152,7 +151,7 @@ int SUIT_MessageBox::error2( QWidget* parent, const QString& textButton1, int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -163,7 +162,7 @@ int SUIT_MessageBox::error2( QWidget* parent, int ret = QMessageBox::critical( parent, caption, text, textButton0, textButton1, QString::null, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); return ( ret == 0 ? idButton0 : idButton1 ); } @@ -178,7 +177,7 @@ int SUIT_MessageBox::question2( QWidget* parent, const QString& textButton1, int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -189,7 +188,7 @@ int SUIT_MessageBox::question2( QWidget* parent, int ret = QMessageBox::question( parent, caption, text, textButton0, textButton1, QString::null, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); return ( ret == 0 ? idButton0 : idButton1 ); } @@ -206,7 +205,7 @@ int SUIT_MessageBox::info3( QWidget* parent, int idButton0, int idButton1, int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -219,7 +218,7 @@ int SUIT_MessageBox::info3( QWidget* parent, int ret = QMessageBox::information( parent, caption, text, textButton0, textButton1, textButton2, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); switch ( ret ) { case 0: @@ -245,7 +244,7 @@ int SUIT_MessageBox::warn3( QWidget* parent, int idButton0, int idButton1, int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -258,7 +257,7 @@ int SUIT_MessageBox::warn3( QWidget* parent, int ret = QMessageBox::warning( parent, caption, text, textButton0, textButton1, textButton2, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); switch ( ret ) { case 0: @@ -284,7 +283,7 @@ int SUIT_MessageBox::error3( QWidget* parent, int idButton0, int idButton1, int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -297,7 +296,7 @@ int SUIT_MessageBox::error3( QWidget* parent, int ret = QMessageBox::critical( parent, caption, text, textButton0, textButton1, textButton2, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); switch ( ret ) { case 0: @@ -323,7 +322,7 @@ int SUIT_MessageBox::question3( QWidget* parent, int idButton0, int idButton1, int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); if ( idDefault == idButton0 ) idDefault = 0; @@ -336,7 +335,7 @@ int SUIT_MessageBox::question3( QWidget* parent, int ret = QMessageBox::question( parent, caption, text, textButton0, textButton1, textButton2, idDefault ); - qApp->processEvents(); + QApplication::processEvents(); switch ( ret ) { case 0: diff --git a/src/SUIT/SUIT_MessageBox.h b/src/SUIT/SUIT_MessageBox.h index 24b350605..714938c1f 100755 --- a/src/SUIT/SUIT_MessageBox.h +++ b/src/SUIT/SUIT_MessageBox.h @@ -22,8 +22,8 @@ #include "SUIT.h" -#include -#include +class QWidget; +class QString; #define SUIT_OK 1 #define SUIT_CANCEL 2