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/QtUI/QtAffiliationEditor.cpp | |
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/QtUI/QtAffiliationEditor.cpp')
-rw-r--r-- | Swift/QtUI/QtAffiliationEditor.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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 @@ -10,61 +10,61 @@ #include <QListWidgetItem> #include <Swift/QtUI/QtSwiftUtil.h> namespace Swift { QtAffiliationEditor::QtAffiliationEditor(QWidget* parent) : QDialog(parent){ ui_.setupUi(this); setAttribute(Qt::WA_DeleteOnClose); connect(ui_.affiliation, SIGNAL(currentIndexChanged(int)), this, SLOT(handleCurrentIndexChanged(int))); connect(ui_.addJID, SIGNAL(clicked()), this, SLOT(handleAddClicked())); connect(ui_.removeJID, SIGNAL(clicked()), this, SLOT(handleRemoveClicked())); } QtAffiliationEditor::~QtAffiliationEditor() { } void QtAffiliationEditor::setAffiliations(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids) { affiliations_[affiliation] = jids; if (affiliationFromIndex(ui_.affiliation->currentIndex()) == affiliation) { handleCurrentIndexChanged(ui_.affiliation->currentIndex()); } } const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& QtAffiliationEditor::getChanges() const { return changes_; } 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())); } } void QtAffiliationEditor::handleAddClicked() { bool ok = false; JID jid = JID(Q2PSTRING(QInputDialog::getText(this, tr("Add User"), tr("Added User's Address:"), QLineEdit::Normal, "", &ok))); if (ok && jid.isValid()) { //FIXME: validation MUCOccupant::Affiliation affiliation = affiliationFromIndex(ui_.affiliation->currentIndex()); changes_.push_back(ChangePair(affiliation, jid)); ui_.list->addItem(P2QSTRING(jid.toString())); affiliations_[affiliation].push_back(jid); } } void QtAffiliationEditor::handleRemoveClicked() { QListWidgetItem* item = ui_.list->currentItem(); if (item) { JID jid(Q2PSTRING(item->text())); changes_.push_back(ChangePair(MUCOccupant::NoAffiliation, jid)); std::vector<JID>& jids = affiliations_[affiliationFromIndex(ui_.affiliation->currentIndex())]; jids.erase(std::remove(jids.begin(), jids.end(), jid), jids.end()); handleCurrentIndexChanged(ui_.affiliation->currentIndex()); } } MUCOccupant::Affiliation QtAffiliationEditor::affiliationFromIndex(int affiliation) { switch (affiliation) { case 0: return MUCOccupant::Owner; |