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

# kmwusers.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 <config.h>
    00021
    00022 #include "kmwusers.h"
    00023 #include "kmwizard.h"
    00024 #include "kmprinter.h"
    00025
    00026 #include <qlabel.h>
    00027 #include <qlayout.h>
    00028 #include <qcombobox.h>
    00029 #include <klocale.h>
    00030 #include <keditlistbox.h>
    00031
    00032 KMWUsers::KMWUsers(QWidget *parent, const char *name)
    00033 : KMWizardPage(parent, name)
    00034 {
    00035     m_ID = KMWizard::Custom+4;
    00036     m_title = i18n("Users Access Settings");
    00037     m_nextpage = KMWizard::Name;
    00038
    00039     m_users = new KEditListBox(i18n("Users"), this, 0, false, KEditListBox::Add|KEditListBox::Remove);
    00040     m_type = new QComboBox(this);
    00041     m_type->insertItem(i18n("Allowed Users"));
    00042     m_type->insertItem(i18n("Denied Users"));
    00043
    00044     QLabel  *lab1 = new QLabel(i18n("Define here a group of allowed/denied users for this printer."), this);
    00045     QLabel  *lab2 = new QLabel(i18n("&Type:"), this);
    00046
    00047     lab2->setBuddy(m_type);
    00048
    00049     QVBoxLayout *l0 = new QVBoxLayout(this, 0, 10);
    00050     QHBoxLayout *l1 = new QHBoxLayout(0, 0, 10);
    00051     l0->addWidget(lab1, 0);
    00052     l0->addLayout(l1, 0);
    00053     l1->addWidget(lab2, 0);
    00054     l1->addWidget(m_type, 1);
    00055     l0->addWidget(m_users, 1);
    00056 }
    00057
    00058 KMWUsers::~KMWUsers()
    00059 {
    00060 }
    00061
    00062 void KMWUsers::initPrinter(KMPrinter *p)
    00063 {
    00064     QStringList l;
    00065     int     i(1);
    00066     if (!p->option("requesting-user-name-denied").isEmpty())
    00067     {
    00068         l = QStringList::split(",", p->option("requesting-user-name-denied"), false);
    00069         if (l.count() == 1 && l[0] == "none")
    00070             l.clear();
    00071     }
    00072     else if (!p->option("requesting-user-name-allowed").isEmpty())
    00073     {
    00074         i = 0;
    00075         l = QStringList::split(",", p->option("requesting-user-name-allowed"), false);
    00076         if (l.count() && l[0] == "all")
    00077             l.clear();
    00078     }
    00079     m_users->insertStringList(l);
    00080     m_type->setCurrentItem(i);
    00081 }
    00082
    00083 void KMWUsers::updatePrinter(KMPrinter *p)
    00084 {
    00085     p->removeOption("requesting-user-name-denied");
    00086     p->removeOption("requesting-user-name-allowed");
    00087
    00088     QString str;
    00089     if (m_users->count() > 0)
    00090         str = m_users->items().join(",");
    00091     else
    00092         str = (m_type->currentItem() == 0 ? "all" : "none");
    00093     QString optname = (m_type->currentItem() == 0 ? "requesting-user-name-allowed" : "requesting-user-name-denied");
    00094     p->setOption(optname, str);
    00095 }
    00096 #include "kmwusers.moc"

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