From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdeprint/management/kmwname.cpp | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 kdeprint/management/kmwname.cpp (limited to 'kdeprint/management/kmwname.cpp') diff --git a/kdeprint/management/kmwname.cpp b/kdeprint/management/kmwname.cpp new file mode 100644 index 000000000..0cfbfbea9 --- /dev/null +++ b/kdeprint/management/kmwname.cpp @@ -0,0 +1,96 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmwname.h" +#include "kmwizard.h" +#include "kmprinter.h" + +#include +#include +#include +#include +#include + +KMWName::KMWName(QWidget *parent, const char *name) +: KMWInfoBase(3,parent,name) +{ + m_ID = KMWizard::Name; + m_title = i18n("General Information"); + m_nextpage = KMWizard::End; + + setInfo(i18n("

Enter the information concerning your printer or class. Name is mandatory, " + "Location and Description are not (they may even not be used on some systems).

")); + setLabel(0,i18n("Name:")); + setLabel(1,i18n("Location:")); + setLabel(2,i18n("Description:")); +} + +bool KMWName::isValid(QString& msg) +{ + if (text(0).isEmpty()) + { + msg = i18n("You must supply at least a name."); + return false; + } + else if (text(0).find(QRegExp("\\s")) != -1) + { + QString conv = text(0); + conv.replace(QRegExp("\\s"), ""); + int result = KMessageBox::warningYesNoCancel(this, + i18n("It is usually not a good idea to include spaces " + "in printer name: it may prevent your printer from " + "working correctly. The wizard can strip all spaces " + "from the string you entered, resulting in %1; " + "what do you want to do?").arg(conv), + QString::null, + i18n("Strip"), i18n("Keep")); + switch (result) + { + case KMessageBox::Yes: + setText(0, conv); + case KMessageBox::No: + return true; + default: + return false; + } + } + return true; +} + +void KMWName::initPrinter(KMPrinter *p) +{ + setText(0,p->printerName()); + setText(1,p->location()); + setText(2,p->description()); + if (text(2).isEmpty()) + if (p->option("kde-driver") == "raw") + setText(2,i18n("Raw printer")); + else + setText(2,p->manufacturer() + " " + p->model()); + + setCurrent(0); +} + +void KMWName::updatePrinter(KMPrinter *p) +{ + p->setPrinterName(text(0)); + p->setName(text(0)); + p->setLocation(text(1)); + p->setDescription(text(2)); +} -- cgit v1.2.3