forked from foldynl/QLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivityEditor.h
118 lines (97 loc) · 3.08 KB
/
ActivityEditor.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef QLOG_UI_ACTIVITYEDITOR_H
#define QLOG_UI_ACTIVITYEDITOR_H
#include <QDialog>
#include <QPointer>
#include <QStringListModel>
#include "ui/NewContactWidget.h"
#include "data/MainLayoutProfile.h"
namespace Ui {
class ActivityEditor;
}
class StringListModel : public QStringListModel
{
public:
StringListModel(QObject *parent = nullptr) :
QStringListModel(parent){};
void append (const QString& string)
{
insertRows(rowCount(), 1);
setData(index(rowCount()-1), string);
};
void deleteItem(const QModelIndex &index)
{
if (!index.isValid() || index.row() >= stringList().size())
return;
removeRow(index.row());
}
void deleteItem(const QString &value)
{
const QModelIndexList &itemIndexList = match(index(0,0),
Qt::DisplayRole,
value,
1,
Qt::MatchExactly);
for ( const QModelIndex & itemIndex: itemIndexList )
{
deleteItem(itemIndex);
}
}
void moveUp(const QModelIndex &index)
{
if ( index.row() - 1 < 0 )
return;
moveRow(index.parent(), index.row(), index.parent(), index.row() - 1);
}
void moveDown(const QModelIndex &inIndex)
{
if ( inIndex.row() + 1 >= rowCount() )
return;
moveUp(index(inIndex.row()+1));
}
StringListModel& operator<<(const QString& string)
{
append(string);
return *this;
};
};
class ActivityEditor : public QDialog
{
Q_OBJECT
public:
explicit ActivityEditor(const QString &activityName = QString(),
QWidget *parent = nullptr);
~ActivityEditor();
private:
Ui::ActivityEditor *ui;
StringListModel *availableFieldsModel;
StringListModel *qsoRowAFieldsModel;
StringListModel *qsoRowBFieldsModel;
StringListModel *detailColAFieldsModel;
StringListModel *detailColBFieldsModel;
StringListModel *detailColCFieldsModel;
QByteArray mainGeometry;
QByteArray mainState;
bool darkMode;
NewContactDynamicWidgets *dynamicWidgets;
private slots:
void save();
void profileNameChanged(const QString&);
void clearMainLayoutClick();
void setValueState();
private:
void fillWidgets(const MainLayoutProfile &profile);
bool activityNameExists(const QString &activityName);
void moveField(StringListModel *source,
StringListModel *destination,
const QModelIndexList &sourceIndexList);
void connectQSORowButtons();
void connectDetailColsButtons();
void connectMoveButtons(QPushButton* downButton, QPushButton* upButton,
QListView* listView, StringListModel* model);
void connectFieldButtons(QPushButton* moveToButton, QPushButton* removeButton,
StringListModel* targetModel, QListView* targetListView);
QList<int> getFieldIndexes(StringListModel *model);
void setupValuesTab(const QString &activityName);
const QString statusUnSavedText = tr("Unsaved");
};
#endif // QLOG_UI_ACTIVITYEDITOR_H