From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001
From: toma
Date: Wed, 25 Nov 2009 17:56:58 +0000
Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
---
kdeprint/cups/kptagspage.cpp | 164 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 164 insertions(+)
create mode 100644 kdeprint/cups/kptagspage.cpp
(limited to 'kdeprint/cups/kptagspage.cpp')
diff --git a/kdeprint/cups/kptagspage.cpp b/kdeprint/cups/kptagspage.cpp
new file mode 100644
index 000000000..ec7e451b7
--- /dev/null
+++ b/kdeprint/cups/kptagspage.cpp
@@ -0,0 +1,164 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "kptagspage.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+KPTagsPage::KPTagsPage(bool ro, QWidget *parent, const char *name)
+: KPrintDialogPage(parent, name)
+{
+
+ //WhatsThis strings.... (added by pfeifle@kde.org)
+ QString whatsThisAdditionalTagsTable = i18n(" Additional Tags
"
+ " You may send additional commands to the CUPS server via this editable list. "
+ " There are 3 purposes for this:"
+ " "
+ " - Use any current or future standard CUPS job option not supported by the "
+ " KDEPrint GUI.
"
+ " - Control any custom job option you may want to support in custom CUPS filters "
+ " and backends plugged into the CUPS filtering chain.
"
+ " - Send short messages to the operators of your production printers in your "
+ " Central Repro Department."
+ "
"
+ " Standard CUPS job options: A complete list of standard CUPS job "
+ " options is in the CUPS User Manual. "
+ " Mappings of the kprinter user interface widgets to respective CUPS job option "
+ " names are named in the various WhatsThis help items..
"
+ " Custom CUPS job options: CUPS print servers may be customized with additional "
+ " print filters and backends which understand custom job options. You can specify such "
+ " custom job options here. If in doubt, ask your system administrator..
"
+ "
"
+ " Operator Messages: You may send additional messages to the operator(s) of your"
+ " production printers (e.g. in your Central Repro Department
)"
+ " Messages can be read by the operator(s) (or yourself) by viewing"
+ " the \"Job IPP Report\" for the job.
"
+ " Examples:
"
+ " "
+ " A standard CUPS job option:
"
+ " (Name) number-up -- (Value) 9
"
+ "
"
+ " A job option for custom CUPS filters or backends:
"
+ " (Name) DANKA_watermark -- (Value) Company_Confidential
"
+ "
"
+ " A message to the operator(s):
"
+ " (Name) Deliver_after_completion -- (Value) to_Marketing_Departm.
"
+ "
"
+ " Note: the fields must not include spaces, tabs or quotes. You may need to "
+ " double-click on a field to edit it."
+ "
Warning: Do not use such standard CUPS option names which also can be used "
+ " through the KDEPrint GUI. Results may be unpredictable if they conflict, "
+ " or if they are sent multiple times. For all options supported by the GUI, please do use "
+ " the GUI. (Each GUI element's 'WhatsThis' names the related CUPS option name.)
"
+ " " );
+ setTitle(i18n("Additional Tags"));
+ setOnlyRealPrinters(true);
+
+ m_tags = new QTable(10, 2, this);
+ m_tags->horizontalHeader()->setStretchEnabled(true);
+ m_tags->horizontalHeader()->setLabel(0, i18n("Name"));
+ m_tags->horizontalHeader()->setLabel(1, i18n("Value"));
+ m_tags->setReadOnly(ro);
+ QWhatsThis::add(m_tags, whatsThisAdditionalTagsTable);
+
+ QVBoxLayout *l0 = new QVBoxLayout(this, 0, 5);
+ l0->addWidget(m_tags);
+
+ if (ro)
+ {
+ QLabel *lab = new QLabel(i18n("Read-Only"), this);
+ QFont f = lab->font();
+ f.setBold(true);
+ lab->setFont(f);
+ lab->setAlignment(AlignVCenter|AlignRight);
+ l0->addWidget(lab);
+ }
+}
+
+KPTagsPage::~KPTagsPage()
+{
+}
+
+bool KPTagsPage::isValid(QString& msg)
+{
+ QRegExp re("\\s");
+ for (int r=0; rnumCols(); r++)
+ {
+ QString tag(m_tags->text(r, 0));
+ if (tag.isEmpty())
+ continue;
+ else if (tag.find(re) != -1)
+ {
+ msg = i18n("The tag name must not contain any spaces, tabs or quotes: %1.").arg(tag);
+ return false;
+ }
+ }
+ return true;
+}
+
+void KPTagsPage::setOptions(const QMap& opts)
+{
+ int r(0);
+ QRegExp re("^\"|\"$");
+ for (QMap::ConstIterator it=opts.begin(); it!=opts.end() && rnumRows(); ++it)
+ {
+ if (it.key().startsWith("KDEPrint-"))
+ {
+ m_tags->setText(r, 0, it.key().mid(9));
+ QString data = it.data();
+ m_tags->setText(r, 1, data.replace(re, ""));
+ r++;
+ }
+ }
+ for (; rnumRows(); r++)
+ {
+ m_tags->setText(r, 0, QString::null);
+ m_tags->setText(r, 1, QString::null);
+ }
+}
+
+void KPTagsPage::getOptions(QMap& opts, bool)
+{
+ for (int r=0; rnumRows(); r++)
+ {
+ QString tag(m_tags->text(r, 0)), val(m_tags->text(r, 1));
+ if (!tag.isEmpty())
+ {
+ tag.prepend("KDEPrint-");
+ opts[tag] = val.prepend("\"").append("\"");
+ }
+ }
+}
+
+QSize KPTagsPage::sizeHint() const
+{
+ return QSize(-1, -1);
+}
+
+QSize KPTagsPage::minimumSizeHint() const
+{
+ return QSize(-1, -1);
+}
--
cgit v1.2.1