diff options
Diffstat (limited to '3rdparty/QtPropertyBrowser/src')
-rw-r--r-- | 3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp | 28 | ||||
-rw-r--r-- | 3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h | 5 |
2 files changed, 31 insertions, 2 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()) diff --git a/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h b/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h index 7bc96b69..194ce627 100644 --- a/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h +++ b/3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h @@ -115,7 +115,7 @@ Q_SIGNALS: void collapsed(QtBrowserItem *item); void expanded(QtBrowserItem *item); - + void hoverPropertyChanged(QtBrowserItem *item); protected: virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem); virtual void itemRemoved(QtBrowserItem *item); @@ -130,7 +130,8 @@ private: Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)) + Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)) + Q_PRIVATE_SLOT(d_func(), void onHoverPropertyChanged(QtBrowserItem *)) }; |