forked from psemiletov/tea-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.cpp
76 lines (56 loc) · 1.45 KB
/
todo.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
#include "utils.h"
#include "todo.h"
void CTodo::check_timeout()
{
QDate cur_date = QDate::currentDate();
if (cur_date.daysTo (prev_date) > 0)
load_dayfile();
QString time = QTime::currentTime().toString ("HH:mm");
if (table.contains (time))
{
text_info->clear();
text_info->insertHtml ("<b>" + time + "</b><br>");
text_info->insertPlainText (table[time]);
w->move (QPoint (1, 1));
w->show();
w->raise();
w->activateWindow();
}
}
CTodo::~CTodo()
{
delete w;
}
CTodo::CTodo()
{
w = new QWidget (0, Qt::Window);
w->resize (QSize (320, 240));
w->setWindowTitle (tr ("Attention! Attention!"));
text_info = new QTextEdit (w);
text_info->setReadOnly (true);
text_info->resize (w->size());
prev_date = QDate::currentDate();
connect (&timer, SIGNAL(timeout()), this, SLOT(check_timeout()));
timer.setInterval (1000 * 60);
timer.start();
}
void CTodo::load_dayfile()
{
QString fname = dir_days + "/" + QDate::currentDate().toString ("yyyy-MM-dd");
if (! file_exists (fname))
{
table.clear();
return;
}
QString ts = qstring_load (fname);
QStringList sl = ts.split ('[');
for (QList <QString>::iterator s = sl.begin(); s != sl.end(); ++s)
{
int br = s->indexOf (']');
if (br == -1)
continue;
QString time = s->left (br);
QString text = s->right (s->size() - br - 1);
table.insert (time, text);
}
}