summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-05-30 22:19:05 (GMT)
committerTobias Markmann <tm@ayena.de>2015-05-31 14:58:12 (GMT)
commite36548d66bdcc70e891ff7f84707ee59c5562c64 (patch)
treee8c6c9ce4d53fae94b4403c8e12467f22de0bdde
parent4e0bc5d233613732b550146fb11570945f12890c (diff)
downloadswift-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
-rw-r--r--Swift/QtUI/QtElidingLabel.cpp9
-rw-r--r--Swift/QtUI/QtElidingLabel.h5
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 @@
1/* 1/*
2 * Copyright (c) 2010 Isode Limited. 2 * Copyright (c) 2010-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
6 6
7#include "Swift/QtUI/QtElidingLabel.h" 7#include <Swift/QtUI/QtElidingLabel.h>
8 8
9namespace Swift { 9namespace Swift {
10QtElidingLabel::QtElidingLabel(QWidget* parent, Qt::WindowFlags f) : QLabel(parent, f) { 10QtElidingLabel::QtElidingLabel(QWidget* parent, Qt::WindowFlags f) : QLabel(parent, f) {
@@ -25,6 +25,10 @@ QtElidingLabel::~QtElidingLabel() {
25 25
26} 26}
27 27
28QSize QtElidingLabel::sizeHint() const {
29 return sizeHint_;
30}
31
28void QtElidingLabel::setSizes() { 32void QtElidingLabel::setSizes() {
29 setMinimumSize(1, minimumHeight()); 33 setMinimumSize(1, minimumHeight());
30} 34}
@@ -32,6 +36,7 @@ void QtElidingLabel::setSizes() {
32void QtElidingLabel::setText(const QString& text) { 36void QtElidingLabel::setText(const QString& text) {
33 fullText_ = text; 37 fullText_ = text;
34 QLabel::setText(text); 38 QLabel::setText(text);
39 sizeHint_ = QLabel::sizeHint();
35 dirty_ = true; 40 dirty_ = true;
36} 41}
37 42
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 @@
1/* 1/*
2 * Copyright (c) 2010 Isode Limited. 2 * Copyright (c) 2010-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -17,6 +17,8 @@ namespace Swift {
17 void setText(const QString& text); 17 void setText(const QString& text);
18 virtual ~QtElidingLabel(); 18 virtual ~QtElidingLabel();
19 19
20 virtual QSize sizeHint() const;
21
20 virtual void paintEvent(QPaintEvent* event); 22 virtual void paintEvent(QPaintEvent* event);
21 23
22 private: 24 private:
@@ -24,5 +26,6 @@ namespace Swift {
24 bool dirty_; 26 bool dirty_;
25 QString fullText_; 27 QString fullText_;
26 QRect lastRect_; 28 QRect lastRect_;
29 QSize sizeHint_;
27 }; 30 };
28} 31}