diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp index 7baf45f4a3..cb942082e6 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp @@ -74,6 +74,29 @@ void ElementView::FUNC(){ \ namespace SketcherGui { + +class ElementItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + explicit ElementItemDelegate(ElementView* parent); + ~ElementItemDelegate() override; + + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; + bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override; + + ElementItem* getElementtItem(const QModelIndex& index) const; + + const int border = 1; //1px, looks good around buttons. + const int leftMargin = 4; //4px on the left of icons, looks good. + mutable int customIconsMargin = 4; + const int textBottomMargin = 5; //5px center the text. + +Q_SIGNALS: + void itemHovered(QModelIndex); + void itemChecked(QModelIndex, Qt::CheckState state); +}; + // helper class to store additional information about the listWidget entry. class ElementItem : public QListWidgetItem { @@ -1465,3 +1488,4 @@ void TaskSketcherElements::onSettingsExtendedInformationChanged() } #include "moc_TaskSketcherElements.cpp" +#include "TaskSketcherElements.moc" // For Delegate as it is QOBJECT diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.h b/src/Mod/Sketcher/Gui/TaskSketcherElements.h index 7efa0a7158..ede72efd5a 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.h +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.h @@ -55,27 +55,7 @@ enum class SubElementType { none }; -class ElementItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - explicit ElementItemDelegate(ElementView* parent); - ~ElementItemDelegate() override; - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override; - - ElementItem* getElementtItem(const QModelIndex& index) const; - - const int border = 1; //1px, looks good around buttons. - const int leftMargin = 4; //4px on the left of icons, looks good. - mutable int customIconsMargin = 4; - const int textBottomMargin = 5; //5px center the text. - -Q_SIGNALS: - void itemHovered(QModelIndex); - void itemChecked(QModelIndex, Qt::CheckState state); -}; class ElementView : public QListWidget {