cupsdbrowsingtimeoutpage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cupsdbrowsingtimeoutpage.h"
00021
00022 #include <klocale.h>
00023 #include <qlayout.h>
00024 #include <qlineedit.h>
00025 #include <qlabel.h>
00026 #include <qwhatsthis.h>
00027
00028 #include "cupsdconf.h"
00029 #include "cupsdoption.h"
00030
00031 CupsdBrowsingTimeoutPage::CupsdBrowsingTimeoutPage(QWidget *parent, const char *name)
00032 : CupsdPage(parent, name)
00033 {
00034 path_.append(i18n("Browsing"));
00035 path_.append(i18n("Timeouts"));
00036 header_ = i18n("Browsing Timeouts Configuration");
00037
00038 for (int i=0;i<2;i++)
00039 opt_[i] = new CupsdOption(this);
00040
00041 browseinterval_ = new QLineEdit(opt_[0]);
00042 browsetimeout_ = new QLineEdit(opt_[1]);
00043
00044 QLabel *l1 = new QLabel(i18n("Browse interval:"), this);
00045 QLabel *l2 = new QLabel(i18n("Browse timeout:"), this);
00046
00047 QGridLayout *main_ = new QGridLayout(this, 5, 2, 10, 10);
00048 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00049 main_->addWidget(opt_[0], 1, 1);
00050 main_->addWidget(opt_[1], 3, 1);
00051 main_->addWidget(l1, 1, 0);
00052 main_->addWidget(l2, 3, 0);
00053 main_->setRowStretch(4, 1);
00054 main_->addRowSpacing(2, 20);
00055 }
00056
00057 CupsdBrowsingTimeoutPage::~CupsdBrowsingTimeoutPage()
00058 {
00059 }
00060
00061 bool CupsdBrowsingTimeoutPage::loadConfig(CupsdConf *conf, QString&)
00062 {
00063 conf_ = conf;
00064 if (conf->browseinterval_ != -1)
00065 {
00066 opt_[0]->setDefault(0);
00067 browseinterval_->setText(QString::number(conf->browseinterval_));
00068 }
00069 if (conf->browsetimeout_ != -1)
00070 {
00071 opt_[1]->setDefault(0);
00072 browsetimeout_->setText(QString::number(conf->browsetimeout_));
00073 }
00074 return true;
00075 }
00076
00077 bool CupsdBrowsingTimeoutPage::saveConfig(CupsdConf *conf, QString& msg)
00078 {
00079 bool ok;
00080 int v1(30), v2(300);
00081 if (!opt_[0]->isDefault())
00082 {
00083 v1 = browseinterval_->text().toInt(&ok);
00084 if (ok) conf->browseinterval_ = v1;
00085 else
00086 {
00087 msg = i18n("%1 wrong argument!").arg(i18n("Browse interval:"));
00088 return false;
00089 }
00090 }
00091 if (!opt_[1]->isDefault())
00092 {
00093 v2 = browsetimeout_->text().toInt(&ok);
00094 if (ok) conf->browsetimeout_ = v2;
00095 else
00096 {
00097 msg = i18n("%1 wrong argument!").arg(i18n("Browse timeout:"));
00098 return false;
00099 }
00100 }
00101 if (v2 <= v1)
00102 {
00103 msg = i18n("Browse timeout value must be greater than browse interval");
00104 return false;
00105 }
00106 return true;
00107 }
00108
00109 void CupsdBrowsingTimeoutPage::setDefaults()
00110 {
00111 browseinterval_->setText(QString::number(30));
00112 browsetimeout_->setText(QString::number(300));
00113 }
00114
00115 void CupsdBrowsingTimeoutPage::setInfos(CupsdConf *conf)
00116 {
00117 QWhatsThis::add(browseinterval_, conf->comments_.toolTip(BROWSEINTERVAL_COMM));
00118 QWhatsThis::add(browsetimeout_, conf->comments_.toolTip(BROWSETIMEOUT_COMM));
00119 }
This file is part of the documentation for kdeprint Library Version 3.3.1.