42 #include <QtCore/qhash.h> 43 #include <QtGui/qpushbutton.h> 44 #include <QtGui/qstyle.h> 45 #include <QtGui/qlayout.h> 46 #include <QtGui/qdialog.h> 47 #include <QtGui/qapplication.h> 48 #include <QtGui/private/qwidget_p.h> 49 #include <QtGui/qaction.h> 53 #ifdef QT_SOFTKEYS_ENABLED 54 #include <QtGui/qaction.h> 223 {
ResetRole,
Stretch,
YesRole,
AcceptRole,
AlternateRole,
DestructiveRole,
NoRole,
ActionRole,
RejectRole,
ApplyRole,
239 {
ResetRole,
ApplyRole,
ActionRole,
Stretch,
HelpRole,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL, EOL }
261 {
ActionRole,
ApplyRole,
ResetRole,
Stretch,
HelpRole,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL,
EOL, EOL }
265 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 266 class QDialogButtonEnabledProxy :
public QObject 271 source->installEventFilter(
this);
272 target->setEnabled(source->isEnabled());
274 ~QDialogButtonEnabledProxy()
276 source->removeEventFilter(
this);
281 target->setEnabled(source->isEnabled());
300 #ifdef QT_SOFTKEYS_ENABLED 310 void createStandardButtons(QDialogButtonBox::StandardButtons
buttons);
312 void layoutButtons();
317 void _q_handleButtonDestroyed();
318 void _q_handleButtonClicked();
320 void retranslateStrings();
322 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 328 : orientation(orient), buttonLayout(0), internalRemove(false),
center(false)
339 if (createNewLayout) {
356 q->setSizePolicy(sp);
374 int start = reverse ? buttonList.
count() - 1 : 0;
375 int end = reverse ? -1 : buttonList.
count();
376 int step = reverse ? -1 : 1;
378 for (
int i = start; i !=
end; i += step) {
388 const int MacGap = 36 - 8;
399 static const int M = 5;
402 bool hasModalButton =
false;
403 for (
int i = 0; i <
M; ++i) {
405 hasModalButton =
true;
420 while (*currentLayout !=
EOL) {
421 int role = (*currentLayout & ~
Reverse);
440 if (acceptRoleList.
size() < 2)
506 const char *buttonText = 0;
558 QStyle *style = q->style();
567 qWarning(
"QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
587 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 588 QAction *action = createSoftKey(button, role);
589 softKeyActions.insert(button, action);
590 new QDialogButtonEnabledProxy(action, button, action);
596 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 629 if ((dialog = qobject_cast<QDialog *>(p)))
636 q->addAction(action);
657 const char *buttonText = 0;
727 const char *buttonText = 0;
734 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 735 QAction *action = softKeyActions.value(button, 0);
752 d_func()->initLayout();
763 d_func()->initLayout();
776 d_func()->initLayout();
777 d_func()->createStandardButtons(buttons);
931 return d_func()->orientation;
937 if (orientation ==
d->orientation)
952 #ifdef QT_SOFTKEYS_ENABLED 955 d->softKeyActions.clear();
959 d->standardButtonHash.clear();
960 for (
int i = 0; i <
NRoles; ++i) {
962 while (list.
count()) {
979 for (
int i = 0; i <
NRoles; ++i) {
981 for (
int j = 0; j < list.
count(); ++j)
996 for (
int i = 0; i <
NRoles; ++i) {
998 for (
int j = 0; j < list.
count(); ++j) {
1019 if (
QPushButton *pushButton = qobject_cast<QPushButton *>(button))
1020 d->standardButtonHash.remove(pushButton);
1021 for (
int i = 0; i <
NRoles; ++i) {
1023 for (
int j = 0; j < list.
count(); ++j) {
1026 if (!
d->internalRemove) {
1034 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 1035 QAction *action =
d->softKeyActions.value(button, 0);
1037 d->softKeyActions.remove(button);
1041 if (!
d->internalRemove)
1059 if (role <= InvalidRole || role >=
NRoles) {
1060 qWarning(
"QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
1065 d->addButton(button, role);
1078 if (role <= InvalidRole || role >=
NRoles) {
1079 qWarning(
"QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
1083 d->addButton(button, role);
1097 return d->createButton(button);
1114 #ifdef QT_SOFTKEYS_ENABLED 1117 d->softKeyActions.clear();
1121 d->standardButtonHash.clear();
1123 d->createStandardButtons(buttons);
1131 while (it !=
d->standardButtonHash.constEnd()) {
1132 standardButtons |= it.
value();
1147 return d->standardButtonHash.key(which);
1159 return d->standardButtonHash.value(static_cast<QPushButton *>(button));
1165 if (
QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
1166 emit q->clicked(button);
1168 switch (q->buttonRole(button)) {
1178 emit q->helpRequested();
1191 q->removeButton(static_cast<QAbstractButton *>(
object));
1212 if (
d->center != center) {
1232 switch (event->
type()) {
1234 if (!
d->standardButtonHash.empty()) {
1236 const StandardButtonHash::iterator
end =
d->standardButtonHash.end();
1237 for (StandardButtonHash::iterator
it =
d->standardButtonHash.begin();
it !=
end; ++
it)
1238 it.key()->setStyle(newStyle);
1262 bool hasDefault =
false;
1267 if ((dialog = qobject_cast<QDialog *>(p)))
1271 foreach (
QPushButton *pb, (dialog ? dialog :
this)->findChildren<QPushButton *>()) {
1272 if (pb->
isDefault() && pb != firstAcceptButton) {
1277 if (!hasDefault && firstAcceptButton)
1279 #ifdef QT_SOFTKEYS_ENABLED 1284 d->retranslateStrings();
1286 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 1292 if ((dialog = qobject_cast<QDialog *>(p)))
1298 it !=
d->softKeyActions.constEnd(); ++
it) {
1316 #include "moc_qdialogbuttonbox.cpp"
T qobject_cast(QObject *object)
QLayoutItem * itemAt(int) const
Reimplemented Function
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
The QBoxLayout class lines up child widgets horizontally or vertically.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
#define it(className, varName)
static C reverse(const C &l)
static Qt::MouseButtons buttons
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
static QStyle * style()
Returns the application's style object.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const T value(const Key &key) const
Returns the value associated with the key.
StandardPixmap
This enum describes the available standard pixmaps.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
QList< QWidget * > associatedWidgets() const
Returns a list of widgets this action has been added to.
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
void append(const T &t)
Inserts value at the end of the list.
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
static bool isEmpty(const char *str)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
int count() const
Reimplemented Function
void setSoftKeyRole(SoftKeyRole softKeyRole)
const T & at(int i) const
Returns the item at index position i in the list.
const T & value() const
Returns the current item's value.
Q_CORE_EXPORT void qWarning(const char *,...)
void setText(const QString &text)
void removeFirst()
Removes the first item in the list.
SoftKeyRole
This enum describes how an action should be placed in the softkey bar.
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
T & first()
Returns a reference to the first item in the list.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
QLayoutItem * takeAt(int)
Reimplemented Function
#define Q_DECLARE_PUBLIC(Class)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout...
const Key key(const T &value) const
Returns the first key mapped to value.
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
QObject * parent() const
Returns a pointer to the parent object.
int size() const
Returns the number of items in the list.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
T takeAt(int i)
Removes the item at index position i and returns it.
The QHBoxLayout class lines up widgets horizontally.
void setContentsMargins(int left, int top, int right, int bottom)
Sets the left, top, right, and bottom margins to use around the layout.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
The QVBoxLayout class lines up widgets vertically.
static const KeyPair *const end
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
The QAction class provides an abstract user interface action that can be inserted into widgets...
The QList class is a template class that provides lists.