| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qcombobox.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_COMBOBOX | - |
| 45 | #include <qstylepainter.h> | - |
| 46 | #include <qpa/qplatformtheme.h> | - |
| 47 | #include <qlineedit.h> | - |
| 48 | #include <qapplication.h> | - |
| 49 | #include <qdesktopwidget.h> | - |
| 50 | #include <qlistview.h> | - |
| 51 | #include <qtableview.h> | - |
| 52 | #include <qitemdelegate.h> | - |
| 53 | #include <qmap.h> | - |
| 54 | #include <qmenu.h> | - |
| 55 | #include <qevent.h> | - |
| 56 | #include <qlayout.h> | - |
| 57 | #include <qscrollbar.h> | - |
| 58 | #include <qtreeview.h> | - |
| 59 | #include <qheaderview.h> | - |
| 60 | #include <qmath.h> | - |
| 61 | #include <qmetaobject.h> | - |
| 62 | #include <private/qguiapplication_p.h> | - |
| 63 | #include <private/qapplication_p.h> | - |
| 64 | #include <private/qcombobox_p.h> | - |
| 65 | #include <private/qabstractitemmodel_p.h> | - |
| 66 | #include <private/qabstractscrollarea_p.h> | - |
| 67 | #include <qdebug.h> | - |
| 68 | #if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) | - |
| 69 | #include <private/qcore_mac_p.h> | - |
| 70 | #include <private/qmacstyle_mac_p.h> | - |
| 71 | #include <private/qt_cocoa_helpers_mac_p.h> | - |
| 72 | #endif | - |
| 73 | #ifndef QT_NO_EFFECTS | - |
| 74 | # include <private/qeffects_p.h> | - |
| 75 | #endif | - |
| 76 | #ifndef QT_NO_ACCESSIBILITY | - |
| 77 | #include "qaccessible.h" | - |
| 78 | #endif | - |
| 79 | | - |
| 80 | QT_BEGIN_NAMESPACE | - |
| 81 | | - |
| 82 | QComboBoxPrivate::QComboBoxPrivate() | - |
| 83 | : QWidgetPrivate(), | - |
| 84 | model(0), | - |
| 85 | lineEdit(0), | - |
| 86 | container(0), | - |
| 87 | insertPolicy(QComboBox::InsertAtBottom), | - |
| 88 | sizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow), | - |
| 89 | minimumContentsLength(0), | - |
| 90 | shownOnce(false), | - |
| 91 | autoCompletion(true), | - |
| 92 | duplicatesEnabled(false), | - |
| 93 | frame(true), | - |
| 94 | maxVisibleItems(10), | - |
| 95 | maxCount(INT_MAX), | - |
| 96 | modelColumn(0), | - |
| 97 | inserting(false), | - |
| 98 | arrowState(QStyle::State_None), | - |
| 99 | hoverControl(QStyle::SC_None), | - |
| 100 | autoCompletionCaseSensitivity(Qt::CaseInsensitive), | - |
| 101 | indexBeforeChange(-1) | - |
| 102 | #ifndef QT_NO_COMPLETER | - |
| 103 | , completer(0) | - |
| 104 | #endif | - |
| 105 | { | - |
| 106 | } executed: }Execution Count:558 | 558 |
| 107 | | - |
| 108 | QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewItem &option, | - |
| 109 | const QModelIndex &index) const | - |
| 110 | { | - |
| 111 | QStyleOptionMenuItem menuOption; never executed (the execution status of this line is deduced): QStyleOptionMenuItem menuOption; | - |
| 112 | | - |
| 113 | QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); never executed (the execution status of this line is deduced): QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); | - |
| 114 | QVariant value = index.data(Qt::ForegroundRole); never executed (the execution status of this line is deduced): QVariant value = index.data(Qt::ForegroundRole); | - |
| 115 | if (value.canConvert<QBrush>()) { never evaluated: value.canConvert<QBrush>() | 0 |
| 116 | resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value)); never executed (the execution status of this line is deduced): resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value)); | - |
| 117 | resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value)); never executed (the execution status of this line is deduced): resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value)); | - |
| 118 | resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); never executed (the execution status of this line is deduced): resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); | - |
| 119 | } | 0 |
| 120 | menuOption.palette = resolvedpalette; never executed (the execution status of this line is deduced): menuOption.palette = resolvedpalette; | - |
| 121 | menuOption.state = QStyle::State_None; never executed (the execution status of this line is deduced): menuOption.state = QStyle::State_None; | - |
| 122 | if (mCombo->window()->isActiveWindow()) never evaluated: mCombo->window()->isActiveWindow() | 0 |
| 123 | menuOption.state = QStyle::State_Active; never executed: menuOption.state = QStyle::State_Active; | 0 |
| 124 | if ((option.state & QStyle::State_Enabled) && (index.model()->flags(index) & Qt::ItemIsEnabled)) never evaluated: (option.state & QStyle::State_Enabled) never evaluated: (index.model()->flags(index) & Qt::ItemIsEnabled) | 0 |
| 125 | menuOption.state |= QStyle::State_Enabled; never executed: menuOption.state |= QStyle::State_Enabled; | 0 |
| 126 | else | - |
| 127 | menuOption.palette.setCurrentColorGroup(QPalette::Disabled); never executed: menuOption.palette.setCurrentColorGroup(QPalette::Disabled); | 0 |
| 128 | if (option.state & QStyle::State_Selected) never evaluated: option.state & QStyle::State_Selected | 0 |
| 129 | menuOption.state |= QStyle::State_Selected; never executed: menuOption.state |= QStyle::State_Selected; | 0 |
| 130 | menuOption.checkType = QStyleOptionMenuItem::NonExclusive; never executed (the execution status of this line is deduced): menuOption.checkType = QStyleOptionMenuItem::NonExclusive; | - |
| 131 | menuOption.checked = mCombo->currentIndex() == index.row(); never executed (the execution status of this line is deduced): menuOption.checked = mCombo->currentIndex() == index.row(); | - |
| 132 | if (QComboBoxDelegate::isSeparator(index)) never evaluated: QComboBoxDelegate::isSeparator(index) | 0 |
| 133 | menuOption.menuItemType = QStyleOptionMenuItem::Separator; never executed: menuOption.menuItemType = QStyleOptionMenuItem::Separator; | 0 |
| 134 | else | - |
| 135 | menuOption.menuItemType = QStyleOptionMenuItem::Normal; never executed: menuOption.menuItemType = QStyleOptionMenuItem::Normal; | 0 |
| 136 | | - |
| 137 | QVariant variant = index.model()->data(index, Qt::DecorationRole); never executed (the execution status of this line is deduced): QVariant variant = index.model()->data(index, Qt::DecorationRole); | - |
| 138 | switch (variant.type()) { | - |
| 139 | case QVariant::Icon: | - |
| 140 | menuOption.icon = qvariant_cast<QIcon>(variant); never executed (the execution status of this line is deduced): menuOption.icon = qvariant_cast<QIcon>(variant); | - |
| 141 | break; | 0 |
| 142 | case QVariant::Color: { | - |
| 143 | static QPixmap pixmap(option.decorationSize); | - |
| 144 | pixmap.fill(qvariant_cast<QColor>(variant)); never executed (the execution status of this line is deduced): pixmap.fill(qvariant_cast<QColor>(variant)); | - |
| 145 | menuOption.icon = pixmap; never executed (the execution status of this line is deduced): menuOption.icon = pixmap; | - |
| 146 | break; } | 0 |
| 147 | default: | - |
| 148 | menuOption.icon = qvariant_cast<QPixmap>(variant); never executed (the execution status of this line is deduced): menuOption.icon = qvariant_cast<QPixmap>(variant); | - |
| 149 | break; | 0 |
| 150 | } | - |
| 151 | if (index.data(Qt::BackgroundRole).canConvert<QBrush>()) { never evaluated: index.data(Qt::BackgroundRole).canConvert<QBrush>() | 0 |
| 152 | menuOption.palette.setBrush(QPalette::All, QPalette::Background, never executed (the execution status of this line is deduced): menuOption.palette.setBrush(QPalette::All, QPalette::Background, | - |
| 153 | qvariant_cast<QBrush>(index.data(Qt::BackgroundRole))); never executed (the execution status of this line is deduced): qvariant_cast<QBrush>(index.data(Qt::BackgroundRole))); | - |
| 154 | } | 0 |
| 155 | menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() never executed (the execution status of this line is deduced): menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() | - |
| 156 | .replace(QLatin1Char('&'), QLatin1String("&&")); never executed (the execution status of this line is deduced): .replace(QLatin1Char('&'), QLatin1String("&&")); | - |
| 157 | menuOption.tabWidth = 0; never executed (the execution status of this line is deduced): menuOption.tabWidth = 0; | - |
| 158 | menuOption.maxIconWidth = option.decorationSize.width() + 4; never executed (the execution status of this line is deduced): menuOption.maxIconWidth = option.decorationSize.width() + 4; | - |
| 159 | menuOption.menuRect = option.rect; never executed (the execution status of this line is deduced): menuOption.menuRect = option.rect; | - |
| 160 | menuOption.rect = option.rect; never executed (the execution status of this line is deduced): menuOption.rect = option.rect; | - |
| 161 | | - |
| 162 | // Make sure fonts set on the combo box also overrides the font for the popup menu. | - |
| 163 | if (mCombo->testAttribute(Qt::WA_SetFont) never evaluated: mCombo->testAttribute(Qt::WA_SetFont) | 0 |
| 164 | || mCombo->testAttribute(Qt::WA_MacSmallSize) never evaluated: mCombo->testAttribute(Qt::WA_MacSmallSize) | 0 |
| 165 | || mCombo->testAttribute(Qt::WA_MacMiniSize) never evaluated: mCombo->testAttribute(Qt::WA_MacMiniSize) | 0 |
| 166 | || mCombo->font() != qt_app_fonts_hash()->value("QComboBox", QFont())) never evaluated: mCombo->font() != qt_app_fonts_hash()->value("QComboBox", QFont()) | 0 |
| 167 | menuOption.font = mCombo->font(); never executed: menuOption.font = mCombo->font(); | 0 |
| 168 | else | - |
| 169 | menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); never executed: menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); | 0 |
| 170 | | - |
| 171 | menuOption.fontMetrics = QFontMetrics(menuOption.font); never executed (the execution status of this line is deduced): menuOption.fontMetrics = QFontMetrics(menuOption.font); | - |
| 172 | | - |
| 173 | return menuOption; never executed: return menuOption; | 0 |
| 174 | } | - |
| 175 | | - |
| 176 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 177 | void QComboBoxPrivate::_q_completerActivated() | - |
| 178 | { | - |
| 179 | Q_Q(QComboBox); | - |
| 180 | if ( QApplication::keypadNavigationEnabled() | - |
| 181 | && q->isEditable() | - |
| 182 | && q->completer() | - |
| 183 | && q->completer()->completionMode() == QCompleter::UnfilteredPopupCompletion ) { | - |
| 184 | q->setEditFocus(false); | - |
| 185 | } | - |
| 186 | } | - |
| 187 | #endif | - |
| 188 | | - |
| 189 | void QComboBoxPrivate::updateArrow(QStyle::StateFlag state) | - |
| 190 | { | - |
| 191 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 192 | if (arrowState == state) partially evaluated: arrowState == state| yes Evaluation Count:133 | no Evaluation Count:0 |
| 0-133 |
| 193 | return; executed: return;Execution Count:133 | 133 |
| 194 | arrowState = state; never executed (the execution status of this line is deduced): arrowState = state; | - |
| 195 | QStyleOptionComboBox opt; never executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 196 | q->initStyleOption(&opt); never executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 197 | q->update(q->style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, q)); never executed (the execution status of this line is deduced): q->update(q->style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, q)); | - |
| 198 | } | 0 |
| 199 | | - |
| 200 | void QComboBoxPrivate::_q_modelReset() | - |
| 201 | { | - |
| 202 | Q_Q(QComboBox); never executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 203 | if (lineEdit) { never evaluated: lineEdit | 0 |
| 204 | lineEdit->setText(QString()); never executed (the execution status of this line is deduced): lineEdit->setText(QString()); | - |
| 205 | updateLineEditGeometry(); never executed (the execution status of this line is deduced): updateLineEditGeometry(); | - |
| 206 | } | 0 |
| 207 | if (currentIndex.row() != indexBeforeChange) never evaluated: currentIndex.row() != indexBeforeChange | 0 |
| 208 | _q_emitCurrentIndexChanged(currentIndex); never executed: _q_emitCurrentIndexChanged(currentIndex); | 0 |
| 209 | q->update(); never executed (the execution status of this line is deduced): q->update(); | - |
| 210 | } | 0 |
| 211 | | - |
| 212 | void QComboBoxPrivate::_q_modelDestroyed() | - |
| 213 | { | - |
| 214 | model = QAbstractItemModelPrivate::staticEmptyModel(); never executed (the execution status of this line is deduced): model = QAbstractItemModelPrivate::staticEmptyModel(); | - |
| 215 | } | 0 |
| 216 | | - |
| 217 | | - |
| 218 | //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't | - |
| 219 | QRect QComboBoxPrivate::popupGeometry(int screen) const | - |
| 220 | { | - |
| 221 | bool useFullScreenForPopupMenu = false; executed (the execution status of this line is deduced): bool useFullScreenForPopupMenu = false; | - |
| 222 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) partially evaluated: const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 223 | useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); executed: useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();Execution Count:1 | 1 |
| 224 | return useFullScreenForPopupMenu ? executed: return useFullScreenForPopupMenu ? QApplication::desktop()->screenGeometry(screen) : QApplication::desktop()->availableGeometry(screen);Execution Count:1 | 1 |
| 225 | QApplication::desktop()->screenGeometry(screen) : executed: return useFullScreenForPopupMenu ? QApplication::desktop()->screenGeometry(screen) : QApplication::desktop()->availableGeometry(screen);Execution Count:1 | 1 |
| 226 | QApplication::desktop()->availableGeometry(screen); executed: return useFullScreenForPopupMenu ? QApplication::desktop()->screenGeometry(screen) : QApplication::desktop()->availableGeometry(screen);Execution Count:1 | 1 |
| 227 | } | - |
| 228 | | - |
| 229 | bool QComboBoxPrivate::updateHoverControl(const QPoint &pos) | - |
| 230 | { | - |
| 231 | | - |
| 232 | Q_Q(QComboBox); never executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 233 | QRect lastHoverRect = hoverRect; never executed (the execution status of this line is deduced): QRect lastHoverRect = hoverRect; | - |
| 234 | QStyle::SubControl lastHoverControl = hoverControl; never executed (the execution status of this line is deduced): QStyle::SubControl lastHoverControl = hoverControl; | - |
| 235 | bool doesHover = q->testAttribute(Qt::WA_Hover); never executed (the execution status of this line is deduced): bool doesHover = q->testAttribute(Qt::WA_Hover); | - |
| 236 | if (lastHoverControl != newHoverControl(pos) && doesHover) { never evaluated: lastHoverControl != newHoverControl(pos) never evaluated: doesHover | 0 |
| 237 | q->update(lastHoverRect); never executed (the execution status of this line is deduced): q->update(lastHoverRect); | - |
| 238 | q->update(hoverRect); never executed (the execution status of this line is deduced): q->update(hoverRect); | - |
| 239 | return true; never executed: return true; | 0 |
| 240 | } | - |
| 241 | return !doesHover; never executed: return !doesHover; | 0 |
| 242 | } | - |
| 243 | | - |
| 244 | QStyle::SubControl QComboBoxPrivate::newHoverControl(const QPoint &pos) | - |
| 245 | { | - |
| 246 | Q_Q(QComboBox); never executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 247 | QStyleOptionComboBox opt; never executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 248 | q->initStyleOption(&opt); never executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 249 | opt.subControls = QStyle::SC_All; never executed (the execution status of this line is deduced): opt.subControls = QStyle::SC_All; | - |
| 250 | hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, pos, q); never executed (the execution status of this line is deduced): hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, pos, q); | - |
| 251 | hoverRect = (hoverControl != QStyle::SC_None) never evaluated: (hoverControl != QStyle::SC_None) | 0 |
| 252 | ? q->style()->subControlRect(QStyle::CC_ComboBox, &opt, hoverControl, q) never executed (the execution status of this line is deduced): ? q->style()->subControlRect(QStyle::CC_ComboBox, &opt, hoverControl, q) | - |
| 253 | : QRect(); never executed (the execution status of this line is deduced): : QRect(); | - |
| 254 | return hoverControl; never executed: return hoverControl; | 0 |
| 255 | } | - |
| 256 | | - |
| 257 | /* | - |
| 258 | Computes a size hint based on the maximum width | - |
| 259 | for the items in the combobox. | - |
| 260 | */ | - |
| 261 | int QComboBoxPrivate::computeWidthHint() const | - |
| 262 | { | - |
| 263 | Q_Q(const QComboBox); never executed (the execution status of this line is deduced): const QComboBox * const q = q_func(); | - |
| 264 | | - |
| 265 | int width = 0; never executed (the execution status of this line is deduced): int width = 0; | - |
| 266 | const int count = q->count(); never executed (the execution status of this line is deduced): const int count = q->count(); | - |
| 267 | const int iconWidth = q->iconSize().width() + 4; never executed (the execution status of this line is deduced): const int iconWidth = q->iconSize().width() + 4; | - |
| 268 | const QFontMetrics &fontMetrics = q->fontMetrics(); never executed (the execution status of this line is deduced): const QFontMetrics &fontMetrics = q->fontMetrics(); | - |
| 269 | | - |
| 270 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
| 271 | const int textWidth = fontMetrics.width(q->itemText(i)); never executed (the execution status of this line is deduced): const int textWidth = fontMetrics.width(q->itemText(i)); | - |
| 272 | if (q->itemIcon(i).isNull()) never evaluated: q->itemIcon(i).isNull() | 0 |
| 273 | width = (qMax(width, textWidth)); never executed: width = (qMax(width, textWidth)); | 0 |
| 274 | else | - |
| 275 | width = (qMax(width, textWidth + iconWidth)); never executed: width = (qMax(width, textWidth + iconWidth)); | 0 |
| 276 | } | - |
| 277 | | - |
| 278 | QStyleOptionComboBox opt; never executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 279 | q->initStyleOption(&opt); never executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 280 | QSize tmp(width, 0); never executed (the execution status of this line is deduced): QSize tmp(width, 0); | - |
| 281 | tmp = q->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, tmp, q); never executed (the execution status of this line is deduced): tmp = q->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, tmp, q); | - |
| 282 | return tmp.width(); never executed: return tmp.width(); | 0 |
| 283 | } | - |
| 284 | | - |
| 285 | QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const | - |
| 286 | { | - |
| 287 | Q_Q(const QComboBox); executed (the execution status of this line is deduced): const QComboBox * const q = q_func(); | - |
| 288 | if (!sh.isValid()) { evaluated: !sh.isValid()| yes Evaluation Count:995 | yes Evaluation Count:196 |
| 196-995 |
| 289 | bool hasIcon = sizeAdjustPolicy == QComboBox::AdjustToMinimumContentsLengthWithIcon ? true : false; partially evaluated: sizeAdjustPolicy == QComboBox::AdjustToMinimumContentsLengthWithIcon| no Evaluation Count:0 | yes Evaluation Count:995 |
| 0-995 |
| 290 | int count = q->count(); executed (the execution status of this line is deduced): int count = q->count(); | - |
| 291 | QSize iconSize = q->iconSize(); executed (the execution status of this line is deduced): QSize iconSize = q->iconSize(); | - |
| 292 | const QFontMetrics &fm = q->fontMetrics(); executed (the execution status of this line is deduced): const QFontMetrics &fm = q->fontMetrics(); | - |
| 293 | | - |
| 294 | // text width | - |
| 295 | if (&sh == &sizeHint || minimumContentsLength == 0) { evaluated: &sh == &sizeHint| yes Evaluation Count:598 | yes Evaluation Count:397 |
partially evaluated: minimumContentsLength == 0| yes Evaluation Count:397 | no Evaluation Count:0 |
| 0-598 |
| 296 | switch (sizeAdjustPolicy) { | - |
| 297 | case QComboBox::AdjustToContents: | - |
| 298 | case QComboBox::AdjustToContentsOnFirstShow: | - |
| 299 | if (count == 0) { evaluated: count == 0| yes Evaluation Count:170 | yes Evaluation Count:447 |
| 170-447 |
| 300 | sh.rwidth() = 7 * fm.width(QLatin1Char('x')); executed (the execution status of this line is deduced): sh.rwidth() = 7 * fm.width(QLatin1Char('x')); | - |
| 301 | } else { executed: }Execution Count:170 | 170 |
| 302 | for (int i = 0; i < count; ++i) { evaluated: i < count| yes Evaluation Count:674 | yes Evaluation Count:447 |
| 447-674 |
| 303 | if (!q->itemIcon(i).isNull()) { evaluated: !q->itemIcon(i).isNull()| yes Evaluation Count:414 | yes Evaluation Count:260 |
| 260-414 |
| 304 | hasIcon = true; executed (the execution status of this line is deduced): hasIcon = true; | - |
| 305 | sh.setWidth(qMax(sh.width(), fm.boundingRect(q->itemText(i)).width() + iconSize.width() + 4)); executed (the execution status of this line is deduced): sh.setWidth(qMax(sh.width(), fm.boundingRect(q->itemText(i)).width() + iconSize.width() + 4)); | - |
| 306 | } else { executed: }Execution Count:414 | 414 |
| 307 | sh.setWidth(qMax(sh.width(), fm.boundingRect(q->itemText(i)).width())); executed (the execution status of this line is deduced): sh.setWidth(qMax(sh.width(), fm.boundingRect(q->itemText(i)).width())); | - |
| 308 | } executed: }Execution Count:260 | 260 |
| 309 | } | - |
| 310 | } executed: }Execution Count:447 | 447 |
| 311 | break; executed: break;Execution Count:617 | 617 |
| 312 | case QComboBox::AdjustToMinimumContentsLength: | - |
| 313 | for (int i = 0; i < count && !hasIcon; ++i) evaluated: i < count| yes Evaluation Count:378 | yes Evaluation Count:378 |
partially evaluated: !hasIcon| yes Evaluation Count:378 | no Evaluation Count:0 |
| 0-378 |
| 314 | hasIcon = !q->itemIcon(i).isNull(); executed: hasIcon = !q->itemIcon(i).isNull();Execution Count:378 | 378 |
| 315 | default: code before this statement executed: default:Execution Count:378 | 378 |
| 316 | ; | - |
| 317 | } executed: }Execution Count:378 | 378 |
| 318 | } else { executed: }Execution Count:995 | 995 |
| 319 | for (int i = 0; i < count && !hasIcon; ++i) never evaluated: i < count never evaluated: !hasIcon | 0 |
| 320 | hasIcon = !q->itemIcon(i).isNull(); never executed: hasIcon = !q->itemIcon(i).isNull(); | 0 |
| 321 | } | 0 |
| 322 | if (minimumContentsLength > 0) partially evaluated: minimumContentsLength > 0| no Evaluation Count:0 | yes Evaluation Count:995 |
| 0-995 |
| 323 | sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0))); never executed: sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0))); | 0 |
| 324 | | - |
| 325 | | - |
| 326 | // height | - |
| 327 | sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); executed (the execution status of this line is deduced): sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); | - |
| 328 | if (hasIcon) { evaluated: hasIcon| yes Evaluation Count:414 | yes Evaluation Count:581 |
| 414-581 |
| 329 | sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); executed (the execution status of this line is deduced): sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); | - |
| 330 | } executed: }Execution Count:414 | 414 |
| 331 | | - |
| 332 | // add style and strut values | - |
| 333 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 334 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 335 | sh = q->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, q); executed (the execution status of this line is deduced): sh = q->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, q); | - |
| 336 | } executed: }Execution Count:995 | 995 |
| 337 | return sh.expandedTo(QApplication::globalStrut()); executed: return sh.expandedTo(QApplication::globalStrut());Execution Count:1191 | 1191 |
| 338 | } | - |
| 339 | | - |
| 340 | void QComboBoxPrivate::adjustComboBoxSize() | - |
| 341 | { | - |
| 342 | viewContainer()->adjustSizeTimer.start(20, container); executed (the execution status of this line is deduced): viewContainer()->adjustSizeTimer.start(20, container); | - |
| 343 | } executed: }Execution Count:189 | 189 |
| 344 | | - |
| 345 | void QComboBoxPrivate::updateLayoutDirection() | - |
| 346 | { | - |
| 347 | Q_Q(const QComboBox); executed (the execution status of this line is deduced): const QComboBox * const q = q_func(); | - |
| 348 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 349 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 350 | Qt::LayoutDirection dir = Qt::LayoutDirection( executed (the execution status of this line is deduced): Qt::LayoutDirection dir = Qt::LayoutDirection( | - |
| 351 | q->style()->styleHint(QStyle::SH_ComboBox_LayoutDirection, &opt, q)); executed (the execution status of this line is deduced): q->style()->styleHint(QStyle::SH_ComboBox_LayoutDirection, &opt, q)); | - |
| 352 | if (lineEdit) evaluated: lineEdit| yes Evaluation Count:152 | yes Evaluation Count:339 |
| 152-339 |
| 353 | lineEdit->setLayoutDirection(dir); executed: lineEdit->setLayoutDirection(dir);Execution Count:152 | 152 |
| 354 | if (container) partially evaluated: container| yes Evaluation Count:491 | no Evaluation Count:0 |
| 0-491 |
| 355 | container->setLayoutDirection(dir); executed: container->setLayoutDirection(dir);Execution Count:491 | 491 |
| 356 | } executed: }Execution Count:491 | 491 |
| 357 | | - |
| 358 | | - |
| 359 | void QComboBoxPrivateContainer::timerEvent(QTimerEvent *timerEvent) | - |
| 360 | { | - |
| 361 | if (timerEvent->timerId() == adjustSizeTimer.timerId()) { never evaluated: timerEvent->timerId() == adjustSizeTimer.timerId() | 0 |
| 362 | adjustSizeTimer.stop(); never executed (the execution status of this line is deduced): adjustSizeTimer.stop(); | - |
| 363 | if (combo->sizeAdjustPolicy() == QComboBox::AdjustToContents) { never evaluated: combo->sizeAdjustPolicy() == QComboBox::AdjustToContents | 0 |
| 364 | combo->updateGeometry(); never executed (the execution status of this line is deduced): combo->updateGeometry(); | - |
| 365 | combo->adjustSize(); never executed (the execution status of this line is deduced): combo->adjustSize(); | - |
| 366 | combo->update(); never executed (the execution status of this line is deduced): combo->update(); | - |
| 367 | } | 0 |
| 368 | } | 0 |
| 369 | } | 0 |
| 370 | | - |
| 371 | void QComboBoxPrivateContainer::resizeEvent(QResizeEvent *e) | - |
| 372 | { | - |
| 373 | QStyleOptionComboBox opt = comboStyleOption(); executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 374 | if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) { partially evaluated: combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 375 | QStyleOption myOpt; never executed (the execution status of this line is deduced): QStyleOption myOpt; | - |
| 376 | myOpt.initFrom(this); never executed (the execution status of this line is deduced): myOpt.initFrom(this); | - |
| 377 | QStyleHintReturnMask mask; never executed (the execution status of this line is deduced): QStyleHintReturnMask mask; | - |
| 378 | if (combo->style()->styleHint(QStyle::SH_Menu_Mask, &myOpt, this, &mask)) { never evaluated: combo->style()->styleHint(QStyle::SH_Menu_Mask, &myOpt, this, &mask) | 0 |
| 379 | setMask(mask.region); never executed (the execution status of this line is deduced): setMask(mask.region); | - |
| 380 | } | 0 |
| 381 | } else { | 0 |
| 382 | clearMask(); executed (the execution status of this line is deduced): clearMask(); | - |
| 383 | } executed: }Execution Count:1 | 1 |
| 384 | QFrame::resizeEvent(e); executed (the execution status of this line is deduced): QFrame::resizeEvent(e); | - |
| 385 | } executed: }Execution Count:1 | 1 |
| 386 | | - |
| 387 | void QComboBoxPrivateContainer::leaveEvent(QEvent *) | - |
| 388 | { | - |
| 389 | // On Mac using the Mac style we want to clear the selection | - |
| 390 | // when the mouse moves outside the popup. | - |
| 391 | #ifdef Q_WS_MAC | - |
| 392 | QStyleOptionComboBox opt = comboStyleOption(); | - |
| 393 | if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) | - |
| 394 | view->clearSelection(); | - |
| 395 | #endif | - |
| 396 | } | - |
| 397 | | - |
| 398 | QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent) | - |
| 399 | : QFrame(parent, Qt::Popup), combo(parent), view(0), top(0), bottom(0) | - |
| 400 | { | - |
| 401 | // we need the combobox and itemview | - |
| 402 | Q_ASSERT(parent); executed (the execution status of this line is deduced): qt_noop(); | - |
| 403 | Q_ASSERT(itemView); executed (the execution status of this line is deduced): qt_noop(); | - |
| 404 | | - |
| 405 | setAttribute(Qt::WA_WindowPropagation); executed (the execution status of this line is deduced): setAttribute(Qt::WA_WindowPropagation); | - |
| 406 | setAttribute(Qt::WA_X11NetWmWindowTypeCombo); executed (the execution status of this line is deduced): setAttribute(Qt::WA_X11NetWmWindowTypeCombo); | - |
| 407 | | - |
| 408 | // setup container | - |
| 409 | blockMouseReleaseTimer.setSingleShot(true); executed (the execution status of this line is deduced): blockMouseReleaseTimer.setSingleShot(true); | - |
| 410 | | - |
| 411 | // we need a vertical layout | - |
| 412 | QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this); executed (the execution status of this line is deduced): QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this); | - |
| 413 | layout->setSpacing(0); executed (the execution status of this line is deduced): layout->setSpacing(0); | - |
| 414 | layout->setMargin(0); executed (the execution status of this line is deduced): layout->setMargin(0); | - |
| 415 | | - |
| 416 | // set item view | - |
| 417 | setItemView(itemView); executed (the execution status of this line is deduced): setItemView(itemView); | - |
| 418 | | - |
| 419 | // add scroller arrows if style needs them | - |
| 420 | QStyleOptionComboBox opt = comboStyleOption(); executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 421 | const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); executed (the execution status of this line is deduced): const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); | - |
| 422 | if (usePopup) { partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 423 | top = new QComboBoxPrivateScroller(QAbstractSlider::SliderSingleStepSub, this); never executed (the execution status of this line is deduced): top = new QComboBoxPrivateScroller(QAbstractSlider::SliderSingleStepSub, this); | - |
| 424 | bottom = new QComboBoxPrivateScroller(QAbstractSlider::SliderSingleStepAdd, this); never executed (the execution status of this line is deduced): bottom = new QComboBoxPrivateScroller(QAbstractSlider::SliderSingleStepAdd, this); | - |
| 425 | top->hide(); never executed (the execution status of this line is deduced): top->hide(); | - |
| 426 | bottom->hide(); never executed (the execution status of this line is deduced): bottom->hide(); | - |
| 427 | } else { | 0 |
| 428 | setLineWidth(1); executed (the execution status of this line is deduced): setLineWidth(1); | - |
| 429 | } executed: }Execution Count:339 | 339 |
| 430 | | - |
| 431 | setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo)); executed (the execution status of this line is deduced): setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo)); | - |
| 432 | | - |
| 433 | if (top) { partially evaluated: top| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 434 | layout->insertWidget(0, top); never executed (the execution status of this line is deduced): layout->insertWidget(0, top); | - |
| 435 | connect(top, SIGNAL(doScroll(int)), this, SLOT(scrollItemView(int))); never executed (the execution status of this line is deduced): connect(top, "2""doScroll(int)", this, "1""scrollItemView(int)"); | - |
| 436 | } | 0 |
| 437 | if (bottom) { partially evaluated: bottom| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 438 | layout->addWidget(bottom); never executed (the execution status of this line is deduced): layout->addWidget(bottom); | - |
| 439 | connect(bottom, SIGNAL(doScroll(int)), this, SLOT(scrollItemView(int))); never executed (the execution status of this line is deduced): connect(bottom, "2""doScroll(int)", this, "1""scrollItemView(int)"); | - |
| 440 | } | 0 |
| 441 | | - |
| 442 | // Some styles (Mac) have a margin at the top and bottom of the popup. | - |
| 443 | layout->insertSpacing(0, 0); executed (the execution status of this line is deduced): layout->insertSpacing(0, 0); | - |
| 444 | layout->addSpacing(0); executed (the execution status of this line is deduced): layout->addSpacing(0); | - |
| 445 | updateTopBottomMargin(); executed (the execution status of this line is deduced): updateTopBottomMargin(); | - |
| 446 | } executed: }Execution Count:339 | 339 |
| 447 | | - |
| 448 | void QComboBoxPrivateContainer::scrollItemView(int action) | - |
| 449 | { | - |
| 450 | #ifndef QT_NO_SCROLLBAR | - |
| 451 | if (view->verticalScrollBar()) never evaluated: view->verticalScrollBar() | 0 |
| 452 | view->verticalScrollBar()->triggerAction(static_cast<QAbstractSlider::SliderAction>(action)); never executed: view->verticalScrollBar()->triggerAction(static_cast<QAbstractSlider::SliderAction>(action)); | 0 |
| 453 | #endif | - |
| 454 | } | 0 |
| 455 | | - |
| 456 | /* | - |
| 457 | Hides or shows the scrollers when we emulate a popupmenu | - |
| 458 | */ | - |
| 459 | void QComboBoxPrivateContainer::updateScrollers() | - |
| 460 | { | - |
| 461 | #ifndef QT_NO_SCROLLBAR | - |
| 462 | if (!top || !bottom) partially evaluated: !top| yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: !bottom | 0-1 |
| 463 | return; executed: return;Execution Count:1 | 1 |
| 464 | | - |
| 465 | if (isVisible() == false) never evaluated: isVisible() == false | 0 |
| 466 | return; | 0 |
| 467 | | - |
| 468 | QStyleOptionComboBox opt = comboStyleOption(); never executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 469 | if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo) && never evaluated: combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo) | 0 |
| 470 | view->verticalScrollBar()->minimum() < view->verticalScrollBar()->maximum()) { never evaluated: view->verticalScrollBar()->minimum() < view->verticalScrollBar()->maximum() | 0 |
| 471 | | - |
| 472 | bool needTop = view->verticalScrollBar()->value() never executed (the execution status of this line is deduced): bool needTop = view->verticalScrollBar()->value() | - |
| 473 | > (view->verticalScrollBar()->minimum() + spacing()); never executed (the execution status of this line is deduced): > (view->verticalScrollBar()->minimum() + spacing()); | - |
| 474 | bool needBottom = view->verticalScrollBar()->value() never executed (the execution status of this line is deduced): bool needBottom = view->verticalScrollBar()->value() | - |
| 475 | < (view->verticalScrollBar()->maximum() - spacing()*2); never executed (the execution status of this line is deduced): < (view->verticalScrollBar()->maximum() - spacing()*2); | - |
| 476 | if (needTop) | 0 |
| 477 | top->show(); never executed: top->show(); | 0 |
| 478 | else | - |
| 479 | top->hide(); never executed: top->hide(); | 0 |
| 480 | if (needBottom) never evaluated: needBottom | 0 |
| 481 | bottom->show(); never executed: bottom->show(); | 0 |
| 482 | else | - |
| 483 | bottom->hide(); never executed: bottom->hide(); | 0 |
| 484 | } else { | - |
| 485 | top->hide(); never executed (the execution status of this line is deduced): top->hide(); | - |
| 486 | bottom->hide(); never executed (the execution status of this line is deduced): bottom->hide(); | - |
| 487 | } | 0 |
| 488 | #endif // QT_NO_SCROLLBAR | - |
| 489 | } | - |
| 490 | | - |
| 491 | /* | - |
| 492 | Cleans up when the view is destroyed. | - |
| 493 | */ | - |
| 494 | void QComboBoxPrivateContainer::viewDestroyed() | - |
| 495 | { | - |
| 496 | view = 0; never executed (the execution status of this line is deduced): view = 0; | - |
| 497 | setItemView(new QComboBoxListView()); never executed (the execution status of this line is deduced): setItemView(new QComboBoxListView()); | - |
| 498 | } | 0 |
| 499 | | - |
| 500 | /* | - |
| 501 | Returns the item view used for the combobox popup. | - |
| 502 | */ | - |
| 503 | QAbstractItemView *QComboBoxPrivateContainer::itemView() const | - |
| 504 | { | - |
| 505 | return view; executed: return view;Execution Count:3409 | 3409 |
| 506 | } | - |
| 507 | | - |
| 508 | /*! | - |
| 509 | Sets the item view to be used for the combobox popup. | - |
| 510 | */ | - |
| 511 | void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) | - |
| 512 | { | - |
| 513 | Q_ASSERT(itemView); executed (the execution status of this line is deduced): qt_noop(); | - |
| 514 | | - |
| 515 | // clean up old one | - |
| 516 | if (view) { partially evaluated: view| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 517 | view->removeEventFilter(this); never executed (the execution status of this line is deduced): view->removeEventFilter(this); | - |
| 518 | view->viewport()->removeEventFilter(this); never executed (the execution status of this line is deduced): view->viewport()->removeEventFilter(this); | - |
| 519 | #ifndef QT_NO_SCROLLBAR | - |
| 520 | disconnect(view->verticalScrollBar(), SIGNAL(valueChanged(int)), never executed (the execution status of this line is deduced): disconnect(view->verticalScrollBar(), "2""valueChanged(int)", | - |
| 521 | this, SLOT(updateScrollers())); never executed (the execution status of this line is deduced): this, "1""updateScrollers()"); | - |
| 522 | disconnect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), never executed (the execution status of this line is deduced): disconnect(view->verticalScrollBar(), "2""rangeChanged(int,int)", | - |
| 523 | this, SLOT(updateScrollers())); never executed (the execution status of this line is deduced): this, "1""updateScrollers()"); | - |
| 524 | #endif | - |
| 525 | disconnect(view, SIGNAL(destroyed()), never executed (the execution status of this line is deduced): disconnect(view, "2""destroyed()", | - |
| 526 | this, SLOT(viewDestroyed())); never executed (the execution status of this line is deduced): this, "1""viewDestroyed()"); | - |
| 527 | | - |
| 528 | delete view; never executed (the execution status of this line is deduced): delete view; | - |
| 529 | view = 0; never executed (the execution status of this line is deduced): view = 0; | - |
| 530 | } | 0 |
| 531 | | - |
| 532 | // setup the item view | - |
| 533 | view = itemView; executed (the execution status of this line is deduced): view = itemView; | - |
| 534 | view->setParent(this); executed (the execution status of this line is deduced): view->setParent(this); | - |
| 535 | view->setAttribute(Qt::WA_MacShowFocusRect, false); executed (the execution status of this line is deduced): view->setAttribute(Qt::WA_MacShowFocusRect, false); | - |
| 536 | qobject_cast<QBoxLayout*>(layout())->insertWidget(top ? 2 : 0, view); executed (the execution status of this line is deduced): qobject_cast<QBoxLayout*>(layout())->insertWidget(top ? 2 : 0, view); | - |
| 537 | view->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); executed (the execution status of this line is deduced): view->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); | - |
| 538 | view->installEventFilter(this); executed (the execution status of this line is deduced): view->installEventFilter(this); | - |
| 539 | view->viewport()->installEventFilter(this); executed (the execution status of this line is deduced): view->viewport()->installEventFilter(this); | - |
| 540 | view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); executed (the execution status of this line is deduced): view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 541 | QStyleOptionComboBox opt = comboStyleOption(); executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 542 | const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); executed (the execution status of this line is deduced): const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); | - |
| 543 | #ifndef QT_NO_SCROLLBAR | - |
| 544 | if (usePopup) partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 545 | view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); never executed: view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 0 |
| 546 | #endif | - |
| 547 | if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || partially evaluated: combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo)| yes Evaluation Count:339 | no Evaluation Count:0 |
| 0-339 |
| 548 | usePopup) { never evaluated: usePopup | 0 |
| 549 | view->setMouseTracking(true); executed (the execution status of this line is deduced): view->setMouseTracking(true); | - |
| 550 | } executed: }Execution Count:339 | 339 |
| 551 | view->setSelectionMode(QAbstractItemView::SingleSelection); executed (the execution status of this line is deduced): view->setSelectionMode(QAbstractItemView::SingleSelection); | - |
| 552 | view->setFrameStyle(QFrame::NoFrame); executed (the execution status of this line is deduced): view->setFrameStyle(QFrame::NoFrame); | - |
| 553 | view->setLineWidth(0); executed (the execution status of this line is deduced): view->setLineWidth(0); | - |
| 554 | view->setEditTriggers(QAbstractItemView::NoEditTriggers); executed (the execution status of this line is deduced): view->setEditTriggers(QAbstractItemView::NoEditTriggers); | - |
| 555 | #ifndef QT_NO_SCROLLBAR | - |
| 556 | connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)), executed (the execution status of this line is deduced): connect(view->verticalScrollBar(), "2""valueChanged(int)", | - |
| 557 | this, SLOT(updateScrollers())); executed (the execution status of this line is deduced): this, "1""updateScrollers()"); | - |
| 558 | connect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), executed (the execution status of this line is deduced): connect(view->verticalScrollBar(), "2""rangeChanged(int,int)", | - |
| 559 | this, SLOT(updateScrollers())); executed (the execution status of this line is deduced): this, "1""updateScrollers()"); | - |
| 560 | #endif | - |
| 561 | connect(view, SIGNAL(destroyed()), executed (the execution status of this line is deduced): connect(view, "2""destroyed()", | - |
| 562 | this, SLOT(viewDestroyed())); executed (the execution status of this line is deduced): this, "1""viewDestroyed()"); | - |
| 563 | } executed: }Execution Count:339 | 339 |
| 564 | | - |
| 565 | /*! | - |
| 566 | Returns the spacing between the items in the view. | - |
| 567 | */ | - |
| 568 | int QComboBoxPrivateContainer::spacing() const | - |
| 569 | { | - |
| 570 | QListView *lview = qobject_cast<QListView*>(view); executed (the execution status of this line is deduced): QListView *lview = qobject_cast<QListView*>(view); | - |
| 571 | if (lview) partially evaluated: lview| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 572 | return lview->spacing(); executed: return lview->spacing();Execution Count:4 | 4 |
| 573 | #ifndef QT_NO_TABLEVIEW | - |
| 574 | QTableView *tview = qobject_cast<QTableView*>(view); never executed (the execution status of this line is deduced): QTableView *tview = qobject_cast<QTableView*>(view); | - |
| 575 | if (tview) | 0 |
| 576 | return tview->showGrid() ? 1 : 0; never executed: return tview->showGrid() ? 1 : 0; | 0 |
| 577 | #endif | - |
| 578 | return 0; never executed: return 0; | 0 |
| 579 | } | - |
| 580 | | - |
| 581 | void QComboBoxPrivateContainer::updateTopBottomMargin() | - |
| 582 | { | - |
| 583 | if (!layout() || layout()->count() < 1) partially evaluated: !layout()| no Evaluation Count:0 | yes Evaluation Count:489 |
partially evaluated: layout()->count() < 1| no Evaluation Count:0 | yes Evaluation Count:489 |
| 0-489 |
| 584 | return; | 0 |
| 585 | | - |
| 586 | QBoxLayout *boxLayout = qobject_cast<QBoxLayout *>(layout()); executed (the execution status of this line is deduced): QBoxLayout *boxLayout = qobject_cast<QBoxLayout *>(layout()); | - |
| 587 | if (!boxLayout) partially evaluated: !boxLayout| no Evaluation Count:0 | yes Evaluation Count:489 |
| 0-489 |
| 588 | return; | 0 |
| 589 | | - |
| 590 | const QStyleOptionComboBox opt = comboStyleOption(); executed (the execution status of this line is deduced): const QStyleOptionComboBox opt = comboStyleOption(); | - |
| 591 | const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); executed (the execution status of this line is deduced): const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); | - |
| 592 | const int margin = usePopup ? combo->style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, combo) : 0; partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:489 |
| 0-489 |
| 593 | | - |
| 594 | QSpacerItem *topSpacer = boxLayout->itemAt(0)->spacerItem(); executed (the execution status of this line is deduced): QSpacerItem *topSpacer = boxLayout->itemAt(0)->spacerItem(); | - |
| 595 | if (topSpacer) partially evaluated: topSpacer| yes Evaluation Count:489 | no Evaluation Count:0 |
| 0-489 |
| 596 | topSpacer->changeSize(0, margin, QSizePolicy::Minimum, QSizePolicy::Fixed); executed: topSpacer->changeSize(0, margin, QSizePolicy::Minimum, QSizePolicy::Fixed);Execution Count:489 | 489 |
| 597 | | - |
| 598 | QSpacerItem *bottomSpacer = boxLayout->itemAt(boxLayout->count() - 1)->spacerItem(); executed (the execution status of this line is deduced): QSpacerItem *bottomSpacer = boxLayout->itemAt(boxLayout->count() - 1)->spacerItem(); | - |
| 599 | if (bottomSpacer && bottomSpacer != topSpacer) partially evaluated: bottomSpacer| yes Evaluation Count:489 | no Evaluation Count:0 |
partially evaluated: bottomSpacer != topSpacer| yes Evaluation Count:489 | no Evaluation Count:0 |
| 0-489 |
| 600 | bottomSpacer->changeSize(0, margin, QSizePolicy::Minimum, QSizePolicy::Fixed); executed: bottomSpacer->changeSize(0, margin, QSizePolicy::Minimum, QSizePolicy::Fixed);Execution Count:489 | 489 |
| 601 | | - |
| 602 | boxLayout->invalidate(); executed (the execution status of this line is deduced): boxLayout->invalidate(); | - |
| 603 | } executed: }Execution Count:489 | 489 |
| 604 | | - |
| 605 | void QComboBoxPrivateContainer::changeEvent(QEvent *e) | - |
| 606 | { | - |
| 607 | if (e->type() == QEvent::StyleChange) { evaluated: e->type() == QEvent::StyleChange| yes Evaluation Count:2 | yes Evaluation Count:361 |
| 2-361 |
| 608 | QStyleOptionComboBox opt = comboStyleOption(); executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 609 | view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || executed (the execution status of this line is deduced): view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || | - |
| 610 | combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)); executed (the execution status of this line is deduced): combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)); | - |
| 611 | setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo)); executed (the execution status of this line is deduced): setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo)); | - |
| 612 | } executed: }Execution Count:2 | 2 |
| 613 | | - |
| 614 | QWidget::changeEvent(e); executed (the execution status of this line is deduced): QWidget::changeEvent(e); | - |
| 615 | } executed: }Execution Count:363 | 363 |
| 616 | | - |
| 617 | | - |
| 618 | bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) | - |
| 619 | { | - |
| 620 | switch (e->type()) { | - |
| 621 | case QEvent::ShortcutOverride: | - |
| 622 | switch (static_cast<QKeyEvent*>(e)->key()) { | - |
| 623 | case Qt::Key_Enter: | - |
| 624 | case Qt::Key_Return: | - |
| 625 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 626 | case Qt::Key_Select: | - |
| 627 | #endif | - |
| 628 | if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) { never evaluated: view->currentIndex().isValid() never evaluated: (view->currentIndex().flags() & Qt::ItemIsEnabled) | 0 |
| 629 | combo->hidePopup(); never executed (the execution status of this line is deduced): combo->hidePopup(); | - |
| 630 | emit itemSelected(view->currentIndex()); never executed (the execution status of this line is deduced): itemSelected(view->currentIndex()); | - |
| 631 | } | 0 |
| 632 | return true; never executed: return true; | 0 |
| 633 | case Qt::Key_Down: | - |
| 634 | if (!(static_cast<QKeyEvent*>(e)->modifiers() & Qt::AltModifier)) never evaluated: !(static_cast<QKeyEvent*>(e)->modifiers() & Qt::AltModifier) | 0 |
| 635 | break; | 0 |
| 636 | // fall through | - |
| 637 | case Qt::Key_F4: code before this statement never executed: case Qt::Key_F4: | 0 |
| 638 | case Qt::Key_Escape: | - |
| 639 | combo->hidePopup(); never executed (the execution status of this line is deduced): combo->hidePopup(); | - |
| 640 | return true; never executed: return true; | 0 |
| 641 | default: | - |
| 642 | break; | 0 |
| 643 | } | - |
| 644 | break; | 0 |
| 645 | case QEvent::MouseMove: | - |
| 646 | if (isVisible()) { never evaluated: isVisible() | 0 |
| 647 | QMouseEvent *m = static_cast<QMouseEvent *>(e); never executed (the execution status of this line is deduced): QMouseEvent *m = static_cast<QMouseEvent *>(e); | - |
| 648 | QWidget *widget = static_cast<QWidget *>(o); never executed (the execution status of this line is deduced): QWidget *widget = static_cast<QWidget *>(o); | - |
| 649 | QPoint vector = widget->mapToGlobal(m->pos()) - initialClickPosition; never executed (the execution status of this line is deduced): QPoint vector = widget->mapToGlobal(m->pos()) - initialClickPosition; | - |
| 650 | if (vector.manhattanLength() > 9 && blockMouseReleaseTimer.isActive()) never evaluated: vector.manhattanLength() > 9 never evaluated: blockMouseReleaseTimer.isActive() | 0 |
| 651 | blockMouseReleaseTimer.stop(); never executed: blockMouseReleaseTimer.stop(); | 0 |
| 652 | QModelIndex indexUnderMouse = view->indexAt(m->pos()); never executed (the execution status of this line is deduced): QModelIndex indexUnderMouse = view->indexAt(m->pos()); | - |
| 653 | if (indexUnderMouse.isValid() never evaluated: indexUnderMouse.isValid() | 0 |
| 654 | && !QComboBoxDelegate::isSeparator(indexUnderMouse)) { never evaluated: !QComboBoxDelegate::isSeparator(indexUnderMouse) | 0 |
| 655 | view->setCurrentIndex(indexUnderMouse); never executed (the execution status of this line is deduced): view->setCurrentIndex(indexUnderMouse); | - |
| 656 | } | 0 |
| 657 | } | 0 |
| 658 | break; | 0 |
| 659 | case QEvent::MouseButtonRelease: { | - |
| 660 | QMouseEvent *m = static_cast<QMouseEvent *>(e); never executed (the execution status of this line is deduced): QMouseEvent *m = static_cast<QMouseEvent *>(e); | - |
| 661 | if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid() never evaluated: isVisible() never evaluated: view->rect().contains(m->pos()) never evaluated: view->currentIndex().isValid() | 0 |
| 662 | && !blockMouseReleaseTimer.isActive() never evaluated: !blockMouseReleaseTimer.isActive() | 0 |
| 663 | && (view->currentIndex().flags() & Qt::ItemIsEnabled) never evaluated: (view->currentIndex().flags() & Qt::ItemIsEnabled) | 0 |
| 664 | && (view->currentIndex().flags() & Qt::ItemIsSelectable)) { never evaluated: (view->currentIndex().flags() & Qt::ItemIsSelectable) | 0 |
| 665 | combo->hidePopup(); never executed (the execution status of this line is deduced): combo->hidePopup(); | - |
| 666 | emit itemSelected(view->currentIndex()); never executed (the execution status of this line is deduced): itemSelected(view->currentIndex()); | - |
| 667 | return true; never executed: return true; | 0 |
| 668 | } | - |
| 669 | break; | 0 |
| 670 | } | - |
| 671 | default: | - |
| 672 | break; executed: break;Execution Count:4192 | 4192 |
| 673 | } | - |
| 674 | return QFrame::eventFilter(o, e); executed: return QFrame::eventFilter(o, e);Execution Count:4192 | 4192 |
| 675 | } | - |
| 676 | | - |
| 677 | void QComboBoxPrivateContainer::showEvent(QShowEvent *) | - |
| 678 | { | - |
| 679 | combo->update(); executed (the execution status of this line is deduced): combo->update(); | - |
| 680 | } executed: }Execution Count:1 | 1 |
| 681 | | - |
| 682 | void QComboBoxPrivateContainer::hideEvent(QHideEvent *) | - |
| 683 | { | - |
| 684 | emit resetButton(); never executed (the execution status of this line is deduced): resetButton(); | - |
| 685 | combo->update(); never executed (the execution status of this line is deduced): combo->update(); | - |
| 686 | #ifndef QT_NO_GRAPHICSVIEW | - |
| 687 | // QGraphicsScenePrivate::removePopup closes the combo box popup, it hides it non-explicitly. | - |
| 688 | // Hiding/showing the QComboBox after this will unexpectedly show the popup as well. | - |
| 689 | // Re-hiding the popup container makes sure it is explicitly hidden. | - |
| 690 | if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) never evaluated: QGraphicsProxyWidget *proxy = graphicsProxyWidget() | 0 |
| 691 | proxy->hide(); never executed: proxy->hide(); | 0 |
| 692 | #endif | - |
| 693 | } | 0 |
| 694 | | - |
| 695 | void QComboBoxPrivateContainer::mousePressEvent(QMouseEvent *e) | - |
| 696 | { | - |
| 697 | | - |
| 698 | QStyleOptionComboBox opt = comboStyleOption(); never executed (the execution status of this line is deduced): QStyleOptionComboBox opt = comboStyleOption(); | - |
| 699 | opt.subControls = QStyle::SC_All; never executed (the execution status of this line is deduced): opt.subControls = QStyle::SC_All; | - |
| 700 | opt.activeSubControls = QStyle::SC_ComboBoxArrow; never executed (the execution status of this line is deduced): opt.activeSubControls = QStyle::SC_ComboBoxArrow; | - |
| 701 | QStyle::SubControl sc = combo->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, never executed (the execution status of this line is deduced): QStyle::SubControl sc = combo->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, | - |
| 702 | combo->mapFromGlobal(e->globalPos()), never executed (the execution status of this line is deduced): combo->mapFromGlobal(e->globalPos()), | - |
| 703 | combo); never executed (the execution status of this line is deduced): combo); | - |
| 704 | if ((combo->isEditable() && sc == QStyle::SC_ComboBoxArrow) never evaluated: combo->isEditable() never evaluated: sc == QStyle::SC_ComboBoxArrow | 0 |
| 705 | || (!combo->isEditable() && sc != QStyle::SC_None)) never evaluated: !combo->isEditable() never evaluated: sc != QStyle::SC_None | 0 |
| 706 | setAttribute(Qt::WA_NoMouseReplay); never executed: setAttribute(Qt::WA_NoMouseReplay); | 0 |
| 707 | combo->hidePopup(); never executed (the execution status of this line is deduced): combo->hidePopup(); | - |
| 708 | } | 0 |
| 709 | | - |
| 710 | void QComboBoxPrivateContainer::mouseReleaseEvent(QMouseEvent *e) | - |
| 711 | { | - |
| 712 | Q_UNUSED(e); never executed (the execution status of this line is deduced): (void)e;; | - |
| 713 | if (!blockMouseReleaseTimer.isActive()){ never evaluated: !blockMouseReleaseTimer.isActive() | 0 |
| 714 | combo->hidePopup(); never executed (the execution status of this line is deduced): combo->hidePopup(); | - |
| 715 | emit resetButton(); never executed (the execution status of this line is deduced): resetButton(); | - |
| 716 | } | 0 |
| 717 | } | 0 |
| 718 | | - |
| 719 | QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const | - |
| 720 | { | - |
| 721 | // ### This should use QComboBox's initStyleOption(), but it's protected | - |
| 722 | // perhaps, we could cheat by having the QCombo private instead? | - |
| 723 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 724 | opt.initFrom(combo); executed (the execution status of this line is deduced): opt.initFrom(combo); | - |
| 725 | opt.subControls = QStyle::SC_All; executed (the execution status of this line is deduced): opt.subControls = QStyle::SC_All; | - |
| 726 | opt.activeSubControls = QStyle::SC_None; executed (the execution status of this line is deduced): opt.activeSubControls = QStyle::SC_None; | - |
| 727 | opt.editable = combo->isEditable(); executed (the execution status of this line is deduced): opt.editable = combo->isEditable(); | - |
| 728 | return opt; executed: return opt;Execution Count:1170 | 1170 |
| 729 | } | - |
| 730 | | - |
| 731 | /*! | - |
| 732 | \enum QComboBox::InsertPolicy | - |
| 733 | | - |
| 734 | This enum specifies what the QComboBox should do when a new string is | - |
| 735 | entered by the user. | - |
| 736 | | - |
| 737 | \value NoInsert The string will not be inserted into the combobox. | - |
| 738 | \value InsertAtTop The string will be inserted as the first item in the combobox. | - |
| 739 | \value InsertAtCurrent The current item will be \e replaced by the string. | - |
| 740 | \value InsertAtBottom The string will be inserted after the last item in the combobox. | - |
| 741 | \value InsertAfterCurrent The string is inserted after the current item in the combobox. | - |
| 742 | \value InsertBeforeCurrent The string is inserted before the current item in the combobox. | - |
| 743 | \value InsertAlphabetically The string is inserted in the alphabetic order in the combobox. | - |
| 744 | */ | - |
| 745 | | - |
| 746 | /*! | - |
| 747 | \enum QComboBox::SizeAdjustPolicy | - |
| 748 | | - |
| 749 | This enum specifies how the size hint of the QComboBox should | - |
| 750 | adjust when new content is added or content changes. | - |
| 751 | | - |
| 752 | \value AdjustToContents The combobox will always adjust to the contents | - |
| 753 | \value AdjustToContentsOnFirstShow The combobox will adjust to its contents the first time it is shown. | - |
| 754 | \value AdjustToMinimumContentsLength Use AdjustToContents or AdjustToContentsOnFirstShow instead. | - |
| 755 | \value AdjustToMinimumContentsLengthWithIcon The combobox will adjust to \l minimumContentsLength plus space for an icon. For performance reasons use this policy on large models. | - |
| 756 | */ | - |
| 757 | | - |
| 758 | /*! | - |
| 759 | \fn void QComboBox::activated(int index) | - |
| 760 | | - |
| 761 | This signal is sent when the user chooses an item in the combobox. | - |
| 762 | The item's \a index is passed. Note that this signal is sent even | - |
| 763 | when the choice is not changed. If you need to know when the | - |
| 764 | choice actually changes, use signal currentIndexChanged(). | - |
| 765 | | - |
| 766 | */ | - |
| 767 | | - |
| 768 | /*! | - |
| 769 | \fn void QComboBox::activated(const QString &text) | - |
| 770 | | - |
| 771 | This signal is sent when the user chooses an item in the combobox. | - |
| 772 | The item's \a text is passed. Note that this signal is sent even | - |
| 773 | when the choice is not changed. If you need to know when the | - |
| 774 | choice actually changes, use signal currentIndexChanged(). | - |
| 775 | | - |
| 776 | */ | - |
| 777 | | - |
| 778 | /*! | - |
| 779 | \fn void QComboBox::highlighted(int index) | - |
| 780 | | - |
| 781 | This signal is sent when an item in the combobox popup list is | - |
| 782 | highlighted by the user. The item's \a index is passed. | - |
| 783 | */ | - |
| 784 | | - |
| 785 | /*! | - |
| 786 | \fn void QComboBox::highlighted(const QString &text) | - |
| 787 | | - |
| 788 | This signal is sent when an item in the combobox popup list is | - |
| 789 | highlighted by the user. The item's \a text is passed. | - |
| 790 | */ | - |
| 791 | | - |
| 792 | /*! | - |
| 793 | \fn void QComboBox::currentIndexChanged(int index) | - |
| 794 | \since 4.1 | - |
| 795 | | - |
| 796 | This signal is sent whenever the currentIndex in the combobox | - |
| 797 | changes either through user interaction or programmatically. The | - |
| 798 | item's \a index is passed or -1 if the combobox becomes empty or the | - |
| 799 | currentIndex was reset. | - |
| 800 | */ | - |
| 801 | | - |
| 802 | /*! | - |
| 803 | \fn void QComboBox::currentIndexChanged(const QString &text) | - |
| 804 | \since 4.1 | - |
| 805 | | - |
| 806 | This signal is sent whenever the currentIndex in the combobox | - |
| 807 | changes either through user interaction or programmatically. The | - |
| 808 | item's \a text is passed. | - |
| 809 | */ | - |
| 810 | | - |
| 811 | /*! | - |
| 812 | \fn void QComboBox::currentTextChanged(const QString &text) | - |
| 813 | \since 5.0 | - |
| 814 | | - |
| 815 | This signal is sent whenever currentText changes. The new value | - |
| 816 | is passed as \a text. | - |
| 817 | */ | - |
| 818 | | - |
| 819 | /*! | - |
| 820 | Constructs a combobox with the given \a parent, using the default | - |
| 821 | model QStandardItemModel. | - |
| 822 | */ | - |
| 823 | QComboBox::QComboBox(QWidget *parent) | - |
| 824 | : QWidget(*new QComboBoxPrivate(), parent, 0) | - |
| 825 | { | - |
| 826 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 827 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 828 | } executed: }Execution Count:418 | 418 |
| 829 | | - |
| 830 | /*! | - |
| 831 | \internal | - |
| 832 | */ | - |
| 833 | QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) | - |
| 834 | : QWidget(dd, parent, 0) | - |
| 835 | { | - |
| 836 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 837 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 838 | } executed: }Execution Count:140 | 140 |
| 839 | | - |
| 840 | | - |
| 841 | /*! | - |
| 842 | \class QComboBox | - |
| 843 | \brief The QComboBox widget is a combined button and popup list. | - |
| 844 | | - |
| 845 | \ingroup basicwidgets | - |
| 846 | \inmodule QtWidgets | - |
| 847 | | - |
| 848 | A QComboBox provides a means of presenting a list of options to the user | - |
| 849 | in a way that takes up the minimum amount of screen space. | - |
| 850 | | - |
| 851 | A combobox is a selection widget that displays the current item, | - |
| 852 | and can pop up a list of selectable items. A combobox may be editable, | - |
| 853 | allowing the user to modify each item in the list. | - |
| 854 | | - |
| 855 | Comboboxes can contain pixmaps as well as strings; the | - |
| 856 | insertItem() and setItemText() functions are suitably overloaded. | - |
| 857 | For editable comboboxes, the function clearEditText() is provided, | - |
| 858 | to clear the displayed string without changing the combobox's | - |
| 859 | contents. | - |
| 860 | | - |
| 861 | There are two signals emitted if the current item of a combobox | - |
| 862 | changes, currentIndexChanged() and activated(). | - |
| 863 | currentIndexChanged() is always emitted regardless if the change | - |
| 864 | was done programmatically or by user interaction, while | - |
| 865 | activated() is only emitted when the change is caused by user | - |
| 866 | interaction. The highlighted() signal is emitted when the user | - |
| 867 | highlights an item in the combobox popup list. All three signals | - |
| 868 | exist in two versions, one with a QString argument and one with an | - |
| 869 | \c int argument. If the user selects or highlights a pixmap, only | - |
| 870 | the \c int signals are emitted. Whenever the text of an editable | - |
| 871 | combobox is changed the editTextChanged() signal is emitted. | - |
| 872 | | - |
| 873 | When the user enters a new string in an editable combobox, the | - |
| 874 | widget may or may not insert it, and it can insert it in several | - |
| 875 | locations. The default policy is \l InsertAtBottom but you can change | - |
| 876 | this using setInsertPolicy(). | - |
| 877 | | - |
| 878 | It is possible to constrain the input to an editable combobox | - |
| 879 | using QValidator; see setValidator(). By default, any input is | - |
| 880 | accepted. | - |
| 881 | | - |
| 882 | A combobox can be populated using the insert functions, | - |
| 883 | insertItem() and insertItems() for example. Items can be | - |
| 884 | changed with setItemText(). An item can be removed with | - |
| 885 | removeItem() and all items can be removed with clear(). The text | - |
| 886 | of the current item is returned by currentText(), and the text of | - |
| 887 | a numbered item is returned with text(). The current item can be | - |
| 888 | set with setCurrentIndex(). The number of items in the combobox is | - |
| 889 | returned by count(); the maximum number of items can be set with | - |
| 890 | setMaxCount(). You can allow editing using setEditable(). For | - |
| 891 | editable comboboxes you can set auto-completion using | - |
| 892 | setCompleter() and whether or not the user can add duplicates | - |
| 893 | is set with setDuplicatesEnabled(). | - |
| 894 | | - |
| 895 | QComboBox uses the \l{Model/View Programming}{model/view | - |
| 896 | framework} for its popup list and to store its items. By default | - |
| 897 | a QStandardItemModel stores the items and a QListView subclass | - |
| 898 | displays the popuplist. You can access the model and view directly | - |
| 899 | (with model() and view()), but QComboBox also provides functions | - |
| 900 | to set and get item data (e.g., setItemData() and itemText()). You | - |
| 901 | can also set a new model and view (with setModel() and setView()). | - |
| 902 | For the text and icon in the combobox label, the data in the model | - |
| 903 | that has the Qt::DisplayRole and Qt::DecorationRole is used. Note | - |
| 904 | that you cannot alter the \l{QAbstractItemView::}{SelectionMode} | - |
| 905 | of the view(), e.g., by using | - |
| 906 | \l{QAbstractItemView::}{setSelectionMode()}. | - |
| 907 | | - |
| 908 | \image qstyle-comboboxes.png Comboboxes in the different built-in styles. | - |
| 909 | | - |
| 910 | \sa QLineEdit, QSpinBox, QRadioButton, QButtonGroup, | - |
| 911 | {fowler}{GUI Design Handbook: Combo Box, Drop-Down List Box} | - |
| 912 | */ | - |
| 913 | | - |
| 914 | void QComboBoxPrivate::init() | - |
| 915 | { | - |
| 916 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 917 | #ifdef Q_OS_MAC | - |
| 918 | // On Mac, only line edits and list views always get tab focus. It's only | - |
| 919 | // when we enable full keyboard access that other controls can get tab focus. | - |
| 920 | // When it's not editable, a combobox looks like a button, and it behaves as | - |
| 921 | // such in this respect. | - |
| 922 | if (!q->isEditable()) | - |
| 923 | q->setFocusPolicy(Qt::TabFocus); | - |
| 924 | else | - |
| 925 | #endif | - |
| 926 | q->setFocusPolicy(Qt::WheelFocus); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::WheelFocus); | - |
| 927 | | - |
| 928 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed, executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed, | - |
| 929 | QSizePolicy::ComboBox)); executed (the execution status of this line is deduced): QSizePolicy::ComboBox)); | - |
| 930 | setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); | - |
| 931 | q->setModel(new QStandardItemModel(0, 1, q)); executed (the execution status of this line is deduced): q->setModel(new QStandardItemModel(0, 1, q)); | - |
| 932 | if (!q->isEditable()) partially evaluated: !q->isEditable()| yes Evaluation Count:558 | no Evaluation Count:0 |
| 0-558 |
| 933 | q->setAttribute(Qt::WA_InputMethodEnabled, false); executed: q->setAttribute(Qt::WA_InputMethodEnabled, false);Execution Count:558 | 558 |
| 934 | else | - |
| 935 | q->setAttribute(Qt::WA_InputMethodEnabled); never executed: q->setAttribute(Qt::WA_InputMethodEnabled); | 0 |
| 936 | } | - |
| 937 | | - |
| 938 | QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer() | - |
| 939 | { | - |
| 940 | if (container) evaluated: container| yes Evaluation Count:2113 | yes Evaluation Count:339 |
| 339-2113 |
| 941 | return container; executed: return container;Execution Count:2113 | 2113 |
| 942 | | - |
| 943 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 944 | container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q); executed (the execution status of this line is deduced): container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q); | - |
| 945 | container->itemView()->setModel(model); executed (the execution status of this line is deduced): container->itemView()->setModel(model); | - |
| 946 | container->itemView()->setTextElideMode(Qt::ElideMiddle); executed (the execution status of this line is deduced): container->itemView()->setTextElideMode(Qt::ElideMiddle); | - |
| 947 | updateDelegate(true); executed (the execution status of this line is deduced): updateDelegate(true); | - |
| 948 | updateLayoutDirection(); executed (the execution status of this line is deduced): updateLayoutDirection(); | - |
| 949 | updateViewContainerPaletteAndOpacity(); executed (the execution status of this line is deduced): updateViewContainerPaletteAndOpacity(); | - |
| 950 | QObject::connect(container, SIGNAL(itemSelected(QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(container, "2""itemSelected(QModelIndex)", | - |
| 951 | q, SLOT(_q_itemSelected(QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_itemSelected(QModelIndex)"); | - |
| 952 | QObject::connect(container->itemView()->selectionModel(), executed (the execution status of this line is deduced): QObject::connect(container->itemView()->selectionModel(), | - |
| 953 | SIGNAL(currentChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): "2""currentChanged(QModelIndex,QModelIndex)", | - |
| 954 | q, SLOT(_q_emitHighlighted(QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_emitHighlighted(QModelIndex)"); | - |
| 955 | QObject::connect(container, SIGNAL(resetButton()), q, SLOT(_q_resetButton())); executed (the execution status of this line is deduced): QObject::connect(container, "2""resetButton()", q, "1""_q_resetButton()"); | - |
| 956 | return container; executed: return container;Execution Count:339 | 339 |
| 957 | } | - |
| 958 | | - |
| 959 | | - |
| 960 | void QComboBoxPrivate::_q_resetButton() | - |
| 961 | { | - |
| 962 | updateArrow(QStyle::State_None); executed (the execution status of this line is deduced): updateArrow(QStyle::State_None); | - |
| 963 | } executed: }Execution Count:132 | 132 |
| 964 | | - |
| 965 | void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) | - |
| 966 | { | - |
| 967 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 968 | if (inserting || topLeft.parent() != root) partially evaluated: inserting| no Evaluation Count:0 | yes Evaluation Count:1550 |
partially evaluated: topLeft.parent() != root| no Evaluation Count:0 | yes Evaluation Count:1550 |
| 0-1550 |
| 969 | return; | 0 |
| 970 | | - |
| 971 | if (sizeAdjustPolicy == QComboBox::AdjustToContents) { partially evaluated: sizeAdjustPolicy == QComboBox::AdjustToContents| no Evaluation Count:0 | yes Evaluation Count:1550 |
| 0-1550 |
| 972 | sizeHint = QSize(); never executed (the execution status of this line is deduced): sizeHint = QSize(); | - |
| 973 | adjustComboBoxSize(); never executed (the execution status of this line is deduced): adjustComboBoxSize(); | - |
| 974 | q->updateGeometry(); never executed (the execution status of this line is deduced): q->updateGeometry(); | - |
| 975 | } | 0 |
| 976 | | - |
| 977 | if (currentIndex.row() >= topLeft.row() && currentIndex.row() <= bottomRight.row()) { partially evaluated: currentIndex.row() >= topLeft.row()| yes Evaluation Count:1550 | no Evaluation Count:0 |
partially evaluated: currentIndex.row() <= bottomRight.row()| yes Evaluation Count:1550 | no Evaluation Count:0 |
| 0-1550 |
| 978 | const QString text = q->itemText(currentIndex.row()); executed (the execution status of this line is deduced): const QString text = q->itemText(currentIndex.row()); | - |
| 979 | if (lineEdit) { partially evaluated: lineEdit| no Evaluation Count:0 | yes Evaluation Count:1550 |
| 0-1550 |
| 980 | lineEdit->setText(text); never executed (the execution status of this line is deduced): lineEdit->setText(text); | - |
| 981 | updateLineEditGeometry(); never executed (the execution status of this line is deduced): updateLineEditGeometry(); | - |
| 982 | } else { | 0 |
| 983 | emit q->currentTextChanged(text); executed (the execution status of this line is deduced): q->currentTextChanged(text); | - |
| 984 | } executed: }Execution Count:1550 | 1550 |
| 985 | q->update(); executed (the execution status of this line is deduced): q->update(); | - |
| 986 | } executed: }Execution Count:1550 | 1550 |
| 987 | #ifndef QT_NO_ACCESSIBILITY | - |
| 988 | QAccessibleEvent event(q, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(q, QAccessible::NameChanged); | - |
| 989 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 990 | #endif | - |
| 991 | } executed: }Execution Count:1550 | 1550 |
| 992 | | - |
| 993 | void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int end) | - |
| 994 | { | - |
| 995 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 996 | if (inserting || parent != root) partially evaluated: inserting| no Evaluation Count:0 | yes Evaluation Count:702 |
partially evaluated: parent != root| no Evaluation Count:0 | yes Evaluation Count:702 |
| 0-702 |
| 997 | return; | 0 |
| 998 | | - |
| 999 | if (sizeAdjustPolicy == QComboBox::AdjustToContents) { partially evaluated: sizeAdjustPolicy == QComboBox::AdjustToContents| no Evaluation Count:0 | yes Evaluation Count:702 |
| 0-702 |
| 1000 | sizeHint = QSize(); never executed (the execution status of this line is deduced): sizeHint = QSize(); | - |
| 1001 | adjustComboBoxSize(); never executed (the execution status of this line is deduced): adjustComboBoxSize(); | - |
| 1002 | q->updateGeometry(); never executed (the execution status of this line is deduced): q->updateGeometry(); | - |
| 1003 | } | 0 |
| 1004 | | - |
| 1005 | // set current index if combo was previously empty | - |
| 1006 | if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid()) { evaluated: start == 0| yes Evaluation Count:592 | yes Evaluation Count:110 |
partially evaluated: (end - start + 1) == q->count()| yes Evaluation Count:592 | no Evaluation Count:0 |
partially evaluated: !currentIndex.isValid()| yes Evaluation Count:592 | no Evaluation Count:0 |
| 0-592 |
| 1007 | q->setCurrentIndex(0); executed (the execution status of this line is deduced): q->setCurrentIndex(0); | - |
| 1008 | // need to emit changed if model updated index "silently" | - |
| 1009 | } else if (currentIndex.row() != indexBeforeChange) { executed: }Execution Count:592 partially evaluated: currentIndex.row() != indexBeforeChange| no Evaluation Count:0 | yes Evaluation Count:110 |
| 0-592 |
| 1010 | q->update(); never executed (the execution status of this line is deduced): q->update(); | - |
| 1011 | _q_emitCurrentIndexChanged(currentIndex); never executed (the execution status of this line is deduced): _q_emitCurrentIndexChanged(currentIndex); | - |
| 1012 | } | 0 |
| 1013 | } | - |
| 1014 | | - |
| 1015 | void QComboBoxPrivate::_q_updateIndexBeforeChange() | - |
| 1016 | { | - |
| 1017 | indexBeforeChange = currentIndex.row(); executed (the execution status of this line is deduced): indexBeforeChange = currentIndex.row(); | - |
| 1018 | } executed: }Execution Count:901 | 901 |
| 1019 | | - |
| 1020 | void QComboBoxPrivate::_q_rowsRemoved(const QModelIndex &parent, int /*start*/, int /*end*/) | - |
| 1021 | { | - |
| 1022 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1023 | if (parent != root) partially evaluated: parent != root| no Evaluation Count:0 | yes Evaluation Count:199 |
| 0-199 |
| 1024 | return; | 0 |
| 1025 | | - |
| 1026 | if (sizeAdjustPolicy == QComboBox::AdjustToContents) { partially evaluated: sizeAdjustPolicy == QComboBox::AdjustToContents| no Evaluation Count:0 | yes Evaluation Count:199 |
| 0-199 |
| 1027 | sizeHint = QSize(); never executed (the execution status of this line is deduced): sizeHint = QSize(); | - |
| 1028 | adjustComboBoxSize(); never executed (the execution status of this line is deduced): adjustComboBoxSize(); | - |
| 1029 | q->updateGeometry(); never executed (the execution status of this line is deduced): q->updateGeometry(); | - |
| 1030 | } | 0 |
| 1031 | | - |
| 1032 | // model has changed the currentIndex | - |
| 1033 | if (currentIndex.row() != indexBeforeChange) { partially evaluated: currentIndex.row() != indexBeforeChange| yes Evaluation Count:199 | no Evaluation Count:0 |
| 0-199 |
| 1034 | if (!currentIndex.isValid() && q->count()) { partially evaluated: !currentIndex.isValid()| yes Evaluation Count:199 | no Evaluation Count:0 |
partially evaluated: q->count()| no Evaluation Count:0 | yes Evaluation Count:199 |
| 0-199 |
| 1035 | q->setCurrentIndex(qMin(q->count() - 1, qMax(indexBeforeChange, 0))); never executed (the execution status of this line is deduced): q->setCurrentIndex(qMin(q->count() - 1, qMax(indexBeforeChange, 0))); | - |
| 1036 | return; | 0 |
| 1037 | } | - |
| 1038 | if (lineEdit) { partially evaluated: lineEdit| no Evaluation Count:0 | yes Evaluation Count:199 |
| 0-199 |
| 1039 | lineEdit->setText(q->itemText(currentIndex.row())); never executed (the execution status of this line is deduced): lineEdit->setText(q->itemText(currentIndex.row())); | - |
| 1040 | updateLineEditGeometry(); never executed (the execution status of this line is deduced): updateLineEditGeometry(); | - |
| 1041 | } | 0 |
| 1042 | q->update(); executed (the execution status of this line is deduced): q->update(); | - |
| 1043 | _q_emitCurrentIndexChanged(currentIndex); executed (the execution status of this line is deduced): _q_emitCurrentIndexChanged(currentIndex); | - |
| 1044 | } executed: }Execution Count:199 | 199 |
| 1045 | } executed: }Execution Count:199 | 199 |
| 1046 | | - |
| 1047 | | - |
| 1048 | void QComboBoxPrivate::updateViewContainerPaletteAndOpacity() | - |
| 1049 | { | - |
| 1050 | if (!container) partially evaluated: !container| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 1051 | return; | 0 |
| 1052 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1053 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 1054 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 1055 | #ifndef QT_NO_MENU | - |
| 1056 | if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) { partially evaluated: q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 1057 | QMenu menu; never executed (the execution status of this line is deduced): QMenu menu; | - |
| 1058 | menu.ensurePolished(); never executed (the execution status of this line is deduced): menu.ensurePolished(); | - |
| 1059 | container->setPalette(menu.palette()); never executed (the execution status of this line is deduced): container->setPalette(menu.palette()); | - |
| 1060 | container->setWindowOpacity(menu.windowOpacity()); never executed (the execution status of this line is deduced): container->setWindowOpacity(menu.windowOpacity()); | - |
| 1061 | } else | 0 |
| 1062 | #endif | - |
| 1063 | { | - |
| 1064 | container->setPalette(q->palette()); executed (the execution status of this line is deduced): container->setPalette(q->palette()); | - |
| 1065 | container->setWindowOpacity(1.0); executed (the execution status of this line is deduced): container->setWindowOpacity(1.0); | - |
| 1066 | } executed: }Execution Count:339 | 339 |
| 1067 | if (lineEdit) partially evaluated: lineEdit| no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
| 1068 | lineEdit->setPalette(q->palette()); never executed: lineEdit->setPalette(q->palette()); | 0 |
| 1069 | } executed: }Execution Count:339 | 339 |
| 1070 | | - |
| 1071 | /*! | - |
| 1072 | Initialize \a option with the values from this QComboBox. This method | - |
| 1073 | is useful for subclasses when they need a QStyleOptionComboBox, but don't want | - |
| 1074 | to fill in all the information themselves. | - |
| 1075 | | - |
| 1076 | \sa QStyleOption::initFrom() | - |
| 1077 | */ | - |
| 1078 | void QComboBox::initStyleOption(QStyleOptionComboBox *option) const | - |
| 1079 | { | - |
| 1080 | if (!option) partially evaluated: !option| no Evaluation Count:0 | yes Evaluation Count:3153 |
| 0-3153 |
| 1081 | return; | 0 |
| 1082 | | - |
| 1083 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1084 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
| 1085 | option->editable = isEditable(); executed (the execution status of this line is deduced): option->editable = isEditable(); | - |
| 1086 | option->frame = d->frame; executed (the execution status of this line is deduced): option->frame = d->frame; | - |
| 1087 | if (hasFocus() && !option->editable) evaluated: hasFocus()| yes Evaluation Count:16 | yes Evaluation Count:3137 |
evaluated: !option->editable| yes Evaluation Count:9 | yes Evaluation Count:7 |
| 7-3137 |
| 1088 | option->state |= QStyle::State_Selected; executed: option->state |= QStyle::State_Selected;Execution Count:9 | 9 |
| 1089 | option->subControls = QStyle::SC_All; executed (the execution status of this line is deduced): option->subControls = QStyle::SC_All; | - |
| 1090 | if (d->arrowState == QStyle::State_Sunken) { partially evaluated: d->arrowState == QStyle::State_Sunken| no Evaluation Count:0 | yes Evaluation Count:3153 |
| 0-3153 |
| 1091 | option->activeSubControls = QStyle::SC_ComboBoxArrow; never executed (the execution status of this line is deduced): option->activeSubControls = QStyle::SC_ComboBoxArrow; | - |
| 1092 | option->state |= d->arrowState; never executed (the execution status of this line is deduced): option->state |= d->arrowState; | - |
| 1093 | } else { | 0 |
| 1094 | option->activeSubControls = d->hoverControl; executed (the execution status of this line is deduced): option->activeSubControls = d->hoverControl; | - |
| 1095 | } executed: }Execution Count:3153 | 3153 |
| 1096 | if (d->currentIndex.isValid()) { evaluated: d->currentIndex.isValid()| yes Evaluation Count:1230 | yes Evaluation Count:1923 |
| 1230-1923 |
| 1097 | option->currentText = currentText(); executed (the execution status of this line is deduced): option->currentText = currentText(); | - |
| 1098 | option->currentIcon = d->itemIcon(d->currentIndex); executed (the execution status of this line is deduced): option->currentIcon = d->itemIcon(d->currentIndex); | - |
| 1099 | } executed: }Execution Count:1230 | 1230 |
| 1100 | option->iconSize = iconSize(); executed (the execution status of this line is deduced): option->iconSize = iconSize(); | - |
| 1101 | if (d->container && d->container->isVisible()) evaluated: d->container| yes Evaluation Count:2477 | yes Evaluation Count:676 |
partially evaluated: d->container->isVisible()| no Evaluation Count:0 | yes Evaluation Count:2477 |
| 0-2477 |
| 1102 | option->state |= QStyle::State_On; never executed: option->state |= QStyle::State_On; | 0 |
| 1103 | } executed: }Execution Count:3153 | 3153 |
| 1104 | | - |
| 1105 | void QComboBoxPrivate::updateLineEditGeometry() | - |
| 1106 | { | - |
| 1107 | if (!lineEdit) evaluated: !lineEdit| yes Evaluation Count:104 | yes Evaluation Count:567 |
| 104-567 |
| 1108 | return; executed: return;Execution Count:104 | 104 |
| 1109 | | - |
| 1110 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1111 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 1112 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 1113 | QRect editRect = q->style()->subControlRect(QStyle::CC_ComboBox, &opt, executed (the execution status of this line is deduced): QRect editRect = q->style()->subControlRect(QStyle::CC_ComboBox, &opt, | - |
| 1114 | QStyle::SC_ComboBoxEditField, q); executed (the execution status of this line is deduced): QStyle::SC_ComboBoxEditField, q); | - |
| 1115 | if (!q->itemIcon(q->currentIndex()).isNull()) { partially evaluated: !q->itemIcon(q->currentIndex()).isNull()| no Evaluation Count:0 | yes Evaluation Count:567 |
| 0-567 |
| 1116 | QRect comboRect(editRect); never executed (the execution status of this line is deduced): QRect comboRect(editRect); | - |
| 1117 | editRect.setWidth(editRect.width() - q->iconSize().width() - 4); never executed (the execution status of this line is deduced): editRect.setWidth(editRect.width() - q->iconSize().width() - 4); | - |
| 1118 | editRect = QStyle::alignedRect(q->layoutDirection(), Qt::AlignRight, never executed (the execution status of this line is deduced): editRect = QStyle::alignedRect(q->layoutDirection(), Qt::AlignRight, | - |
| 1119 | editRect.size(), comboRect); never executed (the execution status of this line is deduced): editRect.size(), comboRect); | - |
| 1120 | } | 0 |
| 1121 | lineEdit->setGeometry(editRect); executed (the execution status of this line is deduced): lineEdit->setGeometry(editRect); | - |
| 1122 | } executed: }Execution Count:567 | 567 |
| 1123 | | - |
| 1124 | Qt::MatchFlags QComboBoxPrivate::matchFlags() const | - |
| 1125 | { | - |
| 1126 | // Base how duplicates are determined on the autocompletion case sensitivity | - |
| 1127 | Qt::MatchFlags flags = Qt::MatchFixedString; executed (the execution status of this line is deduced): Qt::MatchFlags flags = Qt::MatchFixedString; | - |
| 1128 | #ifndef QT_NO_COMPLETER | - |
| 1129 | if (!lineEdit->completer() || lineEdit->completer()->caseSensitivity() == Qt::CaseSensitive) partially evaluated: !lineEdit->completer()| no Evaluation Count:0 | yes Evaluation Count:9 |
evaluated: lineEdit->completer()->caseSensitivity() == Qt::CaseSensitive| yes Evaluation Count:2 | yes Evaluation Count:7 |
| 0-9 |
| 1130 | #endif | - |
| 1131 | flags |= Qt::MatchCaseSensitive; executed: flags |= Qt::MatchCaseSensitive;Execution Count:2 | 2 |
| 1132 | return flags; executed: return flags;Execution Count:9 | 9 |
| 1133 | } | - |
| 1134 | | - |
| 1135 | | - |
| 1136 | void QComboBoxPrivate::_q_editingFinished() | - |
| 1137 | { | - |
| 1138 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1139 | if (lineEdit && !lineEdit->text().isEmpty()) { partially evaluated: lineEdit| yes Evaluation Count:8 | no Evaluation Count:0 |
evaluated: !lineEdit->text().isEmpty()| yes Evaluation Count:7 | yes Evaluation Count:1 |
| 0-8 |
| 1140 | //here we just check if the current item was entered | - |
| 1141 | const int index = q_func()->findText(lineEdit->text(), matchFlags()); executed (the execution status of this line is deduced): const int index = q_func()->findText(lineEdit->text(), matchFlags()); | - |
| 1142 | if (index != -1 && itemText(currentIndex) != lineEdit->text()) { evaluated: index != -1| yes Evaluation Count:5 | yes Evaluation Count:2 |
partially evaluated: itemText(currentIndex) != lineEdit->text()| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1143 | q->setCurrentIndex(index); never executed (the execution status of this line is deduced): q->setCurrentIndex(index); | - |
| 1144 | emitActivated(currentIndex); never executed (the execution status of this line is deduced): emitActivated(currentIndex); | - |
| 1145 | } | 0 |
| 1146 | } executed: }Execution Count:7 | 7 |
| 1147 | | - |
| 1148 | } executed: }Execution Count:8 | 8 |
| 1149 | | - |
| 1150 | void QComboBoxPrivate::_q_returnPressed() | - |
| 1151 | { | - |
| 1152 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1153 | if (lineEdit && !lineEdit->text().isEmpty()) { partially evaluated: lineEdit| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !lineEdit->text().isEmpty()| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 1154 | if (q->count() >= maxCount && !(this->insertPolicy == QComboBox::InsertAtCurrent)) partially evaluated: q->count() >= maxCount| no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: !(this->insertPolicy == QComboBox::InsertAtCurrent) | 0-2 |
| 1155 | return; | 0 |
| 1156 | lineEdit->deselect(); executed (the execution status of this line is deduced): lineEdit->deselect(); | - |
| 1157 | lineEdit->end(false); executed (the execution status of this line is deduced): lineEdit->end(false); | - |
| 1158 | QString text = lineEdit->text(); executed (the execution status of this line is deduced): QString text = lineEdit->text(); | - |
| 1159 | // check for duplicates (if not enabled) and quit | - |
| 1160 | int index = -1; executed (the execution status of this line is deduced): int index = -1; | - |
| 1161 | if (!duplicatesEnabled) { partially evaluated: !duplicatesEnabled| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 1162 | index = q->findText(text, matchFlags()); executed (the execution status of this line is deduced): index = q->findText(text, matchFlags()); | - |
| 1163 | if (index != -1) { evaluated: index != -1| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 1164 | q->setCurrentIndex(index); executed (the execution status of this line is deduced): q->setCurrentIndex(index); | - |
| 1165 | emitActivated(currentIndex); executed (the execution status of this line is deduced): emitActivated(currentIndex); | - |
| 1166 | return; executed: return;Execution Count:1 | 1 |
| 1167 | } | - |
| 1168 | } executed: }Execution Count:1 | 1 |
| 1169 | switch (insertPolicy) { | - |
| 1170 | case QComboBox::InsertAtTop: | - |
| 1171 | index = 0; never executed (the execution status of this line is deduced): index = 0; | - |
| 1172 | break; | 0 |
| 1173 | case QComboBox::InsertAtBottom: | - |
| 1174 | index = q->count(); executed (the execution status of this line is deduced): index = q->count(); | - |
| 1175 | break; executed: break;Execution Count:1 | 1 |
| 1176 | case QComboBox::InsertAtCurrent: | - |
| 1177 | case QComboBox::InsertAfterCurrent: | - |
| 1178 | case QComboBox::InsertBeforeCurrent: | - |
| 1179 | if (!q->count() || !currentIndex.isValid()) never evaluated: !q->count() never evaluated: !currentIndex.isValid() | 0 |
| 1180 | index = 0; never executed: index = 0; | 0 |
| 1181 | else if (insertPolicy == QComboBox::InsertAtCurrent) never evaluated: insertPolicy == QComboBox::InsertAtCurrent | 0 |
| 1182 | q->setItemText(q->currentIndex(), text); never executed: q->setItemText(q->currentIndex(), text); | 0 |
| 1183 | else if (insertPolicy == QComboBox::InsertAfterCurrent) never evaluated: insertPolicy == QComboBox::InsertAfterCurrent | 0 |
| 1184 | index = q->currentIndex() + 1; never executed: index = q->currentIndex() + 1; | 0 |
| 1185 | else if (insertPolicy == QComboBox::InsertBeforeCurrent) never evaluated: insertPolicy == QComboBox::InsertBeforeCurrent | 0 |
| 1186 | index = q->currentIndex(); never executed: index = q->currentIndex(); | 0 |
| 1187 | break; | 0 |
| 1188 | case QComboBox::InsertAlphabetically: | - |
| 1189 | index = 0; never executed (the execution status of this line is deduced): index = 0; | - |
| 1190 | for (int i=0; i< q->count(); i++, index++ ) { never evaluated: i< q->count() | 0 |
| 1191 | if (text.toLower() < q->itemText(i).toLower()) never evaluated: text.toLower() < q->itemText(i).toLower() | 0 |
| 1192 | break; | 0 |
| 1193 | } | 0 |
| 1194 | break; | 0 |
| 1195 | case QComboBox::NoInsert: | - |
| 1196 | default: | - |
| 1197 | break; | 0 |
| 1198 | } | - |
| 1199 | if (index >= 0) { partially evaluated: index >= 0| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1200 | q->insertItem(index, text); executed (the execution status of this line is deduced): q->insertItem(index, text); | - |
| 1201 | q->setCurrentIndex(index); executed (the execution status of this line is deduced): q->setCurrentIndex(index); | - |
| 1202 | emitActivated(currentIndex); executed (the execution status of this line is deduced): emitActivated(currentIndex); | - |
| 1203 | } executed: }Execution Count:1 | 1 |
| 1204 | } executed: }Execution Count:1 | 1 |
| 1205 | } executed: }Execution Count:1 | 1 |
| 1206 | | - |
| 1207 | void QComboBoxPrivate::_q_itemSelected(const QModelIndex &item) | - |
| 1208 | { | - |
| 1209 | Q_Q(QComboBox); never executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1210 | if (item != currentIndex) { never evaluated: item != currentIndex | 0 |
| 1211 | setCurrentIndex(item); never executed (the execution status of this line is deduced): setCurrentIndex(item); | - |
| 1212 | } else if (lineEdit) { never executed: } never evaluated: lineEdit | 0 |
| 1213 | lineEdit->selectAll(); never executed (the execution status of this line is deduced): lineEdit->selectAll(); | - |
| 1214 | lineEdit->setText(q->itemText(currentIndex.row())); never executed (the execution status of this line is deduced): lineEdit->setText(q->itemText(currentIndex.row())); | - |
| 1215 | } | 0 |
| 1216 | emitActivated(currentIndex); never executed (the execution status of this line is deduced): emitActivated(currentIndex); | - |
| 1217 | } | 0 |
| 1218 | | - |
| 1219 | void QComboBoxPrivate::emitActivated(const QModelIndex &index) | - |
| 1220 | { | - |
| 1221 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1222 | if (!index.isValid()) partially evaluated: !index.isValid()| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 1223 | return; | 0 |
| 1224 | QString text(itemText(index)); executed (the execution status of this line is deduced): QString text(itemText(index)); | - |
| 1225 | emit q->activated(index.row()); executed (the execution status of this line is deduced): q->activated(index.row()); | - |
| 1226 | emit q->activated(text); executed (the execution status of this line is deduced): q->activated(text); | - |
| 1227 | } executed: }Execution Count:4 | 4 |
| 1228 | | - |
| 1229 | void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) | - |
| 1230 | { | - |
| 1231 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1232 | if (!index.isValid()) partially evaluated: !index.isValid()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1233 | return; | 0 |
| 1234 | QString text(itemText(index)); executed (the execution status of this line is deduced): QString text(itemText(index)); | - |
| 1235 | emit q->highlighted(index.row()); executed (the execution status of this line is deduced): q->highlighted(index.row()); | - |
| 1236 | emit q->highlighted(text); executed (the execution status of this line is deduced): q->highlighted(text); | - |
| 1237 | } executed: }Execution Count:1 | 1 |
| 1238 | | - |
| 1239 | void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) | - |
| 1240 | { | - |
| 1241 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1242 | emit q->currentIndexChanged(index.row()); executed (the execution status of this line is deduced): q->currentIndexChanged(index.row()); | - |
| 1243 | const QString text = itemText(index); executed (the execution status of this line is deduced): const QString text = itemText(index); | - |
| 1244 | emit q->currentIndexChanged(text); executed (the execution status of this line is deduced): q->currentIndexChanged(text); | - |
| 1245 | // signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here | - |
| 1246 | if (!lineEdit) evaluated: !lineEdit| yes Evaluation Count:818 | yes Evaluation Count:267 |
| 267-818 |
| 1247 | emit q->currentTextChanged(text); executed: q->currentTextChanged(text);Execution Count:818 | 818 |
| 1248 | #ifndef QT_NO_ACCESSIBILITY | - |
| 1249 | QAccessibleEvent event(q, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(q, QAccessible::NameChanged); | - |
| 1250 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 1251 | #endif | - |
| 1252 | } executed: }Execution Count:1085 | 1085 |
| 1253 | | - |
| 1254 | QString QComboBoxPrivate::itemText(const QModelIndex &index) const | - |
| 1255 | { | - |
| 1256 | return index.isValid() ? model->data(index, itemRole()).toString() : QString(); executed: return index.isValid() ? model->data(index, itemRole()).toString() : QString();Execution Count:4717 | 4717 |
| 1257 | } | - |
| 1258 | | - |
| 1259 | int QComboBoxPrivate::itemRole() const | - |
| 1260 | { | - |
| 1261 | return q_func()->isEditable() ? Qt::EditRole : Qt::DisplayRole; executed: return q_func()->isEditable() ? Qt::EditRole : Qt::DisplayRole;Execution Count:4372 | 4372 |
| 1262 | } | - |
| 1263 | | - |
| 1264 | /*! | - |
| 1265 | Destroys the combobox. | - |
| 1266 | */ | - |
| 1267 | QComboBox::~QComboBox() | - |
| 1268 | { | - |
| 1269 | // ### check delegateparent and delete delegate if us? | - |
| 1270 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1271 | | - |
| 1272 | QT_TRY { partially evaluated: true| yes Evaluation Count:557 | no Evaluation Count:0 |
| 0-557 |
| 1273 | disconnect(d->model, SIGNAL(destroyed()), executed (the execution status of this line is deduced): disconnect(d->model, "2""destroyed()", | - |
| 1274 | this, SLOT(_q_modelDestroyed())); executed (the execution status of this line is deduced): this, "1""_q_modelDestroyed()"); | - |
| 1275 | } QT_CATCH(...) { executed: }Execution Count:557 | 557 |
| 1276 | ; // objects can't throw in destructor | - |
| 1277 | } | 0 |
| 1278 | } | - |
| 1279 | | - |
| 1280 | /*! | - |
| 1281 | \property QComboBox::maxVisibleItems | - |
| 1282 | \brief the maximum allowed size on screen of the combo box, measured in items | - |
| 1283 | | - |
| 1284 | By default, this property has a value of 10. | - |
| 1285 | | - |
| 1286 | \note This property is ignored for non-editable comboboxes in styles that returns | - |
| 1287 | true for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. | - |
| 1288 | */ | - |
| 1289 | int QComboBox::maxVisibleItems() const | - |
| 1290 | { | - |
| 1291 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1292 | return d->maxVisibleItems; never executed: return d->maxVisibleItems; | 0 |
| 1293 | } | - |
| 1294 | | - |
| 1295 | void QComboBox::setMaxVisibleItems(int maxItems) | - |
| 1296 | { | - |
| 1297 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1298 | if (maxItems < 0) { never evaluated: maxItems < 0 | 0 |
| 1299 | qWarning("QComboBox::setMaxVisibleItems: " never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 1299, __PRETTY_FUNCTION__).warning("QComboBox::setMaxVisibleItems: " | - |
| 1300 | "Invalid max visible items (%d) must be >= 0", maxItems); never executed (the execution status of this line is deduced): "Invalid max visible items (%d) must be >= 0", maxItems); | - |
| 1301 | return; | 0 |
| 1302 | } | - |
| 1303 | d->maxVisibleItems = maxItems; never executed (the execution status of this line is deduced): d->maxVisibleItems = maxItems; | - |
| 1304 | } | 0 |
| 1305 | | - |
| 1306 | /*! | - |
| 1307 | \property QComboBox::count | - |
| 1308 | \brief the number of items in the combobox | - |
| 1309 | | - |
| 1310 | By default, for an empty combo box, this property has a value of 0. | - |
| 1311 | */ | - |
| 1312 | int QComboBox::count() const | - |
| 1313 | { | - |
| 1314 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1315 | return d->model->rowCount(d->root); executed: return d->model->rowCount(d->root);Execution Count:3637 | 3637 |
| 1316 | } | - |
| 1317 | | - |
| 1318 | /*! | - |
| 1319 | \property QComboBox::maxCount | - |
| 1320 | \brief the maximum number of items allowed in the combobox | - |
| 1321 | | - |
| 1322 | \note If you set the maximum number to be less then the current | - |
| 1323 | amount of items in the combobox, the extra items will be | - |
| 1324 | truncated. This also applies if you have set an external model on | - |
| 1325 | the combobox. | - |
| 1326 | | - |
| 1327 | By default, this property's value is derived from the highest | - |
| 1328 | signed integer available (typically 2147483647). | - |
| 1329 | */ | - |
| 1330 | void QComboBox::setMaxCount(int max) | - |
| 1331 | { | - |
| 1332 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1333 | if (max < 0) { | 0 |
| 1334 | qWarning("QComboBox::setMaxCount: Invalid count (%d) must be >= 0", max); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 1334, __PRETTY_FUNCTION__).warning("QComboBox::setMaxCount: Invalid count (%d) must be >= 0", max); | - |
| 1335 | return; | 0 |
| 1336 | } | - |
| 1337 | | - |
| 1338 | if (max < count()) never evaluated: max < count() | 0 |
| 1339 | d->model->removeRows(max, count() - max, d->root); never executed: d->model->removeRows(max, count() - max, d->root); | 0 |
| 1340 | | - |
| 1341 | d->maxCount = max; never executed (the execution status of this line is deduced): d->maxCount = max; | - |
| 1342 | } | 0 |
| 1343 | | - |
| 1344 | int QComboBox::maxCount() const | - |
| 1345 | { | - |
| 1346 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1347 | return d->maxCount; never executed: return d->maxCount; | 0 |
| 1348 | } | - |
| 1349 | | - |
| 1350 | #ifndef QT_NO_COMPLETER | - |
| 1351 | | - |
| 1352 | /*! | - |
| 1353 | \property QComboBox::autoCompletion | - |
| 1354 | \brief whether the combobox provides auto-completion for editable items | - |
| 1355 | \since 4.1 | - |
| 1356 | \obsolete | - |
| 1357 | | - |
| 1358 | Use setCompleter() instead. | - |
| 1359 | | - |
| 1360 | By default, this property is true. | - |
| 1361 | | - |
| 1362 | \sa editable | - |
| 1363 | */ | - |
| 1364 | | - |
| 1365 | /*! | - |
| 1366 | \obsolete | - |
| 1367 | | - |
| 1368 | Use setCompleter() instead. | - |
| 1369 | */ | - |
| 1370 | bool QComboBox::autoCompletion() const | - |
| 1371 | { | - |
| 1372 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1373 | return d->autoCompletion; never executed: return d->autoCompletion; | 0 |
| 1374 | } | - |
| 1375 | | - |
| 1376 | /*! | - |
| 1377 | \obsolete | - |
| 1378 | | - |
| 1379 | Use setCompleter() instead. | - |
| 1380 | */ | - |
| 1381 | void QComboBox::setAutoCompletion(bool enable) | - |
| 1382 | { | - |
| 1383 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1384 | | - |
| 1385 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 1386 | if (QApplication::keypadNavigationEnabled() && !enable && isEditable()) | - |
| 1387 | qWarning("QComboBox::setAutoCompletion: auto completion is mandatory when combo box editable"); | - |
| 1388 | #endif | - |
| 1389 | | - |
| 1390 | d->autoCompletion = enable; executed (the execution status of this line is deduced): d->autoCompletion = enable; | - |
| 1391 | if (!d->lineEdit) partially evaluated: !d->lineEdit| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1392 | return; | 0 |
| 1393 | if (enable) { partially evaluated: enable| yes Evaluation Count:150 | no Evaluation Count:0 |
| 0-150 |
| 1394 | if (d->lineEdit->completer()) partially evaluated: d->lineEdit->completer()| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1395 | return; | 0 |
| 1396 | d->completer = new QCompleter(d->model, d->lineEdit); executed (the execution status of this line is deduced): d->completer = new QCompleter(d->model, d->lineEdit); | - |
| 1397 | d->completer->setCaseSensitivity(d->autoCompletionCaseSensitivity); executed (the execution status of this line is deduced): d->completer->setCaseSensitivity(d->autoCompletionCaseSensitivity); | - |
| 1398 | d->completer->setCompletionMode(QCompleter::InlineCompletion); executed (the execution status of this line is deduced): d->completer->setCompletionMode(QCompleter::InlineCompletion); | - |
| 1399 | d->completer->setCompletionColumn(d->modelColumn); executed (the execution status of this line is deduced): d->completer->setCompletionColumn(d->modelColumn); | - |
| 1400 | d->lineEdit->setCompleter(d->completer); executed (the execution status of this line is deduced): d->lineEdit->setCompleter(d->completer); | - |
| 1401 | d->completer->setWidget(this); executed (the execution status of this line is deduced): d->completer->setWidget(this); | - |
| 1402 | } else { executed: }Execution Count:150 | 150 |
| 1403 | d->lineEdit->setCompleter(0); never executed (the execution status of this line is deduced): d->lineEdit->setCompleter(0); | - |
| 1404 | } | 0 |
| 1405 | } | - |
| 1406 | | - |
| 1407 | /*! | - |
| 1408 | \property QComboBox::autoCompletionCaseSensitivity | - |
| 1409 | \brief whether string comparisons are case-sensitive or case-insensitive for auto-completion | - |
| 1410 | \obsolete | - |
| 1411 | | - |
| 1412 | By default, this property is Qt::CaseInsensitive. | - |
| 1413 | | - |
| 1414 | Use setCompleter() instead. Case sensitivity of the auto completion can be | - |
| 1415 | changed using QCompleter::setCaseSensitivity(). | - |
| 1416 | | - |
| 1417 | \sa autoCompletion | - |
| 1418 | */ | - |
| 1419 | | - |
| 1420 | /*! | - |
| 1421 | \obsolete | - |
| 1422 | | - |
| 1423 | Use setCompleter() and QCompleter::setCaseSensitivity() instead. | - |
| 1424 | */ | - |
| 1425 | Qt::CaseSensitivity QComboBox::autoCompletionCaseSensitivity() const | - |
| 1426 | { | - |
| 1427 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1428 | return d->autoCompletionCaseSensitivity; never executed: return d->autoCompletionCaseSensitivity; | 0 |
| 1429 | } | - |
| 1430 | | - |
| 1431 | /*! | - |
| 1432 | \obsolete | - |
| 1433 | | - |
| 1434 | Use setCompleter() and QCompleter::setCaseSensitivity() instead. | - |
| 1435 | */ | - |
| 1436 | void QComboBox::setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity) | - |
| 1437 | { | - |
| 1438 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1439 | d->autoCompletionCaseSensitivity = sensitivity; never executed (the execution status of this line is deduced): d->autoCompletionCaseSensitivity = sensitivity; | - |
| 1440 | if (d->lineEdit && d->lineEdit->completer()) never evaluated: d->lineEdit never evaluated: d->lineEdit->completer() | 0 |
| 1441 | d->lineEdit->completer()->setCaseSensitivity(sensitivity); never executed: d->lineEdit->completer()->setCaseSensitivity(sensitivity); | 0 |
| 1442 | } | 0 |
| 1443 | | - |
| 1444 | #endif // QT_NO_COMPLETER | - |
| 1445 | | - |
| 1446 | /*! | - |
| 1447 | \property QComboBox::duplicatesEnabled | - |
| 1448 | \brief whether the user can enter duplicate items into the combobox | - |
| 1449 | | - |
| 1450 | Note that it is always possible to programmatically insert duplicate items into the | - |
| 1451 | combobox. | - |
| 1452 | | - |
| 1453 | By default, this property is false (duplicates are not allowed). | - |
| 1454 | */ | - |
| 1455 | bool QComboBox::duplicatesEnabled() const | - |
| 1456 | { | - |
| 1457 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1458 | return d->duplicatesEnabled; never executed: return d->duplicatesEnabled; | 0 |
| 1459 | } | - |
| 1460 | | - |
| 1461 | void QComboBox::setDuplicatesEnabled(bool enable) | - |
| 1462 | { | - |
| 1463 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1464 | d->duplicatesEnabled = enable; executed (the execution status of this line is deduced): d->duplicatesEnabled = enable; | - |
| 1465 | } executed: }Execution Count:378 | 378 |
| 1466 | | - |
| 1467 | /*! \fn int QComboBox::findText(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const | - |
| 1468 | | - |
| 1469 | Returns the index of the item containing the given \a text; otherwise | - |
| 1470 | returns -1. | - |
| 1471 | | - |
| 1472 | The \a flags specify how the items in the combobox are searched. | - |
| 1473 | */ | - |
| 1474 | | - |
| 1475 | /*! | - |
| 1476 | Returns the index of the item containing the given \a data for the | - |
| 1477 | given \a role; otherwise returns -1. | - |
| 1478 | | - |
| 1479 | The \a flags specify how the items in the combobox are searched. | - |
| 1480 | */ | - |
| 1481 | int QComboBox::findData(const QVariant &data, int role, Qt::MatchFlags flags) const | - |
| 1482 | { | - |
| 1483 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1484 | QModelIndexList result; executed (the execution status of this line is deduced): QModelIndexList result; | - |
| 1485 | QModelIndex start = d->model->index(0, d->modelColumn, d->root); executed (the execution status of this line is deduced): QModelIndex start = d->model->index(0, d->modelColumn, d->root); | - |
| 1486 | result = d->model->match(start, role, data, 1, flags); executed (the execution status of this line is deduced): result = d->model->match(start, role, data, 1, flags); | - |
| 1487 | if (result.isEmpty()) evaluated: result.isEmpty()| yes Evaluation Count:10 | yes Evaluation Count:18 |
| 10-18 |
| 1488 | return -1; executed: return -1;Execution Count:10 | 10 |
| 1489 | return result.first().row(); executed: return result.first().row();Execution Count:18 | 18 |
| 1490 | } | - |
| 1491 | | - |
| 1492 | /*! | - |
| 1493 | \property QComboBox::insertPolicy | - |
| 1494 | \brief the policy used to determine where user-inserted items should | - |
| 1495 | appear in the combobox | - |
| 1496 | | - |
| 1497 | The default value is \l InsertAtBottom, indicating that new items will appear | - |
| 1498 | at the bottom of the list of items. | - |
| 1499 | | - |
| 1500 | \sa InsertPolicy | - |
| 1501 | */ | - |
| 1502 | | - |
| 1503 | QComboBox::InsertPolicy QComboBox::insertPolicy() const | - |
| 1504 | { | - |
| 1505 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1506 | return d->insertPolicy; never executed: return d->insertPolicy; | 0 |
| 1507 | } | - |
| 1508 | | - |
| 1509 | void QComboBox::setInsertPolicy(InsertPolicy policy) | - |
| 1510 | { | - |
| 1511 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1512 | d->insertPolicy = policy; executed (the execution status of this line is deduced): d->insertPolicy = policy; | - |
| 1513 | } executed: }Execution Count:190 | 190 |
| 1514 | | - |
| 1515 | /*! | - |
| 1516 | \property QComboBox::sizeAdjustPolicy | - |
| 1517 | \brief the policy describing how the size of the combobox changes | - |
| 1518 | when the content changes | - |
| 1519 | | - |
| 1520 | The default value is \l AdjustToContentsOnFirstShow. | - |
| 1521 | | - |
| 1522 | \sa SizeAdjustPolicy | - |
| 1523 | */ | - |
| 1524 | | - |
| 1525 | QComboBox::SizeAdjustPolicy QComboBox::sizeAdjustPolicy() const | - |
| 1526 | { | - |
| 1527 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1528 | return d->sizeAdjustPolicy; never executed: return d->sizeAdjustPolicy; | 0 |
| 1529 | } | - |
| 1530 | | - |
| 1531 | void QComboBox::setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy policy) | - |
| 1532 | { | - |
| 1533 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1534 | if (policy == d->sizeAdjustPolicy) partially evaluated: policy == d->sizeAdjustPolicy| no Evaluation Count:0 | yes Evaluation Count:189 |
| 0-189 |
| 1535 | return; | 0 |
| 1536 | | - |
| 1537 | d->sizeAdjustPolicy = policy; executed (the execution status of this line is deduced): d->sizeAdjustPolicy = policy; | - |
| 1538 | d->sizeHint = QSize(); executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 1539 | d->adjustComboBoxSize(); executed (the execution status of this line is deduced): d->adjustComboBoxSize(); | - |
| 1540 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 1541 | } executed: }Execution Count:189 | 189 |
| 1542 | | - |
| 1543 | /*! | - |
| 1544 | \property QComboBox::minimumContentsLength | - |
| 1545 | \brief the minimum number of characters that should fit into the combobox. | - |
| 1546 | | - |
| 1547 | The default value is 0. | - |
| 1548 | | - |
| 1549 | If this property is set to a positive value, the | - |
| 1550 | minimumSizeHint() and sizeHint() take it into account. | - |
| 1551 | | - |
| 1552 | \sa sizeAdjustPolicy | - |
| 1553 | */ | - |
| 1554 | int QComboBox::minimumContentsLength() const | - |
| 1555 | { | - |
| 1556 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1557 | return d->minimumContentsLength; never executed: return d->minimumContentsLength; | 0 |
| 1558 | } | - |
| 1559 | | - |
| 1560 | void QComboBox::setMinimumContentsLength(int characters) | - |
| 1561 | { | - |
| 1562 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1563 | if (characters == d->minimumContentsLength || characters < 0) never evaluated: characters == d->minimumContentsLength never evaluated: characters < 0 | 0 |
| 1564 | return; | 0 |
| 1565 | | - |
| 1566 | d->minimumContentsLength = characters; never executed (the execution status of this line is deduced): d->minimumContentsLength = characters; | - |
| 1567 | | - |
| 1568 | if (d->sizeAdjustPolicy == AdjustToContents never evaluated: d->sizeAdjustPolicy == AdjustToContents | 0 |
| 1569 | || d->sizeAdjustPolicy == AdjustToMinimumContentsLength never evaluated: d->sizeAdjustPolicy == AdjustToMinimumContentsLength | 0 |
| 1570 | || d->sizeAdjustPolicy == AdjustToMinimumContentsLengthWithIcon) { never evaluated: d->sizeAdjustPolicy == AdjustToMinimumContentsLengthWithIcon | 0 |
| 1571 | d->sizeHint = QSize(); never executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 1572 | d->adjustComboBoxSize(); never executed (the execution status of this line is deduced): d->adjustComboBoxSize(); | - |
| 1573 | updateGeometry(); never executed (the execution status of this line is deduced): updateGeometry(); | - |
| 1574 | } | 0 |
| 1575 | } | 0 |
| 1576 | | - |
| 1577 | /*! | - |
| 1578 | \property QComboBox::iconSize | - |
| 1579 | \brief the size of the icons shown in the combobox. | - |
| 1580 | | - |
| 1581 | Unless explicitly set this returns the default value of the | - |
| 1582 | current style. This size is the maximum size that icons can have; | - |
| 1583 | icons of smaller size are not scaled up. | - |
| 1584 | */ | - |
| 1585 | | - |
| 1586 | QSize QComboBox::iconSize() const | - |
| 1587 | { | - |
| 1588 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1589 | if (d->iconSize.isValid()) partially evaluated: d->iconSize.isValid()| no Evaluation Count:0 | yes Evaluation Count:4148 |
| 0-4148 |
| 1590 | return d->iconSize; never executed: return d->iconSize; | 0 |
| 1591 | | - |
| 1592 | int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); executed (the execution status of this line is deduced): int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); | - |
| 1593 | return QSize(iconWidth, iconWidth); executed: return QSize(iconWidth, iconWidth);Execution Count:4148 | 4148 |
| 1594 | } | - |
| 1595 | | - |
| 1596 | void QComboBox::setIconSize(const QSize &size) | - |
| 1597 | { | - |
| 1598 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1599 | if (size == d->iconSize) never evaluated: size == d->iconSize | 0 |
| 1600 | return; | 0 |
| 1601 | | - |
| 1602 | view()->setIconSize(size); never executed (the execution status of this line is deduced): view()->setIconSize(size); | - |
| 1603 | d->iconSize = size; never executed (the execution status of this line is deduced): d->iconSize = size; | - |
| 1604 | d->sizeHint = QSize(); never executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 1605 | updateGeometry(); never executed (the execution status of this line is deduced): updateGeometry(); | - |
| 1606 | } | 0 |
| 1607 | | - |
| 1608 | /*! | - |
| 1609 | \property QComboBox::editable | - |
| 1610 | \brief whether the combo box can be edited by the user | - |
| 1611 | | - |
| 1612 | By default, this property is false. The effect of editing depends | - |
| 1613 | on the insert policy. | - |
| 1614 | | - |
| 1615 | \sa InsertPolicy | - |
| 1616 | */ | - |
| 1617 | bool QComboBox::isEditable() const | - |
| 1618 | { | - |
| 1619 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1620 | return d->lineEdit != 0; executed: return d->lineEdit != 0;Execution Count:9454 | 9454 |
| 1621 | } | - |
| 1622 | | - |
| 1623 | /*! \internal | - |
| 1624 | update the default delegate | - |
| 1625 | depending on the style's SH_ComboBox_Popup hint, we use a different default delegate. | - |
| 1626 | | - |
| 1627 | but we do not change the delegate is the combobox use a custom delegate, | - |
| 1628 | unless \a force is set to true. | - |
| 1629 | */ | - |
| 1630 | void QComboBoxPrivate::updateDelegate(bool force) | - |
| 1631 | { | - |
| 1632 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 1633 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 1634 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 1635 | if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) { partially evaluated: q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)| no Evaluation Count:0 | yes Evaluation Count:491 |
| 0-491 |
| 1636 | if (force || qobject_cast<QComboBoxDelegate *>(q->itemDelegate())) never evaluated: force never evaluated: qobject_cast<QComboBoxDelegate *>(q->itemDelegate()) | 0 |
| 1637 | q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); never executed: q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); | 0 |
| 1638 | } else { | 0 |
| 1639 | if (force || qobject_cast<QComboMenuDelegate *>(q->itemDelegate())) evaluated: force| yes Evaluation Count:339 | yes Evaluation Count:152 |
partially evaluated: qobject_cast<QComboMenuDelegate *>(q->itemDelegate())| no Evaluation Count:0 | yes Evaluation Count:152 |
| 0-339 |
| 1640 | q->setItemDelegate(new QComboBoxDelegate(q->view(), q)); executed: q->setItemDelegate(new QComboBoxDelegate(q->view(), q));Execution Count:339 | 339 |
| 1641 | } executed: }Execution Count:491 | 491 |
| 1642 | } | - |
| 1643 | | - |
| 1644 | QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const | - |
| 1645 | { | - |
| 1646 | QVariant decoration = model->data(index, Qt::DecorationRole); executed (the execution status of this line is deduced): QVariant decoration = model->data(index, Qt::DecorationRole); | - |
| 1647 | if (decoration.type() == QVariant::Pixmap) partially evaluated: decoration.type() == QVariant::Pixmap| no Evaluation Count:0 | yes Evaluation Count:2849 |
| 0-2849 |
| 1648 | return QIcon(qvariant_cast<QPixmap>(decoration)); never executed: return QIcon(qvariant_cast<QPixmap>(decoration)); | 0 |
| 1649 | else | - |
| 1650 | return qvariant_cast<QIcon>(decoration); executed: return qvariant_cast<QIcon>(decoration);Execution Count:2849 | 2849 |
| 1651 | } | - |
| 1652 | | - |
| 1653 | void QComboBox::setEditable(bool editable) | - |
| 1654 | { | - |
| 1655 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1656 | if (isEditable() == editable) evaluated: isEditable() == editable| yes Evaluation Count:30 | yes Evaluation Count:150 |
| 30-150 |
| 1657 | return; executed: return;Execution Count:30 | 30 |
| 1658 | | - |
| 1659 | d->updateDelegate(); executed (the execution status of this line is deduced): d->updateDelegate(); | - |
| 1660 | | - |
| 1661 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 1662 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 1663 | if (editable) { partially evaluated: editable| yes Evaluation Count:150 | no Evaluation Count:0 |
| 0-150 |
| 1664 | if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { partially evaluated: style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1665 | d->viewContainer()->updateScrollers(); never executed (the execution status of this line is deduced): d->viewContainer()->updateScrollers(); | - |
| 1666 | view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); never executed (the execution status of this line is deduced): view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); | - |
| 1667 | } | 0 |
| 1668 | QLineEdit *le = new QLineEdit(this); executed (the execution status of this line is deduced): QLineEdit *le = new QLineEdit(this); | - |
| 1669 | setLineEdit(le); executed (the execution status of this line is deduced): setLineEdit(le); | - |
| 1670 | #ifdef Q_OS_MAC | - |
| 1671 | // See comment in QComboBoxPrivate::init() | - |
| 1672 | setFocusPolicy(Qt::WheelFocus); | - |
| 1673 | #endif | - |
| 1674 | } else { executed: }Execution Count:150 | 150 |
| 1675 | if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { never evaluated: style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) | 0 |
| 1676 | d->viewContainer()->updateScrollers(); never executed (the execution status of this line is deduced): d->viewContainer()->updateScrollers(); | - |
| 1677 | view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); never executed (the execution status of this line is deduced): view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 1678 | } | 0 |
| 1679 | setAttribute(Qt::WA_InputMethodEnabled, false); never executed (the execution status of this line is deduced): setAttribute(Qt::WA_InputMethodEnabled, false); | - |
| 1680 | d->lineEdit->hide(); never executed (the execution status of this line is deduced): d->lineEdit->hide(); | - |
| 1681 | d->lineEdit->deleteLater(); never executed (the execution status of this line is deduced): d->lineEdit->deleteLater(); | - |
| 1682 | d->lineEdit = 0; never executed (the execution status of this line is deduced): d->lineEdit = 0; | - |
| 1683 | #ifdef Q_OS_MAC | - |
| 1684 | // See comment in QComboBoxPrivate::init() | - |
| 1685 | setFocusPolicy(Qt::TabFocus); | - |
| 1686 | #endif | - |
| 1687 | } | 0 |
| 1688 | | - |
| 1689 | d->viewContainer()->updateTopBottomMargin(); executed (the execution status of this line is deduced): d->viewContainer()->updateTopBottomMargin(); | - |
| 1690 | if (!testAttribute(Qt::WA_Resized)) evaluated: !testAttribute(Qt::WA_Resized)| yes Evaluation Count:149 | yes Evaluation Count:1 |
| 1-149 |
| 1691 | adjustSize(); executed: adjustSize();Execution Count:149 | 149 |
| 1692 | } executed: }Execution Count:150 | 150 |
| 1693 | | - |
| 1694 | /*! | - |
| 1695 | Sets the line \a edit to use instead of the current line edit widget. | - |
| 1696 | | - |
| 1697 | The combo box takes ownership of the line edit. | - |
| 1698 | */ | - |
| 1699 | void QComboBox::setLineEdit(QLineEdit *edit) | - |
| 1700 | { | - |
| 1701 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1702 | if (!edit) { partially evaluated: !edit| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1703 | qWarning("QComboBox::setLineEdit: cannot set a 0 line edit"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 1703, __PRETTY_FUNCTION__).warning("QComboBox::setLineEdit: cannot set a 0 line edit"); | - |
| 1704 | return; | 0 |
| 1705 | } | - |
| 1706 | | - |
| 1707 | if (edit == d->lineEdit) partially evaluated: edit == d->lineEdit| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1708 | return; | 0 |
| 1709 | | - |
| 1710 | edit->setText(currentText()); executed (the execution status of this line is deduced): edit->setText(currentText()); | - |
| 1711 | delete d->lineEdit; executed (the execution status of this line is deduced): delete d->lineEdit; | - |
| 1712 | | - |
| 1713 | d->lineEdit = edit; executed (the execution status of this line is deduced): d->lineEdit = edit; | - |
| 1714 | if (d->lineEdit->parent() != this) partially evaluated: d->lineEdit->parent() != this| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 1715 | d->lineEdit->setParent(this); never executed: d->lineEdit->setParent(this); | 0 |
| 1716 | connect(d->lineEdit, SIGNAL(returnPressed()), this, SLOT(_q_returnPressed())); executed (the execution status of this line is deduced): connect(d->lineEdit, "2""returnPressed()", this, "1""_q_returnPressed()"); | - |
| 1717 | connect(d->lineEdit, SIGNAL(editingFinished()), this, SLOT(_q_editingFinished())); executed (the execution status of this line is deduced): connect(d->lineEdit, "2""editingFinished()", this, "1""_q_editingFinished()"); | - |
| 1718 | connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(editTextChanged(QString))); executed (the execution status of this line is deduced): connect(d->lineEdit, "2""textChanged(QString)", this, "2""editTextChanged(QString)"); | - |
| 1719 | connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(currentTextChanged(QString))); executed (the execution status of this line is deduced): connect(d->lineEdit, "2""textChanged(QString)", this, "2""currentTextChanged(QString)"); | - |
| 1720 | d->lineEdit->setFrame(false); executed (the execution status of this line is deduced): d->lineEdit->setFrame(false); | - |
| 1721 | d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); executed (the execution status of this line is deduced): d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); | - |
| 1722 | d->lineEdit->setFocusProxy(this); executed (the execution status of this line is deduced): d->lineEdit->setFocusProxy(this); | - |
| 1723 | d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); executed (the execution status of this line is deduced): d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); | - |
| 1724 | #ifndef QT_NO_COMPLETER | - |
| 1725 | setAutoCompletion(d->autoCompletion); executed (the execution status of this line is deduced): setAutoCompletion(d->autoCompletion); | - |
| 1726 | #endif | - |
| 1727 | | - |
| 1728 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 1729 | #ifndef QT_NO_COMPLETER | - |
| 1730 | if (QApplication::keypadNavigationEnabled()) { | - |
| 1731 | // Editable combo boxes will have a completer that is set to UnfilteredPopupCompletion. | - |
| 1732 | // This means that when the user enters edit mode they are immediately presented with a | - |
| 1733 | // list of possible completions. | - |
| 1734 | setAutoCompletion(true); | - |
| 1735 | if (d->completer) { | - |
| 1736 | d->completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); | - |
| 1737 | connect(d->completer, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated())); | - |
| 1738 | } | - |
| 1739 | } | - |
| 1740 | #endif | - |
| 1741 | #endif | - |
| 1742 | | - |
| 1743 | setAttribute(Qt::WA_InputMethodEnabled); executed (the execution status of this line is deduced): setAttribute(Qt::WA_InputMethodEnabled); | - |
| 1744 | d->updateLayoutDirection(); executed (the execution status of this line is deduced): d->updateLayoutDirection(); | - |
| 1745 | d->updateLineEditGeometry(); executed (the execution status of this line is deduced): d->updateLineEditGeometry(); | - |
| 1746 | if (isVisible()) evaluated: isVisible()| yes Evaluation Count:2 | yes Evaluation Count:148 |
| 2-148 |
| 1747 | d->lineEdit->show(); executed: d->lineEdit->show();Execution Count:2 | 2 |
| 1748 | | - |
| 1749 | update(); executed (the execution status of this line is deduced): update(); | - |
| 1750 | } executed: }Execution Count:150 | 150 |
| 1751 | | - |
| 1752 | /*! | - |
| 1753 | Returns the line edit used to edit items in the combobox, or 0 if there | - |
| 1754 | is no line edit. | - |
| 1755 | | - |
| 1756 | Only editable combo boxes have a line edit. | - |
| 1757 | */ | - |
| 1758 | QLineEdit *QComboBox::lineEdit() const | - |
| 1759 | { | - |
| 1760 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1761 | return d->lineEdit; executed: return d->lineEdit;Execution Count:9 | 9 |
| 1762 | } | - |
| 1763 | | - |
| 1764 | #ifndef QT_NO_VALIDATOR | - |
| 1765 | /*! | - |
| 1766 | \fn void QComboBox::setValidator(const QValidator *validator) | - |
| 1767 | | - |
| 1768 | Sets the \a validator to use instead of the current validator. | - |
| 1769 | */ | - |
| 1770 | | - |
| 1771 | void QComboBox::setValidator(const QValidator *v) | - |
| 1772 | { | - |
| 1773 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1774 | if (d->lineEdit) never evaluated: d->lineEdit | 0 |
| 1775 | d->lineEdit->setValidator(v); never executed: d->lineEdit->setValidator(v); | 0 |
| 1776 | } | 0 |
| 1777 | | - |
| 1778 | /*! | - |
| 1779 | Returns the validator that is used to constrain text input for the | - |
| 1780 | combobox. | - |
| 1781 | | - |
| 1782 | \sa editable | - |
| 1783 | */ | - |
| 1784 | const QValidator *QComboBox::validator() const | - |
| 1785 | { | - |
| 1786 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1787 | return d->lineEdit ? d->lineEdit->validator() : 0; never executed: return d->lineEdit ? d->lineEdit->validator() : 0; | 0 |
| 1788 | } | - |
| 1789 | #endif // QT_NO_VALIDATOR | - |
| 1790 | | - |
| 1791 | #ifndef QT_NO_COMPLETER | - |
| 1792 | | - |
| 1793 | /*! | - |
| 1794 | \fn void QComboBox::setCompleter(QCompleter *completer) | - |
| 1795 | \since 4.2 | - |
| 1796 | | - |
| 1797 | Sets the \a completer to use instead of the current completer. | - |
| 1798 | If \a completer is 0, auto completion is disabled. | - |
| 1799 | | - |
| 1800 | By default, for an editable combo box, a QCompleter that | - |
| 1801 | performs case insensitive inline completion is automatically created. | - |
| 1802 | */ | - |
| 1803 | void QComboBox::setCompleter(QCompleter *c) | - |
| 1804 | { | - |
| 1805 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1806 | if (!d->lineEdit) partially evaluated: !d->lineEdit| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 1807 | return; | 0 |
| 1808 | d->lineEdit->setCompleter(c); executed (the execution status of this line is deduced): d->lineEdit->setCompleter(c); | - |
| 1809 | if (c) partially evaluated: c| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 1810 | c->setWidget(this); executed: c->setWidget(this);Execution Count:2 | 2 |
| 1811 | } executed: }Execution Count:2 | 2 |
| 1812 | | - |
| 1813 | /*! | - |
| 1814 | \since 4.2 | - |
| 1815 | | - |
| 1816 | Returns the completer that is used to auto complete text input for the | - |
| 1817 | combobox. | - |
| 1818 | | - |
| 1819 | \sa editable | - |
| 1820 | */ | - |
| 1821 | QCompleter *QComboBox::completer() const | - |
| 1822 | { | - |
| 1823 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1824 | return d->lineEdit ? d->lineEdit->completer() : 0; executed: return d->lineEdit ? d->lineEdit->completer() : 0;Execution Count:10 | 10 |
| 1825 | } | - |
| 1826 | | - |
| 1827 | #endif // QT_NO_COMPLETER | - |
| 1828 | | - |
| 1829 | /*! | - |
| 1830 | Returns the item delegate used by the popup list view. | - |
| 1831 | | - |
| 1832 | \sa setItemDelegate() | - |
| 1833 | */ | - |
| 1834 | QAbstractItemDelegate *QComboBox::itemDelegate() const | - |
| 1835 | { | - |
| 1836 | return view()->itemDelegate(); executed: return view()->itemDelegate();Execution Count:152 | 152 |
| 1837 | } | - |
| 1838 | | - |
| 1839 | /*! | - |
| 1840 | Sets the item \a delegate for the popup list view. | - |
| 1841 | The combobox takes ownership of the delegate. | - |
| 1842 | | - |
| 1843 | \warning You should not share the same instance of a delegate between comboboxes, | - |
| 1844 | widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior | - |
| 1845 | since each view connected to a given delegate may receive the | - |
| 1846 | \l{QAbstractItemDelegate::}{closeEditor()} signal, and attempt to access, modify or | - |
| 1847 | close an editor that has already been closed. | - |
| 1848 | | - |
| 1849 | \sa itemDelegate() | - |
| 1850 | */ | - |
| 1851 | void QComboBox::setItemDelegate(QAbstractItemDelegate *delegate) | - |
| 1852 | { | - |
| 1853 | if (!delegate) { partially evaluated: !delegate| no Evaluation Count:0 | yes Evaluation Count:479 |
| 0-479 |
| 1854 | qWarning("QComboBox::setItemDelegate: cannot set a 0 delegate"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 1854, __PRETTY_FUNCTION__).warning("QComboBox::setItemDelegate: cannot set a 0 delegate"); | - |
| 1855 | return; | 0 |
| 1856 | } | - |
| 1857 | delete view()->itemDelegate(); executed (the execution status of this line is deduced): delete view()->itemDelegate(); | - |
| 1858 | view()->setItemDelegate(delegate); executed (the execution status of this line is deduced): view()->setItemDelegate(delegate); | - |
| 1859 | } executed: }Execution Count:479 | 479 |
| 1860 | | - |
| 1861 | /*! | - |
| 1862 | Returns the model used by the combobox. | - |
| 1863 | */ | - |
| 1864 | | - |
| 1865 | QAbstractItemModel *QComboBox::model() const | - |
| 1866 | { | - |
| 1867 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1868 | if (d->model == QAbstractItemModelPrivate::staticEmptyModel()) { partially evaluated: d->model == QAbstractItemModelPrivate::staticEmptyModel()| no Evaluation Count:0 | yes Evaluation Count:326 |
| 0-326 |
| 1869 | QComboBox *that = const_cast<QComboBox*>(this); never executed (the execution status of this line is deduced): QComboBox *that = const_cast<QComboBox*>(this); | - |
| 1870 | that->setModel(new QStandardItemModel(0, 1, that)); never executed (the execution status of this line is deduced): that->setModel(new QStandardItemModel(0, 1, that)); | - |
| 1871 | } | 0 |
| 1872 | return d->model; executed: return d->model;Execution Count:326 | 326 |
| 1873 | } | - |
| 1874 | | - |
| 1875 | /*! | - |
| 1876 | Sets the model to be \a model. \a model must not be 0. | - |
| 1877 | If you want to clear the contents of a model, call clear(). | - |
| 1878 | | - |
| 1879 | \sa clear() | - |
| 1880 | */ | - |
| 1881 | void QComboBox::setModel(QAbstractItemModel *model) | - |
| 1882 | { | - |
| 1883 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1884 | | - |
| 1885 | if (!model) { partially evaluated: !model| no Evaluation Count:0 | yes Evaluation Count:887 |
| 0-887 |
| 1886 | qWarning("QComboBox::setModel: cannot set a 0 model"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 1886, __PRETTY_FUNCTION__).warning("QComboBox::setModel: cannot set a 0 model"); | - |
| 1887 | return; | 0 |
| 1888 | } | - |
| 1889 | | - |
| 1890 | #ifndef QT_NO_COMPLETER | - |
| 1891 | if (d->lineEdit && d->lineEdit->completer() evaluated: d->lineEdit| yes Evaluation Count:140 | yes Evaluation Count:747 |
partially evaluated: d->lineEdit->completer()| yes Evaluation Count:140 | no Evaluation Count:0 |
| 0-747 |
| 1892 | && d->lineEdit->completer() == d->completer) partially evaluated: d->lineEdit->completer() == d->completer| yes Evaluation Count:140 | no Evaluation Count:0 |
| 0-140 |
| 1893 | d->lineEdit->completer()->setModel(model); executed: d->lineEdit->completer()->setModel(model);Execution Count:140 | 140 |
| 1894 | #endif | - |
| 1895 | if (d->model) { evaluated: d->model| yes Evaluation Count:329 | yes Evaluation Count:558 |
| 329-558 |
| 1896 | disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): disconnect(d->model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
| 1897 | this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): this, "1""_q_dataChanged(QModelIndex,QModelIndex)"); | - |
| 1898 | disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsAboutToBeInserted(QModelIndex,int,int)", | - |
| 1899 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1900 | disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsInserted(QModelIndex,int,int)", | - |
| 1901 | this, SLOT(_q_rowsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_rowsInserted(QModelIndex,int,int)"); | - |
| 1902 | disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsAboutToBeRemoved(QModelIndex,int,int)", | - |
| 1903 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1904 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsRemoved(QModelIndex,int,int)", | - |
| 1905 | this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_rowsRemoved(QModelIndex,int,int)"); | - |
| 1906 | disconnect(d->model, SIGNAL(destroyed()), executed (the execution status of this line is deduced): disconnect(d->model, "2""destroyed()", | - |
| 1907 | this, SLOT(_q_modelDestroyed())); executed (the execution status of this line is deduced): this, "1""_q_modelDestroyed()"); | - |
| 1908 | disconnect(d->model, SIGNAL(modelAboutToBeReset()), executed (the execution status of this line is deduced): disconnect(d->model, "2""modelAboutToBeReset()", | - |
| 1909 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1910 | disconnect(d->model, SIGNAL(modelReset()), executed (the execution status of this line is deduced): disconnect(d->model, "2""modelReset()", | - |
| 1911 | this, SLOT(_q_modelReset())); executed (the execution status of this line is deduced): this, "1""_q_modelReset()"); | - |
| 1912 | if (d->model->QObject::parent() == this) partially evaluated: d->model->QObject::parent() == this| yes Evaluation Count:329 | no Evaluation Count:0 |
| 0-329 |
| 1913 | delete d->model; executed: delete d->model;Execution Count:329 | 329 |
| 1914 | } executed: }Execution Count:329 | 329 |
| 1915 | | - |
| 1916 | d->model = model; executed (the execution status of this line is deduced): d->model = model; | - |
| 1917 | | - |
| 1918 | connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
| 1919 | this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): this, "1""_q_dataChanged(QModelIndex,QModelIndex)"); | - |
| 1920 | connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(model, "2""rowsAboutToBeInserted(QModelIndex,int,int)", | - |
| 1921 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1922 | connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(model, "2""rowsInserted(QModelIndex,int,int)", | - |
| 1923 | this, SLOT(_q_rowsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_rowsInserted(QModelIndex,int,int)"); | - |
| 1924 | connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(model, "2""rowsAboutToBeRemoved(QModelIndex,int,int)", | - |
| 1925 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1926 | connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(model, "2""rowsRemoved(QModelIndex,int,int)", | - |
| 1927 | this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_rowsRemoved(QModelIndex,int,int)"); | - |
| 1928 | connect(model, SIGNAL(destroyed()), executed (the execution status of this line is deduced): connect(model, "2""destroyed()", | - |
| 1929 | this, SLOT(_q_modelDestroyed())); executed (the execution status of this line is deduced): this, "1""_q_modelDestroyed()"); | - |
| 1930 | connect(model, SIGNAL(modelAboutToBeReset()), executed (the execution status of this line is deduced): connect(model, "2""modelAboutToBeReset()", | - |
| 1931 | this, SLOT(_q_updateIndexBeforeChange())); executed (the execution status of this line is deduced): this, "1""_q_updateIndexBeforeChange()"); | - |
| 1932 | connect(model, SIGNAL(modelReset()), executed (the execution status of this line is deduced): connect(model, "2""modelReset()", | - |
| 1933 | this, SLOT(_q_modelReset())); executed (the execution status of this line is deduced): this, "1""_q_modelReset()"); | - |
| 1934 | | - |
| 1935 | if (d->container) { evaluated: d->container| yes Evaluation Count:140 | yes Evaluation Count:747 |
| 140-747 |
| 1936 | d->container->itemView()->setModel(model); executed (the execution status of this line is deduced): d->container->itemView()->setModel(model); | - |
| 1937 | connect(d->container->itemView()->selectionModel(), executed (the execution status of this line is deduced): connect(d->container->itemView()->selectionModel(), | - |
| 1938 | SIGNAL(currentChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): "2""currentChanged(QModelIndex,QModelIndex)", | - |
| 1939 | this, SLOT(_q_emitHighlighted(QModelIndex)), Qt::UniqueConnection); executed (the execution status of this line is deduced): this, "1""_q_emitHighlighted(QModelIndex)", Qt::UniqueConnection); | - |
| 1940 | } executed: }Execution Count:140 | 140 |
| 1941 | | - |
| 1942 | bool currentReset = false; executed (the execution status of this line is deduced): bool currentReset = false; | - |
| 1943 | | - |
| 1944 | if (count()) { partially evaluated: count()| no Evaluation Count:0 | yes Evaluation Count:887 |
| 0-887 |
| 1945 | for (int pos=0; pos < count(); pos++) { never evaluated: pos < count() | 0 |
| 1946 | if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) { never evaluated: d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled | 0 |
| 1947 | setCurrentIndex(pos); never executed (the execution status of this line is deduced): setCurrentIndex(pos); | - |
| 1948 | currentReset = true; never executed (the execution status of this line is deduced): currentReset = true; | - |
| 1949 | break; | 0 |
| 1950 | } | - |
| 1951 | } | 0 |
| 1952 | } | 0 |
| 1953 | | - |
| 1954 | if (!currentReset) partially evaluated: !currentReset| yes Evaluation Count:887 | no Evaluation Count:0 |
| 0-887 |
| 1955 | setCurrentIndex(-1); executed: setCurrentIndex(-1);Execution Count:887 | 887 |
| 1956 | | - |
| 1957 | d->modelChanged(); executed (the execution status of this line is deduced): d->modelChanged(); | - |
| 1958 | } executed: }Execution Count:887 | 887 |
| 1959 | | - |
| 1960 | /*! | - |
| 1961 | Returns the root model item index for the items in the combobox. | - |
| 1962 | | - |
| 1963 | \sa setRootModelIndex() | - |
| 1964 | */ | - |
| 1965 | | - |
| 1966 | QModelIndex QComboBox::rootModelIndex() const | - |
| 1967 | { | - |
| 1968 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1969 | return QModelIndex(d->root); never executed: return QModelIndex(d->root); | 0 |
| 1970 | } | - |
| 1971 | | - |
| 1972 | /*! | - |
| 1973 | Sets the root model item \a index for the items in the combobox. | - |
| 1974 | | - |
| 1975 | \sa rootModelIndex() | - |
| 1976 | */ | - |
| 1977 | void QComboBox::setRootModelIndex(const QModelIndex &index) | - |
| 1978 | { | - |
| 1979 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 1980 | d->root = QPersistentModelIndex(index); never executed (the execution status of this line is deduced): d->root = QPersistentModelIndex(index); | - |
| 1981 | view()->setRootIndex(index); never executed (the execution status of this line is deduced): view()->setRootIndex(index); | - |
| 1982 | update(); never executed (the execution status of this line is deduced): update(); | - |
| 1983 | } | 0 |
| 1984 | | - |
| 1985 | /*! | - |
| 1986 | \property QComboBox::currentIndex | - |
| 1987 | \brief the index of the current item in the combobox. | - |
| 1988 | | - |
| 1989 | The current index can change when inserting or removing items. | - |
| 1990 | | - |
| 1991 | By default, for an empty combo box or a combo box in which no current | - |
| 1992 | item is set, this property has a value of -1. | - |
| 1993 | */ | - |
| 1994 | int QComboBox::currentIndex() const | - |
| 1995 | { | - |
| 1996 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 1997 | return d->currentIndex.row(); executed: return d->currentIndex.row();Execution Count:600 | 600 |
| 1998 | } | - |
| 1999 | | - |
| 2000 | void QComboBox::setCurrentIndex(int index) | - |
| 2001 | { | - |
| 2002 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2003 | QModelIndex mi = d->model->index(index, d->modelColumn, d->root); executed (the execution status of this line is deduced): QModelIndex mi = d->model->index(index, d->modelColumn, d->root); | - |
| 2004 | d->setCurrentIndex(mi); executed (the execution status of this line is deduced): d->setCurrentIndex(mi); | - |
| 2005 | } executed: }Execution Count:1786 | 1786 |
| 2006 | | - |
| 2007 | void QComboBox::setCurrentText(const QString &text) | - |
| 2008 | { | - |
| 2009 | if (isEditable()) { partially evaluated: isEditable()| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 2010 | setEditText(text); executed (the execution status of this line is deduced): setEditText(text); | - |
| 2011 | } else { executed: }Execution Count:3 | 3 |
| 2012 | const int i = findText(text); never executed (the execution status of this line is deduced): const int i = findText(text); | - |
| 2013 | if (i > -1) | 0 |
| 2014 | setCurrentIndex(i); never executed: setCurrentIndex(i); | 0 |
| 2015 | } | 0 |
| 2016 | } | - |
| 2017 | | - |
| 2018 | void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) | - |
| 2019 | { | - |
| 2020 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 2021 | | - |
| 2022 | QModelIndex normalized; executed (the execution status of this line is deduced): QModelIndex normalized; | - |
| 2023 | if (mi.column() != modelColumn) evaluated: mi.column() != modelColumn| yes Evaluation Count:889 | yes Evaluation Count:897 |
| 889-897 |
| 2024 | normalized = model->index(mi.row(), modelColumn, mi.parent()); executed: normalized = model->index(mi.row(), modelColumn, mi.parent());Execution Count:889 | 889 |
| 2025 | if (!normalized.isValid()) partially evaluated: !normalized.isValid()| yes Evaluation Count:1786 | no Evaluation Count:0 |
| 0-1786 |
| 2026 | normalized = mi; // Fallback to passed index. executed: normalized = mi;Execution Count:1786 | 1786 |
| 2027 | | - |
| 2028 | bool indexChanged = (normalized != currentIndex); executed (the execution status of this line is deduced): bool indexChanged = (normalized != currentIndex); | - |
| 2029 | if (indexChanged) evaluated: indexChanged| yes Evaluation Count:886 | yes Evaluation Count:900 |
| 886-900 |
| 2030 | currentIndex = QPersistentModelIndex(normalized); executed: currentIndex = QPersistentModelIndex(normalized);Execution Count:886 | 886 |
| 2031 | if (lineEdit) { evaluated: lineEdit| yes Evaluation Count:407 | yes Evaluation Count:1379 |
| 407-1379 |
| 2032 | QString newText = q->itemText(normalized.row()); executed (the execution status of this line is deduced): QString newText = q->itemText(normalized.row()); | - |
| 2033 | if (lineEdit->text() != newText) evaluated: lineEdit->text() != newText| yes Evaluation Count:240 | yes Evaluation Count:167 |
| 167-240 |
| 2034 | lineEdit->setText(newText); executed: lineEdit->setText(newText);Execution Count:240 | 240 |
| 2035 | updateLineEditGeometry(); executed (the execution status of this line is deduced): updateLineEditGeometry(); | - |
| 2036 | } executed: }Execution Count:407 | 407 |
| 2037 | if (indexChanged) { evaluated: indexChanged| yes Evaluation Count:886 | yes Evaluation Count:900 |
| 886-900 |
| 2038 | q->update(); executed (the execution status of this line is deduced): q->update(); | - |
| 2039 | _q_emitCurrentIndexChanged(currentIndex); executed (the execution status of this line is deduced): _q_emitCurrentIndexChanged(currentIndex); | - |
| 2040 | } executed: }Execution Count:886 | 886 |
| 2041 | } executed: }Execution Count:1786 | 1786 |
| 2042 | | - |
| 2043 | /*! | - |
| 2044 | \property QComboBox::currentText | - |
| 2045 | \brief the current text | - |
| 2046 | | - |
| 2047 | If the combo box is editable, the current text is the value displayed | - |
| 2048 | by the line edit. Otherwise, it is the value of the current item or | - |
| 2049 | an empty string if the combo box is empty or no current item is set. | - |
| 2050 | | - |
| 2051 | The setter setCurrentText() simply calls setEditText() if the combo box is editable. | - |
| 2052 | Otherwise, if there is a matching text in the list, currentIndex is set to the | - |
| 2053 | corresponding index. | - |
| 2054 | | - |
| 2055 | \sa editable, setEditText() | - |
| 2056 | */ | - |
| 2057 | QString QComboBox::currentText() const | - |
| 2058 | { | - |
| 2059 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2060 | if (d->lineEdit) evaluated: d->lineEdit| yes Evaluation Count:299 | yes Evaluation Count:1131 |
| 299-1131 |
| 2061 | return d->lineEdit->text(); executed: return d->lineEdit->text();Execution Count:299 | 299 |
| 2062 | else if (d->currentIndex.isValid()) evaluated: d->currentIndex.isValid()| yes Evaluation Count:981 | yes Evaluation Count:150 |
| 150-981 |
| 2063 | return d->itemText(d->currentIndex); executed: return d->itemText(d->currentIndex);Execution Count:981 | 981 |
| 2064 | else | - |
| 2065 | return QString(); executed: return QString();Execution Count:150 | 150 |
| 2066 | } | - |
| 2067 | | - |
| 2068 | /*! | - |
| 2069 | Returns the text for the given \a index in the combobox. | - |
| 2070 | */ | - |
| 2071 | QString QComboBox::itemText(int index) const | - |
| 2072 | { | - |
| 2073 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2074 | QModelIndex mi = d->model->index(index, d->modelColumn, d->root); executed (the execution status of this line is deduced): QModelIndex mi = d->model->index(index, d->modelColumn, d->root); | - |
| 2075 | return d->itemText(mi); executed: return d->itemText(mi);Execution Count:2641 | 2641 |
| 2076 | } | - |
| 2077 | | - |
| 2078 | /*! | - |
| 2079 | Returns the icon for the given \a index in the combobox. | - |
| 2080 | */ | - |
| 2081 | QIcon QComboBox::itemIcon(int index) const | - |
| 2082 | { | - |
| 2083 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2084 | QModelIndex mi = d->model->index(index, d->modelColumn, d->root); executed (the execution status of this line is deduced): QModelIndex mi = d->model->index(index, d->modelColumn, d->root); | - |
| 2085 | return d->itemIcon(mi); executed: return d->itemIcon(mi);Execution Count:1619 | 1619 |
| 2086 | } | - |
| 2087 | | - |
| 2088 | /*! | - |
| 2089 | Returns the data for the given \a role in the given \a index in the | - |
| 2090 | combobox, or QVariant::Invalid if there is no data for this role. | - |
| 2091 | */ | - |
| 2092 | QVariant QComboBox::itemData(int index, int role) const | - |
| 2093 | { | - |
| 2094 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2095 | QModelIndex mi = d->model->index(index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): QModelIndex mi = d->model->index(index, d->modelColumn, d->root); | - |
| 2096 | return d->model->data(mi, role); never executed: return d->model->data(mi, role); | 0 |
| 2097 | } | - |
| 2098 | | - |
| 2099 | /*! | - |
| 2100 | \fn void QComboBox::insertItem(int index, const QString &text, const QVariant &userData) | - |
| 2101 | | - |
| 2102 | Inserts the \a text and \a userData (stored in the Qt::UserRole) | - |
| 2103 | into the combobox at the given \a index. | - |
| 2104 | | - |
| 2105 | If the index is equal to or higher than the total number of items, | - |
| 2106 | the new item is appended to the list of existing items. If the | - |
| 2107 | index is zero or negative, the new item is prepended to the list | - |
| 2108 | of existing items. | - |
| 2109 | | - |
| 2110 | \sa insertItems() | - |
| 2111 | */ | - |
| 2112 | | - |
| 2113 | /*! | - |
| 2114 | | - |
| 2115 | Inserts the \a icon, \a text and \a userData (stored in the | - |
| 2116 | Qt::UserRole) into the combobox at the given \a index. | - |
| 2117 | | - |
| 2118 | If the index is equal to or higher than the total number of items, | - |
| 2119 | the new item is appended to the list of existing items. If the | - |
| 2120 | index is zero or negative, the new item is prepended to the list | - |
| 2121 | of existing items. | - |
| 2122 | | - |
| 2123 | \sa insertItems() | - |
| 2124 | */ | - |
| 2125 | void QComboBox::insertItem(int index, const QIcon &icon, const QString &text, const QVariant &userData) | - |
| 2126 | { | - |
| 2127 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2128 | int itemCount = count(); executed (the execution status of this line is deduced): int itemCount = count(); | - |
| 2129 | index = qBound(0, index, itemCount); executed (the execution status of this line is deduced): index = qBound(0, index, itemCount); | - |
| 2130 | if (index >= d->maxCount) partially evaluated: index >= d->maxCount| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 2131 | return; | 0 |
| 2132 | | - |
| 2133 | // For the common case where we are using the built in QStandardItemModel | - |
| 2134 | // construct a QStandardItem, reducing the number of expensive signals from the model | - |
| 2135 | if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)) { partially evaluated: QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)| yes Evaluation Count:132 | no Evaluation Count:0 |
| 0-132 |
| 2136 | QStandardItem *item = new QStandardItem(text); executed (the execution status of this line is deduced): QStandardItem *item = new QStandardItem(text); | - |
| 2137 | if (!icon.isNull()) item->setData(icon, Qt::DecorationRole); never executed: item->setData(icon, Qt::DecorationRole); partially evaluated: !icon.isNull()| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 2138 | if (userData.isValid()) item->setData(userData, Qt::UserRole); never executed: item->setData(userData, Qt::UserRole); partially evaluated: userData.isValid()| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 2139 | m->insertRow(index, item); executed (the execution status of this line is deduced): m->insertRow(index, item); | - |
| 2140 | ++itemCount; executed (the execution status of this line is deduced): ++itemCount; | - |
| 2141 | } else { executed: }Execution Count:132 | 132 |
| 2142 | d->inserting = true; never executed (the execution status of this line is deduced): d->inserting = true; | - |
| 2143 | if (d->model->insertRows(index, 1, d->root)) { never evaluated: d->model->insertRows(index, 1, d->root) | 0 |
| 2144 | QModelIndex item = d->model->index(index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): QModelIndex item = d->model->index(index, d->modelColumn, d->root); | - |
| 2145 | if (icon.isNull() && !userData.isValid()) { never evaluated: icon.isNull() never evaluated: !userData.isValid() | 0 |
| 2146 | d->model->setData(item, text, Qt::EditRole); never executed (the execution status of this line is deduced): d->model->setData(item, text, Qt::EditRole); | - |
| 2147 | } else { | 0 |
| 2148 | QMap<int, QVariant> values; never executed (the execution status of this line is deduced): QMap<int, QVariant> values; | - |
| 2149 | if (!text.isNull()) values.insert(Qt::EditRole, text); never executed: values.insert(Qt::EditRole, text); never evaluated: !text.isNull() | 0 |
| 2150 | if (!icon.isNull()) values.insert(Qt::DecorationRole, icon); never executed: values.insert(Qt::DecorationRole, icon); never evaluated: !icon.isNull() | 0 |
| 2151 | if (userData.isValid()) values.insert(Qt::UserRole, userData); never executed: values.insert(Qt::UserRole, userData); never evaluated: userData.isValid() | 0 |
| 2152 | if (!values.isEmpty()) d->model->setItemData(item, values); never executed: d->model->setItemData(item, values); never evaluated: !values.isEmpty() | 0 |
| 2153 | } | 0 |
| 2154 | d->inserting = false; never executed (the execution status of this line is deduced): d->inserting = false; | - |
| 2155 | d->_q_rowsInserted(d->root, index, index); never executed (the execution status of this line is deduced): d->_q_rowsInserted(d->root, index, index); | - |
| 2156 | ++itemCount; never executed (the execution status of this line is deduced): ++itemCount; | - |
| 2157 | } else { | 0 |
| 2158 | d->inserting = false; never executed (the execution status of this line is deduced): d->inserting = false; | - |
| 2159 | } | 0 |
| 2160 | } | - |
| 2161 | | - |
| 2162 | if (itemCount > d->maxCount) partially evaluated: itemCount > d->maxCount| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 2163 | d->model->removeRows(itemCount - 1, itemCount - d->maxCount, d->root); never executed: d->model->removeRows(itemCount - 1, itemCount - d->maxCount, d->root); | 0 |
| 2164 | } executed: }Execution Count:132 | 132 |
| 2165 | | - |
| 2166 | /*! | - |
| 2167 | Inserts the strings from the \a list into the combobox as separate items, | - |
| 2168 | starting at the \a index specified. | - |
| 2169 | | - |
| 2170 | If the index is equal to or higher than the total number of items, the new items | - |
| 2171 | are appended to the list of existing items. If the index is zero or negative, the | - |
| 2172 | new items are prepended to the list of existing items. | - |
| 2173 | | - |
| 2174 | \sa insertItem() | - |
| 2175 | */ | - |
| 2176 | void QComboBox::insertItems(int index, const QStringList &list) | - |
| 2177 | { | - |
| 2178 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2179 | if (list.isEmpty()) partially evaluated: list.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:224 |
| 0-224 |
| 2180 | return; | 0 |
| 2181 | index = qBound(0, index, count()); executed (the execution status of this line is deduced): index = qBound(0, index, count()); | - |
| 2182 | int insertCount = qMin(d->maxCount - index, list.count()); executed (the execution status of this line is deduced): int insertCount = qMin(d->maxCount - index, list.count()); | - |
| 2183 | if (insertCount <= 0) partially evaluated: insertCount <= 0| no Evaluation Count:0 | yes Evaluation Count:224 |
| 0-224 |
| 2184 | return; | 0 |
| 2185 | // For the common case where we are using the built in QStandardItemModel | - |
| 2186 | // construct a QStandardItem, reducing the number of expensive signals from the model | - |
| 2187 | if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)) { partially evaluated: QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)| yes Evaluation Count:224 | no Evaluation Count:0 |
| 0-224 |
| 2188 | QList<QStandardItem *> items; executed (the execution status of this line is deduced): QList<QStandardItem *> items; | - |
| 2189 | QStandardItem *hiddenRoot = m->invisibleRootItem(); executed (the execution status of this line is deduced): QStandardItem *hiddenRoot = m->invisibleRootItem(); | - |
| 2190 | for (int i = 0; i < insertCount; ++i) evaluated: i < insertCount| yes Evaluation Count:274 | yes Evaluation Count:224 |
| 224-274 |
| 2191 | items.append(new QStandardItem(list.at(i))); executed: items.append(new QStandardItem(list.at(i)));Execution Count:274 | 274 |
| 2192 | hiddenRoot->insertRows(index, items); executed (the execution status of this line is deduced): hiddenRoot->insertRows(index, items); | - |
| 2193 | } else { executed: }Execution Count:224 | 224 |
| 2194 | d->inserting = true; never executed (the execution status of this line is deduced): d->inserting = true; | - |
| 2195 | if (d->model->insertRows(index, insertCount, d->root)) { never evaluated: d->model->insertRows(index, insertCount, d->root) | 0 |
| 2196 | QModelIndex item; never executed (the execution status of this line is deduced): QModelIndex item; | - |
| 2197 | for (int i = 0; i < insertCount; ++i) { never evaluated: i < insertCount | 0 |
| 2198 | item = d->model->index(i+index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): item = d->model->index(i+index, d->modelColumn, d->root); | - |
| 2199 | d->model->setData(item, list.at(i), Qt::EditRole); never executed (the execution status of this line is deduced): d->model->setData(item, list.at(i), Qt::EditRole); | - |
| 2200 | } | 0 |
| 2201 | d->inserting = false; never executed (the execution status of this line is deduced): d->inserting = false; | - |
| 2202 | d->_q_rowsInserted(d->root, index, index + insertCount - 1); never executed (the execution status of this line is deduced): d->_q_rowsInserted(d->root, index, index + insertCount - 1); | - |
| 2203 | } else { | 0 |
| 2204 | d->inserting = false; never executed (the execution status of this line is deduced): d->inserting = false; | - |
| 2205 | } | 0 |
| 2206 | } | - |
| 2207 | | - |
| 2208 | int mc = count(); executed (the execution status of this line is deduced): int mc = count(); | - |
| 2209 | if (mc > d->maxCount) partially evaluated: mc > d->maxCount| no Evaluation Count:0 | yes Evaluation Count:224 |
| 0-224 |
| 2210 | d->model->removeRows(d->maxCount, mc - d->maxCount, d->root); never executed: d->model->removeRows(d->maxCount, mc - d->maxCount, d->root); | 0 |
| 2211 | } executed: }Execution Count:224 | 224 |
| 2212 | | - |
| 2213 | /*! | - |
| 2214 | \since 4.4 | - |
| 2215 | | - |
| 2216 | Inserts a separator item into the combobox at the given \a index. | - |
| 2217 | | - |
| 2218 | If the index is equal to or higher than the total number of items, the new item | - |
| 2219 | is appended to the list of existing items. If the index is zero or negative, the | - |
| 2220 | new item is prepended to the list of existing items. | - |
| 2221 | | - |
| 2222 | \sa insertItem() | - |
| 2223 | */ | - |
| 2224 | void QComboBox::insertSeparator(int index) | - |
| 2225 | { | - |
| 2226 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2227 | int itemCount = count(); never executed (the execution status of this line is deduced): int itemCount = count(); | - |
| 2228 | index = qBound(0, index, itemCount); never executed (the execution status of this line is deduced): index = qBound(0, index, itemCount); | - |
| 2229 | if (index >= d->maxCount) never evaluated: index >= d->maxCount | 0 |
| 2230 | return; | 0 |
| 2231 | insertItem(index, QIcon(), QString()); never executed (the execution status of this line is deduced): insertItem(index, QIcon(), QString()); | - |
| 2232 | QComboBoxDelegate::setSeparator(d->model, d->model->index(index, 0, d->root)); never executed (the execution status of this line is deduced): QComboBoxDelegate::setSeparator(d->model, d->model->index(index, 0, d->root)); | - |
| 2233 | } | 0 |
| 2234 | | - |
| 2235 | /*! | - |
| 2236 | Removes the item at the given \a index from the combobox. | - |
| 2237 | This will update the current index if the index is removed. | - |
| 2238 | | - |
| 2239 | This function does nothing if \a index is out of range. | - |
| 2240 | */ | - |
| 2241 | void QComboBox::removeItem(int index) | - |
| 2242 | { | - |
| 2243 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2244 | if (index < 0 || index >= count()) never evaluated: index < 0 never evaluated: index >= count() | 0 |
| 2245 | return; | 0 |
| 2246 | d->model->removeRows(index, 1, d->root); never executed (the execution status of this line is deduced): d->model->removeRows(index, 1, d->root); | - |
| 2247 | } | 0 |
| 2248 | | - |
| 2249 | /*! | - |
| 2250 | Sets the \a text for the item on the given \a index in the combobox. | - |
| 2251 | */ | - |
| 2252 | void QComboBox::setItemText(int index, const QString &text) | - |
| 2253 | { | - |
| 2254 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2255 | QModelIndex item = d->model->index(index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): QModelIndex item = d->model->index(index, d->modelColumn, d->root); | - |
| 2256 | if (item.isValid()) { never evaluated: item.isValid() | 0 |
| 2257 | d->model->setData(item, text, Qt::EditRole); never executed (the execution status of this line is deduced): d->model->setData(item, text, Qt::EditRole); | - |
| 2258 | } | 0 |
| 2259 | } | 0 |
| 2260 | | - |
| 2261 | /*! | - |
| 2262 | Sets the \a icon for the item on the given \a index in the combobox. | - |
| 2263 | */ | - |
| 2264 | void QComboBox::setItemIcon(int index, const QIcon &icon) | - |
| 2265 | { | - |
| 2266 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2267 | QModelIndex item = d->model->index(index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): QModelIndex item = d->model->index(index, d->modelColumn, d->root); | - |
| 2268 | if (item.isValid()) { never evaluated: item.isValid() | 0 |
| 2269 | d->model->setData(item, icon, Qt::DecorationRole); never executed (the execution status of this line is deduced): d->model->setData(item, icon, Qt::DecorationRole); | - |
| 2270 | } | 0 |
| 2271 | } | 0 |
| 2272 | | - |
| 2273 | /*! | - |
| 2274 | Sets the data \a role for the item on the given \a index in the combobox | - |
| 2275 | to the specified \a value. | - |
| 2276 | */ | - |
| 2277 | void QComboBox::setItemData(int index, const QVariant &value, int role) | - |
| 2278 | { | - |
| 2279 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2280 | QModelIndex item = d->model->index(index, d->modelColumn, d->root); never executed (the execution status of this line is deduced): QModelIndex item = d->model->index(index, d->modelColumn, d->root); | - |
| 2281 | if (item.isValid()) { never evaluated: item.isValid() | 0 |
| 2282 | d->model->setData(item, value, role); never executed (the execution status of this line is deduced): d->model->setData(item, value, role); | - |
| 2283 | } | 0 |
| 2284 | } | 0 |
| 2285 | | - |
| 2286 | /*! | - |
| 2287 | Returns the list view used for the combobox popup. | - |
| 2288 | */ | - |
| 2289 | QAbstractItemView *QComboBox::view() const | - |
| 2290 | { | - |
| 2291 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2292 | return const_cast<QComboBoxPrivate*>(d)->viewContainer()->itemView(); executed: return const_cast<QComboBoxPrivate*>(d)->viewContainer()->itemView();Execution Count:2112 | 2112 |
| 2293 | } | - |
| 2294 | | - |
| 2295 | /*! | - |
| 2296 | Sets the view to be used in the combobox popup to the given \a | - |
| 2297 | itemView. The combobox takes ownership of the view. | - |
| 2298 | | - |
| 2299 | Note: If you want to use the convenience views (like QListWidget, | - |
| 2300 | QTableWidget or QTreeWidget), make sure to call setModel() on the | - |
| 2301 | combobox with the convenience widgets model before calling this | - |
| 2302 | function. | - |
| 2303 | */ | - |
| 2304 | void QComboBox::setView(QAbstractItemView *itemView) | - |
| 2305 | { | - |
| 2306 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2307 | if (!itemView) { never evaluated: !itemView | 0 |
| 2308 | qWarning("QComboBox::setView: cannot set a 0 view"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcombobox.cpp", 2308, __PRETTY_FUNCTION__).warning("QComboBox::setView: cannot set a 0 view"); | - |
| 2309 | return; | 0 |
| 2310 | } | - |
| 2311 | | - |
| 2312 | if (itemView->model() != d->model) never evaluated: itemView->model() != d->model | 0 |
| 2313 | itemView->setModel(d->model); never executed: itemView->setModel(d->model); | 0 |
| 2314 | d->viewContainer()->setItemView(itemView); never executed (the execution status of this line is deduced): d->viewContainer()->setItemView(itemView); | - |
| 2315 | } | 0 |
| 2316 | | - |
| 2317 | /*! | - |
| 2318 | \reimp | - |
| 2319 | */ | - |
| 2320 | QSize QComboBox::minimumSizeHint() const | - |
| 2321 | { | - |
| 2322 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2323 | return d->recomputeSizeHint(d->minimumSizeHint); executed: return d->recomputeSizeHint(d->minimumSizeHint);Execution Count:518 | 518 |
| 2324 | } | - |
| 2325 | | - |
| 2326 | /*! | - |
| 2327 | \reimp | - |
| 2328 | | - |
| 2329 | This implementation caches the size hint to avoid resizing when | - |
| 2330 | the contents change dynamically. To invalidate the cached value | - |
| 2331 | change the \l sizeAdjustPolicy. | - |
| 2332 | */ | - |
| 2333 | QSize QComboBox::sizeHint() const | - |
| 2334 | { | - |
| 2335 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 2336 | return d->recomputeSizeHint(d->sizeHint); executed: return d->recomputeSizeHint(d->sizeHint);Execution Count:673 | 673 |
| 2337 | } | - |
| 2338 | | - |
| 2339 | /*! | - |
| 2340 | Displays the list of items in the combobox. If the list is empty | - |
| 2341 | then the no items will be shown. | - |
| 2342 | | - |
| 2343 | If you reimplement this function to show a custom pop-up, make | - |
| 2344 | sure you call hidePopup() to reset the internal state. | - |
| 2345 | | - |
| 2346 | \sa hidePopup() | - |
| 2347 | */ | - |
| 2348 | void QComboBox::showPopup() | - |
| 2349 | { | - |
| 2350 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2351 | if (count() <= 0) partially evaluated: count() <= 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2352 | return; | 0 |
| 2353 | | - |
| 2354 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2355 | #ifndef QT_NO_COMPLETER | - |
| 2356 | if (QApplication::keypadNavigationEnabled() && d->completer) { | - |
| 2357 | // editable combo box is line edit plus completer | - |
| 2358 | setEditFocus(true); | - |
| 2359 | d->completer->complete(); // show popup | - |
| 2360 | return; | - |
| 2361 | } | - |
| 2362 | #endif | - |
| 2363 | #endif | - |
| 2364 | | - |
| 2365 | QStyle * const style = this->style(); executed (the execution status of this line is deduced): QStyle * const style = this->style(); | - |
| 2366 | | - |
| 2367 | // set current item and select it | - |
| 2368 | view()->selectionModel()->setCurrentIndex(d->currentIndex, executed (the execution status of this line is deduced): view()->selectionModel()->setCurrentIndex(d->currentIndex, | - |
| 2369 | QItemSelectionModel::ClearAndSelect); executed (the execution status of this line is deduced): QItemSelectionModel::ClearAndSelect); | - |
| 2370 | QComboBoxPrivateContainer* container = d->viewContainer(); executed (the execution status of this line is deduced): QComboBoxPrivateContainer* container = d->viewContainer(); | - |
| 2371 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 2372 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 2373 | QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt, executed (the execution status of this line is deduced): QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt, | - |
| 2374 | QStyle::SC_ComboBoxListBoxPopup, this)); executed (the execution status of this line is deduced): QStyle::SC_ComboBoxListBoxPopup, this)); | - |
| 2375 | QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this)); executed (the execution status of this line is deduced): QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this)); | - |
| 2376 | | - |
| 2377 | QPoint below = mapToGlobal(listRect.bottomLeft()); executed (the execution status of this line is deduced): QPoint below = mapToGlobal(listRect.bottomLeft()); | - |
| 2378 | int belowHeight = screen.bottom() - below.y(); executed (the execution status of this line is deduced): int belowHeight = screen.bottom() - below.y(); | - |
| 2379 | QPoint above = mapToGlobal(listRect.topLeft()); executed (the execution status of this line is deduced): QPoint above = mapToGlobal(listRect.topLeft()); | - |
| 2380 | int aboveHeight = above.y() - screen.y(); executed (the execution status of this line is deduced): int aboveHeight = above.y() - screen.y(); | - |
| 2381 | bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen); executed (the execution status of this line is deduced): bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen); | - |
| 2382 | | - |
| 2383 | const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this); executed (the execution status of this line is deduced): const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this); | - |
| 2384 | { | - |
| 2385 | int listHeight = 0; executed (the execution status of this line is deduced): int listHeight = 0; | - |
| 2386 | int count = 0; executed (the execution status of this line is deduced): int count = 0; | - |
| 2387 | QStack<QModelIndex> toCheck; executed (the execution status of this line is deduced): QStack<QModelIndex> toCheck; | - |
| 2388 | toCheck.push(view()->rootIndex()); executed (the execution status of this line is deduced): toCheck.push(view()->rootIndex()); | - |
| 2389 | #ifndef QT_NO_TREEVIEW | - |
| 2390 | QTreeView *treeView = qobject_cast<QTreeView*>(view()); executed (the execution status of this line is deduced): QTreeView *treeView = qobject_cast<QTreeView*>(view()); | - |
| 2391 | if (treeView && treeView->header() && !treeView->header()->isHidden()) partially evaluated: treeView| no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: treeView->header() never evaluated: !treeView->header()->isHidden() | 0-1 |
| 2392 | listHeight += treeView->header()->height(); never executed: listHeight += treeView->header()->height(); | 0 |
| 2393 | #endif | - |
| 2394 | while (!toCheck.isEmpty()) { evaluated: !toCheck.isEmpty()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 2395 | QModelIndex parent = toCheck.pop(); executed (the execution status of this line is deduced): QModelIndex parent = toCheck.pop(); | - |
| 2396 | for (int i = 0; i < d->model->rowCount(parent); ++i) { evaluated: i < d->model->rowCount(parent)| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
| 2397 | QModelIndex idx = d->model->index(i, d->modelColumn, parent); executed (the execution status of this line is deduced): QModelIndex idx = d->model->index(i, d->modelColumn, parent); | - |
| 2398 | if (!idx.isValid()) partially evaluated: !idx.isValid()| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 2399 | continue; never executed: continue; | 0 |
| 2400 | listHeight += view()->visualRect(idx).height() + container->spacing(); executed (the execution status of this line is deduced): listHeight += view()->visualRect(idx).height() + container->spacing(); | - |
| 2401 | #ifndef QT_NO_TREEVIEW | - |
| 2402 | if (d->model->hasChildren(idx) && treeView && treeView->isExpanded(idx)) partially evaluated: d->model->hasChildren(idx)| no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: treeView never evaluated: treeView->isExpanded(idx) | 0-3 |
| 2403 | toCheck.push(idx); never executed: toCheck.push(idx); | 0 |
| 2404 | #endif | - |
| 2405 | ++count; executed (the execution status of this line is deduced): ++count; | - |
| 2406 | if (!usePopup && count >= d->maxVisibleItems) { partially evaluated: !usePopup| yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: count >= d->maxVisibleItems| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 2407 | toCheck.clear(); never executed (the execution status of this line is deduced): toCheck.clear(); | - |
| 2408 | break; | 0 |
| 2409 | } | - |
| 2410 | } executed: }Execution Count:3 | 3 |
| 2411 | } executed: }Execution Count:1 | 1 |
| 2412 | listRect.setHeight(listHeight); never executed (the execution status of this line is deduced): listRect.setHeight(listHeight); | - |
| 2413 | } | - |
| 2414 | | - |
| 2415 | { | - |
| 2416 | // add the spacing for the grid on the top and the bottom; | - |
| 2417 | int heightMargin = 2*container->spacing(); never executed (the execution status of this line is deduced): int heightMargin = 2*container->spacing(); | - |
| 2418 | | - |
| 2419 | // add the frame of the container | - |
| 2420 | int marginTop, marginBottom; never executed (the execution status of this line is deduced): int marginTop, marginBottom; | - |
| 2421 | container->getContentsMargins(0, &marginTop, 0, &marginBottom); never executed (the execution status of this line is deduced): container->getContentsMargins(0, &marginTop, 0, &marginBottom); | - |
| 2422 | heightMargin += marginTop + marginBottom; never executed (the execution status of this line is deduced): heightMargin += marginTop + marginBottom; | - |
| 2423 | | - |
| 2424 | //add the frame of the view | - |
| 2425 | view()->getContentsMargins(0, &marginTop, 0, &marginBottom); never executed (the execution status of this line is deduced): view()->getContentsMargins(0, &marginTop, 0, &marginBottom); | - |
| 2426 | marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top; never executed (the execution status of this line is deduced): marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top; | - |
| 2427 | marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom; never executed (the execution status of this line is deduced): marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom; | - |
| 2428 | heightMargin += marginTop + marginBottom; never executed (the execution status of this line is deduced): heightMargin += marginTop + marginBottom; | - |
| 2429 | | - |
| 2430 | listRect.setHeight(listRect.height() + heightMargin); never executed (the execution status of this line is deduced): listRect.setHeight(listRect.height() + heightMargin); | - |
| 2431 | } | - |
| 2432 | | - |
| 2433 | // Add space for margin at top and bottom if the style wants it. | - |
| 2434 | if (usePopup) partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2435 | listRect.setHeight(listRect.height() + style->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) * 2); never executed: listRect.setHeight(listRect.height() + style->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) * 2); | 0 |
| 2436 | | - |
| 2437 | // Make sure the popup is wide enough to display its contents. | - |
| 2438 | if (usePopup) { partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2439 | const int diff = d->computeWidthHint() - width(); never executed (the execution status of this line is deduced): const int diff = d->computeWidthHint() - width(); | - |
| 2440 | if (diff > 0) never evaluated: diff > 0 | 0 |
| 2441 | listRect.setWidth(listRect.width() + diff); never executed: listRect.setWidth(listRect.width() + diff); | 0 |
| 2442 | } | 0 |
| 2443 | | - |
| 2444 | //we need to activate the layout to make sure the min/maximum size are set when the widget was not yet show | - |
| 2445 | container->layout()->activate(); executed (the execution status of this line is deduced): container->layout()->activate(); | - |
| 2446 | //takes account of the minimum/maximum size of the container | - |
| 2447 | listRect.setSize( listRect.size().expandedTo(container->minimumSize()) executed (the execution status of this line is deduced): listRect.setSize( listRect.size().expandedTo(container->minimumSize()) | - |
| 2448 | .boundedTo(container->maximumSize())); executed (the execution status of this line is deduced): .boundedTo(container->maximumSize())); | - |
| 2449 | | - |
| 2450 | // make sure the widget fits on screen | - |
| 2451 | if (boundToScreen) { partially evaluated: boundToScreen| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 2452 | if (listRect.width() > screen.width() ) partially evaluated: listRect.width() > screen.width()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2453 | listRect.setWidth(screen.width()); never executed: listRect.setWidth(screen.width()); | 0 |
| 2454 | if (mapToGlobal(listRect.bottomRight()).x() > screen.right()) { partially evaluated: mapToGlobal(listRect.bottomRight()).x() > screen.right()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2455 | below.setX(screen.x() + screen.width() - listRect.width()); never executed (the execution status of this line is deduced): below.setX(screen.x() + screen.width() - listRect.width()); | - |
| 2456 | above.setX(screen.x() + screen.width() - listRect.width()); never executed (the execution status of this line is deduced): above.setX(screen.x() + screen.width() - listRect.width()); | - |
| 2457 | } | 0 |
| 2458 | if (mapToGlobal(listRect.topLeft()).x() < screen.x() ) { partially evaluated: mapToGlobal(listRect.topLeft()).x() < screen.x()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2459 | below.setX(screen.x()); never executed (the execution status of this line is deduced): below.setX(screen.x()); | - |
| 2460 | above.setX(screen.x()); never executed (the execution status of this line is deduced): above.setX(screen.x()); | - |
| 2461 | } | 0 |
| 2462 | } executed: }Execution Count:1 | 1 |
| 2463 | | - |
| 2464 | if (usePopup) { partially evaluated: usePopup| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2465 | // Position horizontally. | - |
| 2466 | listRect.moveLeft(above.x()); never executed (the execution status of this line is deduced): listRect.moveLeft(above.x()); | - |
| 2467 | | - |
| 2468 | // Position vertically so the curently selected item lines up | - |
| 2469 | // with the combo box. | - |
| 2470 | const QRect currentItemRect = view()->visualRect(view()->currentIndex()); never executed (the execution status of this line is deduced): const QRect currentItemRect = view()->visualRect(view()->currentIndex()); | - |
| 2471 | const int offset = listRect.top() - currentItemRect.top(); never executed (the execution status of this line is deduced): const int offset = listRect.top() - currentItemRect.top(); | - |
| 2472 | listRect.moveTop(above.y() + offset - listRect.top()); never executed (the execution status of this line is deduced): listRect.moveTop(above.y() + offset - listRect.top()); | - |
| 2473 | | - |
| 2474 | // Clamp the listRect height and vertical position so we don't expand outside the | - |
| 2475 | // available screen geometry.This may override the vertical position, but it is more | - |
| 2476 | // important to show as much as possible of the popup. | - |
| 2477 | const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height()); never evaluated: !boundToScreen | 0 |
| 2478 | listRect.setHeight(height); never executed (the execution status of this line is deduced): listRect.setHeight(height); | - |
| 2479 | | - |
| 2480 | if (boundToScreen) { never evaluated: boundToScreen | 0 |
| 2481 | if (listRect.top() < screen.top()) never evaluated: listRect.top() < screen.top() | 0 |
| 2482 | listRect.moveTop(screen.top()); never executed: listRect.moveTop(screen.top()); | 0 |
| 2483 | if (listRect.bottom() > screen.bottom()) never evaluated: listRect.bottom() > screen.bottom() | 0 |
| 2484 | listRect.moveBottom(screen.bottom()); never executed: listRect.moveBottom(screen.bottom()); | 0 |
| 2485 | } | 0 |
| 2486 | } else if (!boundToScreen || listRect.height() <= belowHeight) { never executed: } partially evaluated: !boundToScreen| no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: listRect.height() <= belowHeight| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 2487 | listRect.moveTopLeft(below); executed (the execution status of this line is deduced): listRect.moveTopLeft(below); | - |
| 2488 | } else if (listRect.height() <= aboveHeight) { executed: }Execution Count:1 never evaluated: listRect.height() <= aboveHeight | 0-1 |
| 2489 | listRect.moveBottomLeft(above); never executed (the execution status of this line is deduced): listRect.moveBottomLeft(above); | - |
| 2490 | } else if (belowHeight >= aboveHeight) { never executed: } never evaluated: belowHeight >= aboveHeight | 0 |
| 2491 | listRect.setHeight(belowHeight); never executed (the execution status of this line is deduced): listRect.setHeight(belowHeight); | - |
| 2492 | listRect.moveTopLeft(below); never executed (the execution status of this line is deduced): listRect.moveTopLeft(below); | - |
| 2493 | } else { | 0 |
| 2494 | listRect.setHeight(aboveHeight); never executed (the execution status of this line is deduced): listRect.setHeight(aboveHeight); | - |
| 2495 | listRect.moveBottomLeft(above); never executed (the execution status of this line is deduced): listRect.moveBottomLeft(above); | - |
| 2496 | } | 0 |
| 2497 | | - |
| 2498 | if (qApp) { partially evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 2499 | qApp->inputMethod()->reset(); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->reset(); | - |
| 2500 | } executed: }Execution Count:1 | 1 |
| 2501 | | - |
| 2502 | QScrollBar *sb = view()->horizontalScrollBar(); executed (the execution status of this line is deduced): QScrollBar *sb = view()->horizontalScrollBar(); | - |
| 2503 | Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy(); executed (the execution status of this line is deduced): Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy(); | - |
| 2504 | bool needHorizontalScrollBar = (policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn) partially evaluated: policy == Qt::ScrollBarAsNeeded| no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: policy == Qt::ScrollBarAlwaysOn| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2505 | && sb->minimum() < sb->maximum(); never evaluated: sb->minimum() < sb->maximum() | 0 |
| 2506 | if (needHorizontalScrollBar) { partially evaluated: needHorizontalScrollBar| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2507 | listRect.adjust(0, 0, 0, sb->height()); never executed (the execution status of this line is deduced): listRect.adjust(0, 0, 0, sb->height()); | - |
| 2508 | } | 0 |
| 2509 | container->setGeometry(listRect); executed (the execution status of this line is deduced): container->setGeometry(listRect); | - |
| 2510 | | - |
| 2511 | #ifndef Q_OS_MAC | - |
| 2512 | const bool updatesEnabled = container->updatesEnabled(); executed (the execution status of this line is deduced): const bool updatesEnabled = container->updatesEnabled(); | - |
| 2513 | #endif | - |
| 2514 | | - |
| 2515 | #if !defined(QT_NO_EFFECTS) | - |
| 2516 | bool scrollDown = (listRect.topLeft() == below); executed (the execution status of this line is deduced): bool scrollDown = (listRect.topLeft() == below); | - |
| 2517 | if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo) partially evaluated: QApplication::isEffectEnabled(Qt::UI_AnimateCombo)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2518 | && !style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && !window()->testAttribute(Qt::WA_DontShowOnScreen)) never evaluated: !style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) never evaluated: !window()->testAttribute(Qt::WA_DontShowOnScreen) | 0 |
| 2519 | qScrollEffect(container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150); never executed: qScrollEffect(container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150); | 0 |
| 2520 | #endif | - |
| 2521 | | - |
| 2522 | // Don't disable updates on Mac OS X. Windows are displayed immediately on this platform, | - |
| 2523 | // which means that the window will be visible before the call to container->show() returns. | - |
| 2524 | // If updates are disabled at this point we'll miss our chance at painting the popup | - |
| 2525 | // menu before it's shown, causing flicker since the window then displays the standard gray | - |
| 2526 | // background. | - |
| 2527 | #ifndef Q_OS_MAC | - |
| 2528 | container->setUpdatesEnabled(false); executed (the execution status of this line is deduced): container->setUpdatesEnabled(false); | - |
| 2529 | #endif | - |
| 2530 | | - |
| 2531 | container->raise(); executed (the execution status of this line is deduced): container->raise(); | - |
| 2532 | container->show(); executed (the execution status of this line is deduced): container->show(); | - |
| 2533 | container->updateScrollers(); executed (the execution status of this line is deduced): container->updateScrollers(); | - |
| 2534 | view()->setFocus(); executed (the execution status of this line is deduced): view()->setFocus(); | - |
| 2535 | | - |
| 2536 | view()->scrollTo(view()->currentIndex(), executed (the execution status of this line is deduced): view()->scrollTo(view()->currentIndex(), | - |
| 2537 | style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) executed (the execution status of this line is deduced): style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) | - |
| 2538 | ? QAbstractItemView::PositionAtCenter executed (the execution status of this line is deduced): ? QAbstractItemView::PositionAtCenter | - |
| 2539 | : QAbstractItemView::EnsureVisible); executed (the execution status of this line is deduced): : QAbstractItemView::EnsureVisible); | - |
| 2540 | | - |
| 2541 | #ifndef Q_OS_MAC | - |
| 2542 | container->setUpdatesEnabled(updatesEnabled); executed (the execution status of this line is deduced): container->setUpdatesEnabled(updatesEnabled); | - |
| 2543 | #endif | - |
| 2544 | | - |
| 2545 | container->update(); executed (the execution status of this line is deduced): container->update(); | - |
| 2546 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2547 | if (QApplication::keypadNavigationEnabled()) | - |
| 2548 | view()->setEditFocus(true); | - |
| 2549 | #endif | - |
| 2550 | } executed: }Execution Count:1 | 1 |
| 2551 | | - |
| 2552 | /*! | - |
| 2553 | Hides the list of items in the combobox if it is currently visible | - |
| 2554 | and resets the internal state, so that if the custom pop-up was | - |
| 2555 | shown inside the reimplemented showPopup(), then you also need to | - |
| 2556 | reimplement the hidePopup() function to hide your custom pop-up | - |
| 2557 | and call the base class implementation to reset the internal state | - |
| 2558 | whenever your custom pop-up widget is hidden. | - |
| 2559 | | - |
| 2560 | \sa showPopup() | - |
| 2561 | */ | - |
| 2562 | void QComboBox::hidePopup() | - |
| 2563 | { | - |
| 2564 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2565 | if (d->container && d->container->isVisible()) { evaluated: d->container| yes Evaluation Count:57 | yes Evaluation Count:75 |
partially evaluated: d->container->isVisible()| no Evaluation Count:0 | yes Evaluation Count:57 |
| 0-75 |
| 2566 | #if !defined(QT_NO_EFFECTS) | - |
| 2567 | d->model->blockSignals(true); never executed (the execution status of this line is deduced): d->model->blockSignals(true); | - |
| 2568 | d->container->itemView()->blockSignals(true); never executed (the execution status of this line is deduced): d->container->itemView()->blockSignals(true); | - |
| 2569 | d->container->blockSignals(true); never executed (the execution status of this line is deduced): d->container->blockSignals(true); | - |
| 2570 | // Flash selected/triggered item (if any). | - |
| 2571 | if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)) { never evaluated: style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) | 0 |
| 2572 | QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : 0; | 0 |
| 2573 | if (selectionModel && selectionModel->hasSelection()) { never evaluated: selectionModel never evaluated: selectionModel->hasSelection() | 0 |
| 2574 | QEventLoop eventLoop; never executed (the execution status of this line is deduced): QEventLoop eventLoop; | - |
| 2575 | const QItemSelection selection = selectionModel->selection(); never executed (the execution status of this line is deduced): const QItemSelection selection = selectionModel->selection(); | - |
| 2576 | | - |
| 2577 | // Deselect item and wait 60 ms. | - |
| 2578 | selectionModel->select(selection, QItemSelectionModel::Toggle); never executed (the execution status of this line is deduced): selectionModel->select(selection, QItemSelectionModel::Toggle); | - |
| 2579 | QTimer::singleShot(60, &eventLoop, SLOT(quit())); never executed (the execution status of this line is deduced): QTimer::singleShot(60, &eventLoop, "1""quit()"); | - |
| 2580 | eventLoop.exec(); never executed (the execution status of this line is deduced): eventLoop.exec(); | - |
| 2581 | | - |
| 2582 | // Select item and wait 20 ms. | - |
| 2583 | selectionModel->select(selection, QItemSelectionModel::Toggle); never executed (the execution status of this line is deduced): selectionModel->select(selection, QItemSelectionModel::Toggle); | - |
| 2584 | QTimer::singleShot(20, &eventLoop, SLOT(quit())); never executed (the execution status of this line is deduced): QTimer::singleShot(20, &eventLoop, "1""quit()"); | - |
| 2585 | eventLoop.exec(); never executed (the execution status of this line is deduced): eventLoop.exec(); | - |
| 2586 | } | 0 |
| 2587 | } | 0 |
| 2588 | | - |
| 2589 | // Fade out. | - |
| 2590 | bool needFade = style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); never executed (the execution status of this line is deduced): bool needFade = style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); | - |
| 2591 | bool didFade = false; never executed (the execution status of this line is deduced): bool didFade = false; | - |
| 2592 | if (needFade) { never evaluated: needFade | 0 |
| 2593 | #if defined(Q_OS_MAC) | - |
| 2594 | QPlatformNativeInterface *platformNativeInterface = qApp->platformNativeInterface(); | - |
| 2595 | int at = platformNativeInterface->metaObject()->indexOfMethod("fadeWindow()"); | - |
| 2596 | if (at != -1) { | - |
| 2597 | QMetaMethod windowFade = platformNativeInterface->metaObject()->method(at); | - |
| 2598 | windowFade.invoke(platformNativeInterface, Q_ARG(QWindow *, d->container->windowHandle())); | - |
| 2599 | didFade = true; | - |
| 2600 | } | - |
| 2601 | | - |
| 2602 | #endif // Q_OS_MAC | - |
| 2603 | // Other platform implementations welcome :-) | - |
| 2604 | } | 0 |
| 2605 | d->model->blockSignals(false); never executed (the execution status of this line is deduced): d->model->blockSignals(false); | - |
| 2606 | d->container->itemView()->blockSignals(false); never executed (the execution status of this line is deduced): d->container->itemView()->blockSignals(false); | - |
| 2607 | d->container->blockSignals(false); never executed (the execution status of this line is deduced): d->container->blockSignals(false); | - |
| 2608 | | - |
| 2609 | if (!didFade) never evaluated: !didFade | 0 |
| 2610 | #endif // QT_NO_EFFECTS | - |
| 2611 | // Fade should implicitly hide as well ;-) | - |
| 2612 | d->container->hide(); never executed: d->container->hide(); | 0 |
| 2613 | } | 0 |
| 2614 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2615 | if (QApplication::keypadNavigationEnabled() && isEditable() && hasFocus()) | - |
| 2616 | setEditFocus(true); | - |
| 2617 | #endif | - |
| 2618 | d->_q_resetButton(); executed (the execution status of this line is deduced): d->_q_resetButton(); | - |
| 2619 | } executed: }Execution Count:132 | 132 |
| 2620 | | - |
| 2621 | /*! | - |
| 2622 | Clears the combobox, removing all items. | - |
| 2623 | | - |
| 2624 | Note: If you have set an external model on the combobox this model | - |
| 2625 | will still be cleared when calling this function. | - |
| 2626 | */ | - |
| 2627 | void QComboBox::clear() | - |
| 2628 | { | - |
| 2629 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2630 | d->model->removeRows(0, d->model->rowCount(d->root), d->root); executed (the execution status of this line is deduced): d->model->removeRows(0, d->model->rowCount(d->root), d->root); | - |
| 2631 | #ifndef QT_NO_ACCESSIBILITY | - |
| 2632 | QAccessibleEvent event(this, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::NameChanged); | - |
| 2633 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 2634 | #endif | - |
| 2635 | } executed: }Execution Count:238 | 238 |
| 2636 | | - |
| 2637 | /*! | - |
| 2638 | Clears the contents of the line edit used for editing in the combobox. | - |
| 2639 | */ | - |
| 2640 | void QComboBox::clearEditText() | - |
| 2641 | { | - |
| 2642 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2643 | if (d->lineEdit) partially evaluated: d->lineEdit| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 2644 | d->lineEdit->clear(); executed: d->lineEdit->clear();Execution Count:1 | 1 |
| 2645 | #ifndef QT_NO_ACCESSIBILITY | - |
| 2646 | QAccessibleEvent event(this, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::NameChanged); | - |
| 2647 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 2648 | #endif | - |
| 2649 | } executed: }Execution Count:1 | 1 |
| 2650 | | - |
| 2651 | /*! | - |
| 2652 | Sets the \a text in the combobox's text edit. | - |
| 2653 | */ | - |
| 2654 | void QComboBox::setEditText(const QString &text) | - |
| 2655 | { | - |
| 2656 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2657 | if (d->lineEdit) partially evaluated: d->lineEdit| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 2658 | d->lineEdit->setText(text); executed: d->lineEdit->setText(text);Execution Count:4 | 4 |
| 2659 | #ifndef QT_NO_ACCESSIBILITY | - |
| 2660 | QAccessibleEvent event(this, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::NameChanged); | - |
| 2661 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 2662 | #endif | - |
| 2663 | } executed: }Execution Count:4 | 4 |
| 2664 | | - |
| 2665 | /*! | - |
| 2666 | \reimp | - |
| 2667 | */ | - |
| 2668 | void QComboBox::focusInEvent(QFocusEvent *e) | - |
| 2669 | { | - |
| 2670 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2671 | update(); executed (the execution status of this line is deduced): update(); | - |
| 2672 | if (d->lineEdit) { evaluated: d->lineEdit| yes Evaluation Count:9 | yes Evaluation Count:7 |
| 7-9 |
| 2673 | d->lineEdit->event(e); executed (the execution status of this line is deduced): d->lineEdit->event(e); | - |
| 2674 | #ifndef QT_NO_COMPLETER | - |
| 2675 | if (d->lineEdit->completer()) partially evaluated: d->lineEdit->completer()| yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
| 2676 | d->lineEdit->completer()->setWidget(this); executed: d->lineEdit->completer()->setWidget(this);Execution Count:9 | 9 |
| 2677 | #endif | - |
| 2678 | } executed: }Execution Count:9 | 9 |
| 2679 | } executed: }Execution Count:16 | 16 |
| 2680 | | - |
| 2681 | /*! | - |
| 2682 | \reimp | - |
| 2683 | */ | - |
| 2684 | void QComboBox::focusOutEvent(QFocusEvent *e) | - |
| 2685 | { | - |
| 2686 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2687 | update(); executed (the execution status of this line is deduced): update(); | - |
| 2688 | if (d->lineEdit) evaluated: d->lineEdit| yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
| 2689 | d->lineEdit->event(e); executed: d->lineEdit->event(e);Execution Count:6 | 6 |
| 2690 | } executed: }Execution Count:11 | 11 |
| 2691 | | - |
| 2692 | /*! \reimp */ | - |
| 2693 | void QComboBox::changeEvent(QEvent *e) | - |
| 2694 | { | - |
| 2695 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2696 | switch (e->type()) { | - |
| 2697 | case QEvent::StyleChange: | - |
| 2698 | d->updateDelegate(); executed (the execution status of this line is deduced): d->updateDelegate(); | - |
| 2699 | #ifdef Q_OS_MAC | - |
| 2700 | case QEvent::MacSizeChange: | - |
| 2701 | #endif | - |
| 2702 | d->sizeHint = QSize(); // invalidate size hint executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 2703 | d->minimumSizeHint = QSize(); executed (the execution status of this line is deduced): d->minimumSizeHint = QSize(); | - |
| 2704 | d->updateLayoutDirection(); executed (the execution status of this line is deduced): d->updateLayoutDirection(); | - |
| 2705 | if (d->lineEdit) partially evaluated: d->lineEdit| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 2706 | d->updateLineEditGeometry(); executed: d->updateLineEditGeometry();Execution Count:2 | 2 |
| 2707 | d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); executed (the execution status of this line is deduced): d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); | - |
| 2708 | | - |
| 2709 | // ### need to update scrollers etc. as well here | - |
| 2710 | break; executed: break;Execution Count:2 | 2 |
| 2711 | case QEvent::EnabledChange: | - |
| 2712 | if (!isEnabled()) evaluated: !isEnabled()| yes Evaluation Count:16 | yes Evaluation Count:12 |
| 12-16 |
| 2713 | hidePopup(); executed: hidePopup();Execution Count:16 | 16 |
| 2714 | break; executed: break;Execution Count:28 | 28 |
| 2715 | case QEvent::PaletteChange: { | - |
| 2716 | d->updateViewContainerPaletteAndOpacity(); never executed (the execution status of this line is deduced): d->updateViewContainerPaletteAndOpacity(); | - |
| 2717 | break; | 0 |
| 2718 | } | - |
| 2719 | case QEvent::FontChange: | - |
| 2720 | d->sizeHint = QSize(); // invalidate size hint never executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 2721 | d->viewContainer()->setFont(font()); never executed (the execution status of this line is deduced): d->viewContainer()->setFont(font()); | - |
| 2722 | if (d->lineEdit) never evaluated: d->lineEdit | 0 |
| 2723 | d->updateLineEditGeometry(); never executed: d->updateLineEditGeometry(); | 0 |
| 2724 | break; | 0 |
| 2725 | default: | - |
| 2726 | break; executed: break;Execution Count:23 | 23 |
| 2727 | } | - |
| 2728 | QWidget::changeEvent(e); executed (the execution status of this line is deduced): QWidget::changeEvent(e); | - |
| 2729 | } executed: }Execution Count:53 | 53 |
| 2730 | | - |
| 2731 | /*! | - |
| 2732 | \reimp | - |
| 2733 | */ | - |
| 2734 | void QComboBox::resizeEvent(QResizeEvent *) | - |
| 2735 | { | - |
| 2736 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2737 | d->updateLineEditGeometry(); executed (the execution status of this line is deduced): d->updateLineEditGeometry(); | - |
| 2738 | } executed: }Execution Count:112 | 112 |
| 2739 | | - |
| 2740 | /*! | - |
| 2741 | \reimp | - |
| 2742 | */ | - |
| 2743 | void QComboBox::paintEvent(QPaintEvent *) | - |
| 2744 | { | - |
| 2745 | QStylePainter painter(this); executed (the execution status of this line is deduced): QStylePainter painter(this); | - |
| 2746 | painter.setPen(palette().color(QPalette::Text)); executed (the execution status of this line is deduced): painter.setPen(palette().color(QPalette::Text)); | - |
| 2747 | | - |
| 2748 | // draw the combobox frame, focusrect and selected etc. | - |
| 2749 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 2750 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 2751 | painter.drawComplexControl(QStyle::CC_ComboBox, opt); executed (the execution status of this line is deduced): painter.drawComplexControl(QStyle::CC_ComboBox, opt); | - |
| 2752 | | - |
| 2753 | // draw the icon and text | - |
| 2754 | painter.drawControl(QStyle::CE_ComboBoxLabel, opt); executed (the execution status of this line is deduced): painter.drawControl(QStyle::CE_ComboBoxLabel, opt); | - |
| 2755 | } executed: }Execution Count:60 | 60 |
| 2756 | | - |
| 2757 | /*! | - |
| 2758 | \reimp | - |
| 2759 | */ | - |
| 2760 | void QComboBox::showEvent(QShowEvent *e) | - |
| 2761 | { | - |
| 2762 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2763 | if (!d->shownOnce && d->sizeAdjustPolicy == QComboBox::AdjustToContentsOnFirstShow) { evaluated: !d->shownOnce| yes Evaluation Count:109 | yes Evaluation Count:7 |
evaluated: d->sizeAdjustPolicy == QComboBox::AdjustToContentsOnFirstShow| yes Evaluation Count:67 | yes Evaluation Count:42 |
| 7-109 |
| 2764 | d->sizeHint = QSize(); executed (the execution status of this line is deduced): d->sizeHint = QSize(); | - |
| 2765 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 2766 | } executed: }Execution Count:67 | 67 |
| 2767 | d->shownOnce = true; executed (the execution status of this line is deduced): d->shownOnce = true; | - |
| 2768 | QWidget::showEvent(e); executed (the execution status of this line is deduced): QWidget::showEvent(e); | - |
| 2769 | } executed: }Execution Count:116 | 116 |
| 2770 | | - |
| 2771 | /*! | - |
| 2772 | \reimp | - |
| 2773 | */ | - |
| 2774 | void QComboBox::hideEvent(QHideEvent *) | - |
| 2775 | { | - |
| 2776 | hidePopup(); executed (the execution status of this line is deduced): hidePopup(); | - |
| 2777 | } executed: }Execution Count:116 | 116 |
| 2778 | | - |
| 2779 | /*! | - |
| 2780 | \reimp | - |
| 2781 | */ | - |
| 2782 | bool QComboBox::event(QEvent *event) | - |
| 2783 | { | - |
| 2784 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2785 | switch(event->type()) { | - |
| 2786 | case QEvent::LayoutDirectionChange: | - |
| 2787 | case QEvent::ApplicationLayoutDirectionChange: | - |
| 2788 | d->updateLayoutDirection(); never executed (the execution status of this line is deduced): d->updateLayoutDirection(); | - |
| 2789 | d->updateLineEditGeometry(); never executed (the execution status of this line is deduced): d->updateLineEditGeometry(); | - |
| 2790 | break; | 0 |
| 2791 | case QEvent::HoverEnter: | - |
| 2792 | case QEvent::HoverLeave: | - |
| 2793 | case QEvent::HoverMove: | - |
| 2794 | if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) never evaluated: const QHoverEvent *he = static_cast<const QHoverEvent *>(event) | 0 |
| 2795 | d->updateHoverControl(he->pos()); never executed: d->updateHoverControl(he->pos()); | 0 |
| 2796 | break; | 0 |
| 2797 | case QEvent::ShortcutOverride: | - |
| 2798 | if (d->lineEdit) evaluated: d->lineEdit| yes Evaluation Count:8 | yes Evaluation Count:1 |
| 1-8 |
| 2799 | return d->lineEdit->event(event); executed: return d->lineEdit->event(event);Execution Count:8 | 8 |
| 2800 | break; executed: break;Execution Count:1 | 1 |
| 2801 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2802 | case QEvent::EnterEditFocus: | - |
| 2803 | if (!d->lineEdit) | - |
| 2804 | setEditFocus(false); // We never want edit focus if we are not editable | - |
| 2805 | else | - |
| 2806 | d->lineEdit->event(event); //so cursor starts | - |
| 2807 | break; | - |
| 2808 | case QEvent::LeaveEditFocus: | - |
| 2809 | if (d->lineEdit) | - |
| 2810 | d->lineEdit->event(event); //so cursor stops | - |
| 2811 | break; | - |
| 2812 | #endif | - |
| 2813 | default: | - |
| 2814 | break; executed: break;Execution Count:4080 | 4080 |
| 2815 | } | - |
| 2816 | return QWidget::event(event); executed: return QWidget::event(event);Execution Count:4081 | 4081 |
| 2817 | } | - |
| 2818 | | - |
| 2819 | /*! | - |
| 2820 | \reimp | - |
| 2821 | */ | - |
| 2822 | void QComboBox::mousePressEvent(QMouseEvent *e) | - |
| 2823 | { | - |
| 2824 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2825 | QStyleOptionComboBox opt; executed (the execution status of this line is deduced): QStyleOptionComboBox opt; | - |
| 2826 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 2827 | QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), executed (the execution status of this line is deduced): QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), | - |
| 2828 | this); executed (the execution status of this line is deduced): this); | - |
| 2829 | if (e->button() == Qt::LeftButton && (sc == QStyle::SC_ComboBoxArrow || !isEditable()) partially evaluated: e->button() == Qt::LeftButton| yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: sc == QStyle::SC_ComboBoxArrow| no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: !isEditable()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2830 | && !d->viewContainer()->isVisible()) { never evaluated: !d->viewContainer()->isVisible() | 0 |
| 2831 | if (sc == QStyle::SC_ComboBoxArrow) never evaluated: sc == QStyle::SC_ComboBoxArrow | 0 |
| 2832 | d->updateArrow(QStyle::State_Sunken); never executed: d->updateArrow(QStyle::State_Sunken); | 0 |
| 2833 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2834 | //if the container already exists, then d->viewContainer() is safe to call | - |
| 2835 | if (d->container) { | - |
| 2836 | #endif | - |
| 2837 | // We've restricted the next couple of lines, because by not calling | - |
| 2838 | // viewContainer(), we avoid creating the QComboBoxPrivateContainer. | - |
| 2839 | d->viewContainer()->blockMouseReleaseTimer.start(QApplication::doubleClickInterval()); never executed (the execution status of this line is deduced): d->viewContainer()->blockMouseReleaseTimer.start(QApplication::doubleClickInterval()); | - |
| 2840 | d->viewContainer()->initialClickPosition = mapToGlobal(e->pos()); never executed (the execution status of this line is deduced): d->viewContainer()->initialClickPosition = mapToGlobal(e->pos()); | - |
| 2841 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2842 | } | - |
| 2843 | #endif | - |
| 2844 | showPopup(); never executed (the execution status of this line is deduced): showPopup(); | - |
| 2845 | } else { | 0 |
| 2846 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2847 | if (QApplication::keypadNavigationEnabled() && sc == QStyle::SC_ComboBoxEditField && d->lineEdit) { | - |
| 2848 | d->lineEdit->event(e); //so lineedit can move cursor, etc | - |
| 2849 | return; | - |
| 2850 | } | - |
| 2851 | #endif | - |
| 2852 | QWidget::mousePressEvent(e); executed (the execution status of this line is deduced): QWidget::mousePressEvent(e); | - |
| 2853 | } executed: }Execution Count:1 | 1 |
| 2854 | } | - |
| 2855 | | - |
| 2856 | /*! | - |
| 2857 | \reimp | - |
| 2858 | */ | - |
| 2859 | void QComboBox::mouseReleaseEvent(QMouseEvent *e) | - |
| 2860 | { | - |
| 2861 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2862 | Q_UNUSED(e); executed (the execution status of this line is deduced): (void)e;; | - |
| 2863 | d->updateArrow(QStyle::State_None); executed (the execution status of this line is deduced): d->updateArrow(QStyle::State_None); | - |
| 2864 | } executed: }Execution Count:1 | 1 |
| 2865 | | - |
| 2866 | /*! | - |
| 2867 | \reimp | - |
| 2868 | */ | - |
| 2869 | void QComboBox::keyPressEvent(QKeyEvent *e) | - |
| 2870 | { | - |
| 2871 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 2872 | | - |
| 2873 | #ifndef QT_NO_COMPLETER | - |
| 2874 | if (d->lineEdit evaluated: d->lineEdit| yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
| 2875 | && d->lineEdit->completer() partially evaluated: d->lineEdit->completer()| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 2876 | && d->lineEdit->completer()->popup() evaluated: d->lineEdit->completer()->popup()| yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
| 2877 | && d->lineEdit->completer()->popup()->isVisible()) { evaluated: d->lineEdit->completer()->popup()->isVisible()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 2878 | // provide same autocompletion support as line edit | - |
| 2879 | d->lineEdit->event(e); executed (the execution status of this line is deduced): d->lineEdit->event(e); | - |
| 2880 | return; executed: return;Execution Count:1 | 1 |
| 2881 | } | - |
| 2882 | #endif | - |
| 2883 | | - |
| 2884 | enum Move { NoMove=0 , MoveUp , MoveDown , MoveFirst , MoveLast}; executed (the execution status of this line is deduced): enum Move { NoMove=0 , MoveUp , MoveDown , MoveFirst , MoveLast}; | - |
| 2885 | | - |
| 2886 | Move move = NoMove; executed (the execution status of this line is deduced): Move move = NoMove; | - |
| 2887 | int newIndex = currentIndex(); executed (the execution status of this line is deduced): int newIndex = currentIndex(); | - |
| 2888 | switch (e->key()) { | - |
| 2889 | case Qt::Key_Up: | - |
| 2890 | if (e->modifiers() & Qt::ControlModifier) never evaluated: e->modifiers() & Qt::ControlModifier | 0 |
| 2891 | break; // pass to line edit for auto completion | 0 |
| 2892 | case Qt::Key_PageUp: code before this statement never executed: case Qt::Key_PageUp: | 0 |
| 2893 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2894 | if (QApplication::keypadNavigationEnabled()) | - |
| 2895 | e->ignore(); | - |
| 2896 | else | - |
| 2897 | #endif | - |
| 2898 | move = MoveUp; never executed (the execution status of this line is deduced): move = MoveUp; | - |
| 2899 | break; | 0 |
| 2900 | case Qt::Key_Down: | - |
| 2901 | if (e->modifiers() & Qt::AltModifier) { partially evaluated: e->modifiers() & Qt::AltModifier| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2902 | showPopup(); never executed (the execution status of this line is deduced): showPopup(); | - |
| 2903 | return; | 0 |
| 2904 | } else if (e->modifiers() & Qt::ControlModifier) partially evaluated: e->modifiers() & Qt::ControlModifier| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2905 | break; // pass to line edit for auto completion | 0 |
| 2906 | // fall through | - |
| 2907 | case Qt::Key_PageDown: code before this statement executed: case Qt::Key_PageDown:Execution Count:2 | 2 |
| 2908 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2909 | if (QApplication::keypadNavigationEnabled()) | - |
| 2910 | e->ignore(); | - |
| 2911 | else | - |
| 2912 | #endif | - |
| 2913 | move = MoveDown; executed (the execution status of this line is deduced): move = MoveDown; | - |
| 2914 | break; executed: break;Execution Count:2 | 2 |
| 2915 | case Qt::Key_Home: | - |
| 2916 | if (!d->lineEdit) never evaluated: !d->lineEdit | 0 |
| 2917 | move = MoveFirst; never executed: move = MoveFirst; | 0 |
| 2918 | break; | 0 |
| 2919 | case Qt::Key_End: | - |
| 2920 | if (!d->lineEdit) never evaluated: !d->lineEdit | 0 |
| 2921 | move = MoveLast; never executed: move = MoveLast; | 0 |
| 2922 | break; | 0 |
| 2923 | case Qt::Key_F4: | - |
| 2924 | if (!e->modifiers()) { never evaluated: !e->modifiers() | 0 |
| 2925 | showPopup(); never executed (the execution status of this line is deduced): showPopup(); | - |
| 2926 | return; | 0 |
| 2927 | } | - |
| 2928 | break; | 0 |
| 2929 | case Qt::Key_Space: | - |
| 2930 | if (!d->lineEdit) { never evaluated: !d->lineEdit | 0 |
| 2931 | showPopup(); never executed (the execution status of this line is deduced): showPopup(); | - |
| 2932 | return; | 0 |
| 2933 | } | - |
| 2934 | case Qt::Key_Enter: code before this statement never executed: case Qt::Key_Enter: | 0 |
| 2935 | case Qt::Key_Return: | - |
| 2936 | case Qt::Key_Escape: | - |
| 2937 | if (!d->lineEdit) partially evaluated: !d->lineEdit| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2938 | e->ignore(); never executed: e->ignore(); | 0 |
| 2939 | break; executed: break;Execution Count:1 | 1 |
| 2940 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 2941 | case Qt::Key_Select: | - |
| 2942 | if (QApplication::keypadNavigationEnabled() | - |
| 2943 | && (!hasEditFocus() || !d->lineEdit)) { | - |
| 2944 | showPopup(); | - |
| 2945 | return; | - |
| 2946 | } | - |
| 2947 | break; | - |
| 2948 | case Qt::Key_Left: | - |
| 2949 | case Qt::Key_Right: | - |
| 2950 | if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) | - |
| 2951 | e->ignore(); | - |
| 2952 | break; | - |
| 2953 | case Qt::Key_Back: | - |
| 2954 | if (QApplication::keypadNavigationEnabled()) { | - |
| 2955 | if (!hasEditFocus() || !d->lineEdit) | - |
| 2956 | e->ignore(); | - |
| 2957 | } else { | - |
| 2958 | e->ignore(); // let the surounding dialog have it | - |
| 2959 | } | - |
| 2960 | break; | - |
| 2961 | #endif | - |
| 2962 | default: | - |
| 2963 | if (!d->lineEdit) { partially evaluated: !d->lineEdit| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 2964 | if (!e->text().isEmpty()) never evaluated: !e->text().isEmpty() | 0 |
| 2965 | d->keyboardSearchString(e->text()); never executed: d->keyboardSearchString(e->text()); | 0 |
| 2966 | else | - |
| 2967 | e->ignore(); never executed: e->ignore(); | 0 |
| 2968 | } | - |
| 2969 | } executed: }Execution Count:3 | 3 |
| 2970 | | - |
| 2971 | if (move != NoMove) { evaluated: move != NoMove| yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
| 2972 | e->accept(); executed (the execution status of this line is deduced): e->accept(); | - |
| 2973 | switch (move) { | - |
| 2974 | case MoveFirst: | - |
| 2975 | newIndex = -1; never executed (the execution status of this line is deduced): newIndex = -1; | - |
| 2976 | case MoveDown: code before this statement never executed: case MoveDown: | 0 |
| 2977 | newIndex++; executed (the execution status of this line is deduced): newIndex++; | - |
| 2978 | while ((newIndex < count()) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)) partially evaluated: (newIndex < count())| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2979 | newIndex++; never executed: newIndex++; | 0 |
| 2980 | break; executed: break;Execution Count:2 | 2 |
| 2981 | case MoveLast: | - |
| 2982 | newIndex = count(); never executed (the execution status of this line is deduced): newIndex = count(); | - |
| 2983 | case MoveUp: code before this statement never executed: case MoveUp: | 0 |
| 2984 | newIndex--; never executed (the execution status of this line is deduced): newIndex--; | - |
| 2985 | while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)) never evaluated: (newIndex >= 0) never evaluated: !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled) | 0 |
| 2986 | newIndex--; never executed: newIndex--; | 0 |
| 2987 | break; | 0 |
| 2988 | default: | - |
| 2989 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
| 2990 | break; | 0 |
| 2991 | } | - |
| 2992 | | - |
| 2993 | if (newIndex >= 0 && newIndex < count() && newIndex != currentIndex()) { partially evaluated: newIndex >= 0| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: newIndex < count()| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: newIndex != currentIndex()| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 2994 | setCurrentIndex(newIndex); executed (the execution status of this line is deduced): setCurrentIndex(newIndex); | - |
| 2995 | d->emitActivated(d->currentIndex); executed (the execution status of this line is deduced): d->emitActivated(d->currentIndex); | - |
| 2996 | } executed: }Execution Count:2 | 2 |
| 2997 | } else if (d->lineEdit) { executed: }Execution Count:2 partially evaluated: d->lineEdit| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 2998 | d->lineEdit->event(e); executed (the execution status of this line is deduced): d->lineEdit->event(e); | - |
| 2999 | } executed: }Execution Count:4 | 4 |
| 3000 | } | - |
| 3001 | | - |
| 3002 | | - |
| 3003 | /*! | - |
| 3004 | \reimp | - |
| 3005 | */ | - |
| 3006 | void QComboBox::keyReleaseEvent(QKeyEvent *e) | - |
| 3007 | { | - |
| 3008 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3009 | if (d->lineEdit) never evaluated: d->lineEdit | 0 |
| 3010 | d->lineEdit->event(e); never executed: d->lineEdit->event(e); | 0 |
| 3011 | } | 0 |
| 3012 | | - |
| 3013 | /*! | - |
| 3014 | \reimp | - |
| 3015 | */ | - |
| 3016 | #ifndef QT_NO_WHEELEVENT | - |
| 3017 | void QComboBox::wheelEvent(QWheelEvent *e) | - |
| 3018 | { | - |
| 3019 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3020 | if (!d->viewContainer()->isVisible()) { never evaluated: !d->viewContainer()->isVisible() | 0 |
| 3021 | int newIndex = currentIndex(); never executed (the execution status of this line is deduced): int newIndex = currentIndex(); | - |
| 3022 | | - |
| 3023 | if (e->delta() > 0) { never evaluated: e->delta() > 0 | 0 |
| 3024 | newIndex--; never executed (the execution status of this line is deduced): newIndex--; | - |
| 3025 | while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)) never evaluated: (newIndex >= 0) never evaluated: !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled) | 0 |
| 3026 | newIndex--; never executed: newIndex--; | 0 |
| 3027 | } else { | 0 |
| 3028 | newIndex++; never executed (the execution status of this line is deduced): newIndex++; | - |
| 3029 | while ((newIndex < count()) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled)) never evaluated: (newIndex < count()) never evaluated: !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled) | 0 |
| 3030 | newIndex++; never executed: newIndex++; | 0 |
| 3031 | } | 0 |
| 3032 | | - |
| 3033 | if (newIndex >= 0 && newIndex < count() && newIndex != currentIndex()) { never evaluated: newIndex >= 0 never evaluated: newIndex < count() never evaluated: newIndex != currentIndex() | 0 |
| 3034 | setCurrentIndex(newIndex); never executed (the execution status of this line is deduced): setCurrentIndex(newIndex); | - |
| 3035 | d->emitActivated(d->currentIndex); never executed (the execution status of this line is deduced): d->emitActivated(d->currentIndex); | - |
| 3036 | } | 0 |
| 3037 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
| 3038 | } | 0 |
| 3039 | } | 0 |
| 3040 | #endif | - |
| 3041 | | - |
| 3042 | #ifndef QT_NO_CONTEXTMENU | - |
| 3043 | /*! | - |
| 3044 | \reimp | - |
| 3045 | */ | - |
| 3046 | void QComboBox::contextMenuEvent(QContextMenuEvent *e) | - |
| 3047 | { | - |
| 3048 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3049 | if (d->lineEdit) { never evaluated: d->lineEdit | 0 |
| 3050 | Qt::ContextMenuPolicy p = d->lineEdit->contextMenuPolicy(); never executed (the execution status of this line is deduced): Qt::ContextMenuPolicy p = d->lineEdit->contextMenuPolicy(); | - |
| 3051 | d->lineEdit->setContextMenuPolicy(Qt::DefaultContextMenu); never executed (the execution status of this line is deduced): d->lineEdit->setContextMenuPolicy(Qt::DefaultContextMenu); | - |
| 3052 | d->lineEdit->event(e); never executed (the execution status of this line is deduced): d->lineEdit->event(e); | - |
| 3053 | d->lineEdit->setContextMenuPolicy(p); never executed (the execution status of this line is deduced): d->lineEdit->setContextMenuPolicy(p); | - |
| 3054 | } | 0 |
| 3055 | } | 0 |
| 3056 | #endif // QT_NO_CONTEXTMENU | - |
| 3057 | | - |
| 3058 | void QComboBoxPrivate::keyboardSearchString(const QString &text) | - |
| 3059 | { | - |
| 3060 | // use keyboardSearch from the listView so we do not duplicate code | - |
| 3061 | QAbstractItemView *view = viewContainer()->itemView(); never executed (the execution status of this line is deduced): QAbstractItemView *view = viewContainer()->itemView(); | - |
| 3062 | view->setCurrentIndex(currentIndex); never executed (the execution status of this line is deduced): view->setCurrentIndex(currentIndex); | - |
| 3063 | int currentRow = view->currentIndex().row(); never executed (the execution status of this line is deduced): int currentRow = view->currentIndex().row(); | - |
| 3064 | view->keyboardSearch(text); never executed (the execution status of this line is deduced): view->keyboardSearch(text); | - |
| 3065 | if (currentRow != view->currentIndex().row()) { never evaluated: currentRow != view->currentIndex().row() | 0 |
| 3066 | setCurrentIndex(view->currentIndex()); never executed (the execution status of this line is deduced): setCurrentIndex(view->currentIndex()); | - |
| 3067 | emitActivated(currentIndex); never executed (the execution status of this line is deduced): emitActivated(currentIndex); | - |
| 3068 | } | 0 |
| 3069 | } | 0 |
| 3070 | | - |
| 3071 | void QComboBoxPrivate::modelChanged() | - |
| 3072 | { | - |
| 3073 | Q_Q(QComboBox); executed (the execution status of this line is deduced): QComboBox * const q = q_func(); | - |
| 3074 | | - |
| 3075 | if (sizeAdjustPolicy == QComboBox::AdjustToContents) { partially evaluated: sizeAdjustPolicy == QComboBox::AdjustToContents| no Evaluation Count:0 | yes Evaluation Count:887 |
| 0-887 |
| 3076 | sizeHint = QSize(); never executed (the execution status of this line is deduced): sizeHint = QSize(); | - |
| 3077 | adjustComboBoxSize(); never executed (the execution status of this line is deduced): adjustComboBoxSize(); | - |
| 3078 | q->updateGeometry(); never executed (the execution status of this line is deduced): q->updateGeometry(); | - |
| 3079 | } | 0 |
| 3080 | } executed: }Execution Count:887 | 887 |
| 3081 | | - |
| 3082 | /*! | - |
| 3083 | \reimp | - |
| 3084 | */ | - |
| 3085 | void QComboBox::inputMethodEvent(QInputMethodEvent *e) | - |
| 3086 | { | - |
| 3087 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3088 | if (d->lineEdit) { never evaluated: d->lineEdit | 0 |
| 3089 | d->lineEdit->event(e); never executed (the execution status of this line is deduced): d->lineEdit->event(e); | - |
| 3090 | } else { | 0 |
| 3091 | if (!e->commitString().isEmpty()) never evaluated: !e->commitString().isEmpty() | 0 |
| 3092 | d->keyboardSearchString(e->commitString()); never executed: d->keyboardSearchString(e->commitString()); | 0 |
| 3093 | else | - |
| 3094 | e->ignore(); never executed: e->ignore(); | 0 |
| 3095 | } | - |
| 3096 | } | - |
| 3097 | | - |
| 3098 | /*! | - |
| 3099 | \reimp | - |
| 3100 | */ | - |
| 3101 | QVariant QComboBox::inputMethodQuery(Qt::InputMethodQuery query) const | - |
| 3102 | { | - |
| 3103 | Q_D(const QComboBox); executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 3104 | if (d->lineEdit) partially evaluated: d->lineEdit| yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
| 3105 | return d->lineEdit->inputMethodQuery(query); executed: return d->lineEdit->inputMethodQuery(query);Execution Count:30 | 30 |
| 3106 | return QWidget::inputMethodQuery(query); never executed: return QWidget::inputMethodQuery(query); | 0 |
| 3107 | } | - |
| 3108 | | - |
| 3109 | /*! | - |
| 3110 | \fn void QComboBox::addItem(const QString &text, const QVariant &userData) | - |
| 3111 | | - |
| 3112 | Adds an item to the combobox with the given \a text, and | - |
| 3113 | containing the specified \a userData (stored in the Qt::UserRole). | - |
| 3114 | The item is appended to the list of existing items. | - |
| 3115 | */ | - |
| 3116 | | - |
| 3117 | /*! | - |
| 3118 | \fn void QComboBox::addItem(const QIcon &icon, const QString &text, | - |
| 3119 | const QVariant &userData) | - |
| 3120 | | - |
| 3121 | Adds an item to the combobox with the given \a icon and \a text, | - |
| 3122 | and containing the specified \a userData (stored in the | - |
| 3123 | Qt::UserRole). The item is appended to the list of existing items. | - |
| 3124 | */ | - |
| 3125 | | - |
| 3126 | /*! | - |
| 3127 | \fn void QComboBox::addItems(const QStringList &texts) | - |
| 3128 | | - |
| 3129 | Adds each of the strings in the given \a texts to the combobox. Each item | - |
| 3130 | is appended to the list of existing items in turn. | - |
| 3131 | */ | - |
| 3132 | | - |
| 3133 | /*! | - |
| 3134 | \fn void QComboBox::editTextChanged(const QString &text) | - |
| 3135 | | - |
| 3136 | This signal is emitted when the text in the combobox's line edit | - |
| 3137 | widget is changed. The new text is specified by \a text. | - |
| 3138 | */ | - |
| 3139 | | - |
| 3140 | /*! | - |
| 3141 | \property QComboBox::frame | - |
| 3142 | \brief whether the combo box draws itself with a frame | - |
| 3143 | | - |
| 3144 | | - |
| 3145 | If enabled (the default) the combo box draws itself inside a | - |
| 3146 | frame, otherwise the combo box draws itself without any frame. | - |
| 3147 | */ | - |
| 3148 | bool QComboBox::hasFrame() const | - |
| 3149 | { | - |
| 3150 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 3151 | return d->frame; never executed: return d->frame; | 0 |
| 3152 | } | - |
| 3153 | | - |
| 3154 | | - |
| 3155 | void QComboBox::setFrame(bool enable) | - |
| 3156 | { | - |
| 3157 | Q_D(QComboBox); executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3158 | d->frame = enable; executed (the execution status of this line is deduced): d->frame = enable; | - |
| 3159 | update(); executed (the execution status of this line is deduced): update(); | - |
| 3160 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 3161 | } executed: }Execution Count:1 | 1 |
| 3162 | | - |
| 3163 | /*! | - |
| 3164 | \property QComboBox::modelColumn | - |
| 3165 | \brief the column in the model that is visible. | - |
| 3166 | | - |
| 3167 | If set prior to populating the combo box, the pop-up view will | - |
| 3168 | not be affected and will show the first column (using this property's | - |
| 3169 | default value). | - |
| 3170 | | - |
| 3171 | By default, this property has a value of 0. | - |
| 3172 | */ | - |
| 3173 | int QComboBox::modelColumn() const | - |
| 3174 | { | - |
| 3175 | Q_D(const QComboBox); never executed (the execution status of this line is deduced): const QComboBoxPrivate * const d = d_func(); | - |
| 3176 | return d->modelColumn; never executed: return d->modelColumn; | 0 |
| 3177 | } | - |
| 3178 | | - |
| 3179 | void QComboBox::setModelColumn(int visibleColumn) | - |
| 3180 | { | - |
| 3181 | Q_D(QComboBox); never executed (the execution status of this line is deduced): QComboBoxPrivate * const d = d_func(); | - |
| 3182 | d->modelColumn = visibleColumn; never executed (the execution status of this line is deduced): d->modelColumn = visibleColumn; | - |
| 3183 | QListView *lv = qobject_cast<QListView *>(d->viewContainer()->itemView()); never executed (the execution status of this line is deduced): QListView *lv = qobject_cast<QListView *>(d->viewContainer()->itemView()); | - |
| 3184 | if (lv) | 0 |
| 3185 | lv->setModelColumn(visibleColumn); never executed: lv->setModelColumn(visibleColumn); | 0 |
| 3186 | #ifndef QT_NO_COMPLETER | - |
| 3187 | if (d->lineEdit && d->lineEdit->completer() never evaluated: d->lineEdit never evaluated: d->lineEdit->completer() | 0 |
| 3188 | && d->lineEdit->completer() == d->completer) never evaluated: d->lineEdit->completer() == d->completer | 0 |
| 3189 | d->lineEdit->completer()->setCompletionColumn(visibleColumn); never executed: d->lineEdit->completer()->setCompletionColumn(visibleColumn); | 0 |
| 3190 | #endif | - |
| 3191 | setCurrentIndex(currentIndex()); //update the text to the text of the new column; never executed (the execution status of this line is deduced): setCurrentIndex(currentIndex()); | - |
| 3192 | } | 0 |
| 3193 | | - |
| 3194 | QT_END_NAMESPACE | - |
| 3195 | | - |
| 3196 | #include "moc_qcombobox.cpp" | - |
| 3197 | | - |
| 3198 | #endif // QT_NO_COMBOBOX | - |
| 3199 | | - |
| | |