summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qabstractbutton.cpp
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2009-05-05 16:50:31 (GMT)
committerMaurice Kalinowski <maurice.kalinowski@nokia.com>2009-05-05 16:50:31 (GMT)
commit98d485b54d2da97b83b7ff2379b31039923f922e (patch)
tree887938de47713a3c48a0c12f753117d4a0d4b9ba /src/gui/widgets/qabstractbutton.cpp
parent2137f41ca0df3c83abce9dd386074e0fd09a33dc (diff)
downloadQt-98d485b54d2da97b83b7ff2379b31039923f922e.zip
Qt-98d485b54d2da97b83b7ff2379b31039923f922e.tar.gz
Qt-98d485b54d2da97b83b7ff2379b31039923f922e.tar.bz2
Fix behavior of QButtonGroup::addButton(QAbstractButton, int).
The method did not adhere to the documented behavior nor according to its precedessor in Qt 3 times. Now, when being passed -1 as argument, it will automatically assign ids. They will all be negative, starting from -2. Reviewed-by: mae <qt-info@nokia.com>
Diffstat (limited to 'src/gui/widgets/qabstractbutton.cpp')
-rw-r--r--src/gui/widgets/qabstractbutton.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index f2a9ceb..1900016 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -215,11 +215,8 @@ void QButtonGroup::setExclusive(bool exclusive)
d->exclusive = exclusive;
}
-/*!
- Adds the given \a button to the end of the group's internal list of buttons.
- \sa removeButton()
-*/
+// TODO: Qt 5: Merge with addButton(QAbstractButton *button, int id)
void QButtonGroup::addButton(QAbstractButton *button)
{
addButton(button, -1);
@@ -232,8 +229,18 @@ void QButtonGroup::addButton(QAbstractButton *button, int id)
previous->removeButton(button);
button->d_func()->group = this;
d->buttonList.append(button);
- if (id != -1)
+ if (id == -1) {
+ QList<int> ids = d->mapping.values();
+ if (ids.isEmpty())
+ d->mapping[button] = -2;
+ else {
+ qSort(ids);
+ d->mapping[button] = ids.first()-1;
+ }
+ } else {
d->mapping[button] = id;
+ }
+
if (d->exclusive && button->isChecked())
button->d_func()->notifyChecked();
}