kmwend.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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kmwend.h"
00021 #include "kmprinter.h"
00022 #include "kmwizard.h"
00023 #include "util.h"
00024 
00025 #include <qtextview.h>
00026 #include <klocale.h>
00027 #include <qlayout.h>
00028 
00029 KMWEnd::KMWEnd(QWidget *parent, const char *name)
00030 : KMWizardPage(parent,name)
00031 {
00032     m_ID = KMWizard::End;
00033     m_title = i18n("Confirmation");
00034     m_nextpage = KMWizard::Error;
00035 
00036     m_view = new QTextView(this);
00037 
00038     QVBoxLayout *lay = new QVBoxLayout(this, 0, 0);
00039     lay->addWidget(m_view,1);
00040 }
00041 
00042 void KMWEnd::initPrinter(KMPrinter *p)
00043 {
00044     QString txt;
00045     QString s(QString::fromLatin1("<li><u>%1</u>: %2</li>"));
00046     int ID = p->option("kde-backend").toInt();
00047 
00048     // general information
00049     txt.append(QString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("General")));
00050     txt.append(s.arg(i18n("Type")).arg(p->option("kde-backend-description")));
00051     txt.append(s.arg(i18n("Name")).arg(p->name()));
00052     txt.append(s.arg(i18n("Location")).arg(p->location()));
00053     txt.append(s.arg(i18n("Description")).arg(p->description()));
00054     txt.append("</ul><br>");
00055 
00056     if (ID == KMWizard::Class)
00057     {
00058         // class members
00059         txt.append(QString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Members")));
00060         QStringList m(p->members());
00061         QString     s1(QString::fromLatin1("<li>%1</li>"));
00062         for (QStringList::ConstIterator it=m.begin(); it!=m.end(); ++it)
00063             txt.append(s1.arg(*it));
00064         txt.append("</ul><br>");
00065     }
00066     else
00067     {
00068         // backend information
00069         txt.append(QString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Backend")));
00070         KURL url ( p->device() );
00071         switch (ID)
00072         {
00073             case KMWizard::Local:
00074                 txt.append(s.arg(i18n("Device")).arg(url.path()));
00075                 break;
00076             case KMWizard::TCP:
00077                 txt.append(s.arg(i18n("Printer IP")).arg(url.host()));
00078                 txt.append(s.arg(i18n("Port")).arg(url.port()));
00079                 break;
00080             case KMWizard::LPD:
00081                 txt.append(s.arg(i18n("Host")).arg(url.host()));
00082                 txt.append(s.arg(i18n("Queue")).arg(url.path().right(url.path().length()-1)));
00083                 break;
00084             case KMWizard::File:
00085                 txt.append(s.arg(i18n("File")).arg(url.path()));
00086                 break;
00087             case KMWizard::IPP:
00088                 txt.append(s.arg(i18n("Host")).arg(url.host()));
00089                 txt.append(s.arg(i18n("Port")).arg(url.port()));
00090                 txt.append(s.arg(i18n("Printer")).arg(url.path().right(url.path().length()-1)));
00091                 if (url.hasUser()) txt.append(s.arg(i18n("Account")).arg(url.user()));
00092                 break;
00093             default:
00094                 // double decoding in case the printer name contains chars like '#' that are
00095                 // not decoded by "prettyURL".
00096                 txt.append(s.arg(i18n("URI")).arg(KURL( p->device()).prettyURL()));
00097                 break;
00098         }
00099         txt.append("</ul><br>");
00100 
00101         if (p->option("kde-driver") == "raw" || p->driver())
00102         {
00103             // driver information
00104             txt.append(QString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Driver")));
00105             if (p->option("kde-driver") == "raw")
00106                 txt.append(s.arg(i18n("Type")).arg(i18n("Raw printer")));
00107             else
00108             {
00109                 txt.append(s.arg(i18n("Type")).arg((p->dbEntry() ? i18n("DB driver") : i18n("External driver"))));
00110                 txt.append(s.arg(i18n("Manufacturer")).arg(p->manufacturer()));
00111                 txt.append(s.arg(i18n("Model")).arg(p->model()));
00112                 txt.append(s.arg(i18n("Description")).arg(p->driverInfo()));
00113             }
00114             txt.append("</ul><br>");
00115         }
00116     }
00117 
00118     m_view->setText(txt);
00119 }
KDE Home | KDE Accessibility Home | Description of Access Keys