| # kdeprint Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmwdriver.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "kmwdriver.h"
    00021 #include "kmwizard.h"
    00022 #include "kmprinter.h"
    00023 #include "kmdriverdbwidget.h"
    00024 #include "kmdriverdb.h"
    00025
    00026 #include <qlayout.h>
    00027 #include <klocale.h>
    00028
    00029 KMWDriver::KMWDriver(QWidget *parent, const char *name)
    00030 : KMWizardPage(parent,name)
    00031 {
    00032     m_ID = KMWizard::Driver;
    00033     m_title = i18n("Printer Model Selection");
    00034     m_nextpage = KMWizard::DriverTest;
    00035
    00036     m_widget = new KMDriverDbWidget(this);
    00037
    00038     QVBoxLayout *lay1 = new QVBoxLayout(this, 0, 0);
    00039     lay1->addWidget(m_widget);
    00040 }
    00041
    00042 void KMWDriver::initPrinter(KMPrinter *p)
    00043 {
    00044     m_widget->init();
    00045     if (p)
    00046     {
    00047         QString autoDetect = p->option( "kde-autodetect" );
    00048         if ( !autoDetect.isEmpty() )
    00049         {
    00050             // use auto-detection info instead: split the string
    00051             // into make/model pair at the first space character
    00052             int p = autoDetect.find( ' ' );
    00053             if ( p != -1 )
    00054             {
    00055                 QString manu = autoDetect.left( p ), model = autoDetect.mid( p+1 );
    00056                 KMDBEntryList *l = KMDriverDB::self()->findPnpEntry( manu, model );
    00057                 if ( l && l->count() > 0 )
    00058                 {
    00059                     m_widget->setDriver( l->getFirst()->manufacturer, l->getFirst()->model );
    00060                     return;
    00061                 }
    00062             }
    00063         }
    00064         m_widget->setDriver(p->manufacturer(),p->model());
    00065     }
    00066 }
    00067
    00068 void KMWDriver::updatePrinter(KMPrinter *p)
    00069 {
    00070     if (p)
    00071     {
    00072         p->setManufacturer(QString::null);
    00073         p->setModel(QString::null);
    00074         p->setDbEntry(0);
    00075         p->setDriverInfo(QString::null);
    00076         p->setOption("kde-driver",QString::null);
    00077         setNextPage(KMWizard::DriverTest);
    00078         if (m_widget->isRaw())
    00079         {
    00080             p->setDriverInfo(i18n("Raw printer"));
    00081             p->setOption("kde-driver","raw");
    00082         }
    00083         else
    00084         {
    00085             p->setManufacturer(m_widget->manufacturer());
    00086             p->setModel(m_widget->model());
    00087             if (m_widget->isExternal())
    00088             {
    00089                 p->setDriverInfo(m_widget->description());
    00090                 p->setOption("kde-driver",m_widget->driverFile());
    00091             }
    00092             else
    00093             {
    00094                 KMDBEntryList   *drvs = m_widget->drivers();
    00095                 if (drvs->count() == 1)
    00096                 {
    00097                     p->setDbEntry(drvs->getFirst());
    00098                     p->setDriverInfo(drvs->getFirst()->description);
    00099                 }
    00100                 else
    00101                     setNextPage(KMWizard::DriverSelect);
    00102             }
    00103         }
    00104     }
    00105 }
    00106
    00107 bool KMWDriver::isValid(QString& msg)
    00108 {
    00109     if (m_widget->isRaw() || m_widget->isExternal() || m_widget->drivers())
    00110         return true;
    00111     else
    00112     {
    00113         msg = i18n("Internal error: unable to locate the driver.");
    00114         return false;
    00115     }
    00116 }

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:03 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003