Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qabstractbutton.cpp

    r2 r561  
    22**
    33** 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])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    166166#endif
    167167    checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
    168     down(false), blockRefresh(false),
     168    down(false), blockRefresh(false),
    169169#ifndef QT_NO_BUTTONGROUP
    170170    group(0),
     
    216216}
    217217
    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)
    223220void QButtonGroup::addButton(QAbstractButton *button)
    224221{
     
    233230    button->d_func()->group = this;
    234231    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 {
    236241        d->mapping[button] = id;
     242
     243
    237244    if (d->exclusive && button->isChecked())
    238245        button->d_func()->notifyChecked();
     
    313320#endif
    314321
    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);
    329332        }
    330333    }
     
    377380    bool exclusive = autoExclusive;
    378381#endif
    379     QWidget *f = qApp->focusWidget();
     382    QWidget *f = focusWidget();
    380383    QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);
    381384    if (!fb || !buttonList.contains(fb))
     
    10881091    if (hitButton(e->pos())) {
    10891092        setDown(true);
     1093
    10901094        repaint(); //flush paint event before invoking potentially expensive operation
    10911095        QApplication::flush();
     
    11011105{
    11021106    Q_D(QAbstractButton);
     1107
     1108
    11031109    if (e->button() != Qt::LeftButton) {
    11041110        e->ignore();
     
    11251131{
    11261132    Q_D(QAbstractButton);
    1127     if (!(e->buttons() & Qt::LeftButton)) {
     1133    if (!(e->buttons() & Qt::LeftButton)) {
    11281134        e->ignore();
    11291135        return;
     
    11701176    case Qt::Key_Down:
    11711177#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))) {
    11731182            e->ignore();
    11741183            return;
     
    12371246        if (d->down) {
    12381247            QPointer<QAbstractButton> guard(this);
    1239             d->emitReleased();
     1248            nextCheckState();
     1249            if (guard)
     1250                d->emitReleased();
    12401251            if (guard)
    12411252                d->emitClicked();
Note: See TracChangeset for help on using the changeset viewer.