townspellswidget.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "baseinspectoritemdelegate.h"
  13. #include "../../lib/mapObjects/CGTownInstance.h"
  14. namespace Ui {
  15. class TownSpellsWidget;
  16. }
  17. class TownSpellsWidget : public QDialog
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit TownSpellsWidget(CGTownInstance &, QWidget * parent = nullptr);
  22. ~TownSpellsWidget();
  23. void obtainData();
  24. void commitChanges();
  25. private slots:
  26. void on_customizeSpells_toggled(bool checked);
  27. private:
  28. Ui::TownSpellsWidget * ui;
  29. CGTownInstance & town;
  30. std::array<QListWidget *, 5> possibleSpellLists;
  31. std::array<QListWidget *, 5> requiredSpellLists;
  32. void resetSpells();
  33. void initSpellLists();
  34. };
  35. class TownSpellsDelegate : public BaseInspectorItemDelegate
  36. {
  37. Q_OBJECT
  38. public:
  39. using BaseInspectorItemDelegate::BaseInspectorItemDelegate;
  40. TownSpellsDelegate(CGTownInstance&);
  41. QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex& index) const override;
  42. void setEditorData(QWidget * editor, const QModelIndex & index) const override;
  43. void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
  44. void updateModelData(QAbstractItemModel * model, const QModelIndex & index) const override;
  45. private:
  46. CGTownInstance& town;
  47. };