-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathstatusview.cc
149 lines (121 loc) · 3.73 KB
/
statusview.cc
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
/*
This file is part of Icecream.
Copyright (c) 2003 Frerich Raabe <raabe@kde.org>
Copyright (c) 2003,2004 Stephan Kulow <coolo@kde.org>
Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2014 Kevin Funk <kfunk@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "statusview.h"
#include "hostinfo.h"
#include "job.h"
#include "utils.h"
#include <QDebug>
#include <QTime>
StatusView::StatusView(QObject *parent)
: QObject(parent)
, m_paused(false)
{
}
StatusView::~StatusView()
{
}
StatusView::Options StatusView::options() const
{
return NoOptions;
}
Monitor *StatusView::monitor() const
{
return m_monitor;
}
void StatusView::setMonitor(Monitor *monitor)
{
if (m_monitor == monitor) {
return;
}
if (m_monitor) {
disconnect(m_monitor.data(), SIGNAL(jobUpdated(Job)), this, SLOT(update(Job)));
disconnect(m_monitor.data(), SIGNAL(nodeRemoved(HostId)), this, SLOT(removeNode(HostId)));
disconnect(m_monitor.data(), SIGNAL(nodeUpdated(HostId)), this, SLOT(checkNode(HostId)));
disconnect(m_monitor.data(), SIGNAL(schedulerStateChanged(Monitor::SchedulerState)),
this, SLOT(updateSchedulerState(Monitor::SchedulerState)));
}
m_monitor = monitor;
if (m_monitor) {
connect(m_monitor.data(), SIGNAL(jobUpdated(Job)), this, SLOT(update(Job)));
connect(m_monitor.data(), SIGNAL(nodeRemoved(HostId)), this, SLOT(removeNode(HostId)));
connect(m_monitor.data(), SIGNAL(nodeUpdated(HostId)), this, SLOT(checkNode(HostId)));
connect(m_monitor.data(), SIGNAL(schedulerStateChanged(Monitor::SchedulerState)),
this, SLOT(updateSchedulerState(Monitor::SchedulerState)));
if (options().testFlag(RememberJobsOption)) {
foreach(const Job &job, m_monitor->jobHistory()) {
update(job);
}
}
}
}
HostInfoManager *StatusView::hostInfoManager() const
{
return (m_monitor ? m_monitor->hostInfoManager() : nullptr);
}
void StatusView::update(const Job &)
{
}
void StatusView::checkNode(HostId)
{
}
void StatusView::removeNode(HostId)
{
}
void StatusView::updateSchedulerState(Monitor::SchedulerState state)
{
Q_UNUSED(state);
}
QString StatusView::nameForHost(HostId id)
{
if (!m_monitor) {
return QString();
}
return m_monitor->hostInfoManager()->nameForHost(id);
}
QColor StatusView::hostColor(HostId id)
{
if (!m_monitor) {
return QColor();
}
return m_monitor->hostInfoManager()->hostColor(id);
}
unsigned int StatusView::processor(const Job &job)
{
unsigned int ret = 0;
if (job.state == Job::LocalOnly || job.state == Job::WaitingForCS) {
ret = job.client;
} else {
ret = job.server;
if (!ret) {
// Q_ASSERT( job.m_state == Job::Finished );
ret = job.client;
}
}
Q_ASSERT(ret);
return ret;
}
void StatusView::togglePause()
{
if (m_paused) {
start();
} else {
stop();
}
m_paused = !m_paused;
}