diff options
Diffstat (limited to 'src/widgets/widgets/qcombobox_p.h')
-rw-r--r-- | src/widgets/widgets/qcombobox_p.h | 91 |
1 files changed, 34 insertions, 57 deletions
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index df3421692f..723d637ae2 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QCOMBOBOX_P_H #define QCOMBOBOX_P_H @@ -63,7 +27,6 @@ #include "QtGui/qpainter.h" #include "QtWidgets/qstyle.h" #include "QtWidgets/qstyleoption.h" -#include "QtCore/qpair.h" #include "QtCore/qtimer.h" #include "private/qwidget_p.h" #include "QtCore/qpointer.h" @@ -85,7 +48,11 @@ class QComboBoxListView : public QListView { Q_OBJECT public: - QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) {} + QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) + { + if (cmb) + setScreen(cmb->screen()); + } protected: void resizeEvent(QResizeEvent *event) override @@ -216,6 +183,7 @@ class Q_WIDGETS_EXPORT QComboBoxPrivateContainer : public QFrame public: QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent); + ~QComboBoxPrivateContainer(); QAbstractItemView *itemView() const; void setItemView(QAbstractItemView *itemView); int spacing() const; @@ -303,7 +271,8 @@ public: {} static bool isSeparator(const QModelIndex &index) { - return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator"); + return index.data(Qt::AccessibleDescriptionRole).toString() + == QLatin1StringView("separator"); } static void setSeparator(QAbstractItemModel *model, const QModelIndex &index) { model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole); @@ -350,24 +319,25 @@ public: QComboBoxPrivateContainer* viewContainer(); void updateLineEditGeometry(); Qt::MatchFlags matchFlags() const; - void _q_editingFinished(); - void _q_returnPressed(); - void _q_complete(); - void _q_itemSelected(const QModelIndex &item); + void editingFinished(); + void returnPressed(); + void complete(); + void itemSelected(const QModelIndex &item); bool contains(const QString &text, int role); void emitActivated(const QModelIndex &index); - void _q_emitHighlighted(const QModelIndex &index); - void _q_emitCurrentIndexChanged(const QModelIndex &index); - void _q_modelDestroyed(); - void _q_modelReset(); + void emitHighlighted(const QModelIndex &index); + void emitCurrentIndexChanged(const QModelIndex &index); + void modelDestroyed(); + void modelReset(); + void updateMicroFocus() { q_func()->updateMicroFocus(); } // PMF connect doesn't handle default args #if QT_CONFIG(completer) - void _q_completerActivated(const QModelIndex &index); + void completerActivated(const QModelIndex &index); #endif - void _q_resetButton(); - void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void _q_updateIndexBeforeChange(); - void _q_rowsInserted(const QModelIndex &parent, int start, int end); - void _q_rowsRemoved(const QModelIndex &parent, int start, int end); + void resetButton(); + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void updateIndexBeforeChange(); + void rowsInserted(const QModelIndex &parent, int start, int end); + void rowsRemoved(const QModelIndex &parent, int start, int end); void updateArrow(QStyle::StateFlag state); bool updateHoverControl(const QPoint &pos); void trySetValidIndex(); @@ -387,6 +357,10 @@ public: void updateViewContainerPaletteAndOpacity(); void updateFocusPolicy(); void showPopupFromMouseEvent(QMouseEvent *e); + void doHidePopup(); + void updateCurrentText(const QString &text); + void connectModel(); + void disconnectModel(); #ifdef Q_OS_MAC void cleanupNativePopup(); @@ -403,15 +377,17 @@ public: }; #endif + std::array<QMetaObject::Connection, 8> modelConnections; QAbstractItemModel *model = nullptr; QLineEdit *lineEdit = nullptr; - QComboBoxPrivateContainer *container = nullptr; + QPointer<QComboBoxPrivateContainer> container; #ifdef Q_OS_MAC QPlatformMenu *m_platformMenu = nullptr; #endif QPersistentModelIndex currentIndex; QPersistentModelIndex root; QString placeholderText; + QString currentText; QRect hoverRect; QSize iconSize; mutable QSize minimumSizeHint; @@ -423,13 +399,14 @@ public: int minimumContentsLength = 0; int indexBeforeChange = -1; int maxVisibleItems = 10; - int maxCount = std::numeric_limits<int>::max(); + int maxCount = (std::numeric_limits<int>::max)(); int modelColumn = 0; int placeholderIndex = -1; bool shownOnce : 1; bool duplicatesEnabled : 1; bool frame : 1; bool inserting : 1; + bool hidingPopup : 1; }; QT_END_NAMESPACE |