summaryrefslogtreecommitdiffstats
path: root/sigtools/PluginTypeModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-03-25 02:25:50 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-03-25 02:25:50 -0400
commitf68f7434b47502f2853638e8041a15ef62035879 (patch)
treed7b411b41745a62eb1e9e579d74e913ad77ec77e /sigtools/PluginTypeModel.cpp
parentaad586616b64fae819de93594c83b815071bce2d (diff)
downloadsigen-f68f7434b47502f2853638e8041a15ef62035879.tar.gz
sigen-f68f7434b47502f2853638e8041a15ef62035879.tar.xz
sigen-f68f7434b47502f2853638e8041a15ef62035879.zip
Move the paint and sizeHint down to BaseModel
Diffstat (limited to 'sigtools/PluginTypeModel.cpp')
-rw-r--r--sigtools/PluginTypeModel.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/sigtools/PluginTypeModel.cpp b/sigtools/PluginTypeModel.cpp
index cfb79f5c..102cdcbc 100644
--- a/sigtools/PluginTypeModel.cpp
+++ b/sigtools/PluginTypeModel.cpp
@@ -22,11 +22,14 @@
#include "PluginModel.h"
#include "RootPluginModel.h"
+// KDE includes
+#include <KColorScheme>
+#include <KGlobalSettings>
+
// Qt includes
#include <QtCore/QSize>
#include <QtGui/QFontMetrics>
#include <QtGui/QPainter>
-#include <QtGui/QStyleOptionViewItem>
using namespace Sigtools;
@@ -46,16 +49,6 @@ Qt::ItemFlags PluginTypeModel::flags() const
return Qt::ItemIsEnabled;
}
-void PluginTypeModel::paint(QPainter* painter, const QStyleOptionViewItem& option) const
-{
- painter->drawText(option.rect.adjusted(borderWidth, borderWidth, -borderWidth, -borderWidth), m_type);
-}
-
-QSize PluginTypeModel::sizeHint(const QStyleOptionViewItem& option) const
-{
- return QFontMetrics(option.font).size(0, m_type) + 2 * QSize(borderWidth, borderWidth);
-}
-
BaseModel* PluginTypeModel::childItem(const int row)
{
if ((0 <= row) && (row < m_services.size()))
@@ -72,3 +65,13 @@ int PluginTypeModel::findChild(BaseModel* model) const
{
return m_services.indexOf(qobject_cast<PluginModel*>(model));
}
+
+void PluginTypeModel::redraw(const int width) const
+{
+ QSize typeSize = QFontMetrics(KGlobalSettings::generalFont()).size(0, m_type) + QSize(2 * borderWidth, 2 * borderWidth);
+ m_pixmap = QPixmap(qMax(width, typeSize.width()) + 2 * borderWidth, typeSize.height() + 2 * borderWidth);
+ m_pixmap.fill(KStatefulBrush(KColorScheme::View, KColorScheme::NormalBackground).brush(QPalette::Normal).color());
+ QPainter painter(&m_pixmap);
+
+ painter.drawText(QRect(QPoint(borderWidth, borderWidth), typeSize), m_type);
+}