[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-i18n-doc
Subject: [parley/KDE/4.13] src/statistics: Calculates the sizes of the rectangles bounding the legend strings
From: Amarvir Singh <amarvir.ammu.93 () gmail ! com>
Date: 2014-03-12 5:32:42
Message-ID: E1WNbmU-0007Yc-C3 () scm ! kde ! org
[Download RAW message or body]
Git commit 1b44adb3947f1032b8d3d49b89742119b3ff8c8a by Amarvir Singh.
Committed on 12/03/2014 at 05:25.
Pushed by amarvirsingh into branch 'KDE/4.13'.
Calculates the sizes of the rectangles bounding the legend strings at \
runtime
BUG: 332028
CCMAIL: kde-i18n-doc@kde.org
M +17 -4 src/statistics/lessonstatistics.cpp
http://commits.kde.org/parley/1b44adb3947f1032b8d3d49b89742119b3ff8c8a
diff --git a/src/statistics/lessonstatistics.cpp \
b/src/statistics/lessonstatistics.cpp index 1fda906..57f665e 100644
--- a/src/statistics/lessonstatistics.cpp
+++ b/src/statistics/lessonstatistics.cpp
@@ -135,10 +135,23 @@ protected:
painter->drawLine(QLine(rect.x() + legendOffsetX + 7 * \
gradeBarWidth, rect.y() + legendOffsetY + 1, rect.x() + legendOffsetX + 7 * \
gradeBarWidth, rect.y() + legendHeight + legendOffsetY - 1)); // Necessary \
hack to get the border on white. painter->setPen(Qt::black);
- const int textBoxWidth = 100;
- const int textBoxHeight = 40;
- painter->drawText(QRect(rect.x() + legendOffsetX - 80, \
rect.y() + legendOffsetY, textBoxWidth, textBoxHeight), Qt::AlignLeft | \
Qt::AlignVCenter, i18nc("adjective, The word has been properly and fully \
learned by the user","Fully learned"));
- painter->drawText(QRect(rect.x() + legendOffsetX + 330, \
rect.y() + legendOffsetY, textBoxWidth, textBoxHeight), Qt::AlignLeft | \
Qt::AlignVCenter, i18nc("adjective, The word has not even been practiced \
once by the user","Not practiced")); + QString leftString = \
i18nc("adjective, The word has been properly and fully learned by the \
user","Fully learned"); + QString rightString = \
i18nc("adjective, The word has not even been practiced once by the \
user","Not practiced"); + const int extraRoomInRectSize = 10;
+ const int horizontalDistanceFromLegend = 10;
+ QFontMetrics fontMetrics(painter->font());
+ // Calculate the size and position of the rectangle that will \
contain the string on the left side of the legend + QRect \
leftRect = fontMetrics.boundingRect(leftString); + \
leftRect.setWidth(leftRect.width() + extraRoomInRectSize); + \
leftRect.setHeight(leftRect.height() + extraRoomInRectSize); + \
leftRect.moveBottomRight(QPoint(rect.x() + legendOffsetX - \
horizontalDistanceFromLegend, rect.y() + legendOffsetY + legendHeight)); + \
// Calculate the size and position of the rectangle that will contain the \
string on the right side of the legend + QRect rightRect = \
fontMetrics.boundingRect(rightString); + \
rightRect.setWidth(rightRect.width() + extraRoomInRectSize); + \
rightRect.setHeight(rightRect.height() + extraRoomInRectSize); + \
rightRect.moveBottomLeft(QPoint(rect.x() + legendOffsetX + legendWidth + \
horizontalDistanceFromLegend, rect.y() + legendOffsetY + legendHeight)); + \
painter->drawText(leftRect, Qt::AlignRight | Qt::AlignVCenter, leftString); \
+ painter->drawText(rightRect, Qt::AlignLeft | Qt::AlignVCenter, \
rightString); }
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic