20 #include "kmprinter.h"
24 #include <tdelocale.h>
25 #include <tdefiledialog.h>
27 KMPrinter::KMPrinter()
30 m_type = KMPrinter::Printer;
32 m_harddefault = m_softdefault = m_ownsoftdefault =
false;
38 KMPrinter::KMPrinter(
const KMPrinter& p)
42 m_harddefault = m_softdefault = m_ownsoftdefault =
false;
47 KMPrinter::~KMPrinter()
52 void KMPrinter::copy(
const KMPrinter& p)
55 m_printername = p.m_printername;
56 m_instancename = p.m_instancename;
59 m_device = p.m_device;
60 m_members = p.m_members;
61 m_description = p.m_description;
62 m_location = p.m_location;
63 m_manufacturer = p.m_manufacturer;
66 m_driverinfo = p.m_driverinfo;
67 m_dbentry = p.m_dbentry;
68 m_pixmap = p.m_pixmap;
71 m_options = p.m_options;
72 m_printercap = p.m_printercap;
76 void KMPrinter::setDriver(DrMain *driver)
82 DrMain* KMPrinter::takeDriver()
84 DrMain *dr = m_driver;
89 TQString KMPrinter::pixmap()
91 if (!m_pixmap.isEmpty())
return m_pixmap;
93 QString str(
"tdeprint_printer");
94 if (!isValid()) str.append(
"_defect");
98 if (isClass(
true)) str.append(
"_class");
99 else if (isRemote()) str.append(
"_remote");
102 case KMPrinter::Stopped:
103 str.append(
"_stopped");
105 case KMPrinter::Processing:
106 str.append(
"_process");
115 int KMPrinter::compare(KMPrinter *p1, KMPrinter *p2)
119 bool s1(p1->isSpecial()), s2(p2->isSpecial());
120 if (s1 && s2)
return TQString::compare(p1->name(),p2->name());
121 else if (s1)
return 1;
122 else if (s2)
return -1;
125 bool c1(p1->isClass(
false)), c2(p2->isClass(
false));
126 if (c1 == c2)
return TQString::compare(p1->name(),p2->name());
127 else if (c1 && !c2)
return -1;
128 else if (!c1 && c2)
return 1;
134 TQString KMPrinter::stateString()
const
139 case KMPrinter::Idle: s = i18n(
"Idle");
break;
140 case KMPrinter::Processing: s = i18n(
"Processing...");
break;
141 case KMPrinter::Stopped: s = i18n(
"Stopped");
break;
142 default:
return i18n(
"Unknown State",
"Unknown");
144 s += (
" " + (m_state & Rejecting ? i18n(
"(rejecting jobs)") : i18n(
"(accepting jobs)")));
148 bool KMPrinter::autoConfigure(
KPrinter *printer, TQWidget *parent)
160 if (option(
"kde-special-file") ==
"1")
163 TQString fName = printer->
docFileName(), ext = option(
"kde-special-extension" );
164 if ( fName.isEmpty() )
165 fName = ( printer->
docName() +
"." + ext );
168 int p = fName.findRev(
'.' );
170 fName.append(
"." ).append( ext );
173 fName.truncate( p+1 );
177 fName.prepend(
"/" ).prepend( printer->
docDirectory() );
180 KFileDialog *dialog =
new KFileDialog (fName,
185 dialog->setOperationMode (KFileDialog::Saving);
187 QString mimetype = option(
"kde-special-mimetype");
189 if (!mimetype.isEmpty())
193 filter <<
"all/allfiles";
194 dialog->setMimeFilter (filter, mimetype);
196 else if (!ext.isEmpty())
197 dialog->setFilter (
"*." + ext +
"\n*|" + i18n (
"All Files"));
210 printer->
setOption(
"kde-isspecial",
"1" );
211 printer->
setOption(
"kde-special-command", option(
"kde-special-command" ) );
217 TQString KMPrinter::deviceProtocol()
const
219 int p = m_device.find(
':' );
221 return m_device.left( p );
223 return TQString::null;
void setSearchName(const TQString &n)
Sets the search name of the KPrinter object.
TQString docDirectory() const
Get the default document directory, that is the directory used for any output file.
void setOption(const TQString &key, const TQString &value)
Adds or modifies an option in the KPrinter object.
void setPrinterName(const TQString &)
See TQPrinter::setPrinterName().
void setOptions(const TQMap< TQString, TQString > &opts)
Sets the option set in one operation.
void setOutputToFile(bool)
See TQPrinter::setOutputToFile().
TQString docName() const
See TQPrinter::docName().
TQString docFileName() const
Get the default document filename, that is the default basename used for the output file.
This class is the main interface to access the TDE print framework.
void setOutputFileName(const TQString &)
See TQPrinter::setOutputFileName().