forked from AttorneyOnline/AO2-Client
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaonotearea.cpp
More file actions
101 lines (77 loc) · 2.85 KB
/
aonotearea.cpp
File metadata and controls
101 lines (77 loc) · 2.85 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
#include "aonotepicker.hpp"
#include "aonotearea.hpp"
#include "courtroom.h"
#include <QDebug>
AONoteArea::AONoteArea(QWidget *p_parent, AOApplication *p_ao_app) : AOImage(p_parent, p_ao_app)
{
ao_app = p_ao_app;
}
AONoteArea::~AONoteArea()
{
}
void Courtroom::on_add_button_clicked()
{
if(ui_note_area->m_layout->count() > 6)
return;
AONotePicker *f_notepicker = new AONotePicker(ui_note_area, ao_app);
AOButton *f_button = new AOButton(f_notepicker, ao_app);
AOButton *f_delete = new AOButton(f_notepicker, ao_app);
QLineEdit *f_line = new QLineEdit(f_notepicker);
AOButton *f_hover = new AOButton(f_notepicker, ao_app);
QHBoxLayout *f_layout = new QHBoxLayout(f_notepicker);
f_notepicker->m_line = f_line;
f_notepicker->m_button = f_button;
f_notepicker->m_layout = f_layout;
f_notepicker->m_delete_button = f_delete;
f_notepicker->m_hover = f_hover;
f_notepicker->setProperty("index", ui_note_area->m_layout->count()-1);
f_button->set_image("note_edit.png");
f_delete->set_image("note_delete.png");
f_hover->set_image("note_select.png");
f_line->setReadOnly(true);
f_layout->setSizeConstraint(QLayout::SetFixedSize);
f_layout->addWidget(f_hover);
f_layout->addWidget(f_line);
f_layout->addWidget(f_button);
f_layout->addWidget(f_delete);
f_notepicker->setLayout(f_layout);
ui_note_area->m_layout->addWidget(f_notepicker);
if(contains_add_button)
{
ui_note_area->m_layout->removeWidget(ui_note_area->add_button);
ui_note_area->m_layout->addWidget(ui_note_area->add_button);
set_note_files();
}
set_dropdown(f_line, "[LINE EDIT]");
connect(f_button, SIGNAL(clicked(bool)), this, SLOT(on_set_file_button_clicked()));
connect(f_delete, SIGNAL(clicked(bool)), this, SLOT(on_delete_button_clicked()));
connect(f_hover, SIGNAL(clicked(bool)), this, SLOT(on_file_selected()));
}
void Courtroom::set_note_files()
{
QString filename = ao_app->get_base_path() + "configs/filesabstract.ini";
QFile config_file(filename);
if(!config_file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Couldn't open" << filename;
return;
}
QTextStream in(&config_file);
QByteArray t = "";
for(int i = 0; i < ui_note_area->m_layout->count()-1; ++i)
{
AONotePicker *f_notepicker = static_cast<AONotePicker*>(ui_note_area->m_layout->itemAt(i)->widget());
QString f_filestring = f_notepicker->real_file;
QString f_filename = f_notepicker->m_line->text();
t += QString::number(i) + " = " + f_filestring + " = " + f_filename + "\n\n";
}
config_file.close();
QFile ex(filename);
if(!ex.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
qDebug() << "Couldn't open" << filename;
return;
}
ex.write(t);
ex.close();
}