00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KMPRINTER_H
00021 #define KMPRINTER_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 <qstring.h>
00028 #include <qstringlist.h>
00029 #include <qptrlist.h>
00030 #include <kurl.h>
00031 #include <qmap.h>
00032 #include <kdeprint/kmobject.h>
00033
00034 class KMDBEntry;
00035 class DrMain;
00036 class KPrinter;
00037 class QWidget;
00038
00046 class KDEPRINT_EXPORT KMPrinter : public KMObject
00047 {
00048 public:
00049 enum PrinterType {
00050 Printer = 0x01,
00051 Class = 0x02,
00052 Implicit = 0x04,
00053 Virtual = 0x08,
00054 Remote = 0x10,
00055 Invalid = 0x20,
00056 Special = 0x40
00057 };
00058 enum PrinterState {
00059 Idle = 0x01,
00060 Stopped = 0x02,
00061 Processing = 0x03,
00062 Unknown = 0x04,
00063 Rejecting = 0x08,
00064 StateMask = 0x07
00065 };
00066 enum PrinterCap {
00067 CapBW = 0x0001,
00068 CapColor = 0x0002,
00069 CapDuplex = 0x0004,
00070 CapStaple = 0x0008,
00071 CapCopies = 0x0010,
00072 CapCollate = 0x0020,
00073 CapPunch = 0x0040,
00074 CapCover = 0x0080,
00075 CapBind = 0x0100,
00076 CapSort = 0x0200,
00077 CapSmall = 0x0400,
00078 CapMedium = 0x0800,
00079 CapLarge = 0x1000,
00080 CapVariable = 0x2000
00081 };
00082
00083
00084 KMPrinter();
00085 KMPrinter(const KMPrinter& p);
00086 ~KMPrinter();
00087 void copy(const KMPrinter& p);
00088
00089
00090
00091 const QString& name() const { return m_name; }
00092 void setName(const QString& s) { m_name = s; if (m_printername.isEmpty()) m_printername = s; }
00093 const QString& printerName() const { return m_printername; }
00094 void setPrinterName(const QString& s) { m_printername = s; if (m_name.isEmpty()) m_name = s; }
00095 const QString& instanceName() const { return m_instancename; }
00096 void setInstanceName(const QString& s) { m_instancename = s; }
00097 int type() const { return m_type; }
00098 void setType(int t) { m_type = t; }
00099 void addType(int t) { m_type |= t; }
00100 PrinterState state(bool complete = false) const { return PrinterState(m_state & (complete ? ~0x0 : StateMask)); }
00101 QString stateString() const;
00102 void setState(PrinterState s) { m_state = PrinterState((m_state & ~StateMask) | s); }
00103 bool acceptJobs() const { return !(m_state & Rejecting); }
00104 void setAcceptJobs(bool on) { m_state = PrinterState((m_state & StateMask) | (on ? 0 : Rejecting)); }
00105 const QString& device() const { return m_device; }
00106 QString deviceProtocol() const;
00107 void setDevice(const QString& d) { m_device = d; }
00108 const QStringList& members() const { return m_members; }
00109 void setMembers(const QStringList& l) { m_members = l; }
00110 void addMember(const QString& s) { m_members.append(s); }
00111 const QString& description() const { return m_description; }
00112 void setDescription(const QString& s) { m_description = s; }
00113 const QString& location() const { return m_location; }
00114 void setLocation(const QString& s) { m_location = s; }
00115 const KURL& uri() const { return m_uri; }
00116 void setUri(const KURL& u) { m_uri = u; }
00117 const QString& manufacturer() const { return m_manufacturer; }
00118 void setManufacturer(const QString&s ) { m_manufacturer = s; }
00119 const QString& model() const { return m_model; }
00120 void setModel(const QString& s) { m_model = s; }
00121 const QString& driverInfo() const { return m_driverinfo; }
00122 void setDriverInfo(const QString& s) { m_driverinfo = s; }
00123 int printerCap() const { return m_printercap; }
00124 void setPrinterCap( int c ) { m_printercap = c; }
00125 void addPrinterCap( int c ) { m_printercap |= c; }
00126
00127
00128 bool isClass(bool useImplicit = true) const { return ((m_type & KMPrinter::Class) || (useImplicit && isImplicit())); }
00129 bool isImplicit() const { return (m_type & KMPrinter::Implicit); }
00130 bool isPrinter() const { return (m_type & KMPrinter::Printer); }
00131 bool isRemote() const { return (m_type & KMPrinter::Remote); }
00132 bool isLocal() const { return !isRemote(); }
00133 bool isVirtual() const { return (m_type & KMPrinter::Virtual); }
00134 bool isValid() const { return !(m_type & KMPrinter::Invalid); }
00135 bool isSpecial() const { return (m_type & KMPrinter::Special); }
00136
00137
00138 KMDBEntry* dbEntry() const { return m_dbentry; }
00139 void setDbEntry(KMDBEntry *e) { m_dbentry = e; }
00140 QString pixmap();
00141 void setPixmap(const QString& s) { m_pixmap = s; }
00142 bool isHardDefault() const { return m_harddefault; }
00143 void setHardDefault(bool on) { m_harddefault = on; }
00144 bool isSoftDefault() const { return m_softdefault; }
00145 void setSoftDefault(bool on) { m_softdefault = on; }
00146 bool ownSoftDefault() const { return m_ownsoftdefault; }
00147 void setOwnSoftDefault(bool on) { m_ownsoftdefault = on; }
00148 static int compare(KMPrinter *p1, KMPrinter *p2);
00149 const QString& option(const QString& key) const { return m_options[key]; }
00150 bool hasOption(const QString& key) const { return m_options.contains(key); }
00151 void setOption(const QString& key, const QString& value) { if (!key.isEmpty()) m_options[key] = value; }
00152 void removeOption(const QString& key) { m_options.remove(key); }
00153 QMap<QString,QString> options() const { return m_options; }
00154 void setOptions(const QMap<QString,QString>& opts) { m_options = opts; }
00155 DrMain* driver() const { return m_driver; }
00156 void setDriver(DrMain*);
00157 DrMain* takeDriver();
00158
00159
00160 bool autoConfigure(KPrinter *prt, QWidget *parent = 0);
00161
00162
00163 const QString& defaultOption(const QString& key) const { return m_defaultoptions[key]; }
00164 void setDefaultOption(const QString& key, const QString& value) { if (!key.isEmpty()) m_defaultoptions[key] = value; }
00165 QMap<QString,QString> defaultOptions() const { return m_defaultoptions; }
00166 void setDefaultOptions(const QMap<QString,QString>& opts) { m_defaultoptions = opts; }
00167
00168 const QString& editedOption(const QString& key) const { return m_editedoptions[key]; }
00169 void setEditedOption(const QString& key, const QString& value) { if (!key.isEmpty()) m_editedoptions[key] = value; }
00170 QMap<QString,QString> editedOptions() const { return m_editedoptions; }
00171 void setEditedOptions(const QMap<QString,QString>& opts) { m_editedoptions = opts; }
00172
00173 bool isEdited() const { return m_isedited; }
00174 void setEdited(bool on) { m_isedited = on; }
00175
00176
00177 protected:
00178
00179 QString m_name;
00180 QString m_printername;
00181 QString m_instancename;
00182 int m_type;
00183 PrinterState m_state;
00189 QString m_device;
00190
00191
00192 QStringList m_members;
00193
00194
00195 QString m_description;
00196 QString m_location;
00197 KURL m_uri;
00198 QString m_manufacturer;
00199 QString m_model;
00200 QString m_driverinfo;
00201
00202
00203 KMDBEntry *m_dbentry;
00204 DrMain *m_driver;
00205 QString m_pixmap;
00206
00207
00208 bool m_harddefault;
00209 bool m_softdefault;
00210 bool m_ownsoftdefault;
00211
00212
00213 QMap<QString,QString> m_options;
00214
00215
00216
00217
00218
00219
00220 QMap<QString,QString> m_defaultoptions;
00221 QMap<QString,QString> m_editedoptions;
00222 bool m_isedited;
00223
00224
00225 int m_printercap;
00226 };
00227
00228 class KMPrinterList : public QPtrList<KMPrinter>
00229 {
00230 public:
00231 KMPrinterList() : QPtrList<KMPrinter>() {}
00232 virtual int compareItems(QPtrCollection::Item i1, QPtrCollection::Item i2)
00233 { return KMPrinter::compare((KMPrinter*)i1, (KMPrinter*)i2); }
00234 };
00235
00236 #endif