Tome
A generic data editor for games supporting arbitrary input and output formats.
mapwidget.h
1 #ifndef MAPWIDGET_H
2 #define MAPWIDGET_H
3 
4 #include <QHBoxLayout>
5 #include <QTableWidget>
6 #include <QString>
7 #include <QToolButton>
8 #include <QVBoxLayout>
9 #include <QWidget>
10 
11 class MapItemWindow;
12 
13 namespace Tome
14 {
15  class FacetsController;
16  class ProjectController;
17  class RecordsController;
18  class TypesController;
19 
23  class MapWidget : public QWidget
24  {
25  Q_OBJECT
26 
27  public:
36  explicit MapWidget(FacetsController& facetsController,
37  ProjectController& projectController,
38  RecordsController& recordsController,
39  TypesController& typesController,
40  QWidget *parent = 0);
41  ~MapWidget();
42 
47  QString getKeyType() const;
48 
53  QString getValueType() const;
54 
59  QVariantMap getMap() const;
60 
65  void setKeyType(const QString& keyType);
66 
71  void setValueType(const QString& valueType);
72 
77  void setMap(const QVariantMap& map);
78 
79  private slots:
80  void addItem();
81  void editItem(QTableWidgetItem* item);
82  void removeItem();
83 
84  void clearTable();
85 
86  private:
87  QString keyType;
88  QString valueType;
89 
90  QVariantMap map;
91 
92  MapItemWindow* mapItemWindow;
93 
94  QHBoxLayout* layout;
95  QVBoxLayout* buttonLayout;
96  QTableWidget* tableWidget;
97 
98  FacetsController& facetsController;
99  ProjectController& projectController;
100  RecordsController& recordsController;
101  TypesController& typesController;
102 
103  QTableWidgetItem* createTableWidgetItem(QVariant value, bool isReference);
104  };
105 }
106 
107 #endif // MAPWIDGET_H
Definition: commandlineoptions.h:6
QVariantMap getMap() const
Gets all current map items.
Definition: mapwidget.cpp:86
Controller for adding, updating and removing records.
Definition: recordscontroller.h:21
QString getValueType() const
Gets the type of the values of the map.
Definition: mapwidget.cpp:81
void setValueType(const QString &valueType)
Gets the type of the values of the map.
Definition: mapwidget.cpp:96
Controller for adding, updating and removing custom types.
Definition: typescontroller.h:14
QString getKeyType() const
Gets the type of the keys of the map.
Definition: mapwidget.cpp:76
MapWidget(FacetsController &facetsController, ProjectController &projectController, RecordsController &recordsController, TypesController &typesController, QWidget *parent=0)
Constructs a new widget for adding, editing, and removing map items.
Definition: mapwidget.cpp:15
Allows adding, editing, and removing map items.
Definition: mapwidget.h:23
void setMap(const QVariantMap &map)
Sets all current map items.
Definition: mapwidget.cpp:101
Window for editing the a single key-value pair of the map.
Definition: mapitemwindow.h:22
void setKeyType(const QString &keyType)
Gets the type of the keys of the map.
Definition: mapwidget.cpp:91
Controller for validating type facets.
Definition: facetscontroller.h:16
Controller for creating, loading and saving projects.
Definition: projectcontroller.h:22