diff options
Diffstat (limited to 'Swift/Controllers/PreviousStatusStore.cpp')
-rw-r--r-- | Swift/Controllers/PreviousStatusStore.cpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp index 5886bdf..0b2d437 100644 --- a/Swift/Controllers/PreviousStatusStore.cpp +++ b/Swift/Controllers/PreviousStatusStore.cpp @@ -1,12 +1,10 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "PreviousStatusStore.h" - -#include "Swiften/Base/foreach.h" +#include <Swift/Controllers/PreviousStatusStore.h> namespace Swift { @@ -19,35 +17,35 @@ PreviousStatusStore::~PreviousStatusStore() { } void PreviousStatusStore::addStatus(StatusShow::Type status, const std::string& message) { - //FIXME: remove old entries - store_.push_back(TypeStringPair(status, message)); + //FIXME: remove old entries + store_.push_back(TypeStringPair(status, message)); } std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const std::string& message) { - std::vector<TypeStringPair> suggestions; - suggestions.push_back(TypeStringPair(status, message)); - return suggestions; + std::vector<TypeStringPair> suggestions; + suggestions.push_back(TypeStringPair(status, message)); + return suggestions; } std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const std::string& message) { - std::vector<TypeStringPair> suggestions; - foreach (TypeStringPair status, store_) { - if (status.second == message) { - suggestions.clear(); - suggestions.push_back(status); - break; - } else if (status.second.find(message) != std::string::npos) { - suggestions.push_back(status); - } - } - if (suggestions.empty()) { - TypeStringPair suggestion(StatusShow::Online, message); - suggestions.push_back(suggestion); - } - if (suggestions.size() == 1) { - suggestions = exactMatchSuggestions(suggestions[0].first, suggestions[0].second); - } - return suggestions; + std::vector<TypeStringPair> suggestions; + for (auto&& status : store_) { + if (status.second == message) { + suggestions.clear(); + suggestions.push_back(status); + break; + } else if (status.second.find(message) != std::string::npos) { + suggestions.push_back(status); + } + } + if (suggestions.empty()) { + TypeStringPair suggestion(StatusShow::Online, message); + suggestions.push_back(suggestion); + } + if (suggestions.size() == 1) { + suggestions = exactMatchSuggestions(suggestions[0].first, suggestions[0].second); + } + return suggestions; } } |