-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.cpp
More file actions
119 lines (97 loc) · 2.68 KB
/
system.cpp
File metadata and controls
119 lines (97 loc) · 2.68 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "provimap.h"
#include "system.h"
#include <QDebug>
#include <QTimer>
#include <QVariant>
#include <QLabel>
System::System(QWidget *parent) : QPushButton(parent)
{
this->name = "";
this->status = CLEAR;
timer = new QTimer(this);
connect(this, SIGNAL (released()), this, SLOT (handleButton()));
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimer()));
}
void System::handleButton()
{
qDebug() << this->pos().x() << " " << this->pos().y();
}
void System::enterEvent(QEvent *event)
{
setCursor(Qt::PointingHandCursor);
}
/*void Planets::leaveEvent(QEvent *event)
{
this->QPushButton::leaveEvent(event);
}*/
void System::setText(const QString &text)
{
QPushButton::setText(text);
if(name == "")
setName(text);
}
QString System::getName()
{
return name;
}
void System::setName(const QString &name)
{
this->name = name;
}
int System::getStatus()
{
return status;
}
void System::setStatus(int status)
{
this->status = status;
if(status == RED)
this->setStyleSheet("QPushButton { background:rgb(255,0,0); }");
else
this->setStyleSheet("QPushButton { background:rgb(0,255,0); }");
statusSince = QDateTime::currentDateTime();
if(timer->isActive())
timer->stop();
timer->start(500);
}
void System::updateTimer()
{
QString statusMessage;
QDateTime timeSince = QDateTime::currentDateTime();
int seconds = statusSince.secsTo(timeSince);
if(status == RED)
statusMessage = getName() + "\n" + QDateTime::fromTime_t(seconds).toUTC().toString("h:mm:ss");
else
statusMessage = getName() + "\nclr" + QDateTime::fromTime_t(seconds).toUTC().toString("h:mm:ss");
this->setText(statusMessage);
}
void System::checkKeywords(QString message)
{
if(getKeywords().isEmpty()){
//qDebug() << this->getName() + " empty";
return;
}
QStringList keywordList = getKeywords();
QStringListIterator keywordIterator(keywordList);
while (keywordIterator.hasNext()){
if(message.contains(keywordIterator.next().toLocal8Bit().constData())){
qDebug() << keywordIterator.next().toLocal8Bit().constData();
setStatus(RED);
break;
}
}
/*while (keywordIterator.hasNext())
{
//qDebug() << keywordIterator.next().toLocal8Bit().constData();
//if(message.contains(keywordIterator.next().toLocal8Bit().constData()))
//qDebug() << keywordIterator.next().toLocal8Bit().constData();
}*/
}
QStringList System::getKeywords(){
return keywordsList;
}
void System::setKeywords(QStringList keywords)
{
keywordsList = keywords;
//qDebug() << this->getName() << keywordsList.length();
}