From f563c816964ec2cd46dfa5bf47a7d0c21270036b Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Wed, 18 May 2016 15:00:57 +0200
Subject: [PATCH] Cleanup in overlay label widgets

---
 .../Views/FitWidgets/FitParameterWidget.cpp   |  6 ++--
 .../Views/FitWidgets/FitParameterWidget.h     |  4 +--
 ...troller.cpp => OverlayLabelController.cpp} | 31 ++++++++-----------
 ...lController.h => OverlayLabelController.h} | 18 +++++------
 ...LabelWidget.cpp => OverlayLabelWidget.cpp} | 14 ++++-----
 ...InfoLabelWidget.h => OverlayLabelWidget.h} | 14 ++++-----
 6 files changed, 41 insertions(+), 46 deletions(-)
 rename GUI/coregui/Views/InfoWidgets/{InfoLabelController.cpp => OverlayLabelController.cpp} (56%)
 rename GUI/coregui/Views/InfoWidgets/{InfoLabelController.h => OverlayLabelController.h} (69%)
 rename GUI/coregui/Views/InfoWidgets/{InfoLabelWidget.cpp => OverlayLabelWidget.cpp} (77%)
 rename GUI/coregui/Views/InfoWidgets/{InfoLabelWidget.h => OverlayLabelWidget.h} (73%)

diff --git a/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp b/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp
index f0fd298137c..1f1632ac94e 100644
--- a/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp
+++ b/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp
@@ -28,7 +28,7 @@
 #include "FitModelHelper.h"
 #include "SessionModelDelegate.h"
 #include "CustomEventFilters.h"
-#include "InfoLabelController.h"
+#include "OverlayLabelController.h"
 #include <QMenu>
 #include <QSignalMapper>
 #include <QTreeView>
@@ -48,7 +48,7 @@ FitParameterWidget::FitParameterWidget(QWidget *parent)
     , m_fitParameterModel(0)
     , m_delegate(new SessionModelDelegate(this))
     , m_keyboardFilter(new DeleteEventFilter(this))
-    , m_infoLabel(new InfoLabelController(this))
+    , m_infoLabel(new OverlayLabelController(this))
 {
     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(m_treeView);
@@ -67,7 +67,7 @@ FitParameterWidget::FitParameterWidget(QWidget *parent)
             this, SLOT(onFitParameterTreeContextMenu(const QPoint &)));
 
     m_infoLabel->setArea(m_treeView);
-    m_infoLabel->setText(QStringLiteral("Drop sample parameter to fit here"));
+    m_infoLabel->setText(QStringLiteral("Drop parameter to fit here"));
 }
 
 void FitParameterWidget::setItem(JobItem *jobItem)
diff --git a/GUI/coregui/Views/FitWidgets/FitParameterWidget.h b/GUI/coregui/Views/FitWidgets/FitParameterWidget.h
index 065e5705f43..d61d4ddc527 100644
--- a/GUI/coregui/Views/FitWidgets/FitParameterWidget.h
+++ b/GUI/coregui/Views/FitWidgets/FitParameterWidget.h
@@ -35,7 +35,7 @@ class FitParameterLinkItem;
 class QItemSelection;
 class SessionModelDelegate;
 class DeleteEventFilter;
-class InfoLabelController;
+class OverlayLabelController;
 
 //! The FitParametersWidget class contains a tree view to set fit parameters (fix/release,
 //! starting value, min/max bounds). It occupies buttom right corner of JobView.
@@ -96,7 +96,7 @@ private:
     FitParameterAbsModel* m_fitParameterModel;
     SessionModelDelegate *m_delegate;
     DeleteEventFilter *m_keyboardFilter;
-    InfoLabelController *m_infoLabel;
+    OverlayLabelController *m_infoLabel;
 };
 
 #endif
diff --git a/GUI/coregui/Views/InfoWidgets/InfoLabelController.cpp b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp
similarity index 56%
rename from GUI/coregui/Views/InfoWidgets/InfoLabelController.cpp
rename to GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp
index 51f84d7a580..5840ca7f7b9 100644
--- a/GUI/coregui/Views/InfoWidgets/InfoLabelController.cpp
+++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      coregui/Views/InfoWidgets/InfoLabelController.cpp
-//! @brief     Implements class InfoLabelController
+//! @file      coregui/Views/InfoWidgets/OverlayLabelController.cpp
+//! @brief     Implements class OverlayLabelController
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -14,14 +14,14 @@
 //
 // ************************************************************************** //
 
