mainwindow.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #pragma once
  2. #include <QMainWindow>
  3. #include <QGraphicsScene>
  4. #include <QStandardItemModel>
  5. #include "mapcontroller.h"
  6. #include "../lib/Terrain.h"
  7. class CMap;
  8. class ObjectBrowser;
  9. class CGObjectInstance;
  10. namespace Ui
  11. {
  12. class MainWindow;
  13. const QString teamName = "VCMI Team";
  14. const QString appName = "VCMI Map Editor";
  15. }
  16. class MainWindow : public QMainWindow
  17. {
  18. Q_OBJECT
  19. const QString mainWindowSizeSetting = "MainWindow/Size";
  20. const QString mainWindowPositionSetting = "MainWindow/Position";
  21. public:
  22. explicit MainWindow(QWidget *parent = nullptr);
  23. ~MainWindow();
  24. void initializeMap(bool isNew);
  25. void saveMap();
  26. bool openMap(const QString &);
  27. MapView * mapView();
  28. void loadObjectsTree();
  29. void setStatusMessage(const QString & status);
  30. int getMapLevel() const {return mapLevel;}
  31. MapController controller;
  32. private slots:
  33. void on_actionOpen_triggered();
  34. void on_actionSave_as_triggered();
  35. void on_actionNew_triggered();
  36. void on_actionLevel_triggered();
  37. void on_actionSave_triggered();
  38. void on_actionErase_triggered();
  39. void on_actionUndo_triggered();
  40. void on_actionRedo_triggered();
  41. void on_actionPass_triggered(bool checked);
  42. void on_actionGrid_triggered(bool checked);
  43. void on_toolBrush_clicked(bool checked);
  44. void on_toolArea_clicked(bool checked);
  45. void terrainButtonClicked(TerrainId terrain);
  46. void roadOrRiverButtonClicked(ui8 type, bool isRoad);
  47. void on_toolErase_clicked();
  48. void on_treeView_activated(const QModelIndex &index);
  49. void on_terrainFilterCombo_currentTextChanged(const QString &arg1);
  50. void on_filter_textChanged(const QString &arg1);
  51. void on_actionFill_triggered();
  52. void on_toolBrush2_clicked(bool checked);
  53. void on_toolBrush4_clicked(bool checked);
  54. void on_inspectorWidget_itemChanged(QTableWidgetItem *item);
  55. void on_actionMapSettings_triggered();
  56. void on_actionPlayers_settings_triggered();
  57. void on_actionValidate_triggered();
  58. void on_actionUpdate_appearance_triggered();
  59. void on_actionRecreate_obstacles_triggered();
  60. void switchDefaultPlayer(const PlayerColor &);
  61. public slots:
  62. void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
  63. void loadInspector(CGObjectInstance * obj, bool switchTab);
  64. void mapChanged();
  65. void enableUndo(bool enable);
  66. void enableRedo(bool enable);
  67. void onSelectionMade(int level, bool anythingSelected);
  68. void onPlayersChanged();
  69. void displayStatus(const QString& message, int timeout = 2000);
  70. private:
  71. void preparePreview(const QModelIndex &index, bool createNew);
  72. void addGroupIntoCatalog(const std::string & groupName, bool staticOnly);
  73. void addGroupIntoCatalog(const std::string & groupName, bool useCustomName, bool staticOnly, int ID);
  74. QAction * getActionPlayer(const PlayerColor &);
  75. void changeBrushState(int idx);
  76. void setTitle();
  77. void closeEvent(QCloseEvent *event) override;
  78. bool getAnswerAboutUnsavedChanges();
  79. void loadUserSettings();
  80. void saveUserSettings();
  81. private:
  82. Ui::MainWindow * ui;
  83. ObjectBrowser * objectBrowser = nullptr;
  84. QGraphicsScene * scenePreview;
  85. QString filename;
  86. bool unsaved = false;
  87. QStandardItemModel objectsModel;
  88. int mapLevel = 0;
  89. std::set<int> catalog;
  90. };