summaryrefslogtreecommitdiff
path: root/src/spellmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-01 23:18:52 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-02 23:50:33 +0300
commit1cafda1147c06a647e3d3f1e3f986d7296ccbd08 (patch)
tree920e60dbd1feb3657edc130aa6a4ba4af562454a /src/spellmanager.cpp
parentb210f1b896039b4909ca5fb7abea8b437896a77a (diff)
downloadmv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.gz
mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.bz2
mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.tar.xz
mv-1cafda1147c06a647e3d3f1e3f986d7296ccbd08.zip
add support for drag and drop in spells window.
Diffstat (limited to 'src/spellmanager.cpp')
-rw-r--r--src/spellmanager.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index bad5cd78b..83fb746a7 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -393,3 +393,37 @@ std::string SpellManager::autoComplete(const std::string &partName) const
}
return newName;
}
+
+void SpellManager::swap(const int id1, const int id2)
+{
+ TextCommand *const spell1 = mSpells[id1];
+ TextCommand *const spell2 = mSpells[id2];
+ // swap in map
+ mSpells[id1] = spell2;
+ mSpells[id2] = spell1;
+
+ // swap id
+ int tmp = spell1->getId();
+ spell1->setId(spell2->getId());
+ spell2->setId(tmp);
+
+ // swap in vector
+ const int sz = SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS;
+ for (unsigned f = 0; f < sz; f++)
+ {
+ const TextCommand *const spellA = mSpellsVector[f];
+ if (spellA == spell1)
+ {
+ for (unsigned d = 0; d < sz; d++)
+ {
+ const TextCommand *const spellB = mSpellsVector[d];
+ if (spellB == spell2)
+ {
+ mSpellsVector[f] = spell2;
+ mSpellsVector[d] = spell1;
+ return;
+ }
+ }
+ }
+ }
+}