summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-07 18:18:59 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-07 18:19:27 (GMT)
commitd1837d06c5d655de759bbfcc66711a71c92296ad (patch)
tree31f93f55949efdc6047d707d5a32f14a392043e8 /Swift/Controllers/RosterGroupExpandinessPersister.cpp
parent3db6fa2e985a286c3b53dc621ba164023272cb60 (diff)
downloadswift-d1837d06c5d655de759bbfcc66711a71c92296ad.zip
swift-d1837d06c5d655de759bbfcc66711a71c92296ad.tar.bz2
Moved Swift-specific roster code out of Swiften.
Diffstat (limited to 'Swift/Controllers/RosterGroupExpandinessPersister.cpp')
-rw-r--r--Swift/Controllers/RosterGroupExpandinessPersister.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/Swift/Controllers/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/RosterGroupExpandinessPersister.cpp
deleted file mode 100644
index d532fcb..0000000
--- a/Swift/Controllers/RosterGroupExpandinessPersister.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swift/Controllers/RosterGroupExpandinessPersister.h"
-
-#include <boost/bind.hpp>
-#include <vector>
-
-#include "Swiften/Roster/GroupRosterItem.h"
-
-namespace Swift {
-
-RosterGroupExpandinessPersister::RosterGroupExpandinessPersister(Roster* roster, SettingsProvider* settings) : roster_(roster), settings_(settings) {
- load();
- roster_->onGroupAdded.connect(boost::bind(&RosterGroupExpandinessPersister::handleGroupAdded, this, _1));
-}
-
-void RosterGroupExpandinessPersister::handleGroupAdded(GroupRosterItem* group) {
- if (collapsed_.find(group->getDisplayName()) != collapsed_.end()) {
- group->setExpanded(false);
- } else {
- group->setExpanded(true);
- }
- group->onExpandedChanged.connect(boost::bind(&RosterGroupExpandinessPersister::handleExpandedChanged, this, group, _1));
-}
-
-void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* group, bool expanded) {
- if (expanded) {
- String displayName = group->getDisplayName();
- //collapsed_.erase(std::remove(collapsed_.begin(), collapsed_.end(), displayName), collapsed_.end());
- collapsed_.erase(displayName);
- } else {
- collapsed_.insert(group->getDisplayName());
- }
- save();
-}
-
-void RosterGroupExpandinessPersister::save() {
- String setting;
- foreach (const String& group, collapsed_) {
- if (!setting.isEmpty()) {
- setting += "\n";
- }
- setting += group;
- }
- settings_->storeString(SettingPath, setting);
-}
-
-void RosterGroupExpandinessPersister::load() {
- String saved = settings_->getStringSetting(SettingPath);
- std::vector<String> collapsed = saved.split('\n');
- collapsed_.insert(collapsed.begin(), collapsed.end());
-}
-
-const String RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness";
-
-}