summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/AdHocManager.cpp5
-rw-r--r--Swift/Controllers/AdHocManager.h5
-rw-r--r--Swift/Controllers/BlockListController.cpp9
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp32
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp14
-rw-r--r--Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp10
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp16
-rw-r--r--Swift/Controllers/ChatMessageSummarizer.cpp3
-rw-r--r--Swift/Controllers/ContactSuggester.cpp3
-rw-r--r--Swift/Controllers/ContactsFromXMPPRoster.cpp3
-rw-r--r--Swift/Controllers/FileTransfer/FileTransferOverview.cpp5
-rw-r--r--Swift/Controllers/HighlightManager.cpp2
-rw-r--r--Swift/Controllers/HighlightRule.cpp11
-rw-r--r--Swift/Controllers/Highlighter.cpp2
-rw-r--r--Swift/Controllers/HistoryViewController.cpp21
-rw-r--r--Swift/Controllers/PreviousStatusStore.cpp4
-rw-r--r--Swift/Controllers/PreviousStatusStore.h1
-rw-r--r--Swift/Controllers/ProfileSettingsProvider.cpp4
-rw-r--r--Swift/Controllers/ProfileSettingsProvider.h10
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.cpp1
-rw-r--r--Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp3
-rw-r--r--Swift/Controllers/Roster/TableRoster.cpp5
-rw-r--r--Swift/Controllers/Settings/SettingsProviderHierachy.cpp14
-rw-r--r--Swift/Controllers/ShowProfileController.cpp4
-rw-r--r--Swift/Controllers/Storages/AvatarFileStorage.cpp1
-rw-r--r--Swift/Controllers/Storages/CertificateMemoryStorage.cpp6
-rw-r--r--Swift/Controllers/Storages/VCardFileStorage.cpp1
-rw-r--r--Swift/Controllers/UIInterfaces/ChatListWindow.h12
-rw-r--r--Swift/Controllers/UnitTest/ContactSuggesterTest.cpp22
-rw-r--r--Swift/Controllers/WhiteboardManager.cpp5
-rw-r--r--Swift/Controllers/XMPPEvents/EventController.cpp6
-rw-r--r--Swift/QtUI/ChatList/ChatListGroupItem.h5
-rw-r--r--Swift/QtUI/ChatList/ChatListModel.cpp5
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp2
-rw-r--r--Swift/QtUI/ChatSnippet.cpp2
-rw-r--r--Swift/QtUI/ChatSnippet.h2
-rw-r--r--Swift/QtUI/CocoaUIHelpers.mm6
-rw-r--r--Swift/QtUI/EventViewer/EventModel.cpp4
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.cpp4
-rw-r--r--Swift/QtUI/QtAffiliationEditor.cpp2
-rw-r--r--Swift/QtUI/QtBlockListEditorWindow.cpp3
-rw-r--r--Swift/QtUI/QtCertificateViewerDialog.cpp8
-rw-r--r--Swift/QtUI/QtChatTabs.cpp2
-rw-r--r--Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp3
-rw-r--r--Swift/QtUI/QtChatWindow.cpp5
-rw-r--r--Swift/QtUI/QtContactEditWidget.cpp12
-rw-r--r--Swift/QtUI/QtContactEditWidget.h4
-rw-r--r--Swift/QtUI/QtEmoticonsGrid.cpp10
-rw-r--r--Swift/QtUI/QtFormResultItemModel.cpp4
-rw-r--r--Swift/QtUI/QtFormWidget.cpp16
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp2
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp2
-rw-r--r--Swift/QtUI/QtPlainChatView.cpp3
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp2
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp4
-rw-r--r--Swift/QtUI/QtSingleWindow.cpp6
-rw-r--r--Swift/QtUI/QtSpellCheckHighlighter.cpp4
-rw-r--r--Swift/QtUI/QtStatusWidget.cpp8
-rw-r--r--Swift/QtUI/QtSubscriptionRequestWindow.cpp2
-rw-r--r--Swift/QtUI/QtTabbable.cpp1
-rw-r--r--Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp6
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp4
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp2
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp4
-rw-r--r--Swift/QtUI/QtWebKitChatView.cpp2
-rw-r--r--Swift/QtUI/Roster/QtFilterWidget.cpp4
-rw-r--r--Swift/QtUI/Roster/QtOccupantListWidget.cpp2
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp2
-rw-r--r--Swift/QtUI/Roster/RosterTooltip.cpp8
-rw-r--r--Swift/QtUI/UserSearch/ContactListModel.cpp1
-rw-r--r--Swift/QtUI/UserSearch/QtContactListWidget.cpp4
-rw-r--r--Swift/QtUI/WinUIHelpers.cpp2
72 files changed, 180 insertions, 234 deletions
diff --git a/Swift/Controllers/AdHocManager.cpp b/Swift/Controllers/AdHocManager.cpp
index 81f80e2..717f083 100644
--- a/Swift/Controllers/AdHocManager.cpp
+++ b/Swift/Controllers/AdHocManager.cpp
@@ -11,7 +11,6 @@
#include <boost/bind.hpp>
#include <Swiften/AdHoc/OutgoingAdHocCommandSession.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swift/Controllers/UIEvents/RequestAdHocUIEvent.h>
@@ -58,7 +57,7 @@ void AdHocManager::setServerDiscoInfo(std::shared_ptr<DiscoInfo> info) {
}
void AdHocManager::setOnline(bool online) {
- foreach (std::shared_ptr<AdHocController> controller, controllers_) {
+ for (auto&& controller : controllers_) {
controller->setOnline(online);
}
}
@@ -66,7 +65,7 @@ void AdHocManager::setOnline(bool online) {
void AdHocManager::handleServerDiscoItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error) {
std::vector<DiscoItems::Item> commands;
if (!error) {
- foreach (DiscoItems::Item item, items->getItems()) {
+ for (const auto& item : items->getItems()) {
if (item.getNode() != "http://isode.com/xmpp/commands#test") {
commands.push_back(item);
}
diff --git a/Swift/Controllers/AdHocManager.h b/Swift/Controllers/AdHocManager.h
index 20e5db7..0786370 100644
--- a/Swift/Controllers/AdHocManager.h
+++ b/Swift/Controllers/AdHocManager.h
@@ -10,7 +10,6 @@
#include <boost/signals2.hpp>
-#include <Swiften/Client/Client.h>
#include <Swiften/Disco/GetDiscoItemsRequest.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/DiscoItems.h>
@@ -25,6 +24,7 @@ class IQRouter;
class MainWindow;
class UIEventStream;
class AdHocCommandWindowFactory;
+
class AdHocManager {
public:
AdHocManager(const JID& jid, AdHocCommandWindowFactory* factory, IQRouter* iqRouter, UIEventStream* uiEventStream, MainWindow* mainWindow);
@@ -32,10 +32,13 @@ public:
void removeController(std::shared_ptr<AdHocController> contoller);
void setServerDiscoInfo(std::shared_ptr<DiscoInfo> info);
void setOnline(bool online);
+
private:
void handleServerDiscoItemsResponse(std::shared_ptr<DiscoItems>, ErrorPayload::ref error);
void handleUIEvent(std::shared_ptr<UIEvent> event);
boost::signals2::signal<void (const AdHocController&)> onControllerComplete;
+
+private:
JID jid_;
IQRouter* iqRouter_;
UIEventStream* uiEventStream_;
diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp
index 560a3f3..37c536b 100644
--- a/Swift/Controllers/BlockListController.cpp
+++ b/Swift/Controllers/BlockListController.cpp
@@ -14,7 +14,6 @@
#include <boost/bind.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/format.h>
#include <Swiften/Client/ClientBlockListManager.h>
@@ -40,13 +39,13 @@ BlockListController::~BlockListController() {
}
void BlockListController::blockListDifferences(const std::vector<JID> &newBlockList, std::vector<JID> &jidsToUnblock, std::vector<JID> &jidsToBlock) const {
- foreach (const JID& jid, blockListBeforeEdit) {
+ for (const auto& jid : blockListBeforeEdit) {
if (std::find(newBlockList.begin(), newBlockList.end(), jid) == newBlockList.end()) {
jidsToUnblock.push_back(jid);
}
}
- foreach (const JID& jid, newBlockList) {
+ for (const auto& jid : newBlockList) {
if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) {
jidsToBlock.push_back(jid);
}
@@ -169,13 +168,13 @@ void BlockListController::handleBlockListChanged() {
blockListDifferences(blockListEditorWidget_->getCurrentBlockList(), jidsToUnblock, jidsToBlock);
blockListBeforeEdit = blockListManager_->getBlockList()->getItems();
- foreach (const JID& jid, jidsToBlock) {
+ for (const auto& jid : jidsToBlock) {
if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) {
blockListBeforeEdit.push_back(jid);
}
}
- foreach (const JID& jid, jidsToUnblock) {
+ for (const auto& jid : jidsToUnblock) {
blockListBeforeEdit.erase(std::remove(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid), blockListBeforeEdit.end());
}
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 9ae3845..349bf8a 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -11,10 +11,10 @@
#include <boost/bind.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include <Swiften/Avatars/AvatarManager.h>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/format.h>
#include <Swiften/Base/Tristate.h>
#include <Swiften/Client/BlockList.h>
@@ -238,7 +238,7 @@ void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction a
void MUCController::handleBareJIDCapsChanged(const JID& /*jid*/) {
Tristate support = Yes;
bool any = false;
- foreach (const std::string& nick, currentOccupants_) {
+ for (const auto& nick : currentOccupants_) {
DiscoInfo::ref disco = entityCapsProvider_->getCaps(toJID_.toBare().toString() + "/" + nick);
if (disco && disco->hasFeature(DiscoInfo::MessageCorrectionFeature)) {
any = true;
@@ -295,9 +295,8 @@ bool MUCController::isImpromptu() const {
std::map<std::string, JID> MUCController::getParticipantJIDs() const {
std::map<std::string, JID> participants;
- typedef std::pair<std::string, MUCOccupant> MUCOccupantPair;
std::map<std::string, MUCOccupant> occupants = muc_->getOccupants();
- foreach(const MUCOccupantPair& occupant, occupants) {
+ for (const auto& occupant : occupants) {
if (occupant.first != nick_) {
participants[occupant.first] = occupant.second.getRealJID().is_initialized() ? occupant.second.getRealJID().get().toBare() : JID();
}
@@ -306,7 +305,7 @@ std::map<std::string, JID> MUCController::getParticipantJIDs() const {
}
void MUCController::sendInvites(const std::vector<JID>& jids, const std::string& reason) const {
- foreach (const JID& jid, jids) {
+ for (const auto& jid : jids) {
muc_->invitePerson(jid, reason, isImpromptu_);
}
}
@@ -859,7 +858,7 @@ std::string MUCController::concatenateListOfNames(const std::vector<NickJoinPart
std::string MUCController::generateJoinPartString(const std::vector<NickJoinPart>& joinParts, bool isImpromptu) {
std::vector<NickJoinPart> sorted[4];
std::string eventStrings[4];
- foreach (NickJoinPart event, joinParts) {
+ for (const auto& event : joinParts) {
sorted[event.type].push_back(event);
}
std::string result;
@@ -937,7 +936,7 @@ void MUCController::handleBookmarkRequest() {
// Check for existing bookmark for this room and, if it exists, use it instead.
std::vector<MUCBookmark> bookmarks = mucBookmarkManager_->getBookmarks();
- foreach (const MUCBookmark& bookmark, bookmarks) {
+ for (const auto& bookmark : bookmarks) {
if (bookmark.getRoom() == jid.toBare()) {
roomBookmark = bookmark;
break;
@@ -1001,7 +1000,7 @@ void MUCController::handleInvitePersonToThisMUCRequest(const std::vector<JID>& j
void MUCController::handleUIEvent(std::shared_ptr<UIEvent> event) {
std::shared_ptr<InviteToMUCUIEvent> inviteEvent = std::dynamic_pointer_cast<InviteToMUCUIEvent>(event);
if (inviteEvent && inviteEvent->getRoom() == muc_->getJID()) {
- foreach (const JID& jid, inviteEvent->getInvites()) {
+ for (const auto& jid : inviteEvent->getInvites()) {
muc_->invitePerson(jid, inviteEvent->getReason(), isImpromptu_);
}
}
@@ -1014,16 +1013,14 @@ void MUCController::handleGetAffiliationsRequest() {
muc_->requestAffiliationList(MUCOccupant::Outcast);
}
-typedef std::pair<MUCOccupant::Affiliation, JID> AffiliationChangePair;
-
void MUCController::handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes) {
std::set<JID> addedJIDs;
- foreach (const AffiliationChangePair& change, changes) {
+ for (const auto& change : changes) {
if (change.first != MUCOccupant::NoAffiliation) {
addedJIDs.insert(change.second);
}
}
- foreach (const AffiliationChangePair& change, changes) {
+ for (const auto& change : changes) {
if (change.first != MUCOccupant::NoAffiliation || addedJIDs.find(change.second) == addedJIDs.end()) {
muc_->changeAffiliation(change.second, change.first);
}
@@ -1070,7 +1067,7 @@ void MUCController::addRecentLogs() {
joinContext_ = historyController_->getMUCContext(selfJID_, toJID_, lastActivity_);
- foreach (const HistoryMessage& message, joinContext_) {
+ for (const auto& message : joinContext_) {
bool senderIsSelf = nick_ == message.getFromJID().getResource();
// the chatWindow uses utc timestamps
@@ -1083,7 +1080,7 @@ void MUCController::checkDuplicates(std::shared_ptr<Message> newMessage) {
JID jid = newMessage->getFrom();
boost::optional<boost::posix_time::ptime> time = newMessage->getTimestamp();
- reverse_foreach (const HistoryMessage& message, joinContext_) {
+ for (const auto& message : boost::adaptors::reverse(joinContext_)) {
boost::posix_time::ptime messageTime = message.getTime() - boost::posix_time::hours(message.getOffset());
if (time && time < messageTime) {
break;
@@ -1112,7 +1109,7 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura
Form::ref result = std::make_shared<Form>(Form::SubmitType);
std::string impromptuConfigs[] = { "muc#roomconfig_enablelogging", "muc#roomconfig_persistentroom", "muc#roomconfig_publicroom", "muc#roomconfig_whois"};
std::set<std::string> impromptuConfigsMissing(impromptuConfigs, impromptuConfigs + 4);
- foreach (std::shared_ptr<FormField> field, roomConfigurationForm->getFields()) {
+ for (const auto& field : roomConfigurationForm->getFields()) {
std::shared_ptr<FormField> resultField;
if (field->getName() == "muc#roomconfig_enablelogging") {
resultField = std::make_shared<FormField>(FormField::BooleanType, "0");
@@ -1138,7 +1135,7 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura
}
}
- foreach (const std::string& config, impromptuConfigsMissing) {
+ for (const auto& config : impromptuConfigsMissing) {
if (config == "muc#roomconfig_publicroom") {
chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(QT_TRANSLATE_NOOP("", "This server doesn't support hiding your chat from other users.")), ChatWindow::DefaultDirection);
} else if (config == "muc#roomconfig_whois") {
@@ -1151,12 +1148,11 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura
void MUCController::setImpromptuWindowTitle() {
std::string title;
- typedef std::pair<std::string, MUCOccupant> StringMUCOccupantPair;
std::map<std::string, MUCOccupant> occupants = muc_->getOccupants();
if (occupants.size() <= 1) {
title = QT_TRANSLATE_NOOP("", "Empty Chat");
} else {
- foreach (StringMUCOccupantPair pair, occupants) {
+ for (const auto& pair : occupants) {
if (pair.first != nick_) {
title += (title.empty() ? "" : ", ") + pair.first;
}
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index 31c9be9..a5e68cf 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -89,7 +89,7 @@ class ChatsManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testChatControllerHighlightingNotificationTesting);
CPPUNIT_TEST(testChatControllerHighlightingNotificationDeduplicateSounds);
CPPUNIT_TEST(testChatControllerMeMessageHandling);
- CPPUNIT_TEST(testRestartingMUCComponentCrash);
+ CPPUNIT_TEST(testRestartingMUCComponentCrash);
CPPUNIT_TEST(testChatControllerMeMessageHandlingInMUC);
// Carbons tests
@@ -455,7 +455,7 @@ public:
uiEventStream_->send(std::make_shared<RequestChatUIEvent>(sender));
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
// The sender supports delivery receipts.
DiscoInfo::ref disco = std::make_shared<DiscoInfo>();
disco->addFeature(DiscoInfo::MessageDeliveryReceiptsFeature);
@@ -478,7 +478,7 @@ public:
CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex<Message>(1)->getPayload<DeliveryReceiptRequest>());
// Two resources respond with message receipts.
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
Message::ref receiptReply = std::make_shared<Message>();
receiptReply->setFrom(senderJID);
receiptReply->setTo(ownJID);
@@ -497,7 +497,7 @@ public:
CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex<Message>(1)->getPayload<DeliveryReceiptRequest>());
// Two resources respond with message receipts.
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
Message::ref receiptReply = std::make_shared<Message>();
receiptReply->setFrom(senderJID);
receiptReply->setTo(ownJID);
@@ -570,7 +570,7 @@ public:
uiEventStream_->send(std::make_shared<RequestChatUIEvent>(sender));
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
// The sender supports delivery receipts.
DiscoInfo::ref disco = std::make_shared<DiscoInfo>();
disco->addFeature(DiscoInfo::MessageDeliveryReceiptsFeature);
@@ -593,7 +593,7 @@ public:
CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex<Message>(1)->getPayload<DeliveryReceiptRequest>());
// Two resources respond with message receipts.
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
Message::ref reply = std::make_shared<Message>();
reply->setFrom(senderJID);
reply->setTo(ownJID);
@@ -612,7 +612,7 @@ public:
CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex<Message>(1)->getPayload<DeliveryReceiptRequest>());
// Two resources respond with message receipts.
- foreach(const JID& senderJID, senderResource) {
+ for (const auto& senderJID : senderResource) {
Message::ref receiptReply = std::make_shared<Message>();
receiptReply->setFrom(senderJID);
receiptReply->setTo(ownJID);
diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
index 1142c98..32639f6 100644
--- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
@@ -11,7 +11,6 @@
#include <hippomocks.h>
#include <Swiften/Avatars/NullAvatarManager.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Client/ClientBlockListManager.h>
#include <Swiften/Client/DummyStanzaChannel.h>
#include <Swiften/Client/NickResolver.h>
@@ -371,8 +370,7 @@ public:
occupants.insert(occupant_map::value_type("Ernie", MUCOccupant("Ernie", MUCOccupant::Participant, MUCOccupant::Owner)));
/* populate the MUC with fake users */
- typedef const std::pair<std::string,MUCOccupant> occupantIterator;
- foreach(occupantIterator &occupant, occupants) {
+ for (auto&& occupant : occupants) {
muc_->insertOccupant(occupant.second);
}
@@ -387,7 +385,7 @@ public:
alterations.push_back(MUCOccupant("Remko", MUCOccupant::NoRole, MUCOccupant::NoAffiliation));
alterations.push_back(MUCOccupant("Ernie", MUCOccupant::Visitor, MUCOccupant::Outcast));
- foreach(const MUCOccupant& alteration, alterations) {
+ for (const auto& alteration : alterations) {
/* perform an alteration to a user's role and affiliation */
occupant_map::iterator occupant = occupants.find(alteration.getNick());
CPPUNIT_ASSERT(occupant != occupants.end());
@@ -506,10 +504,10 @@ public:
void testRoleAffiliationStatesVerify(const std::map<std::string, MUCOccupant> &occupants) {
/* verify that the roster is in sync */
GroupRosterItem* group = window_->getRosterModel()->getRoot();
- foreach(RosterItem* rosterItem, group->getChildren()) {
+ for (auto rosterItem : group->getChildren()) {
GroupRosterItem* child = dynamic_cast<GroupRosterItem*>(rosterItem);
CPPUNIT_ASSERT(child);
- foreach(RosterItem* childItem, child->getChildren()) {
+ for (auto childItem : child->getChildren()) {
ContactRosterItem* item = dynamic_cast<ContactRosterItem*>(childItem);
CPPUNIT_ASSERT(item);
std::map<std::string, MUCOccupant>::const_iterator occupant = occupants.find(item->getJID().getResource());
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp
index 305049f..91e0dea 100644
--- a/Swift/Controllers/Chat/UserSearchController.cpp
+++ b/Swift/Controllers/Chat/UserSearchController.cpp
@@ -12,7 +12,6 @@
#include <Swiften/Avatars/AvatarManager.h>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Disco/DiscoServiceWalker.h>
#include <Swiften/Disco/GetDiscoInfoRequest.h>
#include <Swiften/Disco/GetDiscoItemsRequest.h>
@@ -143,7 +142,8 @@ void UserSearchController::endDiscoWalker() {
void UserSearchController::handleDiscoServiceFound(const JID& jid, std::shared_ptr<DiscoInfo> info) {
//bool isUserDirectory = false;
bool supports55 = false;
- foreach (DiscoInfo::Identity identity, info->getIdentities()) {
+ // TODO: Cleanup code
+ for (const auto& identity : info->getIdentities()) {
if ((identity.getCategory() == "directory"
&& identity.getType() == "user")) {
//isUserDirectory = true;
@@ -186,7 +186,7 @@ void UserSearchController::handleSearchResponse(std::shared_ptr<SearchPayload> r
if (resultsPayload->getForm()) {
window_->setResultsForm(resultsPayload->getForm());
} else {
- foreach (SearchPayload::Item item, resultsPayload->getItems()) {
+ for (auto&& item : resultsPayload->getItems()) {
JID jid(item.jid);
std::map<std::string, std::string> fields;
fields["first"] = item.first;
@@ -232,7 +232,7 @@ void UserSearchController::handleContactSuggestionsRequested(std::string text) {
std::vector<Contact::ref>::iterator i = suggestions.begin();
while (i != suggestions.end()) {
bool found = false;
- foreach (const JID& jid, existingJIDs) {
+ for (const auto& jid : existingJIDs) {
if ((*i)->jid == jid) {
found = true;
break;
@@ -274,7 +274,7 @@ void UserSearchController::handlePresenceChanged(Presence::ref presence) {
void UserSearchController::handleJIDUpdateRequested(const std::vector<JID>& jids) {
if (window_) {
std::vector<Contact::ref> updates;
- foreach(const JID& jid, jids) {
+ for (const auto& jid : jids) {
updates.push_back(convertJIDtoContact(jid));
}
window_->updateContacts(updates);
@@ -283,7 +283,7 @@ void UserSearchController::handleJIDUpdateRequested(const std::vector<JID>& jids
void UserSearchController::handleJIDAddRequested(const std::vector<JID>& jids) {
std::vector<Contact::ref> contacts;
- foreach(const JID& jid, jids) {
+ for (const auto& jid : jids) {
contacts.push_back(convertJIDtoContact(jid));
}
window_->addContacts(contacts);
@@ -358,7 +358,7 @@ void UserSearchController::initializeUserWindow() {
void UserSearchController::loadSavedDirectories() {
savedDirectories_.clear();
- foreach (std::string stringItem, String::split(settings_->getStringSetting(SEARCHED_DIRECTORIES), '\n')) {
+ for (auto&& stringItem : String::split(settings_->getStringSetting(SEARCHED_DIRECTORIES), '\n')) {
if(!stringItem.empty()) {
savedDirectories_.push_back(JID(stringItem));
}
@@ -375,7 +375,7 @@ void UserSearchController::addToSavedDirectories(const JID& jid) {
std::string collapsed;
int i = 0;
- foreach (JID jidItem, savedDirectories_) {
+ for (const auto& jidItem : savedDirectories_) {
if (i >= 15) {
break;
}
diff --git a/Swift/Controllers/ChatMessageSummarizer.cpp b/Swift/Controllers/ChatMessageSummarizer.cpp
index 6b630e7..ac3d896 100644
--- a/Swift/Controllers/ChatMessageSummarizer.cpp
+++ b/Swift/Controllers/ChatMessageSummarizer.cpp
@@ -6,7 +6,6 @@
#include <Swift/Controllers/ChatMessageSummarizer.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/format.h>
#include <Swift/Controllers/Intl.h>
@@ -18,7 +17,7 @@ string ChatMessageSummarizer::getSummary(const string& current, const vector<Unr
vector<UnreadPair> others;
int currentUnread = 0;
int otherCount = 0;
- foreach (UnreadPair unread, unreads) {
+ for (const auto& unread : unreads) {
if (unread.first == current) {
currentUnread += unread.second;
} else {
diff --git a/Swift/Controllers/ContactSuggester.cpp b/Swift/Controllers/ContactSuggester.cpp
index 8a3a6fa..eb27ed4 100644
--- a/Swift/Controllers/ContactSuggester.cpp
+++ b/Swift/Controllers/ContactSuggester.cpp
@@ -23,7 +23,6 @@
#include <boost/lambda/lambda.hpp>
#include <Swiften/Base/Algorithm.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/JID/JID.h>
#include <Swift/Controllers/ContactProvider.h>
@@ -55,7 +54,7 @@ bool ContactSuggester::matchContact(const std::string& search, const Contact::re
std::vector<Contact::ref> ContactSuggester::getSuggestions(const std::string& search, bool withMUCNicks) const {
std::vector<Contact::ref> results;
- foreach(ContactProvider* provider, contactProviders_) {
+ for (auto provider : contactProviders_) {
append(results, provider->getContacts(withMUCNicks));
}
diff --git a/Swift/Controllers/ContactsFromXMPPRoster.cpp b/Swift/Controllers/ContactsFromXMPPRoster.cpp
index e3c5d97..1d1ccd4 100644
--- a/Swift/Controllers/ContactsFromXMPPRoster.cpp
+++ b/Swift/Controllers/ContactsFromXMPPRoster.cpp
@@ -13,7 +13,6 @@
#include <Swift/Controllers/ContactsFromXMPPRoster.h>
#include <Swiften/Avatars/AvatarManager.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Presence/PresenceOracle.h>
#include <Swiften/Roster/XMPPRoster.h>
#include <Swiften/Roster/XMPPRosterItem.h>
@@ -29,7 +28,7 @@ ContactsFromXMPPRoster::~ContactsFromXMPPRoster() {
std::vector<Contact::ref> ContactsFromXMPPRoster::getContacts(bool /*withMUCNicks*/) {
std::vector<Contact::ref> results;
std::vector<XMPPRosterItem> rosterItems = roster_->getItems();
- foreach(const XMPPRosterItem& rosterItem, rosterItems) {
+ for (const auto& rosterItem : rosterItems) {
Contact::ref contact = std::make_shared<Contact>(rosterItem.getName().empty() ? rosterItem.getJID().toString() : rosterItem.getName(), rosterItem.getJID(), StatusShow::None,"");
contact->statusType = presenceOracle_->getAccountPresence(contact->jid) ? presenceOracle_->getAccountPresence(contact->jid)->getShow() : StatusShow::None;
contact->avatarPath = avatarManager_->getAvatarPath(contact->jid);
diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
index af2831c..fcc35e4 100644
--- a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
@@ -17,7 +17,6 @@
#include <boost/signals2.hpp>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
namespace Swift {
@@ -30,7 +29,7 @@ FileTransferOverview::FileTransferOverview(FileTransferManager* ftm) : fileTrans
FileTransferOverview::~FileTransferOverview() {
onNewFileTransferController.disconnect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1));
fileTransferManager->onIncomingFileTransfer.disconnect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1));
- foreach(FileTransferController* controller, fileTransfers) {
+ for (auto controller : fileTransfers) {
controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this));
}
}
@@ -78,7 +77,7 @@ void FileTransferOverview::clearFinished() {
bool FileTransferOverview::isClearable() const {
bool isClearable = false;
- foreach (FileTransferController* controller, fileTransfers) {
+ for (auto controller : fileTransfers) {
if(controller->getState().type == FileTransfer::State::Finished
|| controller->getState().type == FileTransfer::State::Failed
|| controller->getState().type == FileTransfer::State::Canceled) {
diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp
index 2afaf49..9176301 100644
--- a/Swift/Controllers/HighlightManager.cpp
+++ b/Swift/Controllers/HighlightManager.cpp
@@ -23,8 +23,6 @@
#include <boost/regex.hpp>
#include <boost/serialization/vector.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/Controllers/Highlighter.h>
#include <Swift/Controllers/SettingConstants.h>
#include <Swift/Controllers/Settings/SettingsProvider.h>
diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp
index 86ac5f7..a8cb7e4 100644
--- a/Swift/Controllers/HighlightRule.cpp
+++ b/Swift/Controllers/HighlightRule.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2014-2015 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,6 @@
#include <boost/lambda/lambda.hpp>
#include <Swiften/Base/Regex.h>
-#include <Swiften/Base/foreach.h>
namespace Swift {
@@ -45,11 +44,11 @@ boost::regex HighlightRule::regexFromString(const std::string & s) const
void HighlightRule::updateRegex() const
{
keywordRegex_.clear();
- foreach (const std::string & k, keywords_) {
+ for (const auto& k : keywords_) {
keywordRegex_.push_back(regexFromString(k));
}
senderRegex_.clear();
- foreach (const std::string & s, senders_) {
+ for (const auto& s : senders_) {
senderRegex_.push_back(regexFromString(s));
}
}
@@ -79,7 +78,7 @@ bool HighlightRule::isMatch(const std::string& body, const std::string& sender,
// check if a keyword matches
if (!matchesKeyword && !keywords_.empty()) {
- foreach (const boost::regex &keyword, keywordRegex_) {
+ for (const auto& keyword : keywordRegex_) {
if (boost::regex_search(body, keyword)) {
matchesKeyword = true;
break;
@@ -88,7 +87,7 @@ bool HighlightRule::isMatch(const std::string& body, const std::string& sender,
}
}
- foreach (const boost::regex & rx, senderRegex_) {
+ for (const auto& rx : senderRegex_) {
if (boost::regex_search(sender, rx)) {
matchesSender = true;
break;
diff --git a/Swift/Controllers/Highlighter.cpp b/Swift/Controllers/Highlighter.cpp
index 3499217..cea077e 100644
--- a/Swift/Controllers/Highlighter.cpp
+++ b/Swift/Controllers/Highlighter.cpp
@@ -12,8 +12,6 @@
#include <Swift/Controllers/Highlighter.h>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/Controllers/HighlightManager.h>
namespace Swift {
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index d66b2b2..669b002 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -12,9 +12,10 @@
#include <Swift/Controllers/HistoryViewController.h>
+#include <boost/range/adaptor/reversed.hpp>
+
#include <Swiften/Avatars/AvatarManager.h>
#include <Swiften/Base/Path.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Client/NickResolver.h>
#include <Swiften/History/HistoryMessage.h>
@@ -124,7 +125,7 @@ void HistoryViewController::handleSelectedContactChanged(RosterItem* newContact)
historyWindow_->setDate(currentResultDate_);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, false);
}
}
@@ -203,7 +204,7 @@ void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date&
std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, true);
}
historyWindow_->resetConversationViewTopInsertPoint();
@@ -216,7 +217,7 @@ void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::da
std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, false);
}
}
@@ -237,7 +238,7 @@ void HistoryViewController::handleNextButtonClicked() {
std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
historyWindow_->setDate(currentResultDate_);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, false);
}
}
@@ -258,7 +259,7 @@ void HistoryViewController::handlePreviousButtonClicked() {
std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
historyWindow_->setDate(currentResultDate_);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, false);
}
}
@@ -280,7 +281,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date&
newDate = date;
}
else if (date < currentResultDate_) {
- foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ for (const auto& current : contacts_[selectedItemType_][selectedItem_->getJID()]) {
if (current > date) {
newDate = current;
break;
@@ -288,7 +289,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date&
}
}
else {
- reverse_foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ for (const auto& current : boost::adaptors::reverse(contacts_[selectedItemType_][selectedItem_->getJID()])) {
if (current < date) {
newDate = current;
break;
@@ -306,7 +307,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date&
std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
historyWindow_->setDate(currentResultDate_);
- foreach (const HistoryMessage& message, messages) {
+ for (const auto& message : messages) {
addNewMessage(message, false);
}
}
@@ -347,7 +348,7 @@ Presence::ref HistoryViewController::getPresence(const JID& jid, bool isMUC) {
return presence;
}
- foreach (Presence::ref presence, mucPresence) {
+ for (auto&& presence : mucPresence) {
if (presence.get() && presence->getFrom() == jid) {
return presence;
}
diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp
index 4806f9c..0b2d437 100644
--- a/Swift/Controllers/PreviousStatusStore.cpp
+++ b/Swift/Controllers/PreviousStatusStore.cpp
@@ -6,8 +6,6 @@
#include <Swift/Controllers/PreviousStatusStore.h>
-#include <Swiften/Base/foreach.h>
-
namespace Swift {
PreviousStatusStore::PreviousStatusStore() {
@@ -31,7 +29,7 @@ std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusSho
std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const std::string& message) {
std::vector<TypeStringPair> suggestions;
- foreach (TypeStringPair status, store_) {
+ for (auto&& status : store_) {
if (status.second == message) {
suggestions.clear();
suggestions.push_back(status);
diff --git a/Swift/Controllers/PreviousStatusStore.h b/Swift/Controllers/PreviousStatusStore.h
index eb1fb59..b106445 100644
--- a/Swift/Controllers/PreviousStatusStore.h
+++ b/Swift/Controllers/PreviousStatusStore.h
@@ -14,6 +14,7 @@
namespace Swift {
typedef std::pair<StatusShow::Type, std::string> TypeStringPair;
+
class PreviousStatusStore {
public:
PreviousStatusStore();
diff --git a/Swift/Controllers/ProfileSettingsProvider.cpp b/Swift/Controllers/ProfileSettingsProvider.cpp
index bb186fc..b979555 100644
--- a/Swift/Controllers/ProfileSettingsProvider.cpp
+++ b/Swift/Controllers/ProfileSettingsProvider.cpp
@@ -6,13 +6,15 @@
#include <Swift/Controllers/ProfileSettingsProvider.h>
+#include <Swift/Controllers/Settings/SettingsProvider.h>
+
namespace Swift {
ProfileSettingsProvider::ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider) :
profile_(profile) {
provider_ = provider;
bool found = false;
- foreach (std::string existingProfile, provider->getAvailableProfiles()) {
+ for (const auto& existingProfile : provider->getAvailableProfiles()) {
if (existingProfile == profile) {
found = true;
}
diff --git a/Swift/Controllers/ProfileSettingsProvider.h b/Swift/Controllers/ProfileSettingsProvider.h
index f3c3156..e309c11 100644
--- a/Swift/Controllers/ProfileSettingsProvider.h
+++ b/Swift/Controllers/ProfileSettingsProvider.h
@@ -1,17 +1,17 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Swiften/Base/foreach.h>
-
-#include <Swift/Controllers/Settings/SettingsProvider.h>
+#include <string>
namespace Swift {
+class SettingsProvider;
+
class ProfileSettingsProvider {
public:
ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider);
@@ -25,6 +25,8 @@ class ProfileSettingsProvider {
private:
std::string profileSettingPath(const std::string &settingPath);
+
+ private:
SettingsProvider* provider_;
std::string profile_;
};
diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp
index 71c5f8e..8fdf183 100644
--- a/Swift/Controllers/Roster/ContactRosterItem.cpp
+++ b/Swift/Controllers/Roster/ContactRosterItem.cpp
@@ -9,7 +9,6 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Swiften/Base/DateTime.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/Idle.h>
#include <Swiften/Elements/Presence.h>
diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
index af89b54..0f07c0b 100644
--- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
+++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
@@ -11,7 +11,6 @@
#include <boost/bind.hpp>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swift/Controllers/Roster/GroupRosterItem.h>
#include <Swift/Controllers/SettingConstants.h>
@@ -45,7 +44,7 @@ void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* gro
void RosterGroupExpandinessPersister::save() {
std::string setting;
- foreach (const std::string& group, collapsed_) {
+ for (const auto& group : collapsed_) {
if (!setting.empty()) {
setting += "\n";
}
diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp
index f164a4d..713f390 100644
--- a/Swift/Controllers/Roster/TableRoster.cpp
+++ b/Swift/Controllers/Roster/TableRoster.cpp
@@ -12,7 +12,6 @@
#include <boost/cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/Timer.h>
#include <Swiften/Network/TimerFactory.h>
@@ -104,11 +103,11 @@ void TableRoster::handleUpdateTimerTick() {
// Get a model for the new roster
std::vector<Section> newSections;
if (model) {
- foreach(RosterItem* item, model->getRoot()->getDisplayedChildren()) {
+ for (auto item : model->getRoot()->getDisplayedChildren()) {
if (GroupRosterItem* groupItem = boost::polymorphic_downcast<GroupRosterItem*>(item)) {
//std::cerr << "* " << groupItem->getDisplayName() << std::endl;
Section section(groupItem->getDisplayName());
- foreach(RosterItem* groupChildItem, groupItem->getDisplayedChildren()) {
+ for (auto groupChildItem : groupItem->getDisplayedChildren()) {
if (ContactRosterItem* contact = boost::polymorphic_downcast<ContactRosterItem*>(groupChildItem)) {
//std::cerr << " - " << contact->getDisplayJID() << std::endl;
section.items.push_back(Item(contact->getDisplayName(), contact->getStatusText(), contact->getDisplayJID(), contact->getStatusShow(), contact->getAvatarPath()));
diff --git a/Swift/Controllers/Settings/SettingsProviderHierachy.cpp b/Swift/Controllers/Settings/SettingsProviderHierachy.cpp
index 5156d14..a05fabc 100644
--- a/Swift/Controllers/Settings/SettingsProviderHierachy.cpp
+++ b/Swift/Controllers/Settings/SettingsProviderHierachy.cpp
@@ -1,20 +1,20 @@
/*
- * Copyright (c) 2012 Isode Limited.
+ * Copyright (c) 2012-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Log.h>
+
namespace Swift {
SettingsProviderHierachy::~SettingsProviderHierachy() {
}
bool SettingsProviderHierachy::hasSetting(const std::string& key) {
- foreach (SettingsProvider* provider, providers_) {
+ for (auto provider : providers_) {
if (provider->hasSetting(key)) {
return true;
}
@@ -24,7 +24,7 @@ bool SettingsProviderHierachy::hasSetting(const std::string& key) {
std::string SettingsProviderHierachy::getSetting(const Setting<std::string>& setting) {
std::string value = setting.getDefaultValue();
- foreach (SettingsProvider* provider, providers_) {
+ for (auto provider : providers_) {
std::string providerSetting = provider->getSetting(setting);
if (provider->hasSetting(setting.getKey())) {
value = providerSetting;
@@ -44,7 +44,7 @@ void SettingsProviderHierachy::storeSetting(const Setting<std::string>& setting,
bool SettingsProviderHierachy::getSetting(const Setting<bool>& setting) {
bool value = setting.getDefaultValue();
- foreach (SettingsProvider* provider, providers_) {
+ for (auto provider : providers_) {
bool providerSetting = provider->getSetting(setting);
if (provider->hasSetting(setting.getKey())) {
value = providerSetting;
@@ -64,7 +64,7 @@ void SettingsProviderHierachy::storeSetting(const Setting<bool>& setting, const
int SettingsProviderHierachy::getSetting(const Setting<int>& setting) {
int value = setting.getDefaultValue();
- foreach (SettingsProvider* provider, providers_) {
+ for (auto provider : providers_) {
int providerSetting = provider->getSetting(setting);
if (provider->hasSetting(setting.getKey())) {
value = providerSetting;
@@ -97,7 +97,7 @@ void SettingsProviderHierachy::removeProfile(const std::string& profile) {
bool SettingsProviderHierachy::getIsSettingFinal(const std::string& settingPath) {
bool isFinal = false;
- foreach (SettingsProvider* provider, providers_) {
+ for (auto provider : providers_) {
isFinal |= provider->getIsSettingFinal(settingPath);
}
return isFinal;
diff --git a/Swift/Controllers/ShowProfileController.cpp b/Swift/Controllers/ShowProfileController.cpp
index add6e73..b379141 100644
--- a/Swift/Controllers/ShowProfileController.cpp
+++ b/Swift/Controllers/ShowProfileController.cpp
@@ -15,7 +15,6 @@
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/VCards/VCardManager.h>
#include <Swift/Controllers/UIEvents/ShowProfileForRosterItemUIEvent.h>
@@ -30,8 +29,7 @@ ShowProfileController::ShowProfileController(VCardManager* vcardManager, Profile
}
ShowProfileController::~ShowProfileController() {
- typedef std::pair<JID, ProfileWindow*> JIDProfileWindowPair;
- foreach(const JIDProfileWindowPair& jidWndPair, openedProfileWindows) {
+ for (const auto& jidWndPair : openedProfileWindows) {
jidWndPair.second->onWindowAboutToBeClosed.disconnect(boost::bind(&ShowProfileController::handleProfileWindowAboutToBeClosed, this, _1));
delete jidWndPair.second;
}
diff --git a/Swift/Controllers/Storages/AvatarFileStorage.cpp b/Swift/Controllers/Storages/AvatarFileStorage.cpp
index cded945..a103920 100644
--- a/Swift/Controllers/Storages/AvatarFileStorage.cpp
+++ b/Swift/Controllers/Storages/AvatarFileStorage.cpp
@@ -12,7 +12,6 @@
#include <boost/filesystem/fstream.hpp>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/StringCodecs/Hexify.h>
diff --git a/Swift/Controllers/Storages/CertificateMemoryStorage.cpp b/Swift/Controllers/Storages/CertificateMemoryStorage.cpp
index 08c6ee7..545ca65 100644
--- a/Swift/Controllers/Storages/CertificateMemoryStorage.cpp
+++ b/Swift/Controllers/Storages/CertificateMemoryStorage.cpp
@@ -1,20 +1,18 @@
/*
- * Copyright (c) 2011 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/Controllers/Storages/CertificateMemoryStorage.h>
-#include <Swiften/Base/foreach.h>
-
using namespace Swift;
CertificateMemoryStorage::CertificateMemoryStorage() {
}
bool CertificateMemoryStorage::hasCertificate(Certificate::ref certificate) const {
- foreach(Certificate::ref storedCert, certificates) {
+ for (auto&& storedCert : certificates) {
if (storedCert->toDER() == certificate->toDER()) {
return true;
}
diff --git a/Swift/Controllers/Storages/VCardFileStorage.cpp b/Swift/Controllers/Storages/VCardFileStorage.cpp
index dbb6799..2fdadf6 100644
--- a/Swift/Controllers/Storages/VCardFileStorage.cpp
+++ b/Swift/Controllers/Storages/VCardFileStorage.cpp
@@ -13,7 +13,6 @@
#include <Swiften/Base/Path.h>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/Elements/VCard.h>
#include <Swiften/Entity/GenericPayloadPersister.h>
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
@@ -14,7 +14,6 @@
#include <boost/filesystem/path.hpp>
#include <boost/signals2.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/StatusShow.h>
#include <Swiften/MUC/MUCBookmark.h>
@@ -31,11 +30,11 @@ namespace Swift {
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;
@@ -58,9 +57,8 @@ namespace Swift {
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 {
diff --git a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
index 217a2f0..6ac51b2 100644
--- a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
+++ b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
@@ -12,8 +12,6 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/Controllers/ContactSuggester.h>
using namespace Swift;
@@ -55,9 +53,9 @@ public:
std::vector<Contact::ref> contacts;
std::vector<std::string> words = wordList();
std::vector<StatusShow::Type> statuses = statusList();
- foreach (const std::string& name, words) {
- foreach (const std::string& jid, words) {
- foreach (const StatusShow::Type& status, statuses) {
+ for (const auto& name : words) {
+ for (const auto& jid : words) {
+ for (const auto& status : statuses) {
contacts.push_back(std::make_shared<Contact>(name, jid, status, ""));
}
}
@@ -68,7 +66,7 @@ public:
/* a = a */
bool isReflexive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
+ for (const auto& a : contacts) {
if (!comparitor(a, a)) {
return false;
}
@@ -79,8 +77,8 @@ public:
/* a = b -> b = a */
bool isSymmetric(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
- foreach (const Contact::ref& b, contacts) {
+ for (const auto& a : contacts) {
+ for (const auto& b : contacts) {
if (comparitor(a, b)) {
if (!comparitor(b, a)) {
return false;
@@ -94,9 +92,9 @@ public:
/* a = b && b = c -> a = c */
bool isTransitive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
- foreach (const Contact::ref& b, contacts) {
- foreach (const Contact::ref& c, contacts) {
+ for (const auto& a : contacts) {
+ for (const auto& b : contacts) {
+ for (const auto& c : contacts) {
if (comparitor(a, b) && comparitor(b, c)) {
if (!comparitor(a, c)) {
return false;
@@ -120,7 +118,7 @@ public:
void sortTest() {
std::vector<std::string> words = wordList();
- foreach (const std::string& word, words) {
+ for (const auto& word : words) {
CPPUNIT_ASSERT(isTransitive(boost::bind(Contact::sortPredicate, _1, _2, word)));
}
}
diff --git a/Swift/Controllers/WhiteboardManager.cpp b/Swift/Controllers/WhiteboardManager.cpp
index fab5380..37fe8e3 100644
--- a/Swift/Controllers/WhiteboardManager.cpp
+++ b/Swift/Controllers/WhiteboardManager.cpp
@@ -14,7 +14,6 @@
#include <boost/bind.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Client/NickResolver.h>
#include <Swiften/Client/StanzaChannel.h>
#include <Swiften/Whiteboard/WhiteboardSessionManager.h>
@@ -25,8 +24,6 @@
#include <Swift/Controllers/UIEvents/ShowWhiteboardUIEvent.h>
namespace Swift {
- typedef std::pair<JID, WhiteboardWindow*> JIDWhiteboardWindowPair;
-
WhiteboardManager::WhiteboardManager(WhiteboardWindowFactory* whiteboardWindowFactory, UIEventStream* uiEventStream, NickResolver* nickResolver, WhiteboardSessionManager* whiteboardSessionManager) : whiteboardWindowFactory_(whiteboardWindowFactory), uiEventStream_(uiEventStream), nickResolver_(nickResolver), whiteboardSessionManager_(whiteboardSessionManager) {
#ifdef SWIFT_EXPERIMENTAL_WB
@@ -36,7 +33,7 @@ namespace Swift {
}
WhiteboardManager::~WhiteboardManager() {
- foreach (JIDWhiteboardWindowPair whiteboardWindowPair, whiteboardWindows_) {
+ for (auto&& whiteboardWindowPair : whiteboardWindows_) {
delete whiteboardWindowPair.second;
}
}
diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index f0debb9..f8fb192 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -11,8 +11,6 @@
#include <boost/bind.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/Controllers/XMPPEvents/ErrorEvent.h>
#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h>
#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h>
@@ -25,7 +23,7 @@ EventController::EventController() {
}
EventController::~EventController() {
- foreach(std::shared_ptr<StanzaEvent> event, events_) {
+ for (auto&& event : events_) {
event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event));
}
}
@@ -40,7 +38,7 @@ void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEve
/* If it's a duplicate subscription request, remove the previous request first */
if (subscriptionEvent) {
EventList existingEvents(events_);
- foreach(std::shared_ptr<StanzaEvent> existingEvent, existingEvents) {
+ for (auto&& existingEvent : existingEvents) {
std::shared_ptr<SubscriptionRequestEvent> existingSubscriptionEvent = std::dynamic_pointer_cast<SubscriptionRequestEvent>(existingEvent);
if (existingSubscriptionEvent) {
if (existingSubscriptionEvent->getJID() == subscriptionEvent->getJID()) {
diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h
index 427f00b..a9bb9b1 100644
--- a/Swift/QtUI/ChatList/ChatListGroupItem.h
+++ b/Swift/QtUI/ChatList/ChatListGroupItem.h
@@ -8,8 +8,6 @@
#include <QList>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/QtUI/ChatList/ChatListItem.h>
namespace Swift {
@@ -24,13 +22,12 @@ namespace Swift {
int row(ChatListItem* item) {return items_.indexOf(item);}
QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();}
void clear() {
- foreach (ChatListItem* item, items_) {
+ for (auto item : items_) {
delete item;
}
items_.clear();
}
-
private:
static bool pointerItemLessThan(const ChatListItem* first, const ChatListItem* second) {
QString myName = first->data(Qt::DisplayRole).toString().toLower();
diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp
index e5e8963..416b786 100644
--- a/Swift/QtUI/ChatList/ChatListModel.cpp
+++ b/Swift/QtUI/ChatList/ChatListModel.cpp
@@ -96,7 +96,7 @@ void ChatListModel::setRecents(const std::list<ChatListWindow::Chat>& recents) {
recents_->clear();
endRemoveRows();
beginInsertRows(recentsIndex_, 0, recents.size());
- foreach (const ChatListWindow::Chat chat, recents) {
+ for (const auto& chat : recents) {
recents_->addItem(new ChatListRecentItem(chat, recents_));
//whiteboards_->addItem(new ChatListRecentItem(chat, whiteboards_));
}
@@ -121,8 +121,7 @@ QMimeData* ChatListModel::mimeData(const QModelIndexList& indexes) const {
}
dataStream << P2QSTRING(chat.jid.toString());
} else {
- typedef std::map<std::string, JID> JIDMap;
- foreach (const JIDMap::value_type& jid, chat.impromptuJIDs) {
+ for (const auto& jid : chat.impromptuJIDs) {
dataStream << P2QSTRING(jid.second.toString());
}
}
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index 3fe462a..3caed57 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -180,7 +180,7 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) {
ChatListItem* baseItem = index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : nullptr;
contextMenuItem_ = baseItem;
- foreach(QAction* action, onlineOnlyActions_) {
+ for (auto action : onlineOnlyActions_) {
action->setEnabled(isOnline_);
}
diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp
index 0369d0a..87dfac2 100644
--- a/Swift/QtUI/ChatSnippet.cpp
+++ b/Swift/QtUI/ChatSnippet.cpp
@@ -48,7 +48,7 @@ QString ChatSnippet::directionToCSS(Direction direction) {
ChatSnippet::Direction ChatSnippet::getDirection(const ChatWindow::ChatMessage& message) {
std::shared_ptr<ChatWindow::ChatTextMessagePart> textPart;
std::string text = "";
- foreach (std::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) {
+ for (auto&& part : message.getParts()) {
if ((textPart = std::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) {
text = textPart->text;
break;
diff --git a/Swift/QtUI/ChatSnippet.h b/Swift/QtUI/ChatSnippet.h
index f715cbf..d8bc209 100644
--- a/Swift/QtUI/ChatSnippet.h
+++ b/Swift/QtUI/ChatSnippet.h
@@ -11,8 +11,6 @@
#include <QDateTime>
#include <QString>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
#include <Swift/QtUI/QtChatTheme.h>
diff --git a/Swift/QtUI/CocoaUIHelpers.mm b/Swift/QtUI/CocoaUIHelpers.mm
index 3ffa72c..1f4ffc1 100644
--- a/Swift/QtUI/CocoaUIHelpers.mm
+++ b/Swift/QtUI/CocoaUIHelpers.mm
@@ -13,6 +13,7 @@
#include "CocoaUIHelpers.h"
#include <memory>
+
#include <boost/type_traits.hpp>
#include <Cocoa/Cocoa.h>
@@ -20,8 +21,6 @@
#include <Security/Security.h>
#include <SecurityInterface/SFCertificatePanel.h>
-#include <Swiften/Base/foreach.h>
-
#pragma GCC diagnostic ignored "-Wold-style-cast"
namespace Swift {
@@ -29,7 +28,7 @@ namespace Swift {
void CocoaUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std::vector<Certificate::ref>& chain) {
NSWindow* parentWindow = [((NSView*)parent->winId()) window];
NSMutableArray* certificates = [[NSMutableArray alloc] init];
- foreach(Certificate::ref cert, chain) {
+ for (auto&& cert : chain) {
// convert chain to SecCertificateRef
ByteArray certAsDER = cert->toDER();
std::shared_ptr<boost::remove_pointer<CFDataRef>::type> certData(CFDataCreate(nullptr, certAsDER.data(), certAsDER.size()), CFRelease);
@@ -39,7 +38,6 @@ void CocoaUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std::
[certificates addObject: (id)macCert.get()];
}
-
SFCertificatePanel* panel = [[SFCertificatePanel alloc] init];
//[panel setPolicies:(id)policies.get()];
[panel beginSheetForWindow:parentWindow modalDelegate:nil didEndSelector:nullptr contextInfo:nullptr certificates:certificates showGroup:YES];
diff --git a/Swift/QtUI/EventViewer/EventModel.cpp b/Swift/QtUI/EventViewer/EventModel.cpp
index e242003..5b97b3e 100644
--- a/Swift/QtUI/EventViewer/EventModel.cpp
+++ b/Swift/QtUI/EventViewer/EventModel.cpp
@@ -19,10 +19,10 @@ EventModel::EventModel() {
}
EventModel::~EventModel() {
- foreach (QtEvent* event, activeEvents_) {
+ for (auto event : activeEvents_) {
delete event;
}
- foreach (QtEvent* event, inactiveEvents_) {
+ for (auto event : inactiveEvents_) {
delete event;
}
}
diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp
index 6b982b1..65dac91 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.cpp
+++ b/Swift/QtUI/QtAdHocCommandWindow.cpp
@@ -104,7 +104,7 @@ void QtAdHocCommandWindow::handleCompleteClicked() {
void QtAdHocCommandWindow::handleNextStageReceived(Command::ref command) {
QString notes;
- foreach (Command::Note note, command->getNotes()) {
+ for (const auto& note : command->getNotes()) {
if (!notes.isEmpty()) {
notes += "\n";
}
@@ -152,7 +152,7 @@ typedef std::pair<Command::Action, QPushButton*> ActionButton;
void QtAdHocCommandWindow::setAvailableActions(Command::ref /*commandResult*/) {
okButton_->show();
okButton_->setEnabled(true);
- foreach (ActionButton pair, actions_) {
+ for (auto&& pair : actions_) {
OutgoingAdHocCommandSession::ActionState state = command_->getActionState(pair.first);
if (state & OutgoingAdHocCommandSession::Present) {
okButton_->hide();
diff --git a/Swift/QtUI/QtAffiliationEditor.cpp b/Swift/QtUI/QtAffiliationEditor.cpp
index 980b26a..92b6aff 100644
--- a/Swift/QtUI/QtAffiliationEditor.cpp
+++ b/Swift/QtUI/QtAffiliationEditor.cpp
@@ -37,7 +37,7 @@ const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& QtAffiliationEdito
void QtAffiliationEditor::handleCurrentIndexChanged(int index) {
ui_.list->clear();
- foreach (const JID& jid, affiliations_[affiliationFromIndex(index)]) {
+ for (const auto& jid : affiliations_[affiliationFromIndex(index)]) {
ui_.list->addItem(P2QSTRING(jid.toString()));
}
}
diff --git a/Swift/QtUI/QtBlockListEditorWindow.cpp b/Swift/QtUI/QtBlockListEditorWindow.cpp
index 9e13943..30c939f 100644
--- a/Swift/QtUI/QtBlockListEditorWindow.cpp
+++ b/Swift/QtUI/QtBlockListEditorWindow.cpp
@@ -20,7 +20,6 @@
#include <QStyledItemDelegate>
#include <QValidator>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Client/ClientBlockListManager.h>
#include <Swiften/JID/JID.h>
@@ -158,7 +157,7 @@ void QtBlockListEditorWindow::applyChanges() {
void QtBlockListEditorWindow::setCurrentBlockList(const std::vector<JID> &blockedJIDs) {
ui->blockListTreeWidget->clear();
- foreach(const JID& jid, blockedJIDs) {
+ for (const auto& jid : blockedJIDs) {
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(P2QSTRING(jid.toString())) << "");
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->blockListTreeWidget->addTopLevelItem(item);
diff --git a/Swift/QtUI/QtCertificateViewerDialog.cpp b/Swift/QtUI/QtCertificateViewerDialog.cpp
index a99c29a..6454d82 100644
--- a/Swift/QtUI/QtCertificateViewerDialog.cpp
+++ b/Swift/QtUI/QtCertificateViewerDialog.cpp
@@ -18,8 +18,6 @@
#include <QStringList>
#include <QTreeWidgetItem>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/QtUI/ui_QtCertificateViewerDialog.h>
namespace Swift {
@@ -43,7 +41,7 @@ void QtCertificateViewerDialog::setCertificateChain(const std::vector<Certificat
// convert Swift certificate chain to qt certificate chain (root goes first)
currentChain.clear();
- foreach(Certificate::ref cert, chain) {
+ for (auto&& cert : chain) {
ByteArray certAsDer = cert->toDER();
QByteArray dataArray(reinterpret_cast<const char*>(certAsDer.data()), certAsDer.size());
currentChain.push_front(QSslCertificate(dataArray, QSsl::Der));
@@ -125,8 +123,8 @@ void QtCertificateViewerDialog::setCertificateDetails(const QSslCertificate& cer
#endif
if (!altNames.empty()) {
ADD_SECTION(tr("Alternate Subject Names"));
- foreach (const SANTYPE &type, altNames.uniqueKeys()) {
- foreach (QString name, altNames.values(type)) {
+ for (const auto& type : altNames.uniqueKeys()) {
+ for (auto&& name : altNames.values(type)) {
if (type == QSsl::EmailEntry) {
ADD_FIELD(tr("E-mail Address"), name);
} else {
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index bb9c005..3241858 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -80,7 +80,7 @@ QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bo
}
QtChatTabs::~QtChatTabs() {
- foreach (QShortcut* shortcut, shortcuts_) {
+ for (auto shortcut : shortcuts_) {
delete shortcut;
}
diff --git a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp
index fb41446..40ab17f 100644
--- a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp
+++ b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp
@@ -12,7 +12,6 @@
#include <QShortcut>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
#include <Swift/QtUI/QtTabbable.h>
@@ -95,7 +94,7 @@ QList<QtTabbable*> QtChatTabsShortcutOnlySubstitute::tabbableWindows() const {
QList<QWidget*> windows = qApp->topLevelWidgets();
QList<QtTabbable*> tabbables;
- foreach(QWidget* topLevelWidget, windows) {
+ for (auto topLevelWidget : windows) {
QtTabbable* tabbable = dynamic_cast<QtTabbable*>(topLevelWidget);
if (tabbable) {
tabbables << tabbable;
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index bda6b3e..d799e19 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -386,7 +386,7 @@ void QtChatWindow::setAvailableSecurityLabels(const std::vector<SecurityLabelsCa
int i = 0;
int defaultIndex = 0;
labelsWidget_->setModel(labelModel_);
- foreach (SecurityLabelsCatalog::Item label, labels) {
+ for (const auto& label : labels) {
if (label.getIsDefault()) {
defaultIndex = i;
break;
@@ -712,8 +712,7 @@ void QtChatWindow::handleActionButtonClicked() {
}
else {
- foreach(ChatWindow::RoomAction availableAction, availableRoomActions_)
- {
+ for (auto&& availableAction : availableRoomActions_) {
if (impromptu_) {
// hide options we don't need in impromptu chats
if (availableAction == ChatWindow::ChangeSubject ||
diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp
index 4e9a7fe..17f5ccf 100644
--- a/Swift/QtUI/QtContactEditWidget.cpp
+++ b/Swift/QtUI/QtContactEditWidget.cpp
@@ -51,7 +51,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set<std::string>& allGroups,
groupsArea->setWidget(groups);
QVBoxLayout* scrollLayout = new QVBoxLayout(groups);
- foreach (std::string group, allGroups) {
+ for (const auto& group : allGroups) {
QString groupName = doubleAmpersand(group);
QCheckBox* check = new QCheckBox(groups);
check->setText(groupName);
@@ -79,7 +79,7 @@ void QtContactEditWidget::setName(const std::string& name) {
std::string QtContactEditWidget::getName() const {
std::string name = Q2PSTRING(name_->text());
QList<QRadioButton*> buttons = findChildren<QRadioButton*>();
- foreach(const QRadioButton* button, buttons) {
+ for (const auto button : buttons) {
if (button->isChecked()) {
if (button == nameRadioButton_) {
name = Q2PSTRING(name_->text());
@@ -93,14 +93,14 @@ std::string QtContactEditWidget::getName() const {
}
void QtContactEditWidget::setSelectedGroups(const std::vector<std::string>& groups) {
- foreach (std::string group, groups) {
+ for (auto&& group : groups) {
checkBoxes_[group]->setCheckState(Qt::Checked);
}
}
std::set<std::string> QtContactEditWidget::getSelectedGroups() const {
std::set<std::string> groups;
- foreach(const CheckBoxMap::value_type& group, checkBoxes_) {
+ for (const auto& group : checkBoxes_) {
if (group.second->checkState() == Qt::Checked) {
groups.insert(group.first);
}
@@ -124,7 +124,7 @@ void QtContactEditWidget::setNameSuggestions(const std::vector<std::string>& sug
}
// populate new suggestions
- foreach(const std::string& name, suggestions) {
+ for (const auto& name : suggestions) {
suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(doubleAmpersand(name), this));
}
@@ -133,7 +133,7 @@ void QtContactEditWidget::setNameSuggestions(const std::vector<std::string>& sug
QRadioButton* suggestedRadioButton = nullptr;
QList<QRadioButton*> radioButtons = findChildren<QRadioButton*>();
- foreach (QRadioButton* candidate, radioButtons) {
+ for (auto candidate : radioButtons) {
if (candidate->text() == name_->text()) {
suggestedRadioButton = candidate;
break;
diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h
index d4ea609..0718fee 100644
--- a/Swift/QtUI/QtContactEditWidget.h
+++ b/Swift/QtUI/QtContactEditWidget.h
@@ -41,9 +41,9 @@ namespace Swift {
private:
QString doubleAmpersand(const std::string& name) const;
std::string singleAmpersand(const QString& name) const;
+
private:
- typedef std::map<std::string, QCheckBox*> CheckBoxMap;
- CheckBoxMap checkBoxes_;
+ std::map<std::string, QCheckBox*> checkBoxes_;
QHBoxLayout* nameLayout_;
QHBoxLayout* suggestionsLayout_;
QRadioButton* nameRadioButton_;
diff --git a/Swift/QtUI/QtEmoticonsGrid.cpp b/Swift/QtUI/QtEmoticonsGrid.cpp
index a81f516..4c8c024 100644
--- a/Swift/QtUI/QtEmoticonsGrid.cpp
+++ b/Swift/QtUI/QtEmoticonsGrid.cpp
@@ -14,16 +14,14 @@
#include <set>
-#include <QPushButton>
+#include <boost/range/adaptor/reversed.hpp>
-#include <Swiften/Base/foreach.h>
+#include <QPushButton>
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
-typedef std::map<std::string, std::string> EmoticonsMap; // Without this typedef compiler complains when using foreach
-
QtEmoticonsGrid::QtEmoticonsGrid(const std::map<std::string, std::string>& emoticons, QWidget* parent) : QGridLayout(parent) {
makeUniqueEmoticonsMap(emoticons);
@@ -31,7 +29,7 @@ QtEmoticonsGrid::QtEmoticonsGrid(const std::map<std::string, std::string>& emoti
int row = 0;
int column = 0;
- foreach(EmoticonsMap::value_type emoticon, uniqueEmoticons_) {
+ for (auto&& emoticon : uniqueEmoticons_) {
QtEmoticonCell* newCell = new QtEmoticonCell(P2QSTRING(emoticon.first), P2QSTRING(emoticon.second));
addWidget(newCell, row, column);
connect(newCell, SIGNAL(emoticonClicked(QString)), this, SLOT(emoticonClickedSlot(QString)));
@@ -50,7 +48,7 @@ QtEmoticonsGrid::~QtEmoticonsGrid() {
void QtEmoticonsGrid::makeUniqueEmoticonsMap(const std::map<std::string, std::string>& emoticons) {
std::set<std::string> paths;
- reverse_foreach(EmoticonsMap::value_type emoticon, emoticons) {
+ for (auto&& emoticon : boost::adaptors::reverse(emoticons)) {
if (paths.find(emoticon.second) == paths.end()) {
uniqueEmoticons_.insert(emoticon);
paths.insert(emoticon.second);
diff --git a/Swift/QtUI/QtFormResultItemModel.cpp b/Swift/QtUI/QtFormResultItemModel.cpp
index 60cf0c0..b35bb4f 100644
--- a/Swift/QtUI/QtFormResultItemModel.cpp
+++ b/Swift/QtUI/QtFormResultItemModel.cpp
@@ -14,8 +14,6 @@
#include <boost/algorithm/string/join.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
@@ -73,7 +71,7 @@ const std::string QtFormResultItemModel::getFieldValue(const Form::FormItem& ite
// determine field name
std::string name = formResult_->getReportedFields().at(column)->getName();
- foreach(FormField::ref field, item) {
+ for (auto&& field : item) {
if (field->getName() == name) {
std::string delimiter = "";
if (field->getType() == FormField::TextMultiType) {
diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp
index 1d26815..96c2da0 100644
--- a/Swift/QtUI/QtFormWidget.cpp
+++ b/Swift/QtUI/QtFormWidget.cpp
@@ -20,8 +20,6 @@
#include <qdebug.h>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
@@ -43,7 +41,7 @@ QtFormWidget::QtFormWidget(Form::ref form, QWidget* parent) : QWidget(parent), f
QGridLayout* layout = new QGridLayout(scroll);
const std::vector<Form::FormItem> items = form->getItems();
if (items.empty()) { /* single item forms */
- foreach (FormField::ref field, form->getFields()) {
+ for (auto&& field : form->getFields()) {
QWidget* widget = createWidget(field, field->getType(), 0);
if (widget) {
layout->addWidget(new QLabel(field->getLabel().c_str(), this), row, 0);
@@ -80,12 +78,12 @@ QListWidget* QtFormWidget::createList(FormField::ref field) {
std::vector<bool> selected;
/* if this is an editable form, use the 'options' list, otherwise use the 'values' list */
if (form_->getType() != Form::FormType) {
- foreach (const std::string& value, field->getValues()) {
+ for (const auto& value : field->getValues()) {
listWidget->addItem(P2QSTRING(value));
selected.push_back(false);
}
} else {
- foreach (FormField::Option option, field->getOptions()) {
+ for (auto&& option : field->getOptions()) {
listWidget->addItem(option.label.c_str());
if (field->getType() == FormField::ListSingleType) {
selected.push_back(!field->getValues().empty() && option.value == field->getValues()[0]);
@@ -157,7 +155,7 @@ QWidget* QtFormWidget::createWidget(FormField::ref field, const FormField::Type
Form::ref QtFormWidget::getCompletedForm() {
Form::ref result(new Form(Form::SubmitType));
- foreach (std::shared_ptr<FormField> field, form_->getFields()) {
+ for (auto&& field : form_->getFields()) {
std::shared_ptr<FormField> resultField = std::make_shared<FormField>(field->getType());
if (field->getType() == FormField::BooleanType) {
resultField->setBoolValue(qobject_cast<QCheckBox*>(fields_[field->getName()])->checkState() == Qt::Checked);
@@ -191,14 +189,14 @@ Form::ref QtFormWidget::getCompletedForm() {
QString string = widget->toPlainText();
if (!string.isEmpty()) {
QStringList lines = string.split("\n");
- foreach (QString line, lines) {
+ for (auto&& line : lines) {
resultField->addValue(Q2PSTRING(line));
}
}
}
if (field->getType() == FormField::ListMultiType) {
QListWidget* listWidget = qobject_cast<QListWidget*>(fields_[field->getName()]);
- foreach (QListWidgetItem* item, listWidget->selectedItems()) {
+ for (auto item : listWidget->selectedItems()) {
resultField->addValue(field->getOptions()[listWidget->row(item)].value);
}
}
@@ -226,7 +224,7 @@ void QtFormWidget::setEditable(bool editable) {
if (!form_) {
return;
}
- foreach (std::shared_ptr<FormField> field, form_->getFields()) {
+ for (auto&& field : form_->getFields()) {
QWidget* widget = nullptr;
if (field) {
widget = fields_[field->getName()];
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index 53e7ffe..77a7f12 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -176,7 +176,7 @@ void QtHistoryWindow::handleScrollRequested(int pos) {
}
QDate currentDate;
- foreach (const QDate& date, dates_) {
+ for (const auto& date : dates_) {
int snippetPosition = conversation_->getSnippetPositionByDate(date);
if (snippetPosition <= pos) {
currentDate = date;
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index d91f694..865d8b5 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -499,7 +499,7 @@ void QtLoginWindow::morphInto(MainWindow *mainWindow) {
setInitialMenus();
std::vector<QMenu*> mainWindowMenus = qtMainWindow->getMenus();
viewMenu_ = mainWindowMenus[0];
- foreach (QMenu* menu, mainWindowMenus) {
+ for (auto menu : mainWindowMenus) {
menuBar_->addMenu(menu);
}
setFocus();
diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp
index d682cfa..05a2eb0 100644
--- a/Swift/QtUI/QtPlainChatView.cpp
+++ b/Swift/QtUI/QtPlainChatView.cpp
@@ -18,7 +18,6 @@
#include <QVBoxLayout>
#include <Swiften/Base/FileSize.h>
-#include <Swiften/Base/foreach.h>
#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
@@ -45,7 +44,7 @@ QtPlainChatView::~QtPlainChatView() {
QString chatMessageToString(const ChatWindow::ChatMessage& message) {
QString result;
- foreach (std::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) {
+ for (auto&& part : message.getParts()) {
std::shared_ptr<ChatWindow::ChatTextMessagePart> textPart;
std::shared_ptr<ChatWindow::ChatURIMessagePart> uriPart;
std::shared_ptr<ChatWindow::ChatEmoticonMessagePart> emoticonPart;
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
index 461ea38..80e275b 100644
--- a/Swift/QtUI/QtProfileWindow.cpp
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -156,7 +156,7 @@ void QtProfileWindow::handleAdjustSizeTimeout() {
// Force recaluclation of all layout geometry in children widgets.
// This is required on Windows to have the correct size even on first show.
QList<QWidget *> children = findChildren<QWidget*>();
- foreach(QWidget* child, children) {
+ for (auto child : children) {
child->updateGeometry();
}
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp
index 3c32dc8..42ac22d 100644
--- a/Swift/QtUI/QtSettingsProvider.cpp
+++ b/Swift/QtUI/QtSettingsProvider.cpp
@@ -77,7 +77,7 @@ void QtSettingsProvider::storeSetting(const Setting<int>& setting, const int& se
std::vector<std::string> QtSettingsProvider::getAvailableProfiles() {
std::vector<std::string> profiles;
QVariant profilesVariant = settings_.value("profileList");
- foreach(QString profileQString, profilesVariant.toStringList()) {
+ for (const auto& profileQString : profilesVariant.toStringList()) {
profiles.push_back(std::string(profileQString.toUtf8()));
}
return profiles;
@@ -92,7 +92,7 @@ void QtSettingsProvider::createProfile(const std::string& profile) {
void QtSettingsProvider::removeProfile(const std::string& profile) {
QString profileStart(QString(profile.c_str()) + ":");
- foreach (QString key, settings_.allKeys()) {
+ for (auto&& key : settings_.allKeys()) {
if (key.startsWith(profileStart)) {
settings_.remove(key);
}
diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp
index ab7e81e..1fba497 100644
--- a/Swift/QtUI/QtSingleWindow.cpp
+++ b/Swift/QtUI/QtSingleWindow.cpp
@@ -6,8 +6,6 @@
#include <Swift/QtUI/QtSingleWindow.h>
-#include <Swiften/Base/foreach.h>
-
#include <Swift/QtUI/QtChatTabs.h>
#include <Swift/QtUI/QtSettingsProvider.h>
@@ -45,7 +43,7 @@ void QtSingleWindow::handleTabsTitleChanged(const QString& title) {
void QtSingleWindow::handleSplitterMoved(int, int) {
QList<QVariant> variantValues;
QList<int> intValues = sizes();
- foreach (int value, intValues) {
+ for (const auto& value : intValues) {
variantValues.append(QVariant(value));
}
settings_->getQSettings()->setValue(SINGLE_WINDOW_SPLITS, QVariant(variantValues));
@@ -54,7 +52,7 @@ void QtSingleWindow::handleSplitterMoved(int, int) {
void QtSingleWindow::restoreSplitters() {
QList<QVariant> variantValues = settings_->getQSettings()->value(SINGLE_WINDOW_SPLITS).toList();
QList<int> intValues;
- foreach (QVariant value, variantValues) {
+ for (auto&& value : variantValues) {
intValues.append(value.toInt());
}
setSizes(intValues);
diff --git a/Swift/QtUI/QtSpellCheckHighlighter.cpp b/Swift/QtUI/QtSpellCheckHighlighter.cpp
index 6565b06..cb467e2 100644
--- a/Swift/QtUI/QtSpellCheckHighlighter.cpp
+++ b/Swift/QtUI/QtSpellCheckHighlighter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -29,7 +29,7 @@ void QtSpellCheckHighlighter::highlightBlock(const QString& text) {
spellingErrorFormat.setUnderlineColor(QColor(Qt::red));
spellingErrorFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline);
- foreach (PositionPair position, misspelledPositions_) {
+ for (auto&& position : misspelledPositions_) {
setFormat(boost::get<0>(position), boost::get<1>(position) - boost::get<0>(position), spellingErrorFormat);
};
}
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp
index 2e9e4cc..b175e5c 100644
--- a/Swift/QtUI/QtStatusWidget.cpp
+++ b/Swift/QtUI/QtStatusWidget.cpp
@@ -144,7 +144,7 @@ void QtStatusWidget::generateList() {
QString text = statusEdit_->text();
newStatusText_ = text;
menu_->clear();
- foreach (StatusShow::Type type, icons_.keys()) {
+ for (const auto& type : icons_.keys()) {
QListWidgetItem* item = new QListWidgetItem(text == "" ? getNoMessage() : text, menu_);
item->setIcon(icons_[type]);
item->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(type)) + ": " + item->text());
@@ -152,7 +152,7 @@ void QtStatusWidget::generateList() {
item->setData(Qt::UserRole, QVariant(type));
}
std::vector<StatusCache::PreviousStatus> previousStatuses = statusCache_->getMatches(Q2PSTRING(text), 8);
- foreach (StatusCache::PreviousStatus savedStatus, previousStatuses) {
+ for (const auto& savedStatus : previousStatuses) {
if (savedStatus.first.empty() || std::find_if(allTypes_.begin(), allTypes_.end(),
savedStatus.second == lambda::_1 && savedStatus.first == lambda::bind(&statusShowTypeToFriendlyName, lambda::_1)) != allTypes_.end()) {
continue;
@@ -163,7 +163,7 @@ void QtStatusWidget::generateList() {
item->setStatusTip(item->toolTip());
item->setData(Qt::UserRole, QVariant(savedStatus.second));
}
- foreach (StatusShow::Type type, icons_.keys()) {
+ for (const auto& type : icons_.keys()) {
if (Q2PSTRING(text) == statusShowTypeToFriendlyName(type)) {
continue;
}
@@ -203,7 +203,7 @@ void QtStatusWidget::handleClicked() {
if (x + width > screenWidth) {
x = screenWidth - width;
}
- //foreach (StatusShow::Type type, allTypes_) {
+ //for (StatusShow::Type type : allTypes_) {
// if (statusEdit_->text() == P2QSTRING(statusShowTypeToFriendlyName(type))) {
statusEdit_->setText("");
// }
diff --git a/Swift/QtUI/QtSubscriptionRequestWindow.cpp b/Swift/QtUI/QtSubscriptionRequestWindow.cpp
index eea13f2..c8c4178 100644
--- a/Swift/QtUI/QtSubscriptionRequestWindow.cpp
+++ b/Swift/QtUI/QtSubscriptionRequestWindow.cpp
@@ -73,7 +73,7 @@ QtSubscriptionRequestWindow::~QtSubscriptionRequestWindow() {
}
QtSubscriptionRequestWindow* QtSubscriptionRequestWindow::getWindow(std::shared_ptr<SubscriptionRequestEvent> event, QWidget* parent) {
- foreach (QtSubscriptionRequestWindow* window, windows_) {
+ for (auto window : windows_) {
if (window->getEvent() == event) {
return window;
}
diff --git a/Swift/QtUI/QtTabbable.cpp b/Swift/QtUI/QtTabbable.cpp
index bad6315..ed0963b 100644
--- a/Swift/QtUI/QtTabbable.cpp
+++ b/Swift/QtUI/QtTabbable.cpp
@@ -11,7 +11,6 @@
#include <QShortcut>
#include <Swiften/Base/Platform.h>
-#include <Swiften/Base/foreach.h>
#include <Swift/QtUI/QtChatTabs.h>
#include <Swift/QtUI/QtUtilities.h>
diff --git a/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp b/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp
index ed36580..02ceb0a 100644
--- a/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp
@@ -50,7 +50,7 @@ void QtTagComboBox::addTag(const QString &id, const QString &label) {
void QtTagComboBox::setTag(const QString &id, bool value) {
QList<QAction*> tagActions = editMenu->actions();
- foreach(QAction* action, tagActions) {
+ for (auto action : tagActions) {
if (action->data() == id) {
action->setChecked(value);
updateDisplayItem();
@@ -61,7 +61,7 @@ void QtTagComboBox::setTag(const QString &id, bool value) {
bool QtTagComboBox::isTagSet(const QString &id) const {
QList<QAction*> tagActions = editMenu->actions();
- foreach(QAction* action, tagActions) {
+ for (auto action : tagActions) {
if (action->data() == id) {
return action->isChecked();
}
@@ -94,7 +94,7 @@ bool QtTagComboBox::event(QEvent* event) {
void QtTagComboBox::updateDisplayItem() {
QList<QAction*> tagActions = editMenu->actions();
QString text = "";
- foreach(QAction* action, tagActions) {
+ for (auto action : tagActions) {
if (action->isChecked()) {
if (text != "") {
text += ", ";
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
index 4043dbc..596006a 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
@@ -90,7 +90,7 @@ void QtVCardAddressField::setupContentWidgets() {
}
void QtVCardAddressField::customCleanup() {
- foreach(QWidget* widget, textFields) {
+ for (auto widget : textFields) {
widget->hide();
textFieldGridLayout->removeWidget(widget);
}
@@ -170,7 +170,7 @@ void QtVCardAddressField::handleEditibleChanged(bool isEditable) {
domesticRadioButton->setVisible(isEditable);
internationalRadioButton->setVisible(isEditable);
- foreach (QWidget* widget, textFields) {
+ for (auto widget : textFields) {
QtResizableLineEdit* lineEdit;
if ((lineEdit = dynamic_cast<QtResizableLineEdit*>(widget))) {
lineEdit->setVisible(isEditable ? true : !lineEdit->text().isEmpty());
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
index ab69cba..9bb6a35 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
@@ -121,7 +121,7 @@ QGridLayout* QtVCardGeneralField::getGridLayout() const {
void QtVCardGeneralField::handleCloseButtonClicked() {
customCleanup();
- foreach(QWidget* widget, childWidgets) {
+ for (auto widget : childWidgets) {
widget->hide();
layout->removeWidget(widget);
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
index 9e303b7..5162c73 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
@@ -78,7 +78,7 @@ bool QtVCardOrganizationField::isEmpty() const {
void QtVCardOrganizationField::setOrganization(const VCard::Organization& organization) {
organizationLineEdit->setText(P2QSTRING(organization.name));
unitsTreeWidget->clear();
- foreach(std::string unit, organization.units) {
+ for (const auto& unit : organization.units) {
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(P2QSTRING(unit)) << "");
item->setFlags(item->flags() | Qt::ItemIsEditable);
unitsTreeWidget->addTopLevelItem(item);
@@ -134,7 +134,7 @@ void QtVCardOrganizationField::handleRowsRemoved(const QModelIndex&, int, int) {
void QtVCardOrganizationField::guaranteeEmptyRow() {
bool hasEmptyRow = false;
QList<QTreeWidgetItem*> rows = unitsTreeWidget->findItems("", Qt::MatchFixedString);
- foreach(QTreeWidgetItem* row, rows) {
+ for (auto row : rows) {
if (row->text(0).isEmpty()) {
hasEmptyRow = true;
}
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp
index c0ce3dc..6fe9397 100644
--- a/Swift/QtUI/QtWebKitChatView.cpp
+++ b/Swift/QtUI/QtWebKitChatView.cpp
@@ -499,7 +499,7 @@ QString QtWebKitChatView::getHighlightSpanStart(const HighlightAction& highlight
QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& message) {
QString result;
- foreach (std::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) {
+ for (const auto& part : message.getParts()) {
std::shared_ptr<ChatWindow::ChatTextMessagePart> textPart;
std::shared_ptr<ChatWindow::ChatURIMessagePart> uriPart;
std::shared_ptr<ChatWindow::ChatEmoticonMessagePart> emoticonPart;
diff --git a/Swift/QtUI/Roster/QtFilterWidget.cpp b/Swift/QtUI/Roster/QtFilterWidget.cpp
index d2e4d09..2e1ead9 100644
--- a/Swift/QtUI/Roster/QtFilterWidget.cpp
+++ b/Swift/QtUI/Roster/QtFilterWidget.cpp
@@ -100,7 +100,7 @@ bool QtFilterWidget::eventFilter(QObject*, QEvent* event) {
void QtFilterWidget::popAllFilters() {
std::vector<RosterFilter*> filters = treeView_->getRoster()->getFilters();
- foreach(RosterFilter* filter, filters) {
+ for (auto filter : filters) {
filters_.push_back(filter);
treeView_->getRoster()->removeFilter(filter);
}
@@ -111,7 +111,7 @@ void QtFilterWidget::popAllFilters() {
void QtFilterWidget::pushAllFilters() {
treeView_->getRoster()->onFilterAdded.disconnect(boost::bind(&QtFilterWidget::handleFilterAdded, this, _1));
treeView_->getRoster()->onFilterRemoved.disconnect(boost::bind(&QtFilterWidget::handleFilterRemoved, this, _1));
- foreach(RosterFilter* filter, filters_) {
+ for (auto filter : filters_) {
treeView_->getRoster()->addFilter(filter);
}
filters_.clear();
diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.cpp b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
index 03c14fd..a12863d 100644
--- a/Swift/QtUI/Roster/QtOccupantListWidget.cpp
+++ b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
@@ -50,7 +50,7 @@ void QtOccupantListWidget::contextMenuEvent(QContextMenuEvent* event) {
}
else {
std::map<QAction*, ChatWindow::OccupantAction> actions;
- foreach (ChatWindow::OccupantAction availableAction, availableOccupantActions_) {
+ for (const auto& availableAction : availableOccupantActions_) {
QString text = "Error: missing string";
switch (availableAction) {
case ChatWindow::Kick: text = tr("Kick user"); break;
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index 3f77c86..ef4d778 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -53,7 +53,7 @@ void RosterModel::reLayout() {
if (!roster_) {
return;
}
- foreach (RosterItem* item, roster_->getRoot()->getDisplayedChildren()) {
+ for (auto item : roster_->getRoot()->getDisplayedChildren()) {
GroupRosterItem* child = dynamic_cast<GroupRosterItem*>(item);
if (!child) continue;
emit itemExpanded(index(child), child->isExpanded());
diff --git a/Swift/QtUI/Roster/RosterTooltip.cpp b/Swift/QtUI/Roster/RosterTooltip.cpp
index 8d467fd..ea4c9cd 100644
--- a/Swift/QtUI/Roster/RosterTooltip.cpp
+++ b/Swift/QtUI/Roster/RosterTooltip.cpp
@@ -122,7 +122,7 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) {
// star | name | content
QString currentBlock;
- foreach (const VCard::Telephone& tel, vcard->getTelephones()) {
+ for (const auto& tel : vcard->getTelephones()) {
QString type = tel.isFax ? QObject::tr("Fax") : QObject::tr("Telephone");
QString field = buildVCardField(tel.isPreferred, type, htmlEscape(P2QSTRING(tel.number)));
if (tel.isPreferred) {
@@ -134,7 +134,7 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) {
summary += currentBlock;
currentBlock = "";
- foreach (const VCard::EMailAddress& mail, vcard->getEMailAddresses()) {
+ for (const auto& mail : vcard->getEMailAddresses()) {
QString field = buildVCardField(mail.isPreferred, QObject::tr("E-Mail"), htmlEscape(P2QSTRING(mail.address)));
if (mail.isPreferred) {
currentBlock = field;
@@ -145,14 +145,14 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) {
summary += currentBlock;
currentBlock = "";
- foreach (const VCard::Organization& org, vcard->getOrganizations()) {
+ for (const auto& org : vcard->getOrganizations()) {
QString field = buildVCardField(false, QObject::tr("Organization"), htmlEscape(P2QSTRING(org.name)));
currentBlock += field;
}
summary += currentBlock;
currentBlock = "";
- foreach(const std::string& title, vcard->getTitles()) {
+ for (const auto& title : vcard->getTitles()) {
QString field = buildVCardField(false, QObject::tr("Title"), htmlEscape(P2QSTRING(title)));
currentBlock += field;
}
diff --git a/Swift/QtUI/UserSearch/ContactListModel.cpp b/Swift/QtUI/UserSearch/ContactListModel.cpp
index 376d3b1..6ef85d7 100644
--- a/Swift/QtUI/UserSearch/ContactListModel.cpp
+++ b/Swift/QtUI/UserSearch/ContactListModel.cpp
@@ -15,7 +15,6 @@
#include <QMimeData>
#include <Swiften/Base/Path.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/StatusShow.h>
#include <Swift/QtUI/QtResourceHelper.h>
diff --git a/Swift/QtUI/UserSearch/QtContactListWidget.cpp b/Swift/QtUI/UserSearch/QtContactListWidget.cpp
index 1dbfc1f..73a8482 100644
--- a/Swift/QtUI/UserSearch/QtContactListWidget.cpp
+++ b/Swift/QtUI/UserSearch/QtContactListWidget.cpp
@@ -85,8 +85,8 @@ bool QtContactListWidget::isFull() const {
void QtContactListWidget::updateContacts(const std::vector<Contact::ref>& contactUpdates) {
std::vector<Contact::ref> contacts = contactListModel_->getList();
- foreach(const Contact::ref& contactUpdate, contactUpdates) {
- for(auto& contact : contacts) {
+ for (const auto& contactUpdate : contactUpdates) {
+ for (auto&& contact : contacts) {
if (contactUpdate->jid == contact->jid) {
contact = contactUpdate;
break;
diff --git a/Swift/QtUI/WinUIHelpers.cpp b/Swift/QtUI/WinUIHelpers.cpp
index 4898916..ec39c38 100644
--- a/Swift/QtUI/WinUIHelpers.cpp
+++ b/Swift/QtUI/WinUIHelpers.cpp
@@ -19,8 +19,6 @@
#include <memory>
-#include <Swiften/Base/foreach.h>
-
namespace Swift {
void WinUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std::vector<Certificate::ref>& chain) {