Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qcombobox.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QCOMBOBOX_H
0005 #define QCOMBOBOX_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qwidget.h>
0009 #include <QtWidgets/qabstractitemdelegate.h>
0010 #include <QtCore/qabstractitemmodel.h>
0011 #include <QtCore/qvariant.h>
0012 #include <QtGui/qvalidator.h>
0013 
0014 QT_REQUIRE_CONFIG(combobox);
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 class QAbstractItemView;
0019 class QLineEdit;
0020 class QComboBoxPrivate;
0021 class QCompleter;
0022 
0023 class Q_WIDGETS_EXPORT QComboBox : public QWidget
0024 {
0025     Q_OBJECT
0026 
0027     Q_PROPERTY(bool editable READ isEditable WRITE setEditable)
0028     Q_PROPERTY(int count READ count)
0029     Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText NOTIFY currentTextChanged
0030                USER true)
0031     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
0032     Q_PROPERTY(QVariant currentData READ currentData)
0033     Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
0034     Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
0035     Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy)
0036     Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
0037     Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
0038     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
0039     Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
0040     Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled)
0041     Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
0042     Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
0043 
0044 public:
0045     explicit QComboBox(QWidget *parent = nullptr);
0046     ~QComboBox();
0047 
0048     int maxVisibleItems() const;
0049     void setMaxVisibleItems(int maxItems);
0050 
0051     int count() const;
0052     void setMaxCount(int max);
0053     int maxCount() const;
0054 
0055     bool duplicatesEnabled() const;
0056     void setDuplicatesEnabled(bool enable);
0057 
0058     void setFrame(bool);
0059     bool hasFrame() const;
0060 
0061     inline int findText(const QString &text,
0062                         Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
0063         { return findData(text, Qt::DisplayRole, flags); }
0064     int findData(const QVariant &data, int role = Qt::UserRole,
0065                  Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const;
0066 
0067     enum InsertPolicy {
0068         NoInsert,
0069         InsertAtTop,
0070         InsertAtCurrent,
0071         InsertAtBottom,
0072         InsertAfterCurrent,
0073         InsertBeforeCurrent,
0074         InsertAlphabetically
0075     };
0076     Q_ENUM(InsertPolicy)
0077 
0078     InsertPolicy insertPolicy() const;
0079     void setInsertPolicy(InsertPolicy policy);
0080 
0081     enum SizeAdjustPolicy {
0082         AdjustToContents,
0083         AdjustToContentsOnFirstShow,
0084         AdjustToMinimumContentsLengthWithIcon
0085     };
0086     Q_ENUM(SizeAdjustPolicy)
0087 
0088     SizeAdjustPolicy sizeAdjustPolicy() const;
0089     void setSizeAdjustPolicy(SizeAdjustPolicy policy);
0090     int minimumContentsLength() const;
0091     void setMinimumContentsLength(int characters);
0092     QSize iconSize() const;
0093     void setIconSize(const QSize &size);
0094 
0095     void setPlaceholderText(const QString &placeholderText);
0096     QString placeholderText() const;
0097 
0098     bool isEditable() const;
0099     void setEditable(bool editable);
0100     void setLineEdit(QLineEdit *edit);
0101     QLineEdit *lineEdit() const;
0102 #ifndef QT_NO_VALIDATOR
0103     void setValidator(const QValidator *v);
0104     const QValidator *validator() const;
0105 #endif
0106 
0107 #if QT_CONFIG(completer)
0108     void setCompleter(QCompleter *c);
0109     QCompleter *completer() const;
0110 #endif
0111 
0112     QAbstractItemDelegate *itemDelegate() const;
0113     void setItemDelegate(QAbstractItemDelegate *delegate);
0114 
0115     QAbstractItemModel *model() const;
0116     virtual void setModel(QAbstractItemModel *model);
0117 
0118     QModelIndex rootModelIndex() const;
0119     void setRootModelIndex(const QModelIndex &index);
0120 
0121     int modelColumn() const;
0122     void setModelColumn(int visibleColumn);
0123 
0124     int currentIndex() const;
0125     QString currentText() const;
0126     QVariant currentData(int role = Qt::UserRole) const;
0127 
0128     QString itemText(int index) const;
0129     QIcon itemIcon(int index) const;
0130     QVariant itemData(int index, int role = Qt::UserRole) const;
0131 
0132     inline void addItem(const QString &text, const QVariant &userData = QVariant());
0133     inline void addItem(const QIcon &icon, const QString &text,
0134                         const QVariant &userData = QVariant());
0135     inline void addItems(const QStringList &texts)
0136         { insertItems(count(), texts); }
0137 
0138     inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant());
0139     void insertItem(int index, const QIcon &icon, const QString &text,
0140                     const QVariant &userData = QVariant());
0141     void insertItems(int index, const QStringList &texts);
0142     void insertSeparator(int index);
0143 
0144     void removeItem(int index);
0145 
0146     void setItemText(int index, const QString &text);
0147     void setItemIcon(int index, const QIcon &icon);
0148     void setItemData(int index, const QVariant &value, int role = Qt::UserRole);
0149 
0150     QAbstractItemView *view() const;
0151     void setView(QAbstractItemView *itemView);
0152 
0153     QSize sizeHint() const override;
0154     QSize minimumSizeHint() const override;
0155 
0156     virtual void showPopup();
0157     virtual void hidePopup();
0158 
0159     bool event(QEvent *event) override;
0160     QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
0161     Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
0162 
0163 public Q_SLOTS:
0164     void clear();
0165     void clearEditText();
0166     void setEditText(const QString &text);
0167     void setCurrentIndex(int index);
0168     void setCurrentText(const QString &text);
0169 
0170 Q_SIGNALS:
0171     void editTextChanged(const QString &);
0172     void activated(int index);
0173     void textActivated(const QString &);
0174     void highlighted(int index);
0175     void textHighlighted(const QString &);
0176     void currentIndexChanged(int index);
0177     void currentTextChanged(const QString &);
0178 
0179 protected:
0180     void focusInEvent(QFocusEvent *e) override;
0181     void focusOutEvent(QFocusEvent *e) override;
0182     void changeEvent(QEvent *e) override;
0183     void resizeEvent(QResizeEvent *e) override;
0184     void paintEvent(QPaintEvent *e) override;
0185     void showEvent(QShowEvent *e) override;
0186     void hideEvent(QHideEvent *e) override;
0187     void mousePressEvent(QMouseEvent *e) override;
0188     void mouseReleaseEvent(QMouseEvent *e) override;
0189     void keyPressEvent(QKeyEvent *e) override;
0190     void keyReleaseEvent(QKeyEvent *e) override;
0191 #if QT_CONFIG(wheelevent)
0192     void wheelEvent(QWheelEvent *e) override;
0193 #endif
0194 #ifndef QT_NO_CONTEXTMENU
0195     void contextMenuEvent(QContextMenuEvent *e) override;
0196 #endif // QT_NO_CONTEXTMENU
0197     void inputMethodEvent(QInputMethodEvent *) override;
0198     virtual void initStyleOption(QStyleOptionComboBox *option) const;
0199 
0200 
0201 protected:
0202     QComboBox(QComboBoxPrivate &, QWidget *);
0203 
0204 private:
0205     Q_DECLARE_PRIVATE(QComboBox)
0206     Q_DISABLE_COPY(QComboBox)
0207 };
0208 
0209 inline void QComboBox::addItem(const QString &atext, const QVariant &auserData)
0210 { insertItem(count(), atext, auserData); }
0211 inline void QComboBox::addItem(const QIcon &aicon, const QString &atext,
0212                                const QVariant &auserData)
0213 { insertItem(count(), aicon, atext, auserData); }
0214 
0215 inline void QComboBox::insertItem(int aindex, const QString &atext,
0216                                   const QVariant &auserData)
0217 { insertItem(aindex, QIcon(), atext, auserData); }
0218 
0219 QT_END_NAMESPACE
0220 
0221 #endif // QCOMBOBOX_H