2011-05-31 21:11:46 +02:00
|
|
|
#include "squeezelabelv2.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
SqueezeLabelV2::SqueezeLabelV2(QWidget* parent)
|
2011-03-02 16:57:41 +01:00
|
|
|
: QLabel(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-27 17:52:44 +02:00
|
|
|
SqueezeLabelV2::SqueezeLabelV2(const QString &string)
|
|
|
|
: QLabel()
|
|
|
|
{
|
|
|
|
setText(string);
|
|
|
|
}
|
|
|
|
|
2011-05-31 21:11:46 +02:00
|
|
|
void SqueezeLabelV2::setText(const QString &txt)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-05-25 14:26:36 +02:00
|
|
|
m_originalText = txt;
|
2011-05-25 14:30:43 +02:00
|
|
|
QFontMetrics fm = fontMetrics();
|
|
|
|
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
|
|
|
|
QLabel::setText(elided);
|
2011-05-25 14:26:36 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 21:11:46 +02:00
|
|
|
QString SqueezeLabelV2::originalText()
|
2011-05-25 14:26:36 +02:00
|
|
|
{
|
|
|
|
return m_originalText;
|
|
|
|
}
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
void SqueezeLabelV2::resizeEvent(QResizeEvent* event)
|
2011-05-25 14:26:36 +02:00
|
|
|
{
|
|
|
|
QLabel::resizeEvent(event);
|
|
|
|
QFontMetrics fm = fontMetrics();
|
2011-05-25 14:30:43 +02:00
|
|
|
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
|
2011-05-25 14:26:36 +02:00
|
|
|
QLabel::setText(elided);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|