1
/***************************************************************************
2
* Copyright (C) 2004 by Roberto Virga *
3
* rvirga@users.sf.net *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
23
#include <kbsboincmonitor.h>
25
#include <kbssetiprojectmonitor.h>
26
#include <kbssetisignalplot.h>
29
#include "kbssetitelescopepathwindow.h"
31
QDict<KBSSETITelescopePathWindow> KBSSETITelescopePathWindow::s_windows
32
= QDict<KBSSETITelescopePathWindow>();
34
KBSSETITelescopePathWindow *KBSSETITelescopePathWindow::window(const QString &workunit)
36
KBSSETITelescopePathWindow *out = s_windows.find(workunit);
39
out = new KBSSETITelescopePathWindow(workunit);
40
s_windows.insert(workunit, out);
46
KBSSETITelescopePathWindow::KBSSETITelescopePathWindow(const QString &workunit,
47
QWidget *parent, const char *name)
48
: KBSStandardWindow(parent, name),
49
m_view(new KBSSETISignalPlot(this)), m_workunit(workunit)
51
setCaption(i18n("Telescope Path - %1").arg(workunit));
53
setCentralWidget(m_view);
58
QString KBSSETITelescopePathWindow::workunit() const
63
void KBSSETITelescopePathWindow::attachProjectMonitor(KBSSETIProjectMonitor *projectMonitor)
65
if(m_projectMonitors.containsRef(projectMonitor)) return;
67
m_projectMonitors.append(projectMonitor);
69
if(m_projectMonitors.count() == 1) {
70
connectProjectMonitor(projectMonitor);
75
void KBSSETITelescopePathWindow::detachProjectMonitor()
77
KBSSETIProjectMonitor *projectMonitor = m_projectMonitors.first();
79
if(NULL != projectMonitor) {
80
disconnectProjectMonitor();
81
m_projectMonitors.removeRef(projectMonitor);
84
projectMonitor = m_projectMonitors.first();
86
if(NULL != projectMonitor) {
87
connectProjectMonitor(projectMonitor);
93
s_windows.remove(m_workunit);
97
QPixmap KBSSETITelescopePathWindow::pixmap()
99
return m_view->pixmap();
102
void KBSSETITelescopePathWindow::update()
104
KBSSETIProjectMonitor *projectMonitor = m_projectMonitors.first();
105
if(NULL == projectMonitor) return;
107
const SETIResult *result = projectMonitor->result(m_workunit);
110
m_view->setData(result->workunit_header);
113
void KBSSETITelescopePathWindow::update(const QString &workunit)
115
if(workunit == m_workunit) update();
118
void KBSSETITelescopePathWindow::connectProjectMonitor(KBSSETIProjectMonitor *projectMonitor)
120
connect(projectMonitor, SIGNAL(updatedResult(const QString &)), this, SLOT(update(const QString &)));
121
connect(projectMonitor, SIGNAL(destroyed()), this, SLOT(detachProjectMonitor()));
123
KBSBOINCMonitor *boincMonitor = projectMonitor->boincMonitor();
125
connect(boincMonitor, SIGNAL(stateUpdated()), this, SLOT(update()));
128
void KBSSETITelescopePathWindow::disconnectProjectMonitor()
130
disconnect(this, SLOT(update(const QString &)));
131
disconnect(this, SLOT(detachProjectMonitor()));
132
disconnect(this, SLOT(update()));
135
#include "kbssetitelescopepathwindow.moc"