summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-09-18 21:47:37 (GMT)
committerTobias Markmann <tm@ayena.de>2013-10-09 15:56:49 (GMT)
commitc2833f8afa8db40cfebfe51ecf5bb42fd87d8dca (patch)
treeb2a3bf68dfdd4c38879c98824947954bbe9f35d7 /Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
parent1e68d4dffd81e69e2ff740fdf249a696f05e0544 (diff)
downloadswift-c2833f8afa8db40cfebfe51ecf5bb42fd87d8dca.zip
swift-c2833f8afa8db40cfebfe51ecf5bb42fd87d8dca.tar.bz2
VCard UI fixes.
Fix QtRemovableItemDelegate and QtCloseButton rendering on Windows. Fix organization's unit field to allow creation of new units. Fix QtResizableLineEdit's sizeHint to be relative to font metrics. Change-Id: I69809c9504fd4c9e00db3b3782f33dcdd941d0cd License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp b/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
index 90520ad..e7e3175 100644
--- a/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
@@ -5,7 +5,7 @@
*/
#include "QtRemovableItemDelegate.h"
-
+#include <Swiften/Base/Platform.h>
#include <QEvent>
#include <QPainter>
@@ -15,13 +15,21 @@ QtRemovableItemDelegate::QtRemovableItemDelegate(const QStyle* style) : style(st
}
-void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex&) const {
QStyleOption opt;
- opt.state = QStyle::State(0);
- opt.state |= QStyle::State_MouseOver;
+ opt.state = option.state;
+ opt.state |= QStyle::State_AutoRaise;
+ if (option.state.testFlag(QStyle::State_MouseOver)) {
+ opt.state |= QStyle::State_Raised;
+ }
+ opt.rect = option.rect;
painter->save();
- drawBackground(painter, option, index);
- painter->translate(option.rect.x(), option.rect.y()+(option.rect.height() - 12)/2);
+ painter->fillRect(option.rect, option.state & QStyle::State_Selected ? option.palette.highlight() : option.palette.base());
+#ifdef SWIFTEN_PLATFORM_MACOSX
+ // workaround for Qt not painting relative to the cell we're in, on OS X
+ int height = style->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, 0);
+ painter->translate(option.rect.x(), option.rect.y() + (option.rect.height() - height)/2);
+#endif
style->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, painter);
painter->restore();
}
@@ -39,4 +47,9 @@ bool QtRemovableItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* mod
}
}
+QSize QtRemovableItemDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const {
+ QSize size(style->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, 0), style->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, 0));
+ return size;
+}
+
}