heroskillswidget.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * heroskillswidget.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/CGHeroInstance.h"
  14. namespace Ui {
  15. class HeroSkillsWidget;
  16. }
  17. class HeroSkillsWidget : public QDialog
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit HeroSkillsWidget(CGHeroInstance &, QWidget *parent = nullptr);
  22. ~HeroSkillsWidget();
  23. void obtainData();
  24. void commitChanges();
  25. private slots:
  26. void on_addButton_clicked();
  27. void on_removeButton_clicked();
  28. void on_checkBox_toggled(bool checked);
  29. private:
  30. Ui::HeroSkillsWidget *ui;
  31. CGHeroInstance & hero;
  32. std::set<int> occupiedSkills;
  33. };
  34. class HeroSkillsDelegate : public BaseInspectorItemDelegate
  35. {
  36. Q_OBJECT
  37. public:
  38. using BaseInspectorItemDelegate::BaseInspectorItemDelegate;
  39. HeroSkillsDelegate(CGHeroInstance &);
  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. void updateModelData(QAbstractItemModel * model, const QModelIndex & index) const override;
  44. private:
  45. CGHeroInstance & hero;
  46. };