Debian Codegraph @

src/views/summaryview.h

raw
1 /*
2 This file is part of Icecream.
3
4 Copyright (c) 2004 Scott Wheeler <[email protected]>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifndef SUMMARYVIEW_H
22 #define SUMMARYVIEW_H
23
24 #include "statusview.h"
25
26 #include <QScrollArea>
27 #include <QResizeEvent>
28
29 class QLabel;
30 class QGridLayout;
31
32 class SummaryView;
33 class SummaryViewScrollArea;
34
35 class SummaryViewItem
36 {
37 public:
38 SummaryViewItem(unsigned int hostid, QWidget *parent, SummaryView *view, QGridLayout *layout);
39 ~SummaryViewItem();
40 void update(const Job &job);
41 void updateClient(const Job &job);
42
43 private:
44 QLabel *addLine(const QString &caption, QWidget *parent, QGridLayout *grid,
45 Qt::Alignment flags = Qt::AlignTop,
46 const QString &status = QString());
47 void updateStats();
48
49 struct JobHandler
50 {
51 QFrame *stateWidget{nullptr};
52 QLabel *sourceLabel{nullptr};
53 QLabel *stateLabel{nullptr};
54 QString currentFile;
55 };
56
57 QLabel *m_speedLabel;
58 QLabel *m_jobsLabel;
59
60 int m_jobCount{0};
61 double m_totalJobsLength{0.0f};
62 int m_finishedJobCount{0};
63
64 double m_totalRequestedJobsLength{0.0f};
65 int m_requestedJobCount{0};
66
67 SummaryView *m_view;
68
69 QVector<JobHandler> m_jobHandlers;
70 QList<QWidget *> m_widgets;
71 };
72
73 class SummaryView
74 : public StatusView
75 {
76 Q_OBJECT
77
78 public:
79 explicit SummaryView(QObject *parent = nullptr);
80 ~SummaryView() override;
81
82 QWidget *widget() const override;
83
84 void setMonitor(Monitor *monitor) override;
85 void update(const Job &job) override;
86 void removeNode(unsigned int hostid) override;
87 void checkNode(unsigned int hostid) override;
88 QString id() const override { return QStringLiteral("summary"); }
89
90 private:
91 QScopedPointer<SummaryViewScrollArea> m_widget;
92
93 QMap<unsigned int, SummaryViewItem *> m_items;
94 QGridLayout *m_layout;
95 QWidget *m_base;
96
97 void createKnownHosts();
98 };
99
100 #endif