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

tdeprint

  • tdeprint
  • cups
kptagspage.cpp
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 #include "kptagspage.h"
21 
22 #include <tqtable.h>
23 #include <tqheader.h>
24 #include <tqlayout.h>
25 #include <tqlabel.h>
26 #include <tqregexp.h>
27 #include <tqwhatsthis.h>
28 
29 #include <tdelocale.h>
30 
31 KPTagsPage::KPTagsPage(bool ro, TQWidget *parent, const char *name)
32 : KPrintDialogPage(parent, name)
33 {
34 
35  //WhatsThis strings.... (added by pfeifle@kde.org)
36  TQString whatsThisAdditionalTagsTable = i18n(" <qt><p><b>Additional Tags</b></p>"
37  " You may send additional commands to the CUPS server via this editable list. "
38  " There are 3 purposes for this:"
39  " <ul>"
40  " <li>Use any current or future standard CUPS job option not supported by the "
41  " TDEPrint GUI. </li>"
42  " <li>Control any custom job option you may want to support in custom CUPS filters "
43  " and backends plugged into the CUPS filtering chain.</li> "
44  " <li>Send short messages to the operators of your production printers in your "
45  " <em>Central Repro Department</em>."
46  " </ul> "
47  " <p><b>Standard CUPS job options:</b> A complete list of standard CUPS job "
48  " options is in the <a href=\"http://localhost:631/sum.html\">CUPS User Manual</a>. "
49  " Mappings of the kprinter user interface widgets to respective CUPS job option "
50  " names are named in the various <em>WhatsThis</em> help items..</p>"
51  " <p><b>Custom CUPS job options:</b> CUPS print servers may be customized with additional "
52  " print filters and backends which understand custom job options. You can specify such "
53  " custom job options here. If in doubt, ask your system administrator..</p>"
54  " <p><b> </b></p>"
55  " <p><b>Operator Messages:</b> You may send additional messages to the operator(s) of your"
56  " production printers (e.g. in your <em>Central Repro Department</p>)"
57  " Messages can be read by the operator(s) (or yourself) by viewing"
58  " the <em>\"Job IPP Report\"</em> for the job.</p>"
59  " <b>Examples:</b><br>"
60  " <pre>"
61  " A standard CUPS job option:<br> "
62  " <em>(Name) number-up</em> -- <em>(Value) 9</em> <br>"
63  " <br>"
64  " A job option for custom CUPS filters or backends:<br> "
65  " <em>(Name) DANKA_watermark</em> -- <em>(Value) Company_Confidential</em> <br>"
66  " <br>"
67  " A message to the operator(s):<br> "
68  " <em>(Name) Deliver_after_completion</em> -- <em>(Value) to_Marketing_Departm.</em><br>"
69  " </pre>"
70  " <p><b>Note:</b> the fields must not include spaces, tabs or quotes. You may need to "
71  " double-click on a field to edit it."
72  " <p><b>Warning:</b> Do not use such standard CUPS option names which also can be used "
73  " through the TDEPrint GUI. Results may be unpredictable if they conflict, "
74  " or if they are sent multiple times. For all options supported by the GUI, please do use "
75  " the GUI. (Each GUI element's 'WhatsThis' names the related CUPS option name.) </p> "
76  " </qt>" );
77  setTitle(i18n("Additional Tags"));
78  setOnlyRealPrinters(true);
79 
80  m_tags = new TQTable(10, 2, this);
81  m_tags->horizontalHeader()->setStretchEnabled(true);
82  m_tags->horizontalHeader()->setLabel(0, i18n("Name"));
83  m_tags->horizontalHeader()->setLabel(1, i18n("Value"));
84  m_tags->setReadOnly(ro);
85  TQWhatsThis::add(m_tags, whatsThisAdditionalTagsTable);
86 
87  TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 5);
88  l0->addWidget(m_tags);
89 
90  if (ro)
91  {
92  TQLabel *lab = new TQLabel(i18n("Read-Only"), this);
93  TQFont f = lab->font();
94  f.setBold(true);
95  lab->setFont(f);
96  lab->setAlignment(AlignVCenter|AlignRight);
97  l0->addWidget(lab);
98  }
99 }
100 
101 KPTagsPage::~KPTagsPage()
102 {
103 }
104 
105 bool KPTagsPage::isValid(TQString& msg)
106 {
107  TQRegExp re("\\s");
108  for (int r=0; r<m_tags->numCols(); r++)
109  {
110  TQString tag(m_tags->text(r, 0));
111  if (tag.isEmpty())
112  continue;
113  else if (tag.find(re) != -1)
114  {
115  msg = i18n("The tag name must not contain any spaces, tabs or quotes: <b>%1</b>.").arg(tag);
116  return false;
117  }
118  }
119  return true;
120 }
121 
122 void KPTagsPage::setOptions(const TQMap<TQString,TQString>& opts)
123 {
124  int r(0);
125  TQRegExp re("^\"|\"$");
126  for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end() && r<m_tags->numRows(); ++it)
127  {
128  if (it.key().startsWith("KDEPrint-"))
129  {
130  m_tags->setText(r, 0, it.key().mid(9));
131  TQString data = it.data();
132  m_tags->setText(r, 1, data.replace(re, ""));
133  r++;
134  }
135  }
136  for (; r<m_tags->numRows(); r++)
137  {
138  m_tags->setText(r, 0, TQString::null);
139  m_tags->setText(r, 1, TQString::null);
140  }
141 }
142 
143 void KPTagsPage::getOptions(TQMap<TQString,TQString>& opts, bool)
144 {
145  for (int r=0; r<m_tags->numRows(); r++)
146  {
147  TQString tag(m_tags->text(r, 0)), val(m_tags->text(r, 1));
148  if (!tag.isEmpty())
149  {
150  tag.prepend("KDEPrint-");
151  opts[tag] = val.prepend("\"").append("\"");
152  }
153  }
154 }
155 
156 TQSize KPTagsPage::sizeHint() const
157 {
158  return TQSize(-1, -1);
159 }
160 
161 TQSize KPTagsPage::minimumSizeHint() const
162 {
163  return TQSize(-1, -1);
164 }
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91

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.1
This website is maintained by Timothy Pearson.