maxLibQt
TreeComboItemDelegate Class Reference

An item rendering delegate to highlight parent items and draw better item separators. More...

#include "TreeComboBox.h"

Inherits QStyledItemDelegate.

Public Member Functions

 TreeComboItemDelegate (QObject *parent=Q_NULLPTR)
 
- Public Member Functions inherited from QStyledItemDelegate
 QStyledItemDelegate (QObject *parent)
 
virtual ~QStyledItemDelegate ()
 
virtual QWidgetcreateEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
 
virtual QString displayText (const QVariant &value, const QLocale &locale) const const
 
QItemEditorFactoryitemEditorFactory () const const
 
virtual const QMetaObjectmetaObject () const const
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
virtual void * qt_metacast (const char *)
 
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const const override
 
void setItemEditorFactory (QItemEditorFactory *factory)
 
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const const override
 
virtual void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
 
- Public Member Functions inherited from QAbstractItemDelegate
 QAbstractItemDelegate (QObject *parent)
 
virtual ~QAbstractItemDelegate ()
 
void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 
void commitData (QWidget *editor)
 
virtual void destroyEditor (QWidget *editor, const QModelIndex &index) const const
 
virtual bool helpEvent (QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
 
void sizeHintChanged (const QModelIndex &index)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
const QObjectList & children () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static bool isParent (const QModelIndex &index)
 
static bool isSeparator (const QModelIndex &index)
 
static void setParent (QAbstractItemModel *model, const QModelIndex &index, const bool selectable=false)
 
static void setSeparator (QAbstractItemModel *model, const QModelIndex &index)
 
- Static Public Member Functions inherited from QStyledItemDelegate
QString tr (const char *s, const char *c, int n)
 
QString trUtf8 (const char *s, const char *c, int n)
 
- Static Public Member Functions inherited from QAbstractItemDelegate
QString elidedText (const QFontMetrics &fontMetrics, int width, Qt::TextElideMode mode, const QString &text)
 
QString tr (const char *s, const char *c, int n)
 
QString trUtf8 (const char *s, const char *c, int n)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
virtual QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
- Protected Member Functions inherited from QStyledItemDelegate
virtual bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 
virtual bool eventFilter (QObject *editor, QEvent *event) override
 
virtual void initStyleOption (QStyleOptionViewItem *option, const QModelIndex &index) const const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from QAbstractItemDelegate
enum  EndEditHint
 
- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QAbstractItemDelegate
 EditNextItem
 
 EditPreviousItem
 
 NoHint
 
 RevertModelCache
 
 SubmitModelCache
 

Detailed Description

An item rendering delegate to highlight parent items and draw better item separators.

Used by TreeComboBox.

This delegate differs from the default by how it renders separator items and by adding a new formatting style for "parent" items. With this delegate, separators are visible on all platforms. Parent items get bolded and italicisized fonts. Parent items are drawn with enabled style even if they're actually disabled. It also has convenience static functions for flagging/checking a data model item as a separator or parent. The separator type is fully compatible with default QComboBox (it is set the same way).

Definition at line 50 of file TreeComboBox.h.

Constructor & Destructor Documentation

◆ TreeComboItemDelegate()

TreeComboItemDelegate::TreeComboItemDelegate ( QObject parent = Q_NULLPTR)
inlineexplicit

Definition at line 55 of file TreeComboBox.h.

Member Function Documentation

◆ isParent()

bool TreeComboItemDelegate::isParent ( const QModelIndex index)
static

Definition at line 50 of file TreeComboBox.cpp.

◆ isSeparator()

bool TreeComboItemDelegate::isSeparator ( const QModelIndex index)
static

Definition at line 45 of file TreeComboBox.cpp.

◆ paint()

void TreeComboItemDelegate::paint ( QPainter painter,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
overrideprotectedvirtual

Reimplemented from QStyledItemDelegate.

Definition at line 72 of file TreeComboBox.cpp.

◆ setParent()

void TreeComboItemDelegate::setParent ( QAbstractItemModel model,
const QModelIndex index,
const bool  selectable = false 
)
static

Definition at line 63 of file TreeComboBox.cpp.

◆ setSeparator()

void TreeComboItemDelegate::setSeparator ( QAbstractItemModel model,
const QModelIndex index 
)
static

Definition at line 55 of file TreeComboBox.cpp.

◆ sizeHint()

QSize TreeComboItemDelegate::sizeHint ( const QStyleOptionViewItem option,
const QModelIndex index 
) const
overrideprotectedvirtual

Reimplemented from QStyledItemDelegate.

Definition at line 97 of file TreeComboBox.cpp.