townspellswidget.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * townspellswidget.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include <QDialog>
  12. #include "../../lib/mapObjects/CGTownInstance.h"
  13. namespace Ui {
  14. class TownSpellsWidget;
  15. }
  16. class TownSpellsWidget : public QDialog
  17. {
  18. Q_OBJECT
  19. public:
  20. explicit TownSpellsWidget(CGTownInstance &, QWidget * parent = nullptr);
  21. ~TownSpellsWidget();
  22. void obtainData();
  23. void commitChanges();
  24. private slots:
  25. void on_customizeSpells_toggled(bool checked);
  26. private:
  27. Ui::TownSpellsWidget * ui;
  28. CGTownInstance & town;
  29. std::array<QListWidget *, 5> possibleSpellLists;
  30. std::array<QListWidget *, 5> requiredSpellLists;
  31. void resetSpells();
  32. void initSpellLists();
  33. };
  34. class TownSpellsDelegate : public QStyledItemDelegate
  35. {
  36. Q_OBJECT
  37. public:
  38. using QStyledItemDelegate::QStyledItemDelegate;
  39. TownSpellsDelegate(CGTownInstance&);
  40. QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex& index) const override;
  41. void setEditorData(QWidget * editor, const QModelIndex & index) const override;
  42. void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
  43. private:
  44. CGTownInstance& town;
  45. };