Changeset 561 for trunk/src/gui/widgets/qabstractbutton.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qabstractbutton.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 166 166 #endif 167 167 checkable(false), checked(false), autoRepeat(false), autoExclusive(false), 168 down(false), blockRefresh(false), 168 down(false), blockRefresh(false), 169 169 #ifndef QT_NO_BUTTONGROUP 170 170 group(0), … … 216 216 } 217 217 218 /*! 219 Adds the given \a button to the end of the group's internal list of buttons. 220 221 \sa removeButton() 222 */ 218 219 // TODO: Qt 5: Merge with addButton(QAbstractButton *button, int id) 223 220 void QButtonGroup::addButton(QAbstractButton *button) 224 221 { … … 233 230 button->d_func()->group = this; 234 231 d->buttonList.append(button); 235 if (id != -1) 232 if (id == -1) { 233 QList<int> ids = d->mapping.values(); 234 if (ids.isEmpty()) 235 d->mapping[button] = -2; 236 else { 237 qSort(ids); 238 d->mapping[button] = ids.first()-1; 239 } 240 } else { 236 241 d->mapping[button] = id; 242 243 237 244 if (d->exclusive && button->isChecked()) 238 245 button->d_func()->notifyChecked(); … … 313 320 #endif 314 321 315 Q_Q(const QAbstractButton); 316 QList<QAbstractButton*>candidates; 317 if (q->parentWidget()) { 318 candidates = qFindChildren<QAbstractButton *>(q->parentWidget()); 319 if (autoExclusive) { 320 for (int i = candidates.count() - 1; i >= 0; --i) { 321 QAbstractButton *candidate = candidates.at(i); 322 if (!candidate->autoExclusive() 323 #ifndef QT_NO_BUTTONGROUP 324 || candidate->group() 325 #endif 326 ) 327 candidates.removeAt(i); 328 } 322 QList<QAbstractButton*>candidates = qFindChildren<QAbstractButton *>(parent); 323 if (autoExclusive) { 324 for (int i = candidates.count() - 1; i >= 0; --i) { 325 QAbstractButton *candidate = candidates.at(i); 326 if (!candidate->autoExclusive() 327 #ifndef QT_NO_BUTTONGROUP 328 || candidate->group() 329 #endif 330 ) 331 candidates.removeAt(i); 329 332 } 330 333 } … … 377 380 bool exclusive = autoExclusive; 378 381 #endif 379 QWidget *f = qApp->focusWidget();382 QWidget *f = focusWidget(); 380 383 QAbstractButton *fb = qobject_cast<QAbstractButton *>(f); 381 384 if (!fb || !buttonList.contains(fb)) … … 1088 1091 if (hitButton(e->pos())) { 1089 1092 setDown(true); 1093 1090 1094 repaint(); //flush paint event before invoking potentially expensive operation 1091 1095 QApplication::flush(); … … 1101 1105 { 1102 1106 Q_D(QAbstractButton); 1107 1108 1103 1109 if (e->button() != Qt::LeftButton) { 1104 1110 e->ignore(); … … 1125 1131 { 1126 1132 Q_D(QAbstractButton); 1127 if (!(e->buttons() & Qt::LeftButton) ) {1133 if (!(e->buttons() & Qt::LeftButton)) { 1128 1134 e->ignore(); 1129 1135 return; … … 1170 1176 case Qt::Key_Down: 1171 1177 #ifdef QT_KEYPAD_NAVIGATION 1172 if (QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right)) { 1178 if ((QApplication::keypadNavigationEnabled() 1179 && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right)) 1180 || (!QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional 1181 || (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down))) { 1173 1182 e->ignore(); 1174 1183 return; … … 1237 1246 if (d->down) { 1238 1247 QPointer<QAbstractButton> guard(this); 1239 d->emitReleased(); 1248 nextCheckState(); 1249 if (guard) 1250 d->emitReleased(); 1240 1251 if (guard) 1241 1252 d->emitClicked();
Note:
See TracChangeset
for help on using the changeset viewer.