src/gui/dialogs/qmessagebox.cpp File Reference

#include <QtGui/qmessagebox.h>
#include <QtGui/qdialogbuttonbox.h>
#include "private/qlabel_p.h"
#include <QtCore/qlist.h>
#include <QtGui/qstyle.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qgridlayout.h>
#include <QtGui/qdesktopwidget.h>
#include <QtGui/qpushbutton.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qicon.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qapplication.h>
#include <QtGui/qtextedit.h>
#include <QtGui/qmenu.h>
#include "qdialog_p.h"
#include <QDebug>
#include <QtGui/qfont.h>
#include <QtGui/qfontmetrics.h>
#include "moc_qmessagebox.cpp"

Include dependency graph for qmessagebox.cpp:

Go to the source code of this file.

Classes

class  QMessageBoxDetailsText
class  QMessageBoxDetailsText::TextEdit
class  QMessageBoxPrivate

Enumerations

enum  Button
enum  DetailButtonLabel

Functions

static int oldButton (int button)
static QMessageBox::StandardButton showNewMessageBox (QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
static QMessageBox::StandardButton newButton (int button)
static bool detectedCompat (int button0, int button1, int button2)

Variables

static const char *const qtlogo_xpm []
static QStringtranslatedTextAboutQt = 0


Enumeration Type Documentation

enum Button

Definition at line 47 of file qmessagebox.cpp.

00047             { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
00048               Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
00049               NewButtonFlag = 0xFFFFFC00 };

enum DetailButtonLabel

Definition at line 51 of file qmessagebox.cpp.

00051 { ShowLabel = 0, HideLabel = 1 };


Function Documentation

static bool detectedCompat ( int  button0,
int  button1,
int  button2 
) [static]

Definition at line 1467 of file qmessagebox.cpp.

References NewButtonFlag.

Referenced by QMessageBoxPrivate::addOldButtons().

01468 {
01469     if (button0 != 0 && !(button0 & NewButtonFlag))
01470         return true;
01471     if (button1 != 0 && !(button1 & NewButtonFlag))
01472         return true;
01473     if (button2 != 0 && !(button2 & NewButtonFlag))
01474         return true;
01475     return false;
01476 }

static QMessageBox::StandardButton newButton ( int  button  )  [static]

Definition at line 1434 of file qmessagebox.cpp.

References QMessageBox::Abort, QMessageBox::ButtonMask, QMessageBox::Cancel, QMessageBox::Ignore, NewButtonFlag, QMessageBox::No, QMessageBox::NoButton, QMessageBox::NoToAll, QMessageBox::Ok, Old_Abort, Old_ButtonMask, Old_Cancel, Old_Ignore, Old_No, Old_NoAll, Old_Ok, Old_Retry, Old_Yes, Old_YesAll, QMessageBox::Retry, QMessageBox::Yes, and QMessageBox::YesToAll.

Referenced by QMessageBoxPrivate::abstractButtonForId(), QMessageBoxPrivate::addOldButtons(), QMessageBoxPrivate::findButton(), and qdesigner_internal::StringListEditor::StringListEditor().

01435 {
01436     // this is needed for source compatibility with Qt 4.0 and 4.1
01437     if (button == QMessageBox::NoButton || (button & NewButtonFlag))
01438         return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
01439 
01440 #if QT_VERSION < 0x050000
01441     // this is needed for binary compatibility with Qt 4.0 and 4.1
01442     switch (button & Old_ButtonMask) {
01443     case Old_Ok:
01444         return QMessageBox::Ok;
01445     case Old_Cancel:
01446         return QMessageBox::Cancel;
01447     case Old_Yes:
01448         return QMessageBox::Yes;
01449     case Old_No:
01450         return QMessageBox::No;
01451     case Old_Abort:
01452         return QMessageBox::Abort;
01453     case Old_Retry:
01454         return QMessageBox::Retry;
01455     case Old_Ignore:
01456         return QMessageBox::Ignore;
01457     case Old_YesAll:
01458         return QMessageBox::YesToAll;
01459     case Old_NoAll:
01460         return QMessageBox::NoToAll;
01461     default:
01462         return QMessageBox::NoButton;
01463     }
01464 #endif
01465 }

static int oldButton ( int  button  )  [static]

Definition at line 396 of file qmessagebox.cpp.

References QMessageBox::Abort, QMessageBox::ButtonMask, QMessageBox::Cancel, QMessageBox::Ignore, QMessageBox::No, QMessageBox::NoToAll, QMessageBox::Ok, Old_Abort, Old_Cancel, Old_Ignore, Old_No, Old_NoAll, Old_Ok, Old_Retry, Old_Yes, Old_YesAll, QMessageBox::Retry, QMessageBox::Yes, and QMessageBox::YesToAll.

Referenced by QMessageBoxPrivate::execReturnCode().

00397 {
00398     switch (button & QMessageBox::ButtonMask) {
00399     case QMessageBox::Ok:
00400         return Old_Ok;
00401     case QMessageBox::Cancel:
00402         return Old_Cancel;
00403     case QMessageBox::Yes:
00404         return Old_Yes;
00405     case QMessageBox::No:
00406         return Old_No;
00407     case QMessageBox::Abort:
00408         return Old_Abort;
00409     case QMessageBox::Retry:
00410         return Old_Retry;
00411     case QMessageBox::Ignore:
00412         return Old_Ignore;
00413     case QMessageBox::YesToAll:
00414         return Old_YesAll;
00415     case QMessageBox::NoToAll:
00416         return Old_NoAll;
00417     default:
00418         return 0;
00419     }
00420 }

static QMessageBox::StandardButton showNewMessageBox ( QWidget parent,
QMessageBox::Icon  icon,
const QString title,
const QString text,
QMessageBox::StandardButtons  buttons,
QMessageBox::StandardButton  defaultButton 
) [static]

Definition at line 1206 of file qmessagebox.cpp.

References QDialogButtonBox::AcceptRole, QMessageBox::addButton(), QDialogButtonBox::buttonRole(), QMessageBox::Cancel, QMessageBox::clickedButton(), QMessageBox::defaultButton(), QDialog::exec(), QMessageBox::FirstButton, QMessageBox::LastButton, mask, QMessageBox::NoButton, QMessageBox::setDefaultButton(), QMessageBoxPrivate::showOldMessageBox(), and QMessageBox::standardButton().

Referenced by QMessageBox::critical(), QMessageBox::information(), QMessageBox::question(), and QMessageBox::warning().

01211 {
01212     // necessary for source compatibility with Qt 4.0 and 4.1
01213     // handles (Yes, No) and (Yes|Default, No)
01214     if (defaultButton && !(buttons & defaultButton))
01215         return (QMessageBox::StandardButton)
01216                     QMessageBoxPrivate::showOldMessageBox(parent, icon, title,
01217                                                             text, int(buttons),
01218                                                             int(defaultButton), 0);
01219 
01220     QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
01221     QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&msgBox);
01222     Q_ASSERT(buttonBox != 0);
01223 
01224     uint mask = QMessageBox::FirstButton;
01225     while (mask <= QMessageBox::LastButton) {
01226         uint sb = buttons & mask;
01227         mask <<= 1;
01228         if (!sb)
01229             continue;
01230         QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
01231         // Choose the first accept role as the default
01232         if (msgBox.defaultButton())
01233             continue;
01234         if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
01235             || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
01236             msgBox.setDefaultButton(button);
01237     }
01238     if (msgBox.exec() == -1)
01239         return QMessageBox::Cancel;
01240     return msgBox.standardButton(msgBox.clickedButton());
01241 }

Here is the call graph for this function:


Variable Documentation

const char* const qtlogo_xpm[] [static]

Definition at line 98 of file qmessagebox.cpp.

Referenced by QMessageBox::aboutQt().

QString* translatedTextAboutQt = 0 [static]

Definition at line 231 of file qmessagebox.cpp.

Referenced by QMessageBox::aboutQt(), and QMessageBoxPrivate::init().


Generated on Thu Mar 15 13:16:59 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1