diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-22 14:30:13 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-22 14:30:13 (GMT) |
commit | f2266ded1e36e806b0e4b5a6ab434dd0799bdad5 (patch) | |
tree | ef153ff7f6db2d00a2e03cae57bcb74342404278 /Swift/Controllers/Chat/ChatControllerBase.cpp | |
parent | 161c5d178d6afd18038f9a083f4881bbdb1d590b (diff) | |
download | swift-f2266ded1e36e806b0e4b5a6ab434dd0799bdad5.zip swift-f2266ded1e36e806b0e4b5a6ab434dd0799bdad5.tar.bz2 |
Mark file-transfer notice as read when chat window is activated
Applied some foreach modernization in process.
Test-Information:
Tested by sending files between two Swift instances and
verifying the new behavior works as expected.
Tested on OS X 10.11.4 with Qt 5.4.2.
Change-Id: Ie3f9c2126d946d9041b08be98a19cbfb468871f3
Diffstat (limited to 'Swift/Controllers/Chat/ChatControllerBase.cpp')
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 80f4167..15f6112 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -17,7 +17,6 @@ #include <Swiften/Avatars/AvatarManager.h> #include <Swiften/Base/Path.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Base/format.h> #include <Swiften/Client/StanzaChannel.h> #include <Swiften/Disco/EntityCapsProvider.h> @@ -129,12 +128,11 @@ void ChatControllerBase::setAvailableServerFeatures(std::shared_ptr<DiscoInfo> i void ChatControllerBase::handleAllMessagesRead() { if (!unreadMessages_.empty()) { targetedUnreadMessages_.clear(); - foreach (std::shared_ptr<StanzaEvent> stanzaEvent, unreadMessages_) { + for (std::shared_ptr<StanzaEvent> stanzaEvent : unreadMessages_) { stanzaEvent->conclude(); } unreadMessages_.clear(); - chatWindow_->setUnreadMessageCount(0); - onUnreadCountChanged(); + updateMessageCount(); } } @@ -219,7 +217,7 @@ void ChatControllerBase::handleHighlightActions(const ChatWindow::ChatMessage& c highlighter_->handleHighlightAction(chatMessage.getFullMessageHighlightAction()); playedSounds.insert(chatMessage.getFullMessageHighlightAction().getSoundFile()); } - foreach(std::shared_ptr<ChatWindow::ChatMessagePart> part, chatMessage.getParts()) { + for (std::shared_ptr<ChatWindow::ChatMessagePart> part : chatMessage.getParts()) { std::shared_ptr<ChatWindow::ChatHighlightingMessagePart> highlightMessage = std::dynamic_pointer_cast<ChatWindow::ChatHighlightingMessagePart>(part); if (highlightMessage && highlightMessage->action.playSound()) { if (playedSounds.find(highlightMessage->action.getSoundFile()) == playedSounds.end()) { @@ -230,6 +228,11 @@ void ChatControllerBase::handleHighlightActions(const ChatWindow::ChatMessage& c } } +void ChatControllerBase::updateMessageCount() { + chatWindow_->setUnreadMessageCount(boost::numeric_cast<int>(unreadMessages_.size())); + onUnreadCountChanged(); +} + std::string ChatControllerBase::addMessage(const ChatWindow::ChatMessage& chatMessage, const std::string& senderName, bool senderIsSelf, const std::shared_ptr<SecurityLabel> label, const boost::filesystem::path& avatarPath, const boost::posix_time::ptime& time) { if (chatMessage.isMeCommand()) { return chatWindow_->addAction(chatMessage, senderName, senderIsSelf, label, pathToString(avatarPath), time); @@ -330,8 +333,7 @@ void ChatControllerBase::handleIncomingMessage(std::shared_ptr<MessageEvent> mes logMessage(body, from, selfJID_, timeStamp, true); } chatWindow_->show(); - chatWindow_->setUnreadMessageCount(boost::numeric_cast<int>(unreadMessages_.size())); - onUnreadCountChanged(); + updateMessageCount(); postHandleIncomingMessage(messageEvent, chatMessage); } @@ -377,8 +379,7 @@ std::string ChatControllerBase::getErrorMessage(std::shared_ptr<ErrorPayload> er void ChatControllerBase::handleGeneralMUCInvitation(MUCInviteEvent::ref event) { unreadMessages_.push_back(event); chatWindow_->show(); - chatWindow_->setUnreadMessageCount(boost::numeric_cast<int>(unreadMessages_.size())); - onUnreadCountChanged(); + updateMessageCount(); chatWindow_->addMUCInvitation(senderDisplayNameFromMessage(event->getInviter()), event->getRoomJID(), event->getReason(), event->getPassword(), event->getDirect(), event->getImpromptu()); eventController_->handleIncomingEvent(event); } |