summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2013-11-25 10:54:03 (GMT)
committerKevin Smith <git@kismith.co.uk>2013-11-25 10:54:03 (GMT)
commit78df31e45cf9f6c90a82c2a9265b2e3bb509570d (patch)
tree1a6311d09f90e6674533028de6f3c6cd401a7478 /Swift/QtUI/Roster/RosterModel.cpp
parent58da4ae2358b90a9a178ecebf7f33b7e9e0636ee (diff)
downloadswift-78df31e45cf9f6c90a82c2a9265b2e3bb509570d.zip
swift-78df31e45cf9f6c90a82c2a9265b2e3bb509570d.tar.bz2
When in screen-reader mode, change the text used in rosters to include more information.
Change-Id: I8807b2ce6d36dbce510a185f0e4e2c549c623225
Diffstat (limited to 'Swift/QtUI/Roster/RosterModel.cpp')
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index 16c6d7e..a5341fe 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -18,6 +18,7 @@
#include <Swift/Controllers/Roster/ContactRosterItem.h>
#include <Swift/Controllers/Roster/GroupRosterItem.h>
+#include <Swift/Controllers/StatusUtil.h>
#include <Swift/QtUI/Roster/QtTreeWidget.h>
#include <Swift/QtUI/Roster/RosterTooltip.h>
@@ -26,7 +27,7 @@
namespace Swift {
-RosterModel::RosterModel(QtTreeWidget* view) : roster_(NULL), view_(view) {
+RosterModel::RosterModel(QtTreeWidget* view, bool screenReaderMode) : roster_(NULL), view_(view), screenReader_(screenReaderMode) {
const int tooltipAvatarSize = 96; // maximal suggested size according to XEP-0153
cachedImageScaler_ = new QtScaledAvatarCache(tooltipAvatarSize);
}
@@ -92,11 +93,11 @@ QVariant RosterModel::data(const QModelIndex& index, int role) const {
if (!item) return QVariant();
switch (role) {
- case Qt::DisplayRole: return P2QSTRING(item->getDisplayName());
+ case Qt::DisplayRole: return getScreenReaderTextOr(item, P2QSTRING(item->getDisplayName()));
case Qt::TextColorRole: return getTextColor(item);
case Qt::BackgroundColorRole: return getBackgroundColor(item);
case Qt::ToolTipRole: return getToolTip(item);
- case StatusTextRole: return getStatusText(item);
+ case StatusTextRole: return getScreenReaderTextOr(item, getStatusText(item));
case AvatarRole: return getAvatar(item);
case PresenceIconRole: return getPresenceIcon(item);
case ChildCountRole: return getChildCount(item);
@@ -105,6 +106,21 @@ QVariant RosterModel::data(const QModelIndex& index, int role) const {
}
}
+QString RosterModel::getScreenReaderTextOr(RosterItem* item, const QString& alternative) const {
+ QString name = P2QSTRING(item->getDisplayName());
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
+ if (contact && screenReader_) {
+ name += ": " + P2QSTRING(statusShowTypeToFriendlyName(contact->getStatusShow()));
+ if (!contact->getStatusText().empty()) {
+ name += " (" + P2QSTRING(contact->getStatusText()) + ")";
+ }
+ return name;
+ }
+ else {
+ return alternative;
+ }
+}
+
int RosterModel::getChildCount(RosterItem* item) const {
GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
return group ? group->getDisplayedChildren().size() : 0;