00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "cupsdserverjobpage.h"
00021
00022
#include "qdirlineedit.h"
00023
#include <qlineedit.h>
00024
#include <klocale.h>
00025
#include <qlayout.h>
00026
#include <qlabel.h>
00027
#include <qcheckbox.h>
00028
#include <qwhatsthis.h>
00029
00030
#include <kseparator.h>
00031
00032
#include "cupsdconf.h"
00033
#include "cupsdoption.h"
00034
00035 CupsdServerJobPage::CupsdServerJobPage(
QWidget *parent,
const char *name)
00036 : CupsdPage(parent, name)
00037 {
00038 path_.append(i18n(
"Server"));
00039 path_.append(i18n(
"Jobs"));
00040 header_ = i18n(
"Server Jobs Configuration");
00041
00042
for (
int i=0;i<7;i++)
00043 opt_[i] =
new CupsdOption(
this);
00044
00045 preservejobhistory_ =
new QCheckBox(i18n(
"Preserve job history (after completion)"), opt_[0]);
00046 preservejobfiles_ =
new QCheckBox(i18n(
"Preserve job file (after completion)"), opt_[1]);
00047 autopurgejobs_ =
new QCheckBox(i18n(
"Remove jobs if no quotas"), opt_[2]);
00048 maxjobs_ =
new QLineEdit(opt_[3]);
00049 filterlimit_ =
new QLineEdit(opt_[4]);
00050
00051 KSeparator* sep =
new KSeparator( KSeparator::HLine,
this);
00052
00053 classification_ =
new QLineEdit(opt_[5]);
00054 classifyoverride_ =
new QCheckBox(i18n(
"Allow classification override"), opt_[6]);
00055
00056
QLabel *l1 =
new QLabel(i18n(
"Jobs to keep in memory:"),
this);
00057 QLabel *l2 =
new QLabel(i18n(
"Filter limit:"),
this);
00058 QLabel *l3 =
new QLabel(i18n(
"Default classification:"),
this);
00059
00060
QGridLayout *main_ =
new QGridLayout(
this, 10, 2, 10, 10);
00061 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00062 main_->addMultiCellWidget(opt_[0], 1, 1, 0, 1);
00063 main_->addMultiCellWidget(opt_[1], 2, 2, 0, 1);
00064 main_->addMultiCellWidget(opt_[2], 3, 3, 0, 1);
00065 main_->addWidget(opt_[3], 4, 1);
00066 main_->addWidget(opt_[4], 5, 1);
00067 main_->addWidget(l1, 4, 0);
00068 main_->addWidget(l2, 5, 0);
00069 main_->addMultiCellWidget(sep, 6, 6, 0, 1);
00070 main_->addWidget(opt_[5], 7, 1);
00071 main_->addWidget(l3, 7, 0);
00072 main_->addMultiCellWidget(opt_[6], 8, 8, 0, 1);
00073 main_->setRowStretch(9, 1);
00074 }
00075
00076 CupsdServerJobPage::~CupsdServerJobPage()
00077 {
00078 }
00079
00080
bool CupsdServerJobPage::loadConfig(CupsdConf *conf,
QString&)
00081 {
00082 conf_ = conf;
00083
if (conf->preservejobhistory_ != -1)
00084 {
00085 opt_[0]->setDefault(
false);
00086 preservejobhistory_->setChecked(conf->preservejobhistory_ == 1);
00087 }
00088
if (conf->preservejobfiles_ != -1)
00089 {
00090 opt_[1]->setDefault(
false);
00091 preservejobfiles_->setChecked(conf->preservejobfiles_ == 1);
00092 }
00093
if (conf->autopurgejobs_ != -1)
00094 {
00095 opt_[2]->setDefault(
false);
00096 autopurgejobs_->setChecked(conf->autopurgejobs_ == 1);
00097 }
00098
if (conf->maxjobs_ != -1)
00099 {
00100 opt_[3]->setDefault(
false);
00101 maxjobs_->setText(QString::number(conf->maxjobs_));
00102 }
00103
if (conf->filterlimit_ != -1)
00104 {
00105 opt_[4]->setDefault(
false);
00106 filterlimit_->setText(QString::number(conf->filterlimit_));
00107 }
00108
if (!conf->classification_.isNull())
00109 {
00110 opt_[5]->setDefault(
false);
00111 classification_->setText(conf->classification_);
00112 }
00113
if (conf->classifyoverride_ != -1)
00114 {
00115 opt_[6]->setDefault(
false);
00116 classifyoverride_->setChecked(conf->classifyoverride_ == 1);
00117 }
00118
return true;
00119 }
00120
00121
bool CupsdServerJobPage::saveConfig(CupsdConf *conf,
QString& msg)
00122 {
00123
if (!opt_[0]->isDefault()) conf->preservejobhistory_ = (preservejobhistory_->isChecked() ? 1 : 0);
00124
if (!opt_[1]->isDefault()) conf->preservejobfiles_ = (preservejobfiles_->isChecked() ? 1 : 0);
00125
if (!opt_[2]->isDefault()) conf->autopurgejobs_ = (autopurgejobs_->isChecked() ? 1 : 0);
00126
if (!opt_[3]->isDefault())
00127 {
00128
bool ok;
00129
int value = maxjobs_->text().toInt(&ok);
00130
if (ok) conf->maxjobs_ = value;
00131
else
00132 {
00133 msg = i18n(
"%1 wrong argument").arg(i18n(
"Job to keep in memory:"));
00134
return false;
00135 }
00136 }
00137
if (!opt_[4]->isDefault())
00138 {
00139
bool ok;
00140
int value = filterlimit_->text().toInt(&ok);
00141
if (ok) conf->filterlimit_ = value;
00142
else
00143 {
00144 msg = i18n(
"%1 wrong argument").arg(i18n(
"Filter limit:"));
00145
return false;
00146 }
00147 }
00148
if (!opt_[5]->isDefault() && !classification_->text().isNull()) conf->classification_ = classification_->text();
00149
if (!opt_[6]->isDefault()) conf->classifyoverride_ = (classifyoverride_->isChecked() ? 1 : 0);
00150
return true;
00151 }
00152
00153
void CupsdServerJobPage::setDefaults()
00154 {
00155 preservejobhistory_->setChecked(
true);
00156 preservejobfiles_->setChecked(
false);
00157 autopurgejobs_->setChecked(
false);
00158 maxjobs_->setText(
"0");
00159 filterlimit_->setText(
"0");
00160 classification_->setText(QString::null);
00161 classifyoverride_->setChecked(
false);
00162 }
00163
00164
void CupsdServerJobPage::setInfos(CupsdConf *conf)
00165 {
00166 QWhatsThis::add(preservejobhistory_, conf->comments_.toolTip(PRESERVEJOBHIST_COMM));
00167 QWhatsThis::add(preservejobfiles_, conf->comments_.toolTip(PRESERVEJOBFILE_COMM));
00168 QWhatsThis::add(autopurgejobs_, conf->comments_.toolTip(AUTOPURGEJOBS_COMM));
00169 QWhatsThis::add(maxjobs_, conf->comments_.toolTip(MAXJOBS_COMM));
00170 QWhatsThis::add(filterlimit_, conf->comments_.toolTip(FILTERLIMIT_COMM));
00171 QWhatsThis::add(classification_, conf->comments_.toolTip(CLASSIFICATION_COMM));
00172 QWhatsThis::add(classifyoverride_, conf->comments_.toolTip(CLASSIFYOVERRIDE_COMM));
00173 }