summaryrefslogtreecommitdiffstats
path: root/kdeprint/management/kmwdriverselect.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeprint/management/kmwdriverselect.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
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
Diffstat (limited to 'kdeprint/management/kmwdriverselect.cpp')
-rw-r--r--kdeprint/management/kmwdriverselect.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/kdeprint/management/kmwdriverselect.cpp b/kdeprint/management/kmwdriverselect.cpp
new file mode 100644
index 000000000..ed97b967c
--- /dev/null
+++ b/kdeprint/management/kmwdriverselect.cpp
@@ -0,0 +1,116 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <[email protected]>
+ *
+ * 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 "kmwdriverselect.h"
+#include "kmwizard.h"
+#include "kmprinter.h"
+#include "kmdbentry.h"
+#include "kmdriverdb.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <kpushbutton.h>
+#include <klistbox.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+KMWDriverSelect::KMWDriverSelect(QWidget *parent, const char *name)
+: KMWizardPage(parent,name)
+{
+ m_ID = KMWizard::DriverSelect;
+ m_title = i18n("Driver Selection");
+ m_nextpage = KMWizard::DriverTest;
+ m_entries = NULL;
+
+ m_list = new KListBox(this);
+ QLabel *l1 = new QLabel(this);
+ l1->setText(i18n("<p>Several drivers have been detected for this model. Select the driver "
+ "you want to use. You will have the opportunity to test it as well as to "
+ "change it if necessary.</p>"));
+ m_drivercomment = new KPushButton(i18n("Driver Information"), this);
+ connect(m_drivercomment, SIGNAL(clicked()), SLOT(slotDriverComment()));
+
+ QVBoxLayout *main_ = new QVBoxLayout(this, 0, 10);
+ main_->addWidget(l1,0);
+ main_->addWidget(m_list,1);
+ QHBoxLayout *lay0 = new QHBoxLayout(0, 0, 0);
+ main_->addLayout(lay0,0);
+ lay0->addStretch(1);
+ lay0->addWidget(m_drivercomment);
+}
+
+bool KMWDriverSelect::isValid(QString& msg)
+{
+ if (m_list->currentItem() == -1)
+ {
+ msg = i18n("You must select a driver.");
+ return false;
+ }
+ return true;
+}
+
+void KMWDriverSelect::initPrinter(KMPrinter *p)
+{
+ m_entries = KMDriverDB::self()->findEntry(p->manufacturer(),p->model());
+ m_list->clear();
+ if (m_entries)
+ {
+ KMDBEntryListIterator it(*m_entries);
+ int recomm(0);
+ for (;it.current();++it)
+ {
+ QString s(it.current()->description);
+ if (it.current()->recommended)
+ {
+ recomm = m_list->count();
+ s.append(i18n(" [recommended]"));
+ }
+ m_list->insertItem(s);
+ }
+ if (m_entries->count() > 0)
+ m_list->setSelected(recomm, true);
+ }
+}
+
+void KMWDriverSelect::updatePrinter(KMPrinter *p)
+{
+ int index = m_list->currentItem();
+ if (m_entries && index >= 0 && index < (int)(m_entries->count()))
+ {
+ KMDBEntry *entry = m_entries->at(index);
+ p->setDbEntry(entry);
+ p->setDriverInfo(entry->description);
+ }
+ else
+ {
+ p->setDbEntry(0);
+ p->setDriverInfo(QString::null);
+ }
+}
+
+void KMWDriverSelect::slotDriverComment()
+{
+ int index = m_list->currentItem();
+ if (m_entries && index >=0 && index < (int)(m_entries->count()) && !m_entries->at(index)->drivercomment.isEmpty())
+ KMessageBox::information(this, m_entries->at(index)->drivercomment, QString::null, QString::null, KMessageBox::AllowLink);
+ else
+ KMessageBox::error(this, i18n("No information about the selected driver."));
+}
+
+#include "kmwdriverselect.moc"