BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
OverlayLabelController Class Reference

Description

The OverlayLabelController class controlls appearance of InfoLabelWidget (position, show/hide) on top of some scroll area.

Definition at line 27 of file OverlayLabelController.h.

Inheritance diagram for OverlayLabelController:
[legend]
Collaboration diagram for OverlayLabelController:
[legend]

Public Member Functions

 OverlayLabelController (QObject *parent=nullptr)
 
void setArea (QAbstractScrollArea *area)
 
void setShown (bool shown)
 Shows/removes a label from the controlled widget. More...
 
void setText (const QString &text)
 

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
 

Private Member Functions

void updateLabelGeometry ()
 

Private Attributes

QAbstractScrollArea * m_area
 
OverlayLabelWidgetm_label
 
QString m_text
 

Constructor & Destructor Documentation

◆ OverlayLabelController()

OverlayLabelController::OverlayLabelController ( QObject *  parent = nullptr)

Definition at line 22 of file OverlayLabelController.cpp.

23  : QObject(parent)
24  , m_label(nullptr)
25  , m_area(nullptr)
26 {
27 }
QAbstractScrollArea * m_area
OverlayLabelWidget * m_label

Member Function Documentation

◆ eventFilter()

bool OverlayLabelController::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotected

Definition at line 58 of file OverlayLabelController.cpp.

59 {
60  if (event->type() == QEvent::Resize)
62 
63  return QObject::eventFilter(obj, event);
64 }

References updateLabelGeometry().

Here is the call graph for this function:

◆ setArea()

void OverlayLabelController::setArea ( QAbstractScrollArea *  area)

Definition at line 34 of file OverlayLabelController.cpp.

35 {
36  m_area = area;
37  m_area->installEventFilter(this);
38 }

References m_area.

Referenced by FitParameterWidget::FitParameterWidget().

◆ setShown()

void OverlayLabelController::setShown ( bool  shown)

Shows/removes a label from the controlled widget.

Definition at line 42 of file OverlayLabelController.cpp.

43 {
44  if (shown) {
45  ASSERT(m_area);
46  if (!m_label) {
50  m_label->show();
51  }
52  } else {
53  delete m_label;
54  m_label = nullptr;
55  }
56 }
The OverlayLabelWidget is a semi-transparent overlay label to place on top of other widgets outside o...
void setText(const QString &text)

References m_area, m_label, m_text, OverlayLabelWidget::setText(), and updateLabelGeometry().

Referenced by FitParameterWidget::updateInfoLabel().

Here is the call graph for this function:

◆ setText()

void OverlayLabelController::setText ( const QString &  text)

Definition at line 29 of file OverlayLabelController.cpp.

30 {
31  m_text = text;
32 }

References m_text.

Referenced by FitParameterWidget::FitParameterWidget().

◆ updateLabelGeometry()

void OverlayLabelController::updateLabelGeometry ( )
private

Definition at line 66 of file OverlayLabelController.cpp.

67 {
68  if (!m_label || !m_area)
69  return;
70  m_label->setRectangle(QRect(0, 0, m_area->width(), m_area->height()));
71  m_label->setPosition(0, 0);
72 }
void setRectangle(const QRect &rect)
void setPosition(int x, int y)

References m_area, m_label, OverlayLabelWidget::setPosition(), and OverlayLabelWidget::setRectangle().

Referenced by eventFilter(), and setShown().

Here is the call graph for this function:

Member Data Documentation

◆ m_area

QAbstractScrollArea* OverlayLabelController::m_area
private

Definition at line 45 of file OverlayLabelController.h.

Referenced by setArea(), setShown(), and updateLabelGeometry().

◆ m_label

OverlayLabelWidget* OverlayLabelController::m_label
private

Definition at line 44 of file OverlayLabelController.h.

Referenced by setShown(), and updateLabelGeometry().

◆ m_text

QString OverlayLabelController::m_text
private

Definition at line 46 of file OverlayLabelController.h.

Referenced by setShown(), and setText().


The documentation for this class was generated from the following files: