Changeset 561 for trunk/src/gui/util/qcompleter.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/util/qcompleter.cpp
r172 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 ** … … 159 159 QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent) 160 160 : QAbstractProxyModel(*new QCompletionModelPrivate, parent), 161 c(c), engine(0),showAll(false)161 c(c), showAll(false) 162 162 { 163 163 createEngine(); … … 209 209 } 210 210 211 delete engine;212 211 if (sortedEngine) 213 engine = new QSortedModelEngine(c);212 engine.reset(new QSortedModelEngine(c)); 214 213 else 215 engine = new QUnsortedModelEngine(c);214 engine.reset(new QUnsortedModelEngine(c)); 216 215 } 217 216 … … 483 482 QString str = source->index(i, c->column).data().toString(); 484 483 if (str.startsWith(c->prefix, c->cs) 485 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))484 #if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2) 486 485 && (!dirModel || QDir::toNativeSeparators(str) != QDir::separator()) 487 486 #endif … … 773 772 QCompleterPrivate::QCompleterPrivate() 774 773 : widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0), 775 sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)774 maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true) 776 775 { 777 776 } … … 825 824 QString completion; 826 825 827 if (!index.isValid() || ( index.row() >= proxy->engine->matchCount())) {826 if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) { 828 827 completion = prefix; 829 828 } else { 829 if (!(index.flags() & Qt::ItemIsEnabled)) 830 return; 830 831 QModelIndex si = proxy->mapToSource(index); 831 832 si = si.sibling(si.row(), column); // for clicked() … … 862 863 QPoint pos; 863 864 int rw, rh, w; 864 int h = (popup->sizeHintForRow(0) * qMin( 7, popup->model()->rowCount()) + 3) + 3;865 int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3; 865 866 QScrollBar *hsb = popup->horizontalScrollBar(); 866 867 if (hsb && hsb->isVisible()) … … 988 989 #ifndef QT_NO_DIRMODEL 989 990 if (qobject_cast<QDirModel *>(model)) { 990 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_ OS2)991 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2) 991 992 setCaseSensitivity(Qt::CaseInsensitive); 992 993 #else … … 1078 1079 if (popup->model() != d->proxy) 1079 1080 popup->setModel(d->proxy); 1080 popup->hide(); 1081 popup->setParent(0, Qt::Popup); 1082 1083 Qt::FocusPolicy origPolicy; 1081 #ifdef Q_OS_MAC 1082 popup->show(); 1083 #else 1084 popup->hide(); 1085 #endif 1086 1087 Qt::FocusPolicy origPolicy = Qt::NoFocus; 1084 1088 if (d->widget) 1085 1089 origPolicy = d->widget->focusPolicy(); 1090 popup->setParent(0, Qt::Popup); 1086 1091 popup->setFocusPolicy(Qt::NoFocus); 1087 1092 if (d->widget) … … 1099 1104 QObject::connect(popup, SIGNAL(clicked(QModelIndex)), 1100 1105 this, SLOT(_q_complete(QModelIndex))); 1101 QObject::connect(popup, SIGNAL(clicked(QModelIndex)), popup, SLOT(hide())); 1106 QObject::connect(this, SIGNAL(activated(QModelIndex)), 1107 popup, SLOT(hide())); 1102 1108 1103 1109 QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), … … 1179 1185 if (!curIndex.isValid()) { 1180 1186 int rowCount = d->proxy->rowCount(); 1181 QModelIndex lastIndex = d->proxy->index(rowCount - 1, 0);1187 QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column); 1182 1188 d->setCurrentIndex(lastIndex); 1183 1189 return true; … … 1191 1197 case Qt::Key_Down: 1192 1198 if (!curIndex.isValid()) { 1193 QModelIndex firstIndex = d->proxy->index(0, 0);1199 QModelIndex firstIndex = d->proxy->index(0, d->column); 1194 1200 d->setCurrentIndex(firstIndex); 1195 1201 return true; … … 1507 1513 1508 1514 /*! 1515 \property QCompleter::maxVisibleItems 1516 \brief the maximum allowed size on screen of the completer, measured in items 1517 \since 4.6 1518 1519 By default, this property has a value of 7. 1520 */ 1521 int QCompleter::maxVisibleItems() const 1522 { 1523 Q_D(const QCompleter); 1524 return d->maxVisibleItems; 1525 } 1526 1527 void QCompleter::setMaxVisibleItems(int maxItems) 1528 { 1529 Q_D(QCompleter); 1530 if (maxItems < 0) { 1531 qWarning("QCompleter::setMaxVisibleItems: " 1532 "Invalid max visible items (%d) must be >= 0", maxItems); 1533 return; 1534 } 1535 d->maxVisibleItems = maxItems; 1536 } 1537 1538 /*! 1509 1539 \property QCompleter::caseSensitivity 1510 1540 \brief the case sensitivity of the matching … … 1578 1608 that contains all the possible matches for the current completion prefix. 1579 1609 The completion model is auto-updated to reflect the current completions. 1610 1611 \note The return value of this function is defined to be an QAbstractItemModel 1612 purely for generality. This actual kind of model returned is an instance of an 1613 QAbstractProxyModel subclass. 1580 1614 1581 1615 \sa completionPrefix, model() … … 1621 1655 } while (idx.isValid()); 1622 1656 1623 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))1657 #if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2) 1624 1658 if (list.count() == 1) // only the separator or some other text 1625 1659 return list[0]; … … 1655 1689 QString pathCopy = QDir::toNativeSeparators(path); 1656 1690 QString sep = QDir::separator(); 1657 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2) 1691 #if defined(Q_OS_SYMBIAN) 1692 if (pathCopy == QLatin1String("\\")) 1693 return QStringList(pathCopy); 1694 #elif (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2) 1658 1695 if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\")) 1659 1696 return QStringList(pathCopy); … … 1665 1702 #endif 1666 1703 1667 QRegExp re(QLatin1 String("[") + QRegExp::escape(sep) + QLatin1String("]"));1704 QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); 1668 1705 QStringList parts = pathCopy.split(re); 1669 1706 1670 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2) 1707 #if defined(Q_OS_SYMBIAN) 1708 // Do nothing 1709 #elif (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2) 1671 1710 if (!doubleSlash.isEmpty()) 1672 1711 parts[0].prepend(doubleSlash);
Note:
See TracChangeset
for help on using the changeset viewer.