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 | |
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')
-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,10 +1,10 @@ /* - * 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) { @@ -25,6 +25,10 @@ QtElidingLabel::~QtElidingLabel() { } +QSize QtElidingLabel::sizeHint() const { + return sizeHint_; +} + void QtElidingLabel::setSizes() { setMinimumSize(1, minimumHeight()); } @@ -32,6 +36,7 @@ void QtElidingLabel::setSizes() { void QtElidingLabel::setText(const QString& text) { fullText_ = text; QLabel::setText(text); + sizeHint_ = QLabel::sizeHint(); dirty_ = true; } 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,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,6 +17,8 @@ namespace Swift { void setText(const QString& text); virtual ~QtElidingLabel(); + virtual QSize sizeHint() const; + virtual void paintEvent(QPaintEvent* event); private: @@ -24,5 +26,6 @@ namespace Swift { bool dirty_; QString fullText_; QRect lastRect_; + QSize sizeHint_; }; } |