kmwname.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }
|