• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
kmprinter.h
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library 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 GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#ifndef KMPRINTER_H
21#define KMPRINTER_H
22
23#if !defined( _TDEPRINT_COMPILE ) && defined( __GNUC__ )
24#warning internal header, do not use except if you are a TDEPrint developer
25#endif
26
27#include <tqstring.h>
28#include <tqstringlist.h>
29#include <tqptrlist.h>
30#include <kurl.h>
31#include <tqmap.h>
32#include <tdeprint/kmobject.h>
33
34class KMDBEntry;
35class DrMain;
36class KPrinter;
37class TQWidget;
38
46class TDEPRINT_EXPORT KMPrinter : public KMObject
47{
48public:
49 enum PrinterType {
50 Printer = 0x01,
51 Class = 0x02,
52 Implicit = 0x04,
53 Virtual = 0x08,
54 Remote = 0x10,
55 Invalid = 0x20,
56 Special = 0x40
57 };
58 enum PrinterState {
59 Idle = 0x01,
60 Stopped = 0x02,
61 Processing = 0x03,
62 Unknown = 0x04,
63 Rejecting = 0x08,
64 StateMask = 0x07
65 };
66 enum PrinterCap {
67 CapBW = 0x0001,
68 CapColor = 0x0002,
69 CapDuplex = 0x0004,
70 CapStaple = 0x0008,
71 CapCopies = 0x0010,
72 CapCollate = 0x0020,
73 CapPunch = 0x0040,
74 CapCover = 0x0080,
75 CapBind = 0x0100,
76 CapSort = 0x0200,
77 CapSmall = 0x0400,
78 CapMedium = 0x0800,
79 CapLarge = 0x1000,
80 CapVariable = 0x2000
81 };
82
83 // constructor functions
84 KMPrinter();
85 KMPrinter(const KMPrinter& p);
86 ~KMPrinter();
87 void copy(const KMPrinter& p);
88
89
90 // inline access functions
91 const TQString& name() const { return m_name; }
92 void setName(const TQString& s) { m_name = s; if (m_printername.isEmpty()) m_printername = s; }
93 const TQString& printerName() const { return m_printername; }
94 void setPrinterName(const TQString& s) { m_printername = s; if (m_name.isEmpty()) m_name = s; }
95 const TQString& instanceName() const { return m_instancename; }
96 void setInstanceName(const TQString& s) { m_instancename = s; }
97 int type() const { return m_type; }
98 void setType(int t) { m_type = t; }
99 void addType(int t) { m_type |= t; }
100 PrinterState state(bool complete = false) const { return PrinterState(m_state & (complete ? ~0x0 : StateMask)); }
101 TQString stateString() const;
102 void setState(PrinterState s) { m_state = PrinterState((m_state & ~StateMask) | s); }
103 bool acceptJobs() const { return !(m_state & Rejecting); }
104 void setAcceptJobs(bool on) { m_state = PrinterState((m_state & StateMask) | (on ? 0 : Rejecting)); }
105 const TQString& device() const { return m_device; }
106 TQString deviceProtocol() const;
107 void setDevice(const TQString& d) { m_device = d; }
108 const TQStringList& members() const { return m_members; }
109 void setMembers(const TQStringList& l) { m_members = l; }
110 void addMember(const TQString& s) { m_members.append(s); }
111 const TQString& description() const { return m_description; }
112 void setDescription(const TQString& s) { m_description = s; }
113 const TQString& location() const { return m_location; }
114 void setLocation(const TQString& s) { m_location = s; }
115 const KURL& uri() const { return m_uri; }
116 void setUri(const KURL& u) { m_uri = u; }
117 const TQString& manufacturer() const { return m_manufacturer; }
118 void setManufacturer(const TQString&s ) { m_manufacturer = s; }
119 const TQString& model() const { return m_model; }
120 void setModel(const TQString& s) { m_model = s; }
121 const TQString& driverInfo() const { return m_driverinfo; }
122 void setDriverInfo(const TQString& s) { m_driverinfo = s; }
123 int printerCap() const { return m_printercap; }
124 void setPrinterCap( int c ) { m_printercap = c; }
125 void addPrinterCap( int c ) { m_printercap |= c; }
126
127 // some useful functions
128 bool isClass(bool useImplicit = true) const { return ((m_type & KMPrinter::Class) || (useImplicit && isImplicit())); }
129 bool isImplicit() const { return (m_type & KMPrinter::Implicit); }
130 bool isPrinter() const { return (m_type & KMPrinter::Printer); }
131 bool isRemote() const { return (m_type & KMPrinter::Remote); }
132 bool isLocal() const { return !isRemote(); }
133 bool isVirtual() const { return (m_type & KMPrinter::Virtual); }
134 bool isValid() const { return !(m_type & KMPrinter::Invalid); }
135 bool isSpecial() const { return (m_type & KMPrinter::Special); }
136
137 // misc
138 KMDBEntry* dbEntry() const { return m_dbentry; }
139 void setDbEntry(KMDBEntry *e) { m_dbentry = e; }
140 TQString pixmap();
141 void setPixmap(const TQString& s) { m_pixmap = s; }
142 bool isHardDefault() const { return m_harddefault; }
143 void setHardDefault(bool on) { m_harddefault = on; }
144 bool isSoftDefault() const { return m_softdefault; }
145 void setSoftDefault(bool on) { m_softdefault = on; }
146 bool ownSoftDefault() const { return m_ownsoftdefault; }
147 void setOwnSoftDefault(bool on) { m_ownsoftdefault = on; }
148 static int compare(KMPrinter *p1, KMPrinter *p2);
149 const TQString& option(const TQString& key) const { return m_options[key]; }
150 bool hasOption(const TQString& key) const { return m_options.contains(key); }
151 void setOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_options[key] = value; }
152 void removeOption(const TQString& key) { m_options.remove(key); }
153 TQMap<TQString,TQString> options() const { return m_options; }
154 void setOptions(const TQMap<TQString,TQString>& opts) { m_options = opts; }
155 DrMain* driver() const { return m_driver; }
156 void setDriver(DrMain*);
157 DrMain* takeDriver();
158
159 // configure an existing KPrinter object
160 bool autoConfigure(KPrinter *prt, TQWidget *parent = 0);
161
162 // default options
163 const TQString& defaultOption(const TQString& key) const { return m_defaultoptions[key]; }
164 void setDefaultOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_defaultoptions[key] = value; }
165 TQMap<TQString,TQString> defaultOptions() const { return m_defaultoptions; }
166 void setDefaultOptions(const TQMap<TQString,TQString>& opts) { m_defaultoptions = opts; }
167 // edited options
168 const TQString& editedOption(const TQString& key) const { return m_editedoptions[key]; }
169 void setEditedOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_editedoptions[key] = value; }
170 TQMap<TQString,TQString> editedOptions() const { return m_editedoptions; }
171 void setEditedOptions(const TQMap<TQString,TQString>& opts) { m_editedoptions = opts; }
172 // edited flag
173 bool isEdited() const { return m_isedited; }
174 void setEdited(bool on) { m_isedited = on; }
175
176
177protected:
178 // mandantory information
179 TQString m_name; // identification name
180 TQString m_printername; // real printer name
181 TQString m_instancename; // instance name (human-readable)
182 int m_type; // printer type (any PrinterType flag OR-ed together)
183 PrinterState m_state; // printer state
189 TQString m_device; // printer device
190
191 // class specific information
192 TQStringList m_members; // members of the class
193
194 // other useful information that should be completed by manager on demand
195 TQString m_description; // short description, comment
196 TQString m_location; // printer location
197 KURL m_uri; // URI printer identification
198 TQString m_manufacturer; // printer manufacturer (driver)
199 TQString m_model; // printer model (driver)
200 TQString m_driverinfo; // short driver info (ex: nick name in PPD)
201
202 // DB driver entry (used when creating a printer). Internal use only !!!
203 KMDBEntry *m_dbentry;
204 DrMain *m_driver;
205 TQString m_pixmap;
206
207 // default flags
208 bool m_harddefault;
209 bool m_softdefault;
210 bool m_ownsoftdefault;
211
212 // other options (for any use)
213 TQMap<TQString,TQString> m_options;
214
215 // options used for instances, and print library. These options are not
216 // overwritten when copying from another KMPrinter object. This allows to
217 // to keep the user settings through an application session. The difference
218 // between "default" and "edited" can be used for option saving (only save
219 // the options corresponding to current edited printer).
220 TQMap<TQString,TQString> m_defaultoptions;
221 TQMap<TQString,TQString> m_editedoptions;
222 bool m_isedited;
223
224 // printer capabilities (based on CUPS model)
225 int m_printercap;
226};
227
228class KMPrinterList : public TQPtrList<KMPrinter>
229{
230public:
231 KMPrinterList() : TQPtrList<KMPrinter>() {}
232 virtual int compareItems(TQPtrCollection::Item i1, TQPtrCollection::Item i2)
233 { return KMPrinter::compare((KMPrinter*)i1, (KMPrinter*)i2); }
234};
235
236#endif
KPrinter
This class is the main interface to access the TDE print framework.
Definition: kprinter.h:89

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.