diff options
author | Tobias Markmann <tm@ayena.de> | 2015-05-30 22:19:05 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2015-05-31 14:58:12 (GMT) |
commit | e36548d66bdcc70e891ff7f84707ee59c5562c64 (patch) | |
tree | e8c6c9ce4d53fae94b4403c8e12467f22de0bdde /Swift/QtUI | |
parent | 4e0bc5d233613732b550146fb11570945f12890c (diff) | |
download | swift-e36548d66bdcc70e891ff7f84707ee59c5562c64.zip swift-e36548d66bdcc70e891ff7f84707ee59c5562c64.tar.bz2 |
Overriding QtElidingLabel::sizeHint() so preferably all text is shown
Test-Information:
Tested on OS X 10.9.5 with Qt 5.4.1.
Change-Id: I8cad307d967be32a9d67dc8408e4a27f487f6032
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtElidingLabel.cpp | 9 | ||||
-rw-r--r-- | Swift/QtUI/QtElidingLabel.h | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Swift/QtUI/QtElidingLabel.cpp b/Swift/QtUI/QtElidingLabel.cpp index 90483f5..f5a39f0 100644 --- a/Swift/QtUI/QtElidingLabel.cpp +++ b/Swift/QtUI/QtElidingLabel.cpp @@ -1,13 +1,13 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "Swift/QtUI/QtElidingLabel.h" +#include <Swift/QtUI/QtElidingLabel.h> namespace Swift { QtElidingLabel::QtElidingLabel(QWidget* parent, Qt::WindowFlags f) : QLabel(parent, f) { fullText_ = ""; dirty_ = true; setSizes(); @@ -22,19 +22,24 @@ QtElidingLabel::QtElidingLabel(const QString& text, QWidget* parent, Qt::WindowF } QtElidingLabel::~QtElidingLabel() { } +QSize QtElidingLabel::sizeHint() const { + return sizeHint_; +} + void QtElidingLabel::setSizes() { setMinimumSize(1, minimumHeight()); } void QtElidingLabel::setText(const QString& text) { fullText_ = text; QLabel::setText(text); + sizeHint_ = QLabel::sizeHint(); dirty_ = true; } void QtElidingLabel::paintEvent(QPaintEvent* event) { QRect rect = contentsRect(); dirty_ = dirty_ || rect != lastRect_; diff --git a/Swift/QtUI/QtElidingLabel.h b/Swift/QtUI/QtElidingLabel.h index 4d0be95..84fa00f 100644 --- a/Swift/QtUI/QtElidingLabel.h +++ b/Swift/QtUI/QtElidingLabel.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once @@ -14,15 +14,18 @@ namespace Swift { public: QtElidingLabel(QWidget* parent = NULL, Qt::WindowFlags f = 0); QtElidingLabel(const QString &text, QWidget* parent = NULL, Qt::WindowFlags f = 0); void setText(const QString& text); virtual ~QtElidingLabel(); + virtual QSize sizeHint() const; + virtual void paintEvent(QPaintEvent* event); private: void setSizes(); bool dirty_; QString fullText_; QRect lastRect_; + QSize sizeHint_; }; } |