-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvault.h
96 lines (73 loc) · 2.61 KB
/
vault.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
#ifndef VAULT_H
#define VAULT_H
#include <QObject>
#include <QString>
#include <QStringListModel>
#include <QMap>
#include <QVector>
#include <QLineEdit>
struct Summiter
{
public:
QStringList contents;
public:
explicit Summiter(QStringList lst) // constructor (does not set a pic)
: contents(lst)
{
}
explicit Summiter() // default constructor
{
contents.reserve(13);
}
public:
// getters
QString getPeakID() const { return contents[0]; }
QString getPeakName() const { return contents[1]; }
QString getName() const { return contents[2]; }
QString getYearSeason() const { return contents[3]; }
QString getDate() const { return contents[4]; }
QString getTime() const { return contents[5]; }
QString getCitizenship() const { return contents[6]; }
QString getGender() const { return contents[7]; }
QString getAge() const { return contents[8]; }
QString getO2Usage() const { return contents[9]; }
QString getSummitership() const { return contents[10]; }
QString getCauseOfDeath() const { return contents[11]; }
//setter
void setNewData(const QStringList& data) { contents = data; }
};
class Vault : public QObject
{
Q_OBJECT
friend class SortProxy;
public:
explicit Vault(QObject *parent);
~Vault();
QStringListModel* getMasterModel() const { return _masterModel; }
public:
void loadFile(QString& filename);
void updateModel(const QString& name, bool isAfterEdit);
bool nullFileName() const ; // checks nullity of filename
void saveToFile(const QString& filename) const;
void addSummiter(QString name) { summiters.insert(name, new Summiter()); }
QString addSummiter(Summiter* summiter);
void clearFields() const;
void deleteSummiter(QString& name);
void addRow(QString& name);
QVector<QLineEdit*> detailedModelFields() const { return _detailedModelFields; }
void setDetailedModelFields(QVector<QLineEdit*> fields);
QStringList getContentsFromView();
const QMap<QString, Summiter*>* getSummiters() const { return &summiters; }
protected:
void updateDetailedView(const QString& name);
public:
QString getFileName() const { return _filename; }
signals:
void contentsLoaded();
protected:
QStringListModel* _masterModel;
mutable QString _filename; // kinda want to change filename in const methods if nessesary (in saveToFile() for example)
QMap<QString, Summiter*> summiters; // <name, contents>
QVector<QLineEdit*> _detailedModelFields;
};
#endif // VAULT_H