Crossfire Server, Trunk
TreasurePanel.cpp
Go to the documentation of this file.
1 #include "TreasurePanel.h"
2 #include <QMimeData>
3 #include "assets.h"
4 #include "AssetsManager.h"
7 #include "MimeUtils.h"
8 #include "HelpManager.h"
9 
10 TreasurePanel::TreasurePanel(QWidget* parent) : AssetWrapperPanel(parent) {
11  addSpinBox(tr("Chance:"), "chance", 0, 255, false);
12  addSpinBox(tr("Magic:"), "magic", 0, 255, false);
13  addSpinBox(tr("Count:"), "nrof", 0, 65535, false);
14  myList = addTreasureList(tr("Treasure:"), "list", false);
15  myArch = addArchetype(tr("Archetype:"), "arch");
17  setAcceptDrops(true);
18  HelpManager::setHelpId(this, "treasures");
19 }
20 
21 void TreasurePanel::dragEnterEvent(QDragEnterEvent *event) {
22  if (event->mimeData()->hasFormat(MimeUtils::Archetype) || event->mimeData()->hasFormat(MimeUtils::TreasureList)) {
23  event->acceptProposedAction();
24  }
25 }
26 
27 void TreasurePanel::dragMoveEvent(QDragMoveEvent *event) {
28  event->acceptProposedAction();
29 }
30 
31 void TreasurePanel::dropEvent(QDropEvent *event) {
32  auto archs = MimeUtils::extract(event->mimeData(), MimeUtils::Archetype, getManager()->archetypes());
33  if (!archs.empty()) {
34  myArch->setArch(archs.front());
35  event->acceptProposedAction();
36  }
37  auto lists = MimeUtils::extract(event->mimeData(), MimeUtils::TreasureList, getManager()->treasures());
38  if (!lists.empty()) {
39  myList->setList(lists.front());
40  event->acceptProposedAction();
41  }
42 }
AssetWrapperPanel
Definition: AssetWrapperPanel.h:16
MimeUtils::Archetype
static const char * Archetype
Definition: MimeUtils.h:12
TreasurePanel::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *event) override
Definition: TreasurePanel.cpp:21
TreasurePanel::myList
TreasureListComboBox * myList
Definition: TreasurePanel.h:19
AssetsManager.h
lists
ignore_list ** lists
Definition: gridarta-types-convert.c:73
TreasureListComboBox.h
TreasureListComboBox::setList
void setList(const treasurelist *list)
Definition: TreasureListComboBox.cpp:25
getManager
AssetsManager * getManager()
Definition: assets.cpp:333
AssetWrapperPanel::addSpinBox
QSpinBox * addSpinBox(const QString &label, const char *property, int min=0, int max=100, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:74
AssetWrapperPanel::addArchetype
ArchetypeComboBox * addArchetype(const QString &label, const char *property, bool readOnly=false, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:96
MimeUtils::TreasureList
static const char * TreasureList
Definition: MimeUtils.h:13
HelpManager.h
AssetWrapperPanel::addBottomFiller
void addBottomFiller()
Definition: AssetWrapperPanel.cpp:106
MimeUtils::extract
static QList< T * > extract(const QMimeData *data, const QString &mime, AssetsCollection< T > *assets)
Definition: MimeUtils.h:18
HelpManager::setHelpId
static void setHelpId(QWidget *widget, const QString &id)
Definition: HelpManager.cpp:46
TreasurePanel.h
ArchetypeComboBox.h
assets.h
TreasurePanel::dragMoveEvent
virtual void dragMoveEvent(QDragMoveEvent *event) override
Definition: TreasurePanel.cpp:27
AssetWrapperPanel::addTreasureList
TreasureListComboBox * addTreasureList(const QString &label, const char *property, bool readOnly=true, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:86
MimeUtils.h
animate.event
event
DIALOGCHECK MINARGS 1 MAXARGS 2
Definition: animate.py:17
ArchetypeComboBox::setArch
void setArch(const archetype *arch)
Definition: ArchetypeComboBox.cpp:29
TreasurePanel::myArch
ArchetypeComboBox * myArch
Definition: TreasurePanel.h:18
TreasurePanel::dropEvent
virtual void dropEvent(QDropEvent *event) override
Definition: TreasurePanel.cpp:31
TreasurePanel::TreasurePanel
TreasurePanel(QWidget *parent)
Definition: TreasurePanel.cpp:10