┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/information/metatextlabel.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-06-21 11:23:25 +0000
committerPeter Penz <[email protected]>2009-06-21 11:23:25 +0000
commit2f233f27dac57c22a267a8634be6f6422c3bc685 (patch)
tree01b96bca5a537d78bee40a8aff0c17c65e8441d1 /src/panels/information/metatextlabel.cpp
parent1e208254c5816671be7d7ac4753a8888f53062d9 (diff)
fixed issue the label texts with spaces might overlap with other labels
svn path=/trunk/KDE/kdebase/apps/; revision=984673
Diffstat (limited to 'src/panels/information/metatextlabel.cpp')
-rw-r--r--src/panels/information/metatextlabel.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/panels/information/metatextlabel.cpp b/src/panels/information/metatextlabel.cpp
index baa4d0327..793f72669 100644
--- a/src/panels/information/metatextlabel.cpp
+++ b/src/panels/information/metatextlabel.cpp
@@ -81,8 +81,8 @@ void MetaTextLabel::paintEvent(QPaintEvent* event)
labelColor.setAlpha(128);
int y = 0;
- const int infoWidth = width() / 2;
- const int labelWidth = infoWidth - 2 * Spacing;
+ const int infoWidth = infoTextWidth();
+ const int labelWidth = labelTextWidth();
const int infoX = infoWidth;
const int maxHeight = maxHeightPerLine();
@@ -114,23 +114,29 @@ void MetaTextLabel::resizeEvent(QResizeEvent* event)
setMinimumHeight(minimumHeight);
}
-int MetaTextLabel::requiredHeight(const MetaInfo& metaInfo) const
+int MetaTextLabel::requiredHeight(const MetaInfo& info) const
+{
+ const int labelTextHeight = requiredHeight(info.label, labelTextWidth());
+ const int infoTextHeight = requiredHeight(info.info, infoTextWidth());
+ return qMax(labelTextHeight, infoTextHeight);
+}
+
+int MetaTextLabel::requiredHeight(const QString& text, int width) const
{
QTextOption textOption;
textOption.setWrapMode(QTextOption::WordWrap);
qreal height = 0;
const int leading = fontMetrics().leading();
- const int availableWidth = width() / 2;
- QTextLayout textLayout(metaInfo.info);
+ QTextLayout textLayout(text);
textLayout.setFont(font());
textLayout.setTextOption(textOption);
textLayout.beginLayout();
QTextLine line = textLayout.createLine();
while (line.isValid()) {
- line.setLineWidth(availableWidth);
+ line.setLineWidth(width);
height += leading;
height += line.height();
line = textLayout.createLine();