diff options
Diffstat (limited to '3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp')
-rw-r--r-- | 3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp b/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp index 523856eb..bdca7dd5 100644 --- a/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp +++ b/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp @@ -82,6 +82,7 @@ public: void slotCollapsed(const QModelIndex &index); void slotExpanded(const QModelIndex &index); + void onHoverPropertyChanged(QtBrowserItem *item); QColor calculatedBackgroundColor(QtBrowserItem *item) const; @@ -129,12 +130,17 @@ public: { return itemFromIndex(index); } protected: + void mouseMoveEvent(QMouseEvent *event) override; + void leaveEvent(QEvent *event) override; void keyPressEvent(QKeyEvent *event); void mousePressEvent(QMouseEvent *event); void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; +Q_SIGNALS: + void hoverPropertyChanged(QtBrowserItem *item); private: QtTreePropertyBrowserPrivate *m_editorPrivate; + QModelIndex current; }; QtPropertyEditorView::QtPropertyEditorView(QWidget *parent) : @@ -172,6 +178,21 @@ void QtPropertyEditorView::drawRow(QPainter *painter, const QStyleOptionViewItem painter->restore(); } +void QtPropertyEditorView::mouseMoveEvent(QMouseEvent *event) +{ + QModelIndex index = indexAt(event->pos()); + if (index!=current) { + current = index; + Q_EMIT hoverPropertyChanged(m_editorPrivate->indexToBrowserItem(index)); + } + QTreeWidget::mouseMoveEvent(event); +} + +void QtPropertyEditorView::leaveEvent(QEvent *event) +{ + Q_EMIT hoverPropertyChanged(nullptr); +} + void QtPropertyEditorView::keyPressEvent(QKeyEvent *event) { switch (event->key()) { @@ -489,6 +510,7 @@ void QtTreePropertyBrowserPrivate::init(QWidget *parent) QObject::connect(m_treeWidget, SIGNAL(collapsed(const QModelIndex &)), q_ptr, SLOT(slotCollapsed(const QModelIndex &))); QObject::connect(m_treeWidget, SIGNAL(expanded(const QModelIndex &)), q_ptr, SLOT(slotExpanded(const QModelIndex &))); QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), q_ptr, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); + QObject::connect(m_treeWidget, SIGNAL(hoverPropertyChanged(QtBrowserItem *)), q_ptr, SLOT(onHoverPropertyChanged(QtBrowserItem *))); } QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const @@ -688,6 +710,12 @@ void QtTreePropertyBrowserPrivate::slotExpanded(const QModelIndex &index) emit q_ptr->expanded(idx); } +void QtTreePropertyBrowserPrivate::onHoverPropertyChanged(QtBrowserItem *item) +{ + emit q_ptr->hoverPropertyChanged(item); +} + + void QtTreePropertyBrowserPrivate::slotCurrentBrowserItemChanged(QtBrowserItem *item) { if (!m_browserChangedBlocked && item != currentItem()) |