20 #include "kmwdriver.h"
22 #include "kmprinter.h"
23 #include "kmdriverdbwidget.h"
24 #include "kmdriverdb.h"
27 #include <tdelocale.h>
29 KMWDriver::KMWDriver(TQWidget *parent,
const char *name)
30 : KMWizardPage(parent,name)
32 m_ID = KMWizard::Driver;
33 m_title = i18n(
"Printer Model Selection");
34 m_nextpage = KMWizard::DriverTest;
36 m_widget =
new KMDriverDbWidget(
this);
38 TQVBoxLayout *lay1 =
new TQVBoxLayout(
this, 0, 0);
39 lay1->addWidget(m_widget);
42 void KMWDriver::initPrinter(KMPrinter *p)
47 TQString autoDetect = p->option(
"kde-autodetect" );
48 if ( !autoDetect.isEmpty() )
52 int p = autoDetect.find(
' ' );
55 TQString manu = autoDetect.left( p ), model = autoDetect.mid( p+1 );
56 KMDBEntryList *l = KMDriverDB::self()->findPnpEntry( manu, model );
57 if ( l && l->count() > 0 )
59 m_widget->setDriver( l->getFirst()->manufacturer, l->getFirst()->model );
64 m_widget->setDriver(p->manufacturer(),p->model());
68 void KMWDriver::updatePrinter(KMPrinter *p)
72 p->setManufacturer(TQString::null);
73 p->setModel(TQString::null);
75 p->setDriverInfo(TQString::null);
76 p->setOption(
"kde-driver",TQString::null);
77 setNextPage(KMWizard::DriverTest);
78 if (m_widget->isRaw())
80 p->setDriverInfo(i18n(
"Raw printer"));
81 p->setOption(
"kde-driver",
"raw");
85 p->setManufacturer(m_widget->manufacturer());
86 p->setModel(m_widget->model());
87 if (m_widget->isExternal())
89 p->setDriverInfo(m_widget->description());
90 p->setOption(
"kde-driver",m_widget->driverFile());
94 KMDBEntryList *drvs = m_widget->drivers();
95 if (drvs->count() == 1)
97 p->setDbEntry(drvs->getFirst());
98 p->setDriverInfo(drvs->getFirst()->description);
101 setNextPage(KMWizard::DriverSelect);
107 bool KMWDriver::isValid(TQString& msg)
109 if (m_widget->isRaw() || m_widget->isExternal() || m_widget->drivers())
113 msg = i18n(
"Internal error: unable to locate the driver.");