Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
geometrize::dialog::ElidedLabel Class Reference

The ElidedLabel class is a label that elides text that does not fit within it. More...

#include <elidedlabel.h>

Inheritance diagram for geometrize::dialog::ElidedLabel:
Inheritance graph
[legend]
Collaboration diagram for geometrize::dialog::ElidedLabel:
Collaboration graph
[legend]

Classes

class  ElidedLabelImpl
 

Public Member Functions

 ElidedLabel (QWidget *parent=nullptr, Qt::WindowFlags flags=0)
 
 ElidedLabel (const QString &text, QWidget *parent=nullptr, Qt::WindowFlags flags=0)
 
 ElidedLabel (const QString &text, Qt::TextElideMode elideMode, ElidedLabel::TrimMode trimMode, QWidget *parent=nullptr, Qt::WindowFlags flags=0)
 
virtual ~ElidedLabel ()
 
Qt::TextElideMode getElideMode () const
 getElideMode Get the elide mode currently used when displaying text. More...
 
void setElideMode (Qt::TextElideMode elideMode)
 setElideMode Set the elide mode used when displaying text. More...
 
void setText (const QString &)
 setText overrides QLabel::setText. More...
 

Protected Member Functions

void changeEvent (QEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void resizeEvent (QResizeEvent *) override
 

Private Types

enum  TrimMode { TrimMode::None }
 The TrimMode enum specifies the type of additional trimming done after the label text is elided. More...
 

Private Attributes

std::unique_ptr< ElidedLabelImpld
 

Detailed Description

The ElidedLabel class is a label that elides text that does not fit within it.

Member Enumeration Documentation

The TrimMode enum specifies the type of additional trimming done after the label text is elided.

Enumerator
None 

Does no extra trimming.

51  {
52  None
53  };

Constructor & Destructor Documentation

geometrize::dialog::ElidedLabel::ElidedLabel ( QWidget *  parent = nullptr,
Qt::WindowFlags  flags = 0 
)
explicit
98  :
99  QLabel(parent, flags),
100  d{std::make_unique<ElidedLabel::ElidedLabelImpl>(this)}
101 {
102 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
geometrize::dialog::ElidedLabel::ElidedLabel ( const QString &  text,
QWidget *  parent = nullptr,
Qt::WindowFlags  flags = 0 
)
104  :
105  QLabel(text, parent, flags),
106  d{std::make_unique<ElidedLabel::ElidedLabelImpl>(this)}
107 {
108 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
geometrize::dialog::ElidedLabel::ElidedLabel ( const QString &  text,
Qt::TextElideMode  elideMode,
ElidedLabel::TrimMode  trimMode,
QWidget *  parent = nullptr,
Qt::WindowFlags  flags = 0 
)
110  :
111  QLabel(text, parent, flags),
112  d{std::make_unique<ElidedLabel::ElidedLabelImpl>(this, elideMode, trimMode)}
113 {
114 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
geometrize::dialog::ElidedLabel::~ElidedLabel ( )
virtual
117 {
118 }

Member Function Documentation

void geometrize::dialog::ElidedLabel::changeEvent ( QEvent *  event)
overrideprotected
153 {
154  if (event->type() == QEvent::LanguageChange) {
155  d->onLanguageChange();
156  }
157  QLabel::changeEvent(event);
158 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
Qt::TextElideMode geometrize::dialog::ElidedLabel::getElideMode ( ) const

getElideMode Get the elide mode currently used when displaying text.

Returns
The current elide mode.
121 {
122  return d->getElideMode();
123 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
void geometrize::dialog::ElidedLabel::paintEvent ( QPaintEvent *  e)
overrideprotected
143 {
144  if (d->getElideMode() == Qt::ElideNone) {
145  QLabel::paintEvent(e);
146  } else {
147  QPainter p(this);
148  p.drawText(0, 0, geometry().width(), geometry().height(), alignment(), d->getElidedText(), nullptr);
149  }
150 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
void geometrize::dialog::ElidedLabel::resizeEvent ( QResizeEvent *  e)
overrideprotected
137 {
138  QLabel::resizeEvent(e);
139  d->cacheElidedText(text(), e->size().width());
140 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
void geometrize::dialog::ElidedLabel::setElideMode ( Qt::TextElideMode  elideMode)

setElideMode Set the elide mode used when displaying text.

Parameters
elideModeThe elide mode to set.
126 {
127  d->setElideMode(elideMode);
128 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
void geometrize::dialog::ElidedLabel::setText ( const QString &  text)

setText overrides QLabel::setText.

131 {
132  QLabel::setText(text);
133  d->setText(text);
134 }
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84

Member Data Documentation

std::unique_ptr<ElidedLabelImpl> geometrize::dialog::ElidedLabel::d
private

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