[qet] qet/qet: [4773] Display the name of the current hovered element of the element collection tree , in the status bar. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4773
Author: blacksun
Date: 2016-11-10 20:49:33 +0100 (Thu, 10 Nov 2016)
Log Message:
-----------
Display the name of the current hovered element of the element collection tree, in the status bar.
Modified Paths:
--------------
trunk/sources/ElementsCollection/elementscollectionwidget.cpp
trunk/sources/ElementsCollection/elementscollectionwidget.h
trunk/sources/qetapp.cpp
trunk/sources/qetapp.h
Modified: trunk/sources/ElementsCollection/elementscollectionwidget.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.cpp 2016-11-09 16:06:04 UTC (rev 4772)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.cpp 2016-11-10 19:49:33 UTC (rev 4773)
@@ -29,6 +29,7 @@
#include "qetproject.h"
#include "qetelementeditor.h"
#include "elementstreeview.h"
+#include "qetdiagrameditor.h"
#include <QVBoxLayout>
#include <QMenu>
@@ -115,6 +116,14 @@
return QWidget::event(event);
}
+void ElementsCollectionWidget::leaveEvent(QEvent *event)
+{
+ if (QETDiagramEditor *qde = QETApp::diagramEditorAncestorOf(this))
+ qde->statusBar()->clearMessage();
+
+ QWidget::leaveEvent(event);
+}
+
void ElementsCollectionWidget::setUpAction()
{
m_open_dir = new QAction(QET::Icons::DocumentOpen, tr("Ouvrir le dossier correspondant"), this);
@@ -190,6 +199,13 @@
connect(m_tree_view, &QTreeView::doubleClicked, [this](const QModelIndex &index) {
this->m_index_at_context_menu = index ;
this->editElement();});
+
+ connect(m_tree_view, &QTreeView::entered, [this] (const QModelIndex &index) {
+ QETDiagramEditor *qde = QETApp::diagramEditorAncestorOf(this);
+ ElementCollectionItem *eci = elementCollectionItemForIndex(index);
+ if (qde && eci)
+ qde->statusBar()->showMessage(eci->localName());
+ });
}
/**
Modified: trunk/sources/ElementsCollection/elementscollectionwidget.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.h 2016-11-09 16:06:04 UTC (rev 4772)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.h 2016-11-10 19:49:33 UTC (rev 4773)
@@ -54,6 +54,7 @@
protected:
virtual bool event(QEvent *event);
+ virtual void leaveEvent(QEvent *event);
private:
void setUpAction();
Modified: trunk/sources/qetapp.cpp
===================================================================
--- trunk/sources/qetapp.cpp 2016-11-09 16:06:04 UTC (rev 4772)
+++ trunk/sources/qetapp.cpp 2016-11-10 19:49:33 UTC (rev 4773)
@@ -609,6 +609,23 @@
return(0);
}
+/**
+ * @brief QETApp::diagramEditorAncestorOf
+ * @param child
+ * @return the parent QETDiagramEditor (or grandparent and so on to any level) of the given child.
+ * If not return nullptr;
+ */
+QETDiagramEditor *QETApp::diagramEditorAncestorOf (const QWidget *child)
+{
+ foreach (QETDiagramEditor *qde, QETApp::diagramEditors()) {
+ if (qde->isAncestorOf(child)) {
+ return qde;
+ }
+ }
+
+ return nullptr;
+}
+
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
/**
Redefinit le chemin du dossier des elements communs
Modified: trunk/sources/qetapp.h
===================================================================
--- trunk/sources/qetapp.h 2016-11-09 16:06:04 UTC (rev 4772)
+++ trunk/sources/qetapp.h 2016-11-10 19:49:33 UTC (rev 4773)
@@ -122,6 +122,7 @@
static QString lang_dir; ///< Directory containing localization files.
static QFont diagramTextsFont(qreal = -1.0);
static QETDiagramEditor *diagramEditorForFile(const QString &);
+ static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
static QList<QETDiagramEditor *> diagramEditors();
static QList<QETElementEditor *> elementEditors();
static QList<QETElementEditor *> elementEditors(QETProject *);