00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }