kdeprint Library API Documentation

cupslocationaccess.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 "cupslocationaccess.h" 00021 00022 #include <qcombobox.h> 00023 #include <qlayout.h> 00024 #include <qlabel.h> 00025 #include <klocale.h> 00026 #include <qwhatsthis.h> 00027 00028 #include "cupsdconf.h" 00029 #include "cupslist.h" 00030 00031 CupsLocationAccess::CupsLocationAccess(QWidget *parent, const char *name) 00032 : QWidget(parent, name) 00033 { 00034 allow_ = new CupsListBox(this); 00035 deny_ = new CupsListBox(this); 00036 order_ = new QComboBox(this); 00037 order_->insertItem(i18n("Allow, Deny")); 00038 order_->insertItem(i18n("Deny, Allow")); 00039 order_->setCurrentItem(1); 00040 00041 QLabel *l1 = new QLabel(i18n("Allow from:"), this); 00042 QLabel *l2 = new QLabel(i18n("Deny from:"), this); 00043 QLabel *l3 = new QLabel(i18n("Order:"), this); 00044 00045 QGridLayout *main_ = new QGridLayout(this, 6, 2, 10, 10); 00046 main_->addWidget(l1, 0, 0, Qt::AlignTop|Qt::AlignLeft); 00047 main_->addWidget(l2, 2, 0, Qt::AlignTop|Qt::AlignLeft); 00048 main_->addWidget(l3, 4, 0); 00049 main_->addMultiCellWidget(allow_, 0, 1, 1, 1); 00050 main_->addMultiCellWidget(deny_, 2, 3, 1, 1); 00051 main_->addWidget(order_, 4, 1); 00052 main_->setRowStretch(5, 1); 00053 } 00054 00055 CupsLocationAccess::~CupsLocationAccess() 00056 { 00057 } 00058 00059 void CupsLocationAccess::loadLocation(CupsLocation *loc) 00060 { 00061 if (loc->order_ != -1) order_->setCurrentItem(loc->order_); 00062 QStringList::Iterator it; 00063 for (it=loc->allow_.begin();it!=loc->allow_.end();++it) 00064 allow_->insertItem(*it); 00065 for (it=loc->deny_.begin();it!=loc->deny_.end();++it) 00066 deny_->insertItem(*it); 00067 } 00068 00069 void CupsLocationAccess::saveLocation(CupsLocation *loc) 00070 { 00071 if (allow_->count() > 0 || deny_->count() > 0) loc->order_ = order_->currentItem(); 00072 else loc->order_ = -1; 00073 loc->allow_.clear(); 00074 for (int i=0;i<allow_->count();i++) 00075 loc->allow_.append(allow_->text(i)); 00076 loc->deny_.clear(); 00077 for (int i=0;i<deny_->count();i++) 00078 loc->deny_.append(deny_->text(i)); 00079 } 00080 00081 void CupsLocationAccess::setInfos(CupsdConf *conf) 00082 { 00083 QWhatsThis::add(allow_, conf->comments_.toolTip(LOCAUTHALLOW_COMM)); 00084 QWhatsThis::add(deny_, conf->comments_.toolTip(LOCAUTHDENY_COMM)); 00085 QWhatsThis::add(order_, conf->comments_.toolTip(LOCAUTHORDER_COMM)); 00086 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:49:59 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003