add more spacing
[personal-kdebase.git] / workspace / plasma / applets / systemtray / core / job.h
blob16a82b0ac7e64b08c7f975fd886ff1c60262b5f1
1 /***************************************************************************
2 * Copyright (C) 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
20 #ifndef SYSTEMTRAYJOB_H
21 #define SYSTEMTRAYJOB_H
23 #include <QtCore/QHash>
24 #include <QtCore/QObject>
26 namespace SystemTray
29 class Job : public QObject
31 Q_OBJECT
33 public:
34 enum State {
35 Running = 0,
36 Suspended = 1,
37 Stopped = 2
40 Job(QObject *parent = 0);
41 virtual ~Job();
43 /**
44 * Request and signal destruction of this object
46 void destroy();
48 /**
49 * @return the name of the application which started this job.
51 QString applicationName() const;
53 /**
54 * @return the name of the icon to be used for this job.
56 QString applicationIconName() const;
58 /**
59 * @return the descripion of the activity that is performed.
61 QString message() const;
63 /**
64 * @return the errormessage if an error has occured.
66 QString error() const;
68 /**
69 * @return the speed at which the jobs is progressing.
71 QString speed() const;
73 QMap<QString, qlonglong> totalAmounts() const;
75 QMap<QString, qlonglong> processedAmounts() const;
77 /**
78 * @return a list of pairs containing label names/values in the order they should be displayed.
80 QList<QPair<QString, QString> > labels() const;
82 /**
83 * @return the state this job is in.
85 State state() const;
87 bool isSuspendable() const;
89 bool isKillable() const;
91 /**
92 * @retun the percentage of the job that has been completed.
94 uint percentage() const;
96 public slots:
97 /**
98 * suspend this job.
100 virtual void suspend();
103 * resume this job.
105 virtual void resume();
108 * stop this job.
110 virtual void stop();
112 signals:
114 * Emitted when the job is ready to be shown
116 void ready(SystemTray::Job *job);
119 * Emitted when the job changes
121 void changed(SystemTray::Job *job);
124 * Emitted when the job is about to be destroyed
126 void destroyed(SystemTray::Job *job);
128 protected:
129 void setApplicationName(const QString &applicationName);
130 void setApplicationIconName(const QString &applicationIcon);
131 void setMessage(const QString &message);
132 void setError(const QString &error);
133 void setSpeed(const QString &speed);
134 void setTotalAmounts(QMap<QString, qlonglong> amount);
135 void setProcessedAmounts(QMap<QString, qlonglong> amount);
136 void setState(State state);
137 void setSuspendable(bool suspendable);
138 void setKillable(bool killable);
139 void setPercentage(uint percentage);
140 void setLabels(QList<QPair<QString, QString> > labels);
141 void timerEvent(QTimerEvent *);
143 private slots:
144 void show();
146 private:
147 void scheduleChangedSignal();
149 class Private;
150 Private* const d;
154 #endif