summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-04 19:43:56 (GMT)
committerSwift Review <review@swift.im>2014-10-16 08:29:29 (GMT)
commit4da9f6d31e4a606da7f0def3a58197096c816e33 (patch)
tree44475e8f4f5bbd5c05520428affc58046c8bdc00 /Swift/QtUI/QtVCardWidget
parent549dc6aa0642d6cf0d5ae2260f4195cb5b212e59 (diff)
downloadswift-4da9f6d31e4a606da7f0def3a58197096c816e33.zip
swift-4da9f6d31e4a606da7f0def3a58197096c816e33.tar.bz2
Fix user experience issues related to blocking list editor.
This commit enables complete keyboard accessibility for editing the block list including list navigation via cursor keys, editing via enter key and deletion via backspace. The placeholder item for adding new items is now non-removable and is indicated as such. The 'Save'-button is disabled during processing of a request. The window is closed on 'Save' if no changes have been made or the changes have been applied successfully. On failure the error message is shown in the window. A description text has been added at the top to tell the user about the use of the dialog. Test-Information: Success cases have been tested by running Swift and do change the blocking list via mouse and keyboard and doing no changes at all. Error cases have been tested using a server adjustment which replys with IQ errors on any blocklist change. Change-Id: I028a9dd15e66ba7363a30b66c5d5a15ba2a5a518
Diffstat (limited to 'Swift/QtUI/QtVCardWidget')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.cpp20
1 files changed, 14 insertions, 6 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
@@ -4,6 +4,12 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * 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>
#include <QEvent>
@@ -15,7 +21,7 @@ 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;
opt.state |= QStyle::State_AutoRaise;
@@ -25,12 +31,14 @@ void QtRemovableItemDelegate::paint(QPainter* painter, const QStyleOptionViewIte
opt.rect = option.rect;
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
- int height = style->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, 0);
- painter->translate(option.rect.x(), option.rect.y() + (option.rect.height() - height)/2);
+ // 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);
+ style->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, painter);
+ }
painter->restore();
}
@@ -39,7 +47,7 @@ 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;
} else {