summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp b/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
index 1cae00a..d50585c 100644
--- a/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp
@@ -5,4 +5,10 @@
*/
+/*
+ * Copyright (c) 2014 Kevin Smith and Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include "QtRemovableItemDelegate.h"
#include <Swiften/Base/Platform.h>
@@ -16,5 +22,5 @@ QtRemovableItemDelegate::QtRemovableItemDelegate(const QStyle* style) : style(st
}
-void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex&) const {
+void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
QStyleOption opt;
opt.state = option.state;
@@ -26,4 +32,5 @@ void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewIte
painter->save();
painter->fillRect(option.rect, option.state & QStyle::State_Selected ? option.palette.highlight() : option.palette.base());
+ if (index.data().toString().isEmpty()) {
#ifdef SWIFTEN_PLATFORM_MACOSX
// workaround for Qt not painting relative to the cell we're in, on OS X
@@ -32,4 +39,5 @@ void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewIte
#endif
style->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, painter);
+ }
painter->restore();
}
@@ -40,5 +48,5 @@ QWidget* QtRemovableItemDelegate::createEditor(QWidget*, const QStyleOptionViewI
bool QtRemovableItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) {
- if (event->type() == QEvent::MouseButtonRelease) {
+ if (index.data().toString().isEmpty() && event->type() == QEvent::MouseButtonRelease) {
model->removeRow(index.row());
return true;