-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.h
66 lines (49 loc) · 1.64 KB
/
widget.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
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <fstream>
#include <QDebug>
#include <QString>
#include <QMessageBox>
#include <QDesktopServices>
#include <QStandardPaths>
#include <QFileDialog>
using namespace std;
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
//Method descriptions can be found in the .cpp file
//Attribute descriptions can be found in this file
Q_OBJECT
public:
explicit Widget(QWidget *parent = nullptr);
~Widget();
private slots:
void on_btnSave_clicked();
void on_txtNote_textChanged();
void on_chkAutosave_clicked();
void on_btnNextNote_clicked();
void on_btnPreviousNote_clicked();
void on_btnAdd_clicked();
void on_btnDiscard_clicked();
void on_btnChangeFile_clicked();
private:
Ui::Widget *ui;
string versionLine = "BG V12";
void loadNotes();
void readSingleNote();
bool fileOkay(fstream *file);
QVector<int> startLines;
int amountOfLines(std::fstream &file);
fstream &GotoLine(fstream &file, int num);
bool setupFile(bool save);
void validateCurrentLine();
void invalidFileErrorBox(QString expectedLineContent, QString currentLineContent = nullptr);
fstream file; //file object (opened and closed when needed)
string currentLine = ""; //buffer variable to save the line which is currently being read
int lineCount = 0; //variable to save the amount of lines the file has
int currentLineNr = 0; //variable to be able to determine the line number of the current line, increased with every use of getline(), experimental, sadly not integrated in fstream, maybe QFile?
};
#endif // WIDGET_H