From 0204a75a049d6819719cf41ac92116012ed50d86 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Sun, 14 Aug 2016 20:50:08 +0300
Subject: Allow drag cast type from skills window into shortcuts.

---
 src/dragdrop.h                            | 12 ++++++++++++
 src/gui/shortcut/itemshortcut.h           |  4 ++++
 src/gui/widgets/itemshortcutcontainer.cpp |  5 +++++
 src/gui/widgets/skilllistbox.h            |  3 +++
 4 files changed, 24 insertions(+)

(limited to 'src')

diff --git a/src/dragdrop.h b/src/dragdrop.h
index d684110ee..729a96bc4 100644
--- a/src/dragdrop.h
+++ b/src/dragdrop.h
@@ -42,6 +42,7 @@ class DragDrop final
                  const DragDropSourceT source) :
             mItemImage(item ? item->getImage() : nullptr),
             mText(),
+            mItemData(),
             mSource(source),
             mItem(item ? item->getId() : 0),
             mSelItem(0),
@@ -73,6 +74,12 @@ class DragDrop final
         Image *getItemImage()
         { return mItemImage; }
 
+        void setItemData(const std::string &data)
+        { mItemData = data; }
+
+        std::string getItemData()
+        { return mItemData; }
+
         DragDropSourceT getSource() const
         { return mSource; }
 
@@ -83,6 +90,7 @@ class DragDrop final
             if (mItemImage)
                 mItemImage->decRef();
 
+            mItemData.clear();
             mText.clear();
             if (item)
             {
@@ -113,6 +121,7 @@ class DragDrop final
                 mItemImage->decRef();
             mItem = 0;
             mItemColor = ItemColor_one;
+            mItemData.clear();
 
             if (command)
             {
@@ -151,6 +160,7 @@ class DragDrop final
             mItemImage = nullptr;
             mSource = DragDropSource::Empty;
             mTag = -1;
+            mItemData.clear();
             if (info)
             {
                 const SkillData *const data = info->data;
@@ -178,6 +188,7 @@ class DragDrop final
             mItemImage = nullptr;
             mSource = DragDropSource::Empty;
             mText.clear();
+            mItemData.clear();
             mTag = -1;
         }
 
@@ -241,6 +252,7 @@ class DragDrop final
     private:
         Image *mItemImage;
         std::string mText;
+        std::string mItemData;
         DragDropSourceT mSource;
         int mItem;
         int mSelItem;
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
index 4f223478f..2f1b10569 100644
--- a/src/gui/shortcut/itemshortcut.h
+++ b/src/gui/shortcut/itemshortcut.h
@@ -73,6 +73,10 @@ class ItemShortcut final
         ItemColor getItemColor(const int index) const A_WARN_UNUSED
         { return mItemColors[index]; }
 
+        void setItemData(const int index,
+                         const std::string &data)
+        { mItemData[index] = data; }
+
         std::string getItemData(const int index) const A_WARN_UNUSED
         { return mItemData[index]; }
 
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 7b6df7644..60519699e 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -432,12 +432,15 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
                     = skillDialog->getSkillByItem(itemId);
                 if (skill)
                 {
+                    const std::string itemData = selShortcut->getItemData(
+                        index);
                     selShortcut->removeItem(index);
                     dragDrop.dragSkill(skill,
                         DragDropSource::Shortcuts,
                         index);
                     dragDrop.setItem(itemId);
                     dragDrop.setItemColor(itemColor);
+                    dragDrop.setItemData(itemData);
                 }
                 else
                 {
@@ -522,6 +525,8 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
             }
             else
             {
+                selShortcut->setItemData(index,
+                    dragDrop.getItemData());
                 selShortcut->setItem(index, dragDrop.getItem(),
                     dragDrop.getItemColor());
             }
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 533d12b5e..ab45c5122 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -220,6 +220,9 @@ class SkillListBox final : public ListBox
                             return;
                         dragDrop.dragSkill(skill, DragDropSource::Skills);
                         dragDrop.setItem(skill->id + SKILL_MIN_ID);
+                        // +++ using only cast type in data
+                        dragDrop.setItemData(toString(CAST_S32(
+                            skill->customCastType)));
                     }
                     ListBox::mouseDragged(event);
                 }
-- 
cgit v1.2.3-70-g09d2