towneventswidget.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * towneventswidget.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 "../lib/mapping/CMapDefines.h"
  14. #include "../lib/mapObjects/CGTownInstance.h"
  15. #include "../mapcontroller.h"
  16. namespace Ui {
  17. class TownEventsWidget;
  18. }
  19. class TownEventsWidget : public QDialog
  20. {
  21. Q_OBJECT
  22. public:
  23. explicit TownEventsWidget(CGTownInstance &, QWidget * parent = nullptr);
  24. ~TownEventsWidget();
  25. void obtainData();
  26. void commitChanges(MapController & controller);
  27. private slots:
  28. void on_timedEventAdd_clicked();
  29. void on_timedEventRemove_clicked();
  30. void on_eventsList_itemActivated(QListWidgetItem * item);
  31. private:
  32. Ui::TownEventsWidget * ui;
  33. CGTownInstance & town;
  34. };
  35. class TownEventsDelegate : public QStyledItemDelegate
  36. {
  37. Q_OBJECT
  38. public:
  39. using QStyledItemDelegate::QStyledItemDelegate;
  40. TownEventsDelegate(CGTownInstance &, MapController &);
  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. private:
  45. CGTownInstance & town;
  46. MapController & controller;
  47. };