herospellwidget.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * herospellwidget.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 HeroSpellWidget;
  16. }
  17. class HeroSpellWidget : public QDialog
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit HeroSpellWidget(CGHeroInstance &, QWidget * parent = nullptr);
  22. ~HeroSpellWidget();
  23. void obtainData();
  24. void commitChanges();
  25. private slots:
  26. void on_customizeSpells_toggled(bool checked);
  27. void on_filter_textChanged(const QString & keyword);
  28. private:
  29. Ui::HeroSpellWidget * ui;
  30. CGHeroInstance & hero;
  31. void initSpellLists();
  32. void showItemIfMatches(const QString & match);
  33. void hideItemIfMatches(const QString & match);
  34. void toggleHiddenForItemIfMatches(const QString & match, bool hidden);
  35. void hideEmptySpellLists();
  36. };
  37. class HeroSpellDelegate : public BaseInspectorItemDelegate
  38. {
  39. Q_OBJECT
  40. public:
  41. using BaseInspectorItemDelegate::BaseInspectorItemDelegate;
  42. HeroSpellDelegate(CGHeroInstance &);
  43. QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex& index) const override;
  44. void setEditorData(QWidget * editor, const QModelIndex & index) const override;
  45. void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
  46. void updateModelData(QAbstractItemModel * model, const QModelIndex & index) const override;
  47. private:
  48. CGHeroInstance & hero;
  49. };