00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cupsdfilterpage.h"
00021 #include "cupsdconf.h"
00022 #include "sizewidget.h"
00023
00024 #include <qlabel.h>
00025 #include <qlineedit.h>
00026 #include <qlayout.h>
00027 #include <qwhatsthis.h>
00028 #include <qcombobox.h>
00029
00030 #include <klocale.h>
00031 #include <knuminput.h>
00032
00033 CupsdFilterPage::CupsdFilterPage(QWidget *parent, const char *name)
00034 : CupsdPage(parent, name)
00035 {
00036 setPageLabel(i18n("Filter"));
00037 setHeader(i18n("Filter Settings"));
00038 setPixmap("filter");
00039
00040 user_ = new QLineEdit(this);
00041 group_ = new QLineEdit(this);
00042 ripcache_ = new SizeWidget(this);
00043 filterlimit_ = new KIntNumInput(this);
00044
00045 filterlimit_->setRange(0, 1000, 1, true);
00046 filterlimit_->setSpecialValueText(i18n("Unlimited"));
00047 filterlimit_->setSteps(1, 10);
00048
00049 QLabel *l1 = new QLabel(i18n("User:"), this);
00050 QLabel *l2 = new QLabel(i18n("Group:"), this);
00051 QLabel *l3 = new QLabel(i18n("RIP cache:"), this);
00052 QLabel *l4 = new QLabel(i18n("Filter limit:"), this);
00053
00054 QGridLayout *m1 = new QGridLayout(this, 5, 2, 10, 7);
00055 m1->setRowStretch(4, 1);
00056 m1->setColStretch(1, 1);
00057 m1->addWidget(l1, 0, 0, Qt::AlignRight);
00058 m1->addWidget(l2, 1, 0, Qt::AlignRight);
00059 m1->addWidget(l3, 2, 0, Qt::AlignRight);
00060 m1->addWidget(l4, 3, 0, Qt::AlignRight);
00061 m1->addWidget(user_, 0, 1);
00062 m1->addWidget(group_, 1, 1);
00063 m1->addWidget(ripcache_, 2, 1);
00064 m1->addWidget(filterlimit_, 3, 1);
00065 }
00066
00067 bool CupsdFilterPage::loadConfig(CupsdConf *conf, QString&)
00068 {
00069 conf_ = conf;
00070 user_->setText(conf_->user_);
00071 group_->setText(conf_->group_);
00072 ripcache_->setSizeString(conf_->ripcache_);
00073 filterlimit_->setValue(conf_->filterlimit_);
00074
00075 return true;
00076 }
00077
00078 bool CupsdFilterPage::saveConfig(CupsdConf *conf, QString&)
00079 {
00080 conf->user_ = user_->text();
00081 conf->group_ = group_->text();
00082 conf->ripcache_ = ripcache_->sizeString();
00083 conf->filterlimit_ = filterlimit_->value();
00084
00085 return true;
00086 }
00087
00088 void CupsdFilterPage::setInfos(CupsdConf *conf)
00089 {
00090 QWhatsThis::add(user_, conf->comments_.toolTip("user"));
00091 QWhatsThis::add(group_, conf->comments_.toolTip("group"));
00092 QWhatsThis::add(ripcache_, conf->comments_.toolTip("ripcache"));
00093 QWhatsThis::add(filterlimit_, conf->comments_.toolTip("filterlimit"));
00094 }