heroartifactswidget.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * heroartifactswidget.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 HeroArtifactsWidget;
  16. }
  17. class HeroArtifactsWidget : public QDialog
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit HeroArtifactsWidget(CGHeroInstance &, QWidget *parent = nullptr);
  22. ~HeroArtifactsWidget();
  23. void obtainData();
  24. void commitChanges();
  25. private slots:
  26. void onSaveArtifact(int32_t artifactIndex, ArtifactPosition slot);
  27. void on_addButton_clicked();
  28. void on_removeButton_clicked();
  29. private:
  30. enum Column
  31. {
  32. SLOT, ARTIFACT
  33. };
  34. Ui::HeroArtifactsWidget * ui;
  35. CGHeroInstance & hero;
  36. CArtifactFittingSet fittingSet;
  37. void addArtifactToTable(int32_t artifactIndex, ArtifactPosition slot);
  38. };
  39. class HeroArtifactsDelegate : public BaseInspectorItemDelegate
  40. {
  41. Q_OBJECT
  42. public:
  43. using BaseInspectorItemDelegate::BaseInspectorItemDelegate;
  44. HeroArtifactsDelegate(CGHeroInstance &);
  45. QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
  46. void setEditorData(QWidget * editor, const QModelIndex & index) const override;
  47. void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
  48. void updateModelData(QAbstractItemModel * model, const QModelIndex & index) const override;
  49. private:
  50. CGHeroInstance & hero;
  51. };