-#include "InfoLabelController.h"
-#include "InfoLabelWidget.h"
+#include "OverlayLabelController.h"
+#include "OverlayLabelWidget.h"
 #include <QAbstractScrollArea>
 #include <QEvent>
 #include <QRect>
 #include <QDebug>
 
-InfoLabelController::InfoLabelController(QObject *parent)
+OverlayLabelController::OverlayLabelController(QObject *parent)
     : QObject(parent)
     , m_label(0)
     , m_area(0)
@@ -29,12 +29,12 @@ InfoLabelController::InfoLabelController(QObject *parent)
 
 }
 
-void InfoLabelController::setText(const QString &text)
+void OverlayLabelController::setText(const QString &text)
 {
     m_text = text;
 }
 
-void InfoLabelController::setArea(QAbstractScrollArea *area)
+void OverlayLabelController::setArea(QAbstractScrollArea *area)
 {
     m_area = area;
     m_area->installEventFilter(this);
@@ -42,14 +42,15 @@ void InfoLabelController::setArea(QAbstractScrollArea *area)
 
 //! Shows/removes a label from the controlled widget
 
-void InfoLabelController::setShown(bool shown)
+void OverlayLabelController::setShown(bool shown)
 {
     if(shown) {
         Q_ASSERT(m_area);
         if(!m_label) {
-            m_label = new InfoLabelWidget(m_area);
+            m_label = new OverlayLabelWidget(m_area);
             m_label->setText(m_text);
             updateLabelGeometry();
+            m_label->show();
         }
 
     } else {
@@ -58,23 +59,17 @@ void InfoLabelController::setShown(bool shown)
     }
 }
 
-bool InfoLabelController::eventFilter(QObject *obj, QEvent *event)
+bool OverlayLabelController::eventFilter(QObject *obj, QEvent *event)
 {
-    if (event->type() == QEvent::Resize) {
-        qDebug() << "InfoLabelController::eventFilter" << m_area->viewport()->width() << m_area->viewport()->height();
-//        widget()->setMaximumWidth(viewport()->width());
-//        setMaximumHeight(height() - viewport()->height() + widget()->height());
+    if (event->type() == QEvent::Resize)
         updateLabelGeometry();
-    }
 
     return QObject::eventFilter(obj, event);
 }
 
-void InfoLabelController::updateLabelGeometry()
+void OverlayLabelController::updateLabelGeometry()
 {
     if(!m_label || !m_area) return;
-    qDebug() << "InfoLabelController::updateLabelGeometry()" << m_area->width() << m_area->height() << m_area << m_text;
     m_label->setRectangle(QRect(0, 0, m_area->width(), m_area->height()));
     m_label->setPosition(0, 0);
-    m_label->show();
 }
diff --git a/GUI/coregui/Views/InfoWidgets/InfoLabelController.h b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h
similarity index 69%
rename from GUI/coregui/Views/InfoWidgets/InfoLabelController.h
rename to GUI/coregui/Views/InfoWidgets/OverlayLabelController.h
index 29f4bf495ed..45676a0eac2 100644
--- a/GUI/coregui/Views/InfoWidgets/InfoLabelController.h
+++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      coregui/Views/InfoWidgets/InfoLabelController.h
-//! @brief     Declares class InfoLabelController
+//! @file      coregui/Views/InfoWidgets/OverlayLabelController.h
+//! @brief     Declares class OverlayLabelController
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -14,24 +14,24 @@
 //
 // ************************************************************************** //
 
-#ifndef INFOLABELCONTROLLER_H
-#define INFOLABELCONTROLLER_H
+#ifndef OVERLAYLABELCONTROLLER_H
+#define OVERLAYLABELCONTROLLER_H
 
 #include "WinDllMacros.h"
 #include <QObject>
 #include <QString>
 
-class InfoLabelWidget;
+class OverlayLabelWidget;
 class QAbstractScrollArea;
 
-//! The InfoLabelController class controlls appearance of InfoLabelWidget (position, show/hide)
+//! The OverlayLabelController class controlls appearance of InfoLabelWidget (position, show/hide)
 //! on top of some scroll area.
 
-class BA_CORE_API_ InfoLabelController : public QObject
+class BA_CORE_API_ OverlayLabelController : public QObject
 {
     Q_OBJECT
 public:
-    InfoLabelController(QObject *parent = 0);
+    OverlayLabelController(QObject *parent = 0);
 
     void setText(const QString &text);
 
@@ -45,7 +45,7 @@ protected:
 private:
     void updateLabelGeometry();
 
-    InfoLabelWidget *m_label;
+    OverlayLabelWidget *m_label;
     QAbstractScrollArea *m_area;
     QString m_text;
 };
diff --git a/GUI/coregui/Views/InfoWidgets/InfoLabelWidget.cpp b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp
similarity index 77%
rename from GUI/coregui/Views/InfoWidgets/InfoLabelWidget.cpp
rename to GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp
index de98c51ffe1..6b32ec893f5 100644
--- a/GUI/coregui/Views/InfoWidgets/InfoLabelWidget.cpp
+++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      coregui/Views/InfoWidgets/InfoLabelWidget.cpp
-//! @brief     Implements class InfoLabelWidget
+//! @file      coregui/Views/InfoWidgets/OverlayLabelWidget.cpp
+//! @brief     Implements class OverlayLabelWidget
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -14,30 +14,30 @@
 //
 // ************************************************************************** //
 
-#include "InfoLabelWidget.h"
+#include "OverlayLabelWidget.h"
 #include "DesignerHelper.h"
 #include <QPainter>
 #include <QColor>
 #include <QFont>
 
-InfoLabelWidget::InfoLabelWidget(QWidget *parent)
+OverlayLabelWidget::OverlayLabelWidget(QWidget *parent)
     : QWidget(parent)
     , m_bounding_rect(QRect(0,0,10,10))
 {
     setAttribute(Qt::WA_TransparentForMouseEvents);
 }
 
-void InfoLabelWidget::setRectangle(const QRect &rect)
+void OverlayLabelWidget::setRectangle(const QRect &rect)
 {
     m_bounding_rect = rect;
 }
 
-void InfoLabelWidget::setPosition(int x, int y)
+void OverlayLabelWidget::setPosition(int x, int y)
 {
     setGeometry(x, y, m_bounding_rect.width(), m_bounding_rect.height());
 }
 
-void InfoLabelWidget::paintEvent(QPaintEvent *event)
+void OverlayLabelWidget::paintEvent(QPaintEvent *event)
 {
     Q_UNUSED(event);
     QPainter painter(this);
diff --git a/GUI/coregui/Views/InfoWidgets/InfoLabelWidget.h b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h
similarity index 73%
rename from GUI/coregui/Views/InfoWidgets/InfoLabelWidget.h
rename to GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h
index 48c689123b9..11dc7169fae 100644
--- a/GUI/coregui/Views/InfoWidgets/InfoLabelWidget.h
+++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      coregui/Views/InfoWidgets/InfoLabelWidget.h
-//! @brief     Declares class InfoLabelWidget
+//! @file      coregui/Views/InfoWidgets/OverlayLabelWidget.h
+//! @brief     Declares class OverlayLabelWidget
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -14,22 +14,22 @@
 //
 // ************************************************************************** //
 
-#ifndef INFOLABELWIDGET_H
-#define INFOLABELWIDGET_H
+#ifndef OVERLAYLABELWIDGET
+#define OVERLAYLABELWIDGET
 
 #include "WinDllMacros.h"
 #include <QWidget>
 #include <QString>
 #include <QRect>
 
-//! The InfoLabelWidget is a semi-transparent overlay label to place on top of other
+//! The OverlayLabelWidget is a semi-transparent overlay label to place on top of other
 //! widgets outside of any layout context.
 
-class BA_CORE_API_ InfoLabelWidget : public QWidget
+class BA_CORE_API_ OverlayLabelWidget : public QWidget
 {
     Q_OBJECT
 public:
-    InfoLabelWidget(QWidget *parent = 0);
+    OverlayLabelWidget(QWidget *parent = 0);
 
     void setRectangle(const QRect &rect);
     void setPosition(int x, int y);
-- 
GitLab