Changeset 561 for trunk/src/gui/itemviews/qstyleditemdelegate.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/itemviews/qstyleditemdelegate.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 #include <qlineedit.h> 49 49 #include <qtextedit.h> 50 #include <qplaintextedit.h> 50 51 #include <qpainter.h> 51 52 #include <qpalette.h> … … 112 113 113 114 \ingroup model-view 114 \mainclass 115 115 116 \since 4.4 116 117 … … 148 149 \row \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead) 149 150 \row \o \l Qt::CheckStateRole \o Qt::CheckState 150 \row \o \l Qt::DecorationRole \o QIcon and QColor151 \row \o \l Qt::DecorationRole \o QIcon, QPixmap, QImage and QColor 151 152 \row \o \l Qt::DisplayRole \o QString and types with a string representation 152 153 \row \o \l Qt::EditRole \o See QItemEditorFactory for details … … 267 268 { 268 269 QString text; 269 switch (value.type()) { 270 switch (value.userType()) { 271 case QMetaType::Float: 270 272 case QVariant::Double: 271 text = locale.toString(value.to Double());273 text = locale.toString(value.toReal()); 272 274 break; 273 275 case QVariant::Int: … … 322 324 value = index.data(Qt::TextAlignmentRole); 323 325 if (value.isValid() && !value.isNull()) 324 option->displayAlignment = (Qt::Alignment)value.toInt();326 option->displayAlignment = Qt::Alignment(value.toInt()); 325 327 326 328 value = index.data(Qt::ForegroundRole); … … 508 510 509 511 /*! 510 Gets data drom the \a editor widget and stores it in the specified512 Gets data from the \a editor widget and stores it in the specified 511 513 \a model at the item \a index. 512 514 … … 647 649 case Qt::Key_Return: 648 650 #ifndef QT_NO_TEXTEDIT 649 if (qobject_cast<QTextEdit *>(editor))651 if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor)) 650 652 return false; // don't filter enter key events for QTextEdit 651 653 // We want the editor to be able to process the key press … … 671 673 editor->parentWidget()->setFocus(); 672 674 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())) { 674 676 //the Hide event will take care of he editors that are in fact complete dialogs 675 677 if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) { … … 686 688 return false; 687 689 #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 695 691 emit commitData(editor); 696 692 emit closeEditor(editor, NoHint); … … 752 748 } 753 749 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 755 755 ? Qt::Unchecked : Qt::Checked); 756 } 756 757 return model->setData(index, state, Qt::CheckStateRole); 757 758 }
Note:
See TracChangeset
for help on using the changeset viewer.