# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmwname.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 "kmwname.h"
    00021 #include "kmwizard.h"
    00022 #include "kmprinter.h"
    00023
    00024 #include <qlabel.h>
    00025 #include <qlineedit.h>
    00026 #include <klocale.h>
    00027 #include <kmessagebox.h>
    00028 #include <qregexp.h>
    00029
    00030 KMWName::KMWName(QWidget *parent, const char *name)
    00031 : KMWInfoBase(3,parent,name)
    00032 {
    00033     m_ID = KMWizard::Name;
    00034     m_title = i18n("General Information");
    00035     m_nextpage = KMWizard::End;
    00036
    00037     setInfo(i18n("<p>Enter the information concerning your printer or class. <b>Name</b> is mandatory, "
    00038              "<b>Location</b> and <b>Description</b> are not (they may even not be used on some systems).</p>"));
    00039     setLabel(0,i18n("Name:"));
    00040     setLabel(1,i18n("Location:"));
    00041     setLabel(2,i18n("Description:"));
    00042 }
    00043
    00044 bool KMWName::isValid(QString& msg)
    00045 {
    00046     if (text(0).isEmpty())
    00047     {
    00048         msg = i18n("You must supply at least a name.");
    00049         return false;
    00050     }
    00051     else if (text(0).find(QRegExp("\\s")) != -1)
    00052     {
    00053         QString conv = text(0);
    00054         conv.replace(QRegExp("\\s"), "");
    00055         int result = KMessageBox::warningYesNoCancel(this,
    00056                     i18n("It is usually not a good idea to include spaces "
    00057                          "in printer name: it may prevent your printer from "
    00058                          "working correctly. The wizard can strip all spaces "
    00059                          "from the string you entered, resulting in %1; "
    00060                          "what do you want to do?").arg(conv),
    00061                     QString::null,
    00062                     i18n("Strip"), i18n("Keep"));
    00063         switch (result)
    00064         {
    00065             case KMessageBox::Yes:
    00066                 setText(0, conv);
    00067             case KMessageBox::No:
    00068                 return true;
    00069             default:
    00070                 return false;
    00071         }
    00072     }
    00073     return true;
    00074 }
    00075
    00076 void KMWName::initPrinter(KMPrinter *p)
    00077 {
    00078     setText(0,p->printerName());
    00079     setText(1,p->location());
    00080     setText(2,p->description());
    00081     if (text(2).isEmpty())
    00082         if (p->option("kde-driver") == "raw")
    00083             setText(2,i18n("Raw printer"));
    00084         else
    00085             setText(2,p->manufacturer() + " " + p->model());
    00086
    00087     setCurrent(0);
    00088 }
    00089
    00090 void KMWName::updatePrinter(KMPrinter *p)
    00091 {
    00092     p->setPrinterName(text(0));
    00093     p->setName(text(0));
    00094     p->setLocation(text(1));
    00095     p->setDescription(text(2));
    00096 }

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