cupsdnetworkgeneralpage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cupsdnetworkgeneralpage.h"
00021
00022 #include <klocale.h>
00023 #include <qlayout.h>
00024 #include <qcheckbox.h>
00025 #include <qlabel.h>
00026 #include <qlineedit.h>
00027 #include <qwhatsthis.h>
00028
00029 #include "cupsdconf.h"
00030 #include "cupsdoption.h"
00031 #include "cupslist.h"
00032
00033 CupsdNetworkGeneralPage::CupsdNetworkGeneralPage(QWidget *parent, const char *name)
00034 : CupsdPage(parent, name)
00035 {
00036 path_.append(i18n("Network"));
00037 header_ = i18n("Network General Configuration");
00038
00039 for (int i=0;i<4;i++)
00040 opt_[i] = new CupsdOption(this);
00041
00042 port_ = new CupsListBox(opt_[0]);
00043 hostnamelookups_ = new QCheckBox(i18n("Look for hostname on IP addresses"), opt_[1]);
00044 maxrequestsize_ = new QLineEdit(opt_[2]);
00045 timeout_ = new QLineEdit(opt_[3]);
00046
00047 QLabel *l1 = new QLabel(i18n("Port:"), this);
00048 QLabel *l3 = new QLabel(i18n("Max request size:"), this);
00049 QLabel *l4 = new QLabel(i18n("Timeout:"), this);
00050
00051 QGridLayout *main_ = new QGridLayout(this, 8, 2, 10, 10);
00052 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00053 main_->addMultiCellWidget(opt_[1], 1, 1, 0, 1);
00054 main_->addMultiCellWidget(opt_[0], 2, 3, 1, 1);
00055 main_->addWidget(opt_[2], 5, 1);
00056 main_->addWidget(opt_[3], 6, 1);
00057 main_->addWidget(l1, 2, 0, Qt::AlignLeft|Qt::AlignTop);
00058 main_->addWidget(l3, 5, 0);
00059 main_->addWidget(l4, 6, 0);
00060 main_->addRowSpacing(4, 20);
00061 main_->setRowStretch(7, 1);
00062 }
00063
00064 CupsdNetworkGeneralPage::~CupsdNetworkGeneralPage()
00065 {
00066 }
00067
00068 bool CupsdNetworkGeneralPage::loadConfig(CupsdConf *conf, QString&)
00069 {
00070 conf_ = conf;
00071 QValueList<int>::Iterator it;
00072 if (conf->port_.count() > 0)
00073 {
00074 opt_[0]->setDefault(false);
00075 for (it=conf->port_.begin();it!=conf->port_.end();++it)
00076 port_->insertItem(QString::number(*it));
00077 }
00078 if (conf->hostnamelookups_ != -1)
00079 {
00080 opt_[1]->setDefault(false);
00081 hostnamelookups_->setChecked(conf->hostnamelookups_ == 1);
00082 }
00083 if (conf->maxrequestsize_ != -1)
00084 {
00085 opt_[2]->setDefault(false);
00086 maxrequestsize_->setText(QString::number(conf->maxrequestsize_));
00087 }
00088 if (conf->timeout_ != -1)
00089 {
00090 opt_[3]->setDefault(false);
00091 timeout_->setText(QString::number(conf->timeout_));
00092 }
00093 return true;
00094 }
00095
00096 bool CupsdNetworkGeneralPage::saveConfig(CupsdConf *conf, QString& msg)
00097 {
00098 bool ok;
00099 int p;
00100 if (!opt_[0]->isDefault() && port_->count() > 0)
00101 {
00102 conf->port_.clear();
00103 for (int i=0;i<port_->count();i++)
00104 {
00105 p = port_->text(i).toInt(&ok);
00106 if (ok) conf->port_.append(p);
00107 else
00108 {
00109 msg = i18n("%1 wrong argument").arg(i18n("Port:"));
00110 return false;
00111 }
00112 }
00113 }
00114 if (!opt_[1]->isDefault()) conf->hostnamelookups_ = (hostnamelookups_->isChecked() ? 1 : 0);
00115 if (!opt_[2]->isDefault() && !maxrequestsize_->text().isNull())
00116 {
00117 p = maxrequestsize_->text().toInt(&ok);
00118 if (ok) conf->maxrequestsize_ = p;
00119 else
00120 {
00121 msg = i18n("%1 wrong argument").arg(i18n("Max request size:"));
00122 return false;
00123 }
00124 }
00125 if (!opt_[3]->isDefault() && !timeout_->text().isNull())
00126 {
00127 p = timeout_->text().toInt(&ok);
00128 if (ok) conf->timeout_ = p;
00129 else
00130 {
00131 msg = i18n("%1 wrong argument").arg(i18n("Timeout:"));
00132 return false;
00133 }
00134 }
00135 return true;
00136 }
00137
00138 void CupsdNetworkGeneralPage::setDefaults()
00139 {
00140 hostnamelookups_->setChecked(false);
00141 maxrequestsize_->setText(QString::number(0));
00142 timeout_->setText(QString::number(300));
00143 }
00144
00145 void CupsdNetworkGeneralPage::setInfos(CupsdConf *conf)
00146 {
00147 QWhatsThis::add(hostnamelookups_, conf->comments_.toolTip(HOSTNAMELOOKUPS_COMM));
00148 QWhatsThis::add(maxrequestsize_, conf->comments_.toolTip(MAXREQUESTSIZE_COMM));
00149 QWhatsThis::add(timeout_, conf->comments_.toolTip(TIMEOUT_COMM));
00150 QWhatsThis::add(port_, conf->comments_.toolTip(PORT_COMM));
00151 }
This file is part of the documentation for kdeprint Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:12:53 2004 by
doxygen 1.3.8-20040913 written by
Dimitri van Heesch, © 1997-2003