From 2eb15d389f85e300cb124b990ebbf2663acaa637 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Jul 2013 15:48:02 +0300 Subject: add support for drag and drop from/to shortcuts window. --- src/itemshortcut.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/itemshortcut.cpp') diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 499b8e5b8..0ca90e9be 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -202,8 +202,6 @@ void ItemShortcut::setItemSelected(const Item *const item) { if (item) { -// logger->log("set selected id: %d", item->getId()); -// logger->log("set selected color: %d", item->getColor()); mItemSelected = item->getId(); mItemColorSelected = item->getColor(); } @@ -220,3 +218,28 @@ void ItemShortcut::setItem(const int index) mItemColors[index] = mItemColorSelected; save(); } + +void ItemShortcut::setItem(const int index, const int item, + const unsigned char color) +{ + mItems[index] = item; + mItemColors[index] = color; + save(); +} + +void ItemShortcut::swap(const int index1, const int index2) +{ + if (index1 < 0 || index2 < 0 || (unsigned int)index1 >= SHORTCUT_ITEMS + || (unsigned int)index2 >= SHORTCUT_ITEMS) + { + return; + } + + const int tmpItem = mItems[index1]; + mItems[index1] = mItems[index2]; + mItems[index2] = tmpItem; + const unsigned char tmpColor = mItemColors[index1]; + mItemColors[index1] = mItemColors[index2]; + mItemColors[index2] = tmpColor; + save(); +} -- cgit v1.2.3-60-g2f50