28 #ifndef TREECOMBOBOX_H 29 #define TREECOMBOBOX_H 32 #include <QStyledItemDelegate> 34 #include <QModelIndex> 189 virtual void showPopup() Q_DECL_OVERRIDE;
191 virtual
void hidePopup() Q_DECL_OVERRIDE;
266 #endif // TREECOMBOBOX_H void adjustPopupHeight()
Resize visible popup height when items are expanded/collapsed in the tree view.
An item rendering delegate to highlight parent items and draw better item separators.
QModelIndex indexBelow(QModelIndex index)
Find first valid item index which if after given index.
QAbstractItemModel * model() const const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QModelIndex lastIndex(const QModelIndex &index)
Find last (greatest) valid item index in a set (eg.
QTreeView subclass used to display the combo box popup items.
QModelIndex addParentItem(const QString &text, const bool selectable=false, const QModelIndex &parentIndex=QModelIndex(), const QVariant &userData=QVariant())
int findText(const QString &text, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
void setView(QAbstractItemView *itemView=Q_NULLPTR)
Like QComboBox::setView but only accepts QTreeView (and derived) view classes.
void insertItems(int index, const QStringList &texts)
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
QIcon itemIcon(int index) const
Reimplemented from superclass.
virtual void keyPressEvent(QKeyEvent *event) override
Reimplemented from superclass.
QModelIndex indexAbove(QModelIndex index)
Find first valid item index which if before given index.
static void setParent(QAbstractItemModel *model, const QModelIndex &index, const bool selectable=false)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData=QVariant())
QVariant itemData(int index, int role=Qt::UserRole) const
Reimplemented from superclass.
void insertItem(int index, const QIcon &icon, const QString &text, const QVariant &userData=QVariant())
QModelIndex addItem(const QString &text, const QModelIndex &parentIndex, const QVariant &userData=QVariant())
A QComboBox control which works with a tree-based data model & view, allowing drill-down selection of...
QModelIndex insertItem(int index, const QMap< int, QVariant > &values=QMap< int, QVariant >(), const QModelIndex &parentIndex=QModelIndex(), const bool reload=true)
Insert an item at given index (row), with optional data values, under parent item indicated by parent...
QMap< int, QPersistentModelIndex > m_indexMap
static bool isParent(const QModelIndex &index)
virtual void hidePopup() override
Reimplemented from superclass.
void clear()
Like QComboBox::clear() but does NOT remove any items from the current data model.
virtual int sizeHintForColumn(int column) const const override
virtual bool event(QEvent *event) override
int currentIndex() const
Reimplemented from superclass.
void setItemData(const QModelIndex &index, const QVariant &value, int role=Qt::UserRole)
Sets the data role for the item at index to the specified value.
void keyboardSearchString(const QString &text)
Reimplemented from superclass.
void resizeColumnToContents(int column)
QModelIndex insertParentItem(int index, const QIcon &icon, const QString &text, const bool selectable=false, const QModelIndex &parentIndex=QModelIndex(), const QVariant &userData=QVariant())
Inserts an item and marks is as a "parent" type item.
void insertItems(int index, const QStringList &texts, const QModelIndex &parentIndex)
Inserts multiple items from a list as children of parentIndex.
void addItems(const QStringList &texts, const QModelIndex &parentIndex)
void adjustWidth(int maxWidth)
QModelIndex addParentItem(const QIcon &icon, const QString &text, const bool selectable=false, const QModelIndex &parentIndex=QModelIndex(), const QVariant &userData=QVariant())
static void setSeparator(QAbstractItemModel *model, const QModelIndex &index)
int indentation() const const
void setCurrentText(const QString &text)
TreeComboBox(QWidget *parent=Q_NULLPTR)
QVariant fromValue(const T &value)
QVariant currentData(int role=Qt::UserRole) const
Reimplemented from superclass.
void ensureCurrentExpanded()
Called before showing popup to make sure the initial view size is correct.
bool usePopup(QStyleOptionComboBox *option=NULL)
Return true if style options are set to use a "popup" presentation style (typ.
static bool isSeparator(const QModelIndex &index)
int findData(const QVariant &data, int role=Qt::UserRole, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
Reimplemented from superclass.
virtual void wheelEvent(QWheelEvent *event) override
Reimplemented from superclass.
void setItemIcon(int index, const QIcon &icon)
void addItems(const QStringList &texts)
void adjustPopupWidth()
Make sure tree view has a reasonable width.
void setModel(QAbstractItemModel *model)
Reimplemented from superclass.
QModelIndex addItem(const QIcon &icon, const QString &text, const QModelIndex &parentIndex, const QVariant &userData=QVariant())
void addItem(const QString &text, const QVariant &userData=QVariant())
int buildMap(QModelIndex parent=QModelIndex(), int row=0)
Emitted along with currentIndexChanged() signals and if item has valid Qt::UserRole data.
void currentModelIndexChanged(const QModelIndex &index)
void setItemText(int index, const QString &text)
QMap< QPersistentModelIndex, int > m_rowMap
void setItemData(int index, const QVariant &value, int role=Qt::UserRole)
QString itemText(int index) const
virtual void showPopup() override
Reimplemented from superclass.
int setCurrentData(const QVariant &data, const int defaultIdx=-1, int role=Qt::UserRole, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchExactly|Qt::MatchCaseSensitive))
This is a shortcut to using setCurrentIndex(findData()), and also returns the new index (like findDat...
QPersistentModelIndex m_currentIndex
void setCurrentIndex(int index)
Reimplemented from superclass.
void insertItem(int index, const QString &text, const QVariant &userData=QVariant())
QObject * parent() const const
void setAutoData(bool enable)
QString toString() const const
TreeComboItemDelegate(QObject *parent=Q_NULLPTR)
const T value(const Key &key, const T &defaultValue) const const
void currentDataChanged(const QVariant &data)
virtual bool eventFilter(QObject *object, QEvent *event) override
Reimplemented from superclass.