-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase2.cpp
192 lines (129 loc) · 3.29 KB
/
base2.cpp
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "base.h"
#include "ui_base.h"
namespace variable {
int i = 0;
int x = 5;
int y = 5;
QString limit = "bis zu 10 Veranstaltungen";
QString pathToRemove;
}
void Base::SaveToFile()
{
QFile file(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/Events/" + filename2 + ".txt");
file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
QTextStream in(&file);
for (int i = 0; i < textarr.size(); i++) {
in<<textarr[i]<<"\n";
}
}
void Base::on_savebtn_clicked()
{
QString text = ui->textcal->text();
QString textdate = ui->timecal->text();
textarr.push_back(textdate + " " + text);
qDebug()<<textarr.last();
NewCalendarlbl(textdate + " " + text);
}
void Base::NewCalendarlbl(QString event)
{
ui->textcal->clear();
using variable::i;
using variable::x;
using variable::y;
using variable::limit;
if(i >= 10){
ui->textcal->setText(limit);
}
else{
//event button
lbl2[i] = new QLabel(event, ui->gB2);
lbl2[i]->resize(340,30);
lbl2[i]->move(x,y);
lbl2[i]->setStyleSheet("color: #ffffff; font:87 14pt Arial Black;");
lbl2[i]->setAlignment(Qt::AlignVCenter);
lbl2[i]->show();
y += 35;
i++;
}
qDebug()<<i;
}
void Base::ClearLabels()
{
using variable::i;
using variable::y;
for(int j = 0; j < i; j++){
delete lbl2[j];
}
i = 0;
y = 5;
QTime time(00,00,00,00);
ui->timecal->setTime(time);
}
void Base::on_backbtn_clicked()
{
SaveToFile();
ClearLabels();
ui->sW->setCurrentIndex(0);
}
void Base::ReadFromFile(QString path)
{
using variable::pathToRemove;
pathToRemove = path;
QFile file(path);
file.open(QIODevice::ReadOnly | QIODevice::Text);
if(!file.exists()){qDebug()<<"File doesn't exists";}
else{
QTextStream out(&file);
QString event;
while(!out.atEnd()){
event = out.readLine();
if(!event.isEmpty())
NewCalendarlbl(event);
}
}
}
void Base::ChangeLanguageEng()
{
using variable::limit;
int j = 0;
for(auto i : lbl){
i->setText(englishName[j]);
j++;
}
ui->displayevents->setText("Show saved events");
ui->savebtn->setText("Add");
ui->settingslbl->setText("Settings");
ui->langlbl->setText("Change language");
this->setWindowTitle("Calendar");
limit = "The limit is 10 events per day";
}
void Base::ChangeLanguagePl()
{
using variable::limit;
int j = 0;
for(auto i : lbl){
i->setText(polishName[j]);
j++;
}
ui->displayevents->setText("Pokaż zapisane wydarzenia");
ui->savebtn->setText("Dodaj");
ui->settingslbl->setText("Ustawienia");
ui->langlbl->setText("Zmień język");
this->setWindowTitle("Kalendarz");
limit = "Limit to 10 zdarzeń na dzień";
}
void Base::ChangeLanguageGer()
{
using variable::limit;
int j = 0;
for(auto i : lbl){
i->setText(germanName[j]);
j++;
}
ui->displayevents->setText("Ereignisse zeigen");
ui->savebtn->setText("einfügen");
ui->settingslbl->setText("Einstellungen");
ui->langlbl->setText("Sprache ändern");
this->setWindowTitle("Kalender");
limit = "bis zu 10 Veranstaltungen";
}