OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
WScaleLabel Class Reference

Special Label that can shrink and expand in a layout. More...

#include <WScaleLabel.h>

+ Inheritance diagram for WScaleLabel:
+ Collaboration diagram for WScaleLabel:

Public Member Functions

 WScaleLabel (size_t length=WPREFERRED_LABEL_LENGTH, QWidget *parent=NULL)
 Constructor. More...
 
 WScaleLabel (const QString &text, size_t length=WPREFERRED_LABEL_LENGTH, QWidget *parent=NULL)
 Constructor. More...
 
 WScaleLabel (QWidget *parent)
 Constructor. More...
 
 WScaleLabel (const QString &text, QWidget *parent)
 Constructor. More...
 
virtual QSize sizeHint () const
 overwritten from QLabel, returning the widgets prefered size More...
 
virtual QSize minimumSizeHint () const
 overwritten from QLabel, returning the widgets prefered size More...
 
virtual void setText (const QString &text)
 reimplemented function to setText More...
 
virtual void addAdditionalWidth (int margin)
 Set this to reserve extra space for a margin. More...
 
virtual void setMinimalLength (size_t chars)
 How many characters should be visible all the time? More...
 
virtual size_t getMinimalLength () const
 Get the current minimal number of characters. More...
 
virtual size_t calculateSize (size_t chars) const
 Calculate the size that is needed for the given number of chars. More...
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *event)
 custom implementation of the resize event to fit the QString into the labels current size More...
 

Private Member Functions

void construct ()
 Deferred construction. More...
 
void fitTextToSize ()
 set the actual text which is shown on the QLabel More...
 

Private Attributes

QString m_orgText
 QString to remember the original unshortend text of the widget. More...
 
int m_additionalWidth
 The additional width we need to reserver (like for margins). More...
 
size_t m_minLength
 Minimal character number. More...
 

Detailed Description

Special Label that can shrink and expand in a layout.

Definition at line 36 of file WScaleLabel.h.

Constructor & Destructor Documentation

◆ WScaleLabel() [1/4]

WScaleLabel::WScaleLabel ( size_t  length = WPREFERRED_LABEL_LENGTH,
QWidget *  parent = NULL 
)

Constructor.

Parameters
parentthe widgets parent
lengththe minimal number of characters visible.

Definition at line 31 of file WScaleLabel.cpp.

References construct().

+ Here is the call graph for this function:

◆ WScaleLabel() [2/4]

WScaleLabel::WScaleLabel ( const QString &  text,
size_t  length = WPREFERRED_LABEL_LENGTH,
QWidget *  parent = NULL 
)

Constructor.

Creates the label with its original text

Parameters
texttext of the label
parentthe widgets parent
lengththe minimal number of characters visible.

Definition at line 39 of file WScaleLabel.cpp.

References construct().

+ Here is the call graph for this function:

◆ WScaleLabel() [3/4]

WScaleLabel::WScaleLabel ( QWidget *  parent)
explicit

Constructor.

Parameters
parentthe widgets parent

Definition at line 48 of file WScaleLabel.cpp.

References construct().

+ Here is the call graph for this function:

◆ WScaleLabel() [4/4]

WScaleLabel::WScaleLabel ( const QString &  text,
QWidget *  parent 
)

Constructor.

Creates the label with its original text

Parameters
texttext of the label
parentthe widgets parent

Definition at line 56 of file WScaleLabel.cpp.

References construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalWidth()

void WScaleLabel::addAdditionalWidth ( int  margin)
virtual

Set this to reserve extra space for a margin.

This function does not set the margin. This is still your task, using stylesheets. You will not need this when using QLabel::setMargin().

Parameters
marginthe margin to keep in mind for size calculations

Definition at line 106 of file WScaleLabel.cpp.

References m_additionalWidth.

Referenced by WPropertyWidget::WPropertyWidget().

+ Here is the caller graph for this function:

◆ calculateSize()

size_t WScaleLabel::calculateSize ( size_t  chars) const
virtual

Calculate the size that is needed for the given number of chars.

Parameters
charsnumber of chars
Returns
the size in pixels

Definition at line 88 of file WScaleLabel.cpp.

References m_additionalWidth, and m_orgText.

Referenced by minimumSizeHint(), sizeHint(), and WQtDockTitleWidget::updateLayouts().

+ Here is the caller graph for this function:

◆ construct()

void WScaleLabel::construct ( )
private

Deferred construction.

Definition at line 65 of file WScaleLabel.cpp.

References m_additionalWidth, m_minLength, and m_orgText.

Referenced by WScaleLabel().

+ Here is the caller graph for this function:

◆ fitTextToSize()

void WScaleLabel::fitTextToSize ( )
private

set the actual text which is shown on the QLabel

Definition at line 100 of file WScaleLabel.cpp.

References m_orgText.

Referenced by resizeEvent(), and setText().

+ Here is the caller graph for this function:

◆ getMinimalLength()

size_t WScaleLabel::getMinimalLength ( ) const
virtual

Get the current minimal number of characters.

Returns
the number of chars visible all the time

Definition at line 117 of file WScaleLabel.cpp.

References m_minLength.

◆ minimumSizeHint()

QSize WScaleLabel::minimumSizeHint ( ) const
virtual

overwritten from QLabel, returning the widgets prefered size

Returns
minimum size of the label

Definition at line 83 of file WScaleLabel.cpp.

References calculateSize(), and m_minLength.

+ Here is the call graph for this function:

◆ resizeEvent()

void WScaleLabel::resizeEvent ( QResizeEvent *  event)
protectedvirtual

custom implementation of the resize event to fit the QString into the labels current size

Parameters
eventresize event passed from the parent widgets event handling

Definition at line 73 of file WScaleLabel.cpp.

References fitTextToSize().

+ Here is the call graph for this function:

◆ setMinimalLength()

void WScaleLabel::setMinimalLength ( size_t  chars)
virtual

How many characters should be visible all the time?

Parameters
charsthe number of chars

Definition at line 111 of file WScaleLabel.cpp.

References m_minLength, m_orgText, and setText().

+ Here is the call graph for this function:

◆ setText()

void WScaleLabel::setText ( const QString &  text)
virtual

◆ sizeHint()

QSize WScaleLabel::sizeHint ( ) const
virtual

overwritten from QLabel, returning the widgets prefered size

Returns
prefered size of the label

Definition at line 78 of file WScaleLabel.cpp.

References calculateSize(), and m_orgText.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_additionalWidth

int WScaleLabel::m_additionalWidth
private

The additional width we need to reserver (like for margins).

Definition at line 150 of file WScaleLabel.h.

Referenced by addAdditionalWidth(), calculateSize(), construct(), and setText().

◆ m_minLength

size_t WScaleLabel::m_minLength
private

Minimal character number.

Definition at line 155 of file WScaleLabel.h.

Referenced by construct(), getMinimalLength(), minimumSizeHint(), setMinimalLength(), and setText().

◆ m_orgText

QString WScaleLabel::m_orgText
private

QString to remember the original unshortend text of the widget.

Definition at line 145 of file WScaleLabel.h.

Referenced by calculateSize(), construct(), fitTextToSize(), setMinimalLength(), setText(), and sizeHint().


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