-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.h
115 lines (94 loc) · 2.9 KB
/
GUI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#include <qwidget.h>
#include <QtWidgets/QMainWindow>
#include <qlistwidget.h>
#include <qformlayout.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qtabwidget.h>
#include <QtCharts>
#include <qsortfilterproxymodel.h>
#include "domain.h"
#include "controller.h"
#include "GUICharter.h"
#include "ui_QtGUI_Hybris.h"
#include "TowerModel.h"
class QTowerListItem : public QListWidgetItem, public Tower
{
public:
QTowerListItem(Tower tower) : QListWidgetItem{ QString::fromStdString(tower.print()) }, Tower{ tower }{}
};
class ImageDelegate : public QStyledItemDelegate {
protected:
void paint(QPainter* painter, const QStyleOptionViewItem& opt, const QModelIndex& index) const {
/*if (opt.state & QStyle::State_Selected) {
painter->setBrush(Qt::green);
}
else {
painter->setBrush(Qt::blue);
}*/
QPixmap image{ index.data().toString() + ".png" };
painter->drawPixmap(opt.rect, image);
}
};
class TestWidget : public QDialog
{
private:
QTableView* view;
public:
TestWidget(TowerModel* model, QWidget* parent = nullptr) : QDialog{ parent }
{
this->setFixedWidth(755);
this->setMinimumHeight(500);
QHBoxLayout* layout = new QHBoxLayout(this);
this->view = new QTableView;
this->view->setModel(model);
QHeaderView* verticalHeader = this->view->verticalHeader();
verticalHeader->setSectionResizeMode(QHeaderView::Fixed);
verticalHeader->setDefaultSectionSize(200);
verticalHeader->hide();
this->view->setColumnWidth(4, 200);
layout->addWidget(this->view);
this->view->setItemDelegateForColumn(4, new ImageDelegate);
}
};
class QtGUI_Hybris : public QMainWindow
{
Q_OBJECT
public:
QtGUI_Hybris(Controller& controller, QWidget* parent = Q_NULLPTR) : QMainWindow(parent), controller{ controller } { initGUI(); };
~QtGUI_Hybris() { delete model; }
private:
Ui::QtGUI_HybrisClass ui;
Controller controller;
TowerModel* model;
TowerModel* savedModel;
QSortFilterProxyModel* filter;
QShortcut* undo;
QShortcut* redo;
TestWidget* widget;
//RepoInMemory repo;
GUICharter* charter;
void initGUI();
void connectSignalsAndSlots();
void populateTowerList(const std::string& sizeFilter = "");
void populateSavedList();
//void keyPressEvent(QKeyEvent* myEvent);
void addTowerHandler();
void deleteTowerHandler();
void updateTowerHandler();
void saveTowerHandler();
void filterHandler();
void changedTabHandler(const int& tab);
void undoHandler();
void redoHandler();
void populateLineEdits();
signals:
void towersUpdateSignal(const std::string& sizeFilter = "");
void savedUpdateSignal();
void towerAddSignal(const std::string& location, const std::string& size, const std::string& auraLevel, const std::string& parts, const std::string& vision);
private slots:
void addTower(const std::string& location, const std::string& size, const std::string& auraLevel, const std::string& parts, const std::string& vision);
};