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

# kminfopage.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 "kminfopage.h"
    00021 #include "kmprinter.h"
    00022
    00023 #include <qpixmap.h>
    00024 #include <qlabel.h>
    00025 #include <qlayout.h>
    00026 #include <klocale.h>
    00027 #include <kiconloader.h>
    00028 #include <kseparator.h>
    00029
    00030 KMInfoPage::KMInfoPage(QWidget *parent, const char *name)
    00031 : QWidget(parent,name)
    00032 {
    00033     m_title = new QLabel(this);
    00034     m_titlepixmap = new QLabel(this);
    00035     m_titlepixmap->setAlignment(Qt::AlignCenter);
    00036         KSeparator* sep = new KSeparator( KSeparator::HLine, this);
    00037     m_type = new QLabel(this);
    00038     m_description = new QLabel(this);
    00039     m_state = new QLabel(this);
    00040     m_location = new QLabel(this);
    00041     m_model = new QLabel(this);
    00042     m_uri = new QLabel(this);
    00043     m_device = new QLabel(this);
    00044     QLabel  *m_loclabel = new QLabel(i18n("Physical Location", "Location:"), this);
    00045     m_loclabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00046     QLabel  *m_desclabel = new QLabel(i18n("Description:"), this);
    00047     m_desclabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00048     QLabel  *m_typelabel = new QLabel(i18n("Type:"), this);
    00049     m_typelabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00050     QLabel  *m_statelabel = new QLabel(i18n("Status", "State:"), this);
    00051     m_statelabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00052     QLabel  *m_urilabel = new QLabel(i18n("URI:"), this);
    00053     m_urilabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00054     m_devlabel = new QLabel(i18n("Device:"), this);
    00055     m_devlabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00056     QLabel  *m_modellabel = new QLabel(i18n("Model:"), this);
    00057     m_modellabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    00058
    00059     QGridLayout *lay0 = new QGridLayout(this, 11, 2, 0, 5);
    00060     QHBoxLayout *lay1 = new QHBoxLayout(0, 0, 10);
    00061     lay0->addRowSpacing(7,20);
    00062     lay0->setRowStretch(7,0);
    00063     lay0->setRowStretch(10,1);
    00064     lay0->setColStretch(1,1);
    00065     lay0->addMultiCellLayout(lay1, 0, 0, 0, 1);
    00066     lay0->addMultiCellWidget(sep, 1, 1, 0, 1);
    00067     lay0->addWidget(m_typelabel, 2, 0);
    00068     lay0->addWidget(m_statelabel, 3, 0);
    00069     lay0->addWidget(m_loclabel, 4, 0);
    00070     lay0->addWidget(m_desclabel, 5, 0);
    00071     lay0->addWidget(m_urilabel, 6, 0);
    00072     lay0->addWidget(m_devlabel, 8, 0);
    00073     lay0->addWidget(m_modellabel, 9, 0);
    00074     lay0->addWidget(m_type, 2, 1);
    00075     lay0->addWidget(m_state, 3, 1);
    00076     lay0->addWidget(m_location, 4, 1);
    00077     lay0->addWidget(m_description, 5, 1);
    00078     lay0->addWidget(m_uri, 6, 1);
    00079     lay0->addWidget(m_device, 8, 1);
    00080     lay0->addWidget(m_model, 9, 1);
    00081     lay1->addWidget(m_title, 1);
    00082     lay1->addWidget(m_titlepixmap, 0);
    00083 }
    00084
    00085 KMInfoPage::~KMInfoPage()
    00086 {
    00087 }
    00088
    00089 void KMInfoPage::setPrinter(KMPrinter *p)
    00090 {
    00091     // change "Device" label if it's a real class (not true for implicit classes)
    00092     if (p && p->isClass(false)) m_devlabel->setText(i18n("Members:"));
    00093     else m_devlabel->setText(i18n("Device:"));
    00094
    00095     // clear everything if p == 0
    00096     if (!p)
    00097     {
    00098         m_title->setText(QString::null);
    00099         m_titlepixmap->setPixmap(QPixmap());
    00100         m_type->setText(QString::null);
    00101         m_state->setText(QString::null);
    00102         m_location->setText(QString::null);
    00103         m_description->setText(QString::null);
    00104         m_uri->setText(QString::null);
    00105         m_device->setText(QString::null);
    00106         m_model->setText(QString::null);
    00107     }
    00108     else
    00109     {
    00110         m_title->setText(QString::fromLatin1("<b>%1</b>").arg(p->name()));
    00111         m_titlepixmap->setPixmap(SmallIcon(p->pixmap()));
    00112         if (p->isImplicit()) m_type->setText(i18n("Implicit class"));
    00113         else if (p->isClass(false))
    00114             if (p->isRemote()) m_type->setText(i18n("Remote class"));
    00115             else m_type->setText(i18n("Local class"));
    00116         else if (p->isPrinter())
    00117             if (p->isRemote()) m_type->setText(i18n("Remote printer"));
    00118             else m_type->setText(i18n("Local printer"));
    00119         else if (p->isSpecial())
    00120             m_type->setText(i18n("Special (pseudo) printer"));
    00121         else m_type->setText(i18n("Unknown class of printer", "Unknown"));
    00122         m_state->setText(p->stateString());
    00123         m_location->setText(p->location());
    00124         m_description->setText(p->description());
    00125         m_uri->setText(p->uri().prettyURL());
    00126         if (p->isClass(false))
    00127         {
    00128             QString s;
    00129             for (QStringList::ConstIterator it=p->members().begin(); it!=p->members().end(); ++it)
    00130                 s.append((*it) + ", ");
    00131             s.truncate(s.length()-2);
    00132             m_device->setText(s);
    00133         }
    00134         else
    00135         {
    00136             // double decoding in case printer name contains
    00137             // annoying chars like '#'
    00138             m_device->setText(KURL::decode_string(p->device()));
    00139         }
    00140         m_model->setText(p->driverInfo());
    00141     }
    00142 }

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:02 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003