-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuilogic.h
More file actions
72 lines (63 loc) · 1.97 KB
/
uilogic.h
File metadata and controls
72 lines (63 loc) · 1.97 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
/////////////////////////////////////////////////////////////////////////////
// Name: uilogic.h
// Purpose: QListWidget & QTextEdit logic, JSON conversion (header)
// Author: Jan Buchholz
// Created: 2025-10-13
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QTextEdit>
#include <QTextBrowser>
#include <QJsonObject>
#include <QByteArray>
#include "jblistwidget.h"
#include "synchelper.h"
class UILogic : public QObject {
Q_OBJECT
public:
explicit UILogic(QObject *parent = nullptr);
~UILogic();
typedef struct {
int id;
int icon;
QString subject;
QString payload;
} journalData;
QListWidget* getListWidget() const {return m_listWidget;}
QTextEdit* getmdViewer() const {return m_mdViewer;}
QTextEdit* getmdEditor() const {return m_mdEditor;}
void resetAll();
void startUp(const QByteArray ba, QString workDir);
bool addListItem();
bool editListItem();
bool deleteListItem();
UILogic::journalData getSelectedListItem();
bool getTextChangeIgnore() const {return m_textChangeIgnore;}
void openListSettingsDialog();
bool isAnyItemSelected();
int getItemCount();
void refreshDocument(QString workDir);
QByteArray dataToJson();
private:
JBListWidget *m_listWidget;
QTextBrowser *m_mdViewer;
QTextEdit *m_mdEditor;
QVector<journalData> m_data;
SyncHelper *mc_synchelper;
int m_id;
bool m_textChangeIgnore;
void createListWidget();
void createMdViewer();
void createMdEditor();
void setPayload(int id, QString payload);
QString getPayLoad(int id);
void jsonToData(QByteArray ba);
QJsonObject journalDataToJson(journalData data);
journalData journalDataFromJson(QJsonObject json);
private slots:
void onCurrentItemChanged(QListWidgetItem*, QListWidgetItem*);
void onJBListDropEvent();
void onTextChanged();
signals:
void listChanged();
};