kmwdriverselect.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kmwdriverselect.h"
00021 #include "kmwizard.h"
00022 #include "kmprinter.h"
00023 #include "kmdbentry.h"
00024 #include "kmdriverdb.h"
00025
00026 #include <qlabel.h>
00027 #include <qlayout.h>
00028 #include <kpushbutton.h>
00029 #include <klistbox.h>
00030 #include <klocale.h>
00031 #include <kmessagebox.h>
00032
00033 KMWDriverSelect::KMWDriverSelect(QWidget *parent, const char *name)
00034 : KMWizardPage(parent,name)
00035 {
00036 m_ID = KMWizard::DriverSelect;
00037 m_title = i18n("Driver Selection");
00038 m_nextpage = KMWizard::DriverTest;
00039 m_entries = NULL;
00040
00041 m_list = new KListBox(this);
00042 QLabel *l1 = new QLabel(this);
00043 l1->setText(i18n("<p>Several drivers have been detected for this model. Select the driver "
00044 "you want to use. You will have the opportunity to test it as well as to "
00045 "change it if necessary.</p>"));
00046 m_drivercomment = new KPushButton(i18n("Driver Information"), this);
00047 connect(m_drivercomment, SIGNAL(clicked()), SLOT(slotDriverComment()));
00048
00049 QVBoxLayout *main_ = new QVBoxLayout(this, 0, 10);
00050 main_->addWidget(l1,0);
00051 main_->addWidget(m_list,1);
00052 QHBoxLayout *lay0 = new QHBoxLayout(0, 0, 0);
00053 main_->addLayout(lay0,0);
00054 lay0->addStretch(1);
00055 lay0->addWidget(m_drivercomment);
00056 }
00057
00058 bool KMWDriverSelect::isValid(QString& msg)
00059 {
00060 if (m_list->currentItem() == -1)
00061 {
00062 msg = i18n("You must select a driver.");
00063 return false;
00064 }
00065 return true;
00066 }
00067
00068 void KMWDriverSelect::initPrinter(KMPrinter *p)
00069 {
00070 m_entries = KMDriverDB::self()->findEntry(p->manufacturer(),p->model());
00071 m_list->clear();
00072 if (m_entries)
00073 {
00074 KMDBEntryListIterator it(*m_entries);
00075 int recomm(0);
00076 for (;it.current();++it)
00077 {
00078 QString s(it.current()->description);
00079 if (it.current()->recommended)
00080 {
00081 recomm = m_list->count();
00082 s.append(i18n(" [recommended]"));
00083 }
00084 m_list->insertItem(s);
00085 }
00086 if (m_entries->count() > 0)
00087 m_list->setSelected(recomm, true);
00088 }
00089 }
00090
00091 void KMWDriverSelect::updatePrinter(KMPrinter *p)
00092 {
00093 int index = m_list->currentItem();
00094 if (m_entries && index >= 0 && index < (int)(m_entries->count()))
00095 {
00096 KMDBEntry *entry = m_entries->at(index);
00097 p->setDbEntry(entry);
00098 p->setDriverInfo(entry->description);
00099 }
00100 else
00101 {
00102 p->setDbEntry(0);
00103 p->setDriverInfo(QString::null);
00104 }
00105 }
00106
00107 void KMWDriverSelect::slotDriverComment()
00108 {
00109 int index = m_list->currentItem();
00110 if (m_entries && index >=0 && index < (int)(m_entries->count()) && !m_entries->at(index)->drivercomment.isEmpty())
00111 KMessageBox::information(this, m_entries->at(index)->drivercomment, QString::null, QString::null, KMessageBox::AllowLink);
00112 else
00113 KMessageBox::error(this, i18n("No information about the selected driver."));
00114 }
00115
00116 #include "kmwdriverselect.moc"
|