diff options
author | Tobias Markmann <tm@ayena.de> | 2016-11-23 07:09:39 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-11-23 11:30:02 (GMT) |
commit | e405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch) | |
tree | 9118ef838ebfaec1df90ec24761944b5d833774c /Swift/Controllers/UIInterfaces/ChatListWindow.h | |
parent | 8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff) | |
download | swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2 |
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information:
Build on macOS 10.12.1 and all tests pass.
Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Swift/Controllers/UIInterfaces/ChatListWindow.h')
-rw-r--r-- | Swift/Controllers/UIInterfaces/ChatListWindow.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index c84d130..dde596e 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -1,93 +1,91 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <list> #include <map> #include <memory> #include <set> #include <boost/filesystem/path.hpp> #include <boost/signals2.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/StatusShow.h> #include <Swiften/MUC/MUCBookmark.h> namespace Swift { class ChatListWindow { public: class Chat { public: Chat() : statusType(StatusShow::None), isMUC(false), unreadCount(0), isPrivateMessage(false) {} Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, bool isPrivateMessage = false, const std::string& nick = "", const boost::optional<std::string> password = boost::optional<std::string>()) : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), password(password), unreadCount(unreadCount), avatarPath(avatarPath), isPrivateMessage(isPrivateMessage) {} /** Assume that nicks and other transient features aren't important for equality */ bool operator==(const Chat& other) const { if (impromptuJIDs.empty()) { return jid.toBare() == other.jid.toBare() && isMUC == other.isMUC; - } else { /* compare the chat occupant lists */ - typedef std::map<std::string, JID> JIDMap; - foreach (const JIDMap::value_type& jid, impromptuJIDs) { + } + else { /* compare the chat occupant lists */ + for (const auto& jid : impromptuJIDs) { bool found = false; - foreach (const JIDMap::value_type& otherJID, other.impromptuJIDs) { + for (const auto& otherJID : other.impromptuJIDs) { if (jid.second.toBare() == otherJID.second.toBare()) { found = true; break; } } if (!found) { return false; } } return true; } } void setUnreadCount(int unread) { unreadCount = unread; } void setStatusType(StatusShow::Type type) { statusType = type; } void setAvatarPath(const boost::filesystem::path& path) { avatarPath = path; } std::string getImpromptuTitle() const { - typedef std::pair<std::string, JID> StringJIDPair; std::string title; - foreach(StringJIDPair pair, impromptuJIDs) { + for (auto& pair : impromptuJIDs) { if (title.empty()) { title += pair.first; } else { title += ", " + pair.first; } } return title; } JID jid; std::string chatName; std::string activity; StatusShow::Type statusType; bool isMUC; std::string nick; boost::optional<std::string> password; int unreadCount; boost::filesystem::path avatarPath; std::map<std::string, JID> impromptuJIDs; bool isPrivateMessage; }; virtual ~ChatListWindow(); virtual void setBookmarksEnabled(bool enabled) = 0; virtual void addMUCBookmark(const MUCBookmark& bookmark) = 0; virtual void addWhiteboardSession(const ChatListWindow::Chat& chat) = 0; virtual void removeWhiteboardSession(const JID& jid) = 0; virtual void removeMUCBookmark(const MUCBookmark& bookmark) = 0; virtual void setRecents(const std::list<Chat>& recents) = 0; virtual void setUnreadCount(int unread) = 0; virtual void clearBookmarks() = 0; |