-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsonlineseditor.h
More file actions
133 lines (99 loc) · 3.37 KB
/
jsonlineseditor.h
File metadata and controls
133 lines (99 loc) · 3.37 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef JSONLINESEDITOR_H
#define JSONLINESEDITOR_H
#include <QMainWindow>
#include "core/appcache.h"
#include <QCloseEvent>
#include <QPushButton>
QT_BEGIN_NAMESPACE
namespace Ui { class JsonLinesEditor; }
QT_END_NAMESPACE
class JsonLinesEditor : public QMainWindow
{
Q_OBJECT
Q_PROPERTY(bool isFileChanged READ isFileChanged WRITE setIsFileChanged NOTIFY isFileChangedUpdated)
Q_PROPERTY(bool isItemChanged READ isItemChanged WRITE setIsItemChanged NOTIFY isItemChangedUpdated)
Q_PROPERTY(QString openedFile READ openedFile WRITE setOpenedFile NOTIFY openedFileUpdated)
public:
JsonLinesEditor(QWidget *parent = nullptr);
~JsonLinesEditor();
protected:
void closeEvent(QCloseEvent *event) override {
if (checkForExit()) {
saveDailyJournal();
event->accept();
} else {
event->ignore();
}
}
private slots:
void on_actionExit_triggered();
bool checkForExit();
void checkForCloseFile();
void selectFileAndOpen();
bool loadEditableFile(const QString &filePath);
void journalMessage(const QString& message);
void saveDailyJournal();
void openedFileChanged(const QString &filePath);
void on_actionAbout_triggered();
void on_actionClearCache_triggered();
void on_actionOpen_triggered();
void on_tableWidgetFile_itemSelectionChanged();
void on_toolButton_TermSearchGoogle_clicked();
void on_toolButton_TermOrigSearchGooglech_clicked();
void on_lineEditTerm_textChanged();
void on_lineEditTermOrig_textChanged();
void on_plainTextDefinition_textChanged();
void on_plainTextEditDefinitionOrig_textChanged();
void on_lineEditSource_textChanged();
void on_toolButtonSaveItem_clicked();
void on_actionSave_triggered();
void on_actionCloseFile_triggered();
void on_actionSaveAs_triggered();
void on_actionCreate_triggered();
void on_toolButton_AddRow_clicked();
void on_toolButton_RemoveRow_clicked();
signals:
void isFileChangedUpdated(bool);
void isItemChangedUpdated(bool);
void openedFileUpdated(QString);
// void newJournalMessage(const QString& message);
private:
Ui::JsonLinesEditor *ui;
const QString defaultFileUnsaved = "unsaved";
AppCache *appCache = new AppCache();
int rowsUpdated = 0;
int rowsInserted = 0;
QString lastPath = "";
bool isFileChangedVal = false;
bool isItemChangedVal = false;
QString openedFileVal = "";
bool isFileChanged() const { return isFileChangedVal; }
void setIsFileChanged(bool val) {
if (isFileChangedVal != val) {
isFileChangedVal = val;
emit isFileChangedUpdated(val);
}
}
bool isItemChanged() const { return isItemChangedVal; }
void setIsItemChanged(bool val) {
if (isItemChangedVal != val) {
isItemChangedVal = val;
emit isItemChangedUpdated(val);
}
}
QString openedFile() const { return openedFileVal; }
void setOpenedFile(QString val) {
if (openedFileVal != val) {
openedFileVal = val;
emit openedFileUpdated(val);
}
}
bool initDataDirs();
bool checkItemChanged();
void checkItemChanges();
void enableEditor();
void disableEditor();
bool saveFile(bool saveAs = false);
bool createFileBackup(const QString &filePath);
};
#endif // JSONLINESEDITOR_H