From: vsr Date: Tue, 13 Dec 2005 15:13:14 +0000 (+0000) Subject: Provide additional static methods with standard Qt question icon (?). X-Git-Tag: T_3_1_0pre~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c84609854ea00e5efdccaed78658fd565e75078;p=modules%2Fgui.git Provide additional static methods with standard Qt question icon (?). --- diff --git a/src/SUIT/SUIT_MessageBox.cxx b/src/SUIT/SUIT_MessageBox.cxx index 9d38c0519..1d4d03cad 100755 --- a/src/SUIT/SUIT_MessageBox.cxx +++ b/src/SUIT/SUIT_MessageBox.cxx @@ -32,211 +32,318 @@ /*! 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 ); - int ret = QMessageBox::information( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::information( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows warning message box with one button [ static ] */ -int SUIT_MessageBox::warn1( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ) +int SUIT_MessageBox::warn1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - int ret = QMessageBox::warning( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::warning( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows error message box with one button [ static ] */ -int SUIT_MessageBox::error1( QWidget* parent, const QString& caption, - const QString& text, const QString& textButton0 ) +int SUIT_MessageBox::error1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - int ret = QMessageBox::critical( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::critical( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; +} + +/*! + Shows question message box with one button [ static ] +*/ +int SUIT_MessageBox::question1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::question( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows info message box with two buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::info2( QWidget* parent, const QString& caption, - const QString& text, const QString& textButton0, - const QString& textButton1, int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::info2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::information( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! - Shows warning message box with two buttons. + Shows warning message box with two buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::warn2( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::warn2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::warning( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! Shows error message box with two buttons Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::error2( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::error2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::critical( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); +} - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); +/*! + Shows question message box with two buttons + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int SUIT_MessageBox::question2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::question( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! Shows info message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::info3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::info3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::information( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } /*! Shows warning message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::warn3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::warn3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::warning( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } /*! Shows error message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::error3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::error3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::critical( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) + { + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; + } + return -1; +} - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) +/*! + Shows question message box with three buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int SUIT_MessageBox::question3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::question( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } diff --git a/src/SUIT/SUIT_MessageBox.h b/src/SUIT/SUIT_MessageBox.h index dd8dccd53..f8cf626be 100755 --- a/src/SUIT/SUIT_MessageBox.h +++ b/src/SUIT/SUIT_MessageBox.h @@ -48,6 +48,8 @@ public: const QString& textButton0 ); static int error1 ( QWidget* parent, const QString& caption, const QString& text, const QString& textButton0 ); + static int question1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ); //@} /** @name Two buttons message boxes.*/ @@ -61,6 +63,9 @@ public: static int error2 ( QWidget* parent, const QString& caption, const QString& text, const QString& textButton0, const QString& textButton1, int idButton0, int idButton1, int idDefault ); + static int question2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ); //@} /** @name Three buttons message boxes.*/ @@ -77,6 +82,10 @@ public: const QString& textButton0, const QString& textButton1, const QString& textButton2, int idButton0, int idButton1, int idButton2, int idDefault ); + static int question3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ); //@} };