Disable clipboardsharing in view only mode.
[kdenetwork.git] / kget / core / scheduler.h
blobac898b1076cc9e2a2349195c98017e6df4696226
1 /* This file is part of the KDE project
3 Copyright (C) 2005 Dario Massarin <nekkar@libero.it>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #ifndef SCHEDULER_H
12 #define SCHEDULER_H
14 #include <QObject>
15 #include <QMap>
16 #include <QTimerEvent>
18 #include "core/job.h"
19 #include "core/jobqueue.h"
21 /**
22 * @brief Scheduler class: what handle all the jobs in kget.
24 * This class handles all the jobs in kget. See job.h for further details.
25 * When we want a job to be executed in kget, we have to add the queue
26 * that owns the job in the scheduler calling the addQueue(JobQueue *) function.
30 class Scheduler : public QObject
32 Q_OBJECT
34 public:
35 Scheduler();
36 ~Scheduler();
38 /**
39 * Starts globally the execution of the jobs
41 * @see stop()
43 void start();
45 /**
46 * Stops globally the execution of the jobs
48 * @see start()
50 void stop();
52 /**
53 * Adds a queue to the scheduler.
55 * @param queue The queue that should be added
57 void addQueue(JobQueue * queue);
59 /**
60 * Deletes a queue from the scheduler.
61 * If some jobs in the given queue are being executed, they are
62 * first stopped, then removed from the scheduler.
64 * @param queue The queue that should be removed
66 void delQueue(JobQueue * queue);
68 /**
69 * @returns the number of jobs that are currently in a Running state
71 int countRunningJobs();
73 //JobQueue notifications
74 virtual void jobQueueChangedEvent(JobQueue * queue, JobQueue::Status status);
75 virtual void jobQueueMovedJobEvent(JobQueue * queue, Job * job);
76 virtual void jobQueueAddedJobEvent(JobQueue * queue, Job * job);
77 virtual void jobQueueRemovedJobEvent(JobQueue * queue, Job * job);
79 //Job notifications
80 virtual void jobChangedEvent(Job * job, Job::Status status);
81 virtual void jobChangedEvent(Job * job, Job::Policy status);
83 //Accessors methods
84 void startDelayTimer(Job * job, int seconds);
85 void stopDelayTimer(Job * job);
87 protected:
88 /**
89 * Updates the given queue, starting the jobs that come first in the queue
90 * and stopping all the other
92 * @param queue the queue to update
94 void updateQueue( JobQueue * queue );
96 /**
97 * @return true if the given job should be running (and this depends
98 * on the job policy and on its jobQueue status)
100 * @param job the job to evaluate
102 bool shouldBeRunning( Job * job );
104 private:
105 //Virtual QObject method
106 void timerEvent ( QTimerEvent * event);
108 QList<JobQueue *> m_queues;
109 QMap<int, Job *> m_activeTimers;
112 #endif