kmjobmanager.h

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #ifndef KMJOBMANAGER_H
00021 #define KMJOBMANAGER_H
00022 
00023 #if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ )
00024 #warning internal header, do not use except if you are a KDEPrint developer
00025 #endif
00026 
00027 #include <qobject.h>
00028 #include <qptrlist.h>
00029 #include <qdict.h>
00030 #include <qvaluelist.h>
00031 
00032 #include <kdelibs_export.h>
00033 
00034 class KMJob;
00035 class KMThreadJob;
00036 class KActionCollection;
00037 class KAction;
00038 
00046 class KDEPRINT_EXPORT KMJobManager : public QObject
00047 {
00048     Q_OBJECT
00049 
00050 public:
00051     enum JobType { ActiveJobs = 0, CompletedJobs = 1 };
00052     struct JobFilter
00053     {
00054         JobFilter() { m_type[0] = m_type[1] = 0; m_isspecial = false; }
00055         int m_type[2];
00056         bool m_isspecial;
00057     };
00058 
00059     KMJobManager(QObject *parent = 0, const char *name = 0);
00060     virtual ~KMJobManager();
00061 
00062     static KMJobManager* self();
00063 
00064     void addPrinter(const QString& pr, JobType type = ActiveJobs, bool isSpecial = false);
00065     void removePrinter(const QString& pr, JobType type = ActiveJobs);
00066     void clearFilter();
00067     QDict<JobFilter>* filter();
00068     int limit();
00069     void setLimit(int val);
00070 
00071     //KMJob* findJob(int ID);
00072     KMJob* findJob(const QString& uri);
00073     //bool sendCommand(int ID, int action, const QString& arg = QString::null);
00074     bool sendCommand(const QString& uri, int action, const QString& arg = QString::null);
00075     bool sendCommand(const QPtrList<KMJob>& jobs, int action, const QString& arg = QString::null);
00076     const QPtrList<KMJob>& jobList(bool reload = true);
00077     void addJob(KMJob*);
00078     KMThreadJob* threadJob();
00079 
00080     virtual int actions();
00081     virtual QValueList<KAction*> createPluginActions(KActionCollection*);
00082     virtual void validatePluginActions(KActionCollection*, const QPtrList<KMJob>&);
00083     virtual bool doPluginAction(int, const QPtrList<KMJob>&);
00084 
00085 protected:
00086     void discardAllJobs();
00087     void removeDiscardedJobs();
00088 
00089 protected:
00090     virtual bool listJobs(const QString& prname, JobType type, int limit = 0);
00091     virtual bool sendCommandSystemJob(const QPtrList<KMJob>& jobs, int action, const QString& arg = QString::null);
00092     bool sendCommandThreadJob(const QPtrList<KMJob>& jobs, int action, const QString& arg = QString::null);
00093 
00094 protected:
00095     QPtrList<KMJob> m_jobs;
00096     QDict<JobFilter>    m_filter;
00097     KMThreadJob *m_threadjob;
00098 };
00099 
00100 inline QDict<KMJobManager::JobFilter>* KMJobManager::filter()
00101 { return &m_filter; }
00102 
00103 inline void KMJobManager::clearFilter()
00104 { m_filter.clear(); }
00105 
00106 inline KMThreadJob* KMJobManager::threadJob()
00107 { return m_threadjob; }
00108 
00109 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys