summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-07-16 13:47:27 (GMT)
committerSwift Review <review@swift.im>2014-07-29 09:48:04 (GMT)
commit4ab20a452e0af56c7ee210f863aeae31450954cc (patch)
treebe0a3777eb7bd814e4c6b9660a77dbb8fafb90d3 /Swift/Controllers
parent9c5c731845881996f45b32ea6de12e0647f4634d (diff)
downloadswift-4ab20a452e0af56c7ee210f863aeae31450954cc.zip
swift-4ab20a452e0af56c7ee210f863aeae31450954cc.tar.bz2
Add ability to reorder highlight rules list.
Test-Information: Add several highlight rules. Verify that the up and down buttons reorder the items in the list. Change-Id: I6272799e2b2767ddfa01068c2ffcd1fb4651e11d
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/HighlightManager.cpp8
-rw-r--r--Swift/Controllers/HighlightManager.h8
2 files changed, 14 insertions, 2 deletions
diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp
index eac562f..ca0567e 100644
--- a/Swift/Controllers/HighlightManager.cpp
+++ b/Swift/Controllers/HighlightManager.cpp
@@ -103,6 +103,14 @@ void HighlightManager::removeRule(int index)
rules_->list_.erase(rules_->list_.begin() + index);
}
+void HighlightManager::swapRules(const size_t first, const size_t second) {
+ assert(first < rules_->getSize());
+ assert(second < rules_->getSize());
+ const HighlightRule swap = rules_->getRule(first);
+ rules_->setRule(first, rules_->getRule(second));
+ rules_->setRule(second, swap);
+}
+
void HighlightManager::storeSettings()
{
storingSettings_ = true; // don't reload settings while saving
diff --git a/Swift/Controllers/HighlightManager.h b/Swift/Controllers/HighlightManager.h
index 3da72eb..07a3fe3 100644
--- a/Swift/Controllers/HighlightManager.h
+++ b/Swift/Controllers/HighlightManager.h
@@ -31,10 +31,13 @@ namespace Swift {
friend class HighlightManager;
size_t getSize() const { return list_.size(); }
const HighlightRule& getRule(const size_t index) const { return list_[index]; }
- void addRule(const HighlightRule &rule) { list_.push_back(rule); }
- void combineRules(const HighlightRulesList &rhs) {
+ void addRule(const HighlightRule& rule) { list_.push_back(rule); }
+ void combineRules(const HighlightRulesList& rhs) {
list_.insert(list_.end(), rhs.list_.begin(), rhs.list_.end());
}
+ void setRule(const size_t index, const HighlightRule& rule) {
+ list_[index] = rule;
+ }
private:
std::vector<HighlightRule> list_;
};
@@ -49,6 +52,7 @@ namespace Swift {
void setRule(int index, const HighlightRule& rule);
void insertRule(int index, const HighlightRule& rule);
void removeRule(int index);
+ void swapRules(const size_t first, const size_t second);
void storeSettings();
void loadSettings();