rewardswidget.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * rewardswidget.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 "../StdInc.h"
  12. #include <QDialog>
  13. #include "baseinspectoritemdelegate.h"
  14. #include "../lib/mapObjects/CRewardableObject.h"
  15. namespace Ui {
  16. class RewardsWidget;
  17. }
  18. class RewardsWidget : public QDialog
  19. {
  20. Q_OBJECT
  21. public:
  22. explicit RewardsWidget(CMap &, CRewardableObject &, QWidget *parent = nullptr);
  23. ~RewardsWidget();
  24. void obtainData();
  25. bool commitChanges();
  26. private slots:
  27. void on_addVisitInfo_clicked();
  28. void on_removeVisitInfo_clicked();
  29. void on_selectMode_currentIndexChanged(int index);
  30. void on_resetPeriod_valueChanged(int arg1);
  31. void on_visitInfoList_itemSelectionChanged();
  32. void on_visitInfoList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
  33. void on_rCreatureAdd_clicked();
  34. void on_rCreatureRemove_clicked();
  35. void on_lCreatureAdd_clicked();
  36. void on_lCreatureRemove_clicked();
  37. void on_castSpellCheck_toggled(bool checked);
  38. void on_bonusAdd_clicked();
  39. void on_bonusRemove_clicked();
  40. private:
  41. void saveCurrentVisitInfo(int index);
  42. void loadCurrentVisitInfo(int index);
  43. void onCreatureAdd(QTableWidget * listWidget, QComboBox * comboWidget, QSpinBox * spinWidget);
  44. Ui::RewardsWidget *ui;
  45. CRewardableObject & object;
  46. CMap & map;
  47. };
  48. class RewardsDelegate : public BaseInspectorItemDelegate
  49. {
  50. Q_OBJECT
  51. public:
  52. RewardsDelegate(CMap &, CRewardableObject &);
  53. using BaseInspectorItemDelegate::BaseInspectorItemDelegate;
  54. void setEditorData(QWidget *editor, const QModelIndex &index) const override;
  55. void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
  56. QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
  57. void updateModelData(QAbstractItemModel * model, const QModelIndex & index) const override;
  58. private:
  59. CRewardableObject & object;
  60. CMap & map;
  61. };