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/itemviews/qstyleditemdelegate.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4848#include <qlineedit.h>
    4949#include <qtextedit.h>
     50#include <qplaintextedit.h>
    5051#include <qpainter.h>
    5152#include <qpalette.h>
     
    112113
    113114    \ingroup model-view
    114     \mainclass
     115
    115116    \since 4.4
    116117
     
    148149    \row    \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead)
    149150    \row    \o \l Qt::CheckStateRole \o Qt::CheckState
    150     \row    \o \l Qt::DecorationRole \o QIcon and QColor
     151    \row    \o \l Qt::DecorationRole \o QIcon, QPixmap, QImage and QColor
    151152    \row    \o \l Qt::DisplayRole \o QString and types with a string representation
    152153    \row    \o \l Qt::EditRole \o See QItemEditorFactory for details
     
    267268{
    268269    QString text;
    269     switch (value.type()) {
     270    switch (value.userType()) {
     271    case QMetaType::Float:
    270272    case QVariant::Double:
    271         text = locale.toString(value.toDouble());
     273        text = locale.toString(value.toReal());
    272274        break;
    273275    case QVariant::Int:
     
    322324    value = index.data(Qt::TextAlignmentRole);
    323325    if (value.isValid() && !value.isNull())
    324         option->displayAlignment = (Qt::Alignment)value.toInt();
     326        option->displayAlignment = Qt::Alignment(value.toInt());
    325327
    326328    value = index.data(Qt::ForegroundRole);
     
    508510
    509511/*!
    510     Gets data drom the \a editor widget and stores it in the specified
     512    Gets data from the \a editor widget and stores it in the specified
    511513    \a model at the item \a index.
    512514
     
    647649        case Qt::Key_Return:
    648650#ifndef QT_NO_TEXTEDIT
    649             if (qobject_cast<QTextEdit*>(editor))
     651            if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
    650652                return false; // don't filter enter key events for QTextEdit
    651653            // We want the editor to be able to process the key press
     
    671673            editor->parentWidget()->setFocus();
    672674        return true;
    673     } else if (event->type() == QEvent::FocusOut || event->type() == QEvent::Hide) {
     675    } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) {
    674676        //the Hide event will take care of he editors that are in fact complete dialogs
    675677        if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) {
     
    686688                return false;
    687689#endif
    688             // Opening a modal dialog will start a new eventloop
    689             // that will process the deleteLater event.
    690             QWidget *activeModalWidget = QApplication::activeModalWidget();
    691             if (activeModalWidget
    692                 && !activeModalWidget->isAncestorOf(editor)
    693                 && qobject_cast<QDialog*>(activeModalWidget))
    694                 return false;
     690
    695691            emit commitData(editor);
    696692            emit closeEditor(editor, NoHint);
     
    752748    }
    753749
    754     Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
     750    Qt::CheckState state;
     751    if ( flags & Qt::ItemIsTristate ) {
     752        state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
     753    } else {
     754        state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
    755755                            ? Qt::Unchecked : Qt::Checked);
     756    }
    756757    return model->setData(index, state, Qt::CheckStateRole);
    757758}
Note: See TracChangeset for help on using the changeset viewer.