diff options
author | Tobias Markmann <tm@ayena.de> | 2016-07-29 20:59:54 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2016-08-09 20:15:12 (GMT) |
commit | 42defb3516a8b7f06c7b0fbc832332a4e60c0f86 (patch) | |
tree | b833bc3cf0166947da16345be511b71dcb04baca /Swift/Controllers/Roster/ContactRosterItem.cpp | |
parent | 3c7b2b3dc884f347771f6e3036779193e7e45627 (diff) | |
download | swift-42defb3516a8b7f06c7b0fbc832332a4e60c0f86.zip swift-42defb3516a8b7f06c7b0fbc832332a4e60c0f86.tar.bz2 |
Enable better date formatting in the UI
This adds the ability to provide more specific date formatting
via the Translator interface. The default translator will use
Boost's formatting capabilities. The QtTranslator use more
localized and better readable formatting.
Test-Information:
Tested with Qt 5.5.1 on OS X 10.11.6. Checked that tooltips
and presence text in new chat views show the new formatting.
Change-Id: I90ff5ab8b31fb41f2dcbea2c40b8846c534c355f
Diffstat (limited to 'Swift/Controllers/Roster/ContactRosterItem.cpp')
-rw-r--r-- | Swift/Controllers/Roster/ContactRosterItem.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index 0ad023a..71c5f8e 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -11,6 +11,7 @@ #include <Swiften/Base/DateTime.h> #include <Swiften/Base/foreach.h> #include <Swiften/Elements/Idle.h> +#include <Swiften/Elements/Presence.h> #include <Swift/Controllers/Intl.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> @@ -34,7 +35,7 @@ StatusShow::Type ContactRosterItem::getSimplifiedStatusShow() const { switch (presence_ ? presence_->getShow() : StatusShow::None) { case StatusShow::Online: return StatusShow::Online; case StatusShow::Away: return StatusShow::Away; - case StatusShow::XA: return StatusShow::Away; + case StatusShow::XA: return StatusShow::Away; case StatusShow::FFC: return StatusShow::Online; case StatusShow::DND: return StatusShow::DND; case StatusShow::None: return StatusShow::None; @@ -48,22 +49,41 @@ std::string ContactRosterItem::getStatusText() const { } std::string ContactRosterItem::getIdleText() const { - Idle::ref idle = presence_ ? presence_->getPayload<Idle>() : Idle::ref(); - if (!idle || idle->getSince().is_not_a_date_time()) { + boost::posix_time::ptime idleTime = getIdle(); + if (idleTime.is_not_a_date_time()) { return ""; } else { - return dateTimeToLocalString(idle->getSince()); + return dateTimeToLocalString(idleTime); + } +} + +boost::posix_time::ptime ContactRosterItem::getIdle() const { + Idle::ref idle = presence_ ? presence_->getPayload<Idle>() : Idle::ref(); + if (idle) { + return idle->getSince(); + } + else { + return boost::posix_time::not_a_date_time; } } std::string ContactRosterItem::getOfflineSinceText() const { + boost::posix_time::ptime offlineSince = getOfflineSince(); + if (!offlineSince.is_not_a_date_time()) { + return dateTimeToLocalString(offlineSince); + } + return ""; +} + +boost::posix_time::ptime ContactRosterItem::getOfflineSince() const { + boost::posix_time::ptime offlineSince = boost::posix_time::not_a_date_time; if (presence_ && presence_->getType() == Presence::Unavailable) { boost::optional<boost::posix_time::ptime> delay = presence_->getTimestamp(); if (delay) { - return dateTimeToLocalString(*delay); + offlineSince = delay.get(); } } - return ""; + return offlineSince; } void ContactRosterItem::setAvatarPath(const boost::filesystem::path& path) { |