forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatsView.h
101 lines (80 loc) · 3.04 KB
/
StatsView.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
#ifndef STATSVIEW_H
#define STATSVIEW_H
#include <QWidget>
#include <vector>
#include "GenStatsReader.h"
#include "LsbObject.h"
#include <QTreeWidgetItem>
#include <QTableWidgetItem>
#include <string>
class DataContainerTreeItem : public QTreeWidgetItem {
std::string data;
public:
DataContainerTreeItem(QTreeWidgetItem *parent) : QTreeWidgetItem(parent) {
}
DataContainerTreeItem(QTreeWidget *parent = 0) : QTreeWidgetItem(parent) {
}
std::string getData() const {
return data;
}
void setData(const std::string &value) {
data = value;
}
};
class StatsButtonCallback {
public:
virtual void onClick(DataContainerTreeItem *&selectedItem, QTreeWidget *statsTree) = 0;
};
class TableEditCallback {
public:
virtual void onEdit(DataContainerTreeItem *&selectedItem, QTreeWidget *statsTree, QTableWidgetItem *editedItem, QTableWidget *table) = 0;
};
namespace Ui {
class StatsView;
}
class StatsView : public QWidget
{
Q_OBJECT
public:
explicit StatsView(std::vector<StatsContainer *> &allItemStats, std::map<std::string, std::string> &nameMappings, QWidget *parent = 0);
void addStatsDirectory(std::string name, std::string text, QTreeWidgetItem *parent = 0);
void addStatsDirectoryByPrefix(std::string prefix, std::string text, QTreeWidgetItem *parent = 0);
void addBoostDirectory(std::string modifierType, std::string text);
void addToTree(std::vector<StatsContainer *>& boosts, QTreeWidgetItem *parent = 0);
void addToTree(std::vector<LsbObject *>& objects, QTreeWidgetItem *parent = 0);
void addIndividualDataItemToTree(std::string dataName, QTreeWidgetItem *parent);
void addDataToTree(StatsContainer *stat, QTreeWidgetItem *parent);
void selectNodeByName(const char *name);
void enableSelectButton(StatsButtonCallback *callback);
void enableAddButton(StatsButtonCallback *callback);
void enableCancelButton(StatsButtonCallback *callback);
void enableRemoveButton(StatsButtonCallback *callback);
void registerTableEditCallback(TableEditCallback *tableEditCallback);
DataContainerTreeItem *addFolder(std::string folderName);
void resizeTree();
void clearTree();
~StatsView();
protected:
void showEvent(QShowEvent *event);
private slots:
void on_statsTree_itemClicked(QTreeWidgetItem *item, int column);
void on_statsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void on_selectButton_released();
void on_addButton_released();
void on_statsTree_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_cancelButton_released();
void on_removeButton_released();
void on_modTable_itemChanged(QTableWidgetItem *tableItem);
private:
DataContainerTreeItem *findNodeByData(QTreeWidgetItem *node, std::string &data);
Ui::StatsView *ui;
std::vector<StatsContainer *> &allItemStats;
DataContainerTreeItem *selectedItem = 0;
StatsButtonCallback *addCallback = 0;
StatsButtonCallback *selectCallback = 0;
StatsButtonCallback *cancelCallback = 0;
StatsButtonCallback *removeCallback = 0;
TableEditCallback *tableEditCallback = 0;
std::map<std::string, std::string> &nameMappings;
};
#endif // STATSVIEW_H