• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

cupsdnetworkpage.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "cupsdnetworkpage.h"
00021 #include "cupsdconf.h"
00022 #include "editlist.h"
00023 #include "portdialog.h"
00024 #include "sizewidget.h"
00025 
00026 #include <tqlabel.h>
00027 #include <tqcheckbox.h>
00028 #include <tqcombobox.h>
00029 #include <tqlayout.h>
00030 #include <tqwhatsthis.h>
00031 
00032 #include <tdelocale.h>
00033 #include <knuminput.h>
00034 
00035 CupsdNetworkPage::CupsdNetworkPage(TQWidget *parent, const char *name)
00036     : CupsdPage(parent, name)
00037 {
00038     setPageLabel(i18n("Network"));
00039     setHeader(i18n("Network Settings"));
00040     setPixmap("network");
00041 
00042     keepalive_ = new TQCheckBox(i18n("Keep alive"), this);
00043     keepalivetimeout_ = new KIntNumInput(this);
00044     maxclients_ = new KIntNumInput(this);
00045     maxrequestsize_ = new SizeWidget(this);
00046     clienttimeout_ = new KIntNumInput(this);
00047     hostnamelookup_ = new TQComboBox(this);
00048     listen_ = new EditList(this);
00049 
00050     keepalivetimeout_->setRange(0, 10000, 1, true);
00051     keepalivetimeout_->setSteps(1, 10);
00052     keepalivetimeout_->setSpecialValueText(i18n("Unlimited"));
00053     keepalivetimeout_->setSuffix(i18n(" sec"));
00054 
00055     maxclients_->setRange(1, 1000, 1, true);
00056     maxclients_->setSteps(1, 10);
00057 
00058     clienttimeout_->setRange(0, 10000, 1, true);
00059     clienttimeout_->setSteps(1, 10);
00060     clienttimeout_->setSpecialValueText(i18n("Unlimited"));
00061     clienttimeout_->setSuffix(i18n(" sec"));
00062 
00063     hostnamelookup_->insertItem(i18n("Off"));
00064     hostnamelookup_->insertItem(i18n("On"));
00065     hostnamelookup_->insertItem(i18n("Double"));
00066 
00067     TQLabel *l1 = new TQLabel(i18n("Hostname lookups:"), this);
00068     TQLabel *l2 = new TQLabel(i18n("Keep-alive timeout:"), this);
00069     TQLabel *l3 = new TQLabel(i18n("Max clients:"), this);
00070     TQLabel *l4 = new TQLabel(i18n("Max request size:"), this);
00071     TQLabel *l5 = new TQLabel(i18n("Client timeout:"), this);
00072     TQLabel *l6 = new TQLabel(i18n("Listen to:"), this);
00073 
00074     TQGridLayout    *m1 = new TQGridLayout(this, 8, 2, 10, 7);
00075     m1->setRowStretch(7, 1);
00076     m1->setColStretch(1, 1);
00077     m1->addWidget(l1, 0, 0, Qt::AlignRight);
00078     m1->addWidget(l2, 2, 0, Qt::AlignRight);
00079     m1->addWidget(l3, 3, 0, Qt::AlignRight);
00080     m1->addWidget(l4, 4, 0, Qt::AlignRight);
00081     m1->addWidget(l5, 5, 0, Qt::AlignRight);
00082     m1->addWidget(l6, 6, 0, Qt::AlignTop|Qt::AlignRight);
00083     m1->addWidget(keepalive_, 1, 1);
00084     m1->addWidget(hostnamelookup_, 0, 1);
00085     m1->addWidget(keepalivetimeout_, 2, 1);
00086     m1->addWidget(maxclients_, 3, 1);
00087     m1->addWidget(maxrequestsize_, 4, 1);
00088     m1->addWidget(clienttimeout_, 5, 1);
00089     m1->addWidget(listen_, 6, 1);
00090 
00091     connect(listen_, TQT_SIGNAL(add()), TQT_SLOT(slotAdd()));
00092     connect(listen_, TQT_SIGNAL(edit(int)), TQT_SLOT(slotEdit(int)));
00093     connect(listen_, TQT_SIGNAL(defaultList()), TQT_SLOT(slotDefaultList()));
00094     connect(keepalive_, TQT_SIGNAL(toggled(bool)), keepalivetimeout_, TQT_SLOT(setEnabled(bool)));
00095     keepalive_->setChecked(true);
00096 }
00097 
00098 bool CupsdNetworkPage::loadConfig(CupsdConf *conf, TQString&)
00099 {
00100     conf_ = conf;
00101     hostnamelookup_->setCurrentItem(conf_->hostnamelookup_);
00102     keepalive_->setChecked(conf_->keepalive_);
00103     keepalivetimeout_->setValue(conf_->keepalivetimeout_);
00104     maxclients_->setValue(conf_->maxclients_);
00105     maxrequestsize_->setSizeString(conf_->maxrequestsize_);
00106     clienttimeout_->setValue(conf_->clienttimeout_);
00107     listen_->insertItems(conf_->listenaddresses_);
00108 
00109     return true;
00110 }
00111 
00112 bool CupsdNetworkPage::saveConfig(CupsdConf *conf, TQString&)
00113 {
00114     conf->hostnamelookup_ = hostnamelookup_->currentItem();
00115     conf->keepalive_ = keepalive_->isChecked();
00116     conf->keepalivetimeout_ = keepalivetimeout_->value();
00117     conf->maxclients_ = maxclients_->value();
00118     conf->maxrequestsize_ = maxrequestsize_->sizeString();
00119     conf->clienttimeout_ = clienttimeout_->value();
00120     conf->listenaddresses_ = listen_->items();
00121 
00122     return true;
00123 }
00124 
00125 void CupsdNetworkPage::setInfos(CupsdConf *conf)
00126 {
00127     TQWhatsThis::add(hostnamelookup_, conf->comments_.toolTip("hostnamelookups"));
00128     TQWhatsThis::add(keepalive_, conf->comments_.toolTip("keepalive"));
00129     TQWhatsThis::add(keepalivetimeout_, conf->comments_.toolTip("keepalivetimeout"));
00130     TQWhatsThis::add(maxclients_, conf->comments_.toolTip("maxclients"));
00131     TQWhatsThis::add(maxrequestsize_, conf->comments_.toolTip("maxrequestsize"));
00132     TQWhatsThis::add(clienttimeout_, conf->comments_.toolTip("timeout"));
00133     TQWhatsThis::add(listen_, conf->comments_.toolTip("listen"));
00134 }
00135 
00136 void CupsdNetworkPage::slotAdd()
00137 {
00138     TQString    s = PortDialog::newListen(this, conf_);
00139     if (!s.isEmpty())
00140         listen_->insertItem(s);
00141 }
00142 
00143 void CupsdNetworkPage::slotEdit(int index)
00144 {
00145     TQString s = listen_->text(index);
00146     s = PortDialog::editListen(s, this, conf_);
00147     if (!s.isEmpty())
00148         listen_->setText(index, s);
00149 }
00150 
00151 void CupsdNetworkPage::slotDefaultList()
00152 {
00153     listen_->clear();
00154     TQStringList    l;
00155     l << "Listen *:631";
00156     listen_->insertItems(l);
00157 }
00158 
00159 #include "cupsdnetworkpage.moc"

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.1
This website is maintained by Timothy Pearson.