# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# cupsdbrowsingpage.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@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., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "cupsdbrowsingpage.h"
    00021 #include "cupsdconf.h"
    00022 #include "editlist.h"
    00023 #include "browsedialog.h"
    00024
    00025 #include <qlabel.h>
    00026 #include <qlayout.h>
    00027 #include <qcheckbox.h>
    00028 #include <qcombobox.h>
    00029 #include <qwhatsthis.h>
    00030
    00031 #include <klocale.h>
    00032 #include <knuminput.h>
    00033
    00034 CupsdBrowsingPage::CupsdBrowsingPage(QWidget *parent, const char *name)
    00035     : CupsdPage(parent, name)
    00036 {
    00037     setPageLabel(i18n("Browsing"));
    00038     setHeader(i18n("Browsing Settings"));
    00039     setPixmap("kdeprint_printer_remote");
    00040
    00041     browseinterval_ = new KIntNumInput(this);
    00042     browseport_ = new KIntNumInput(this);
    00043     browsetimeout_ = new KIntNumInput(this);
    00044     browsing_ = new QCheckBox(i18n("Use browsing"), this);
    00045     cups_ = new QCheckBox("CUPS", this);
    00046     slp_ = new QCheckBox("SLP", this);
    00047     browseaddresses_ = new EditList(this);
    00048     browseorder_ = new QComboBox(this);
    00049     useimplicitclasses_ = new QCheckBox(i18n("Implicit classes"), this);
    00050     hideimplicitmembers_ = new QCheckBox(i18n("Hide implicit members"), this);
    00051     useshortnames_ = new QCheckBox(i18n("Use short names"), this);
    00052     useanyclasses_ = new QCheckBox(i18n("Use \"any\" classes"), this);
    00053
    00054     browseorder_->insertItem(i18n("Allow, Deny"));
    00055     browseorder_->insertItem(i18n("Deny, Allow"));
    00056
    00057     browseport_->setRange(0, 9999, 1, true);
    00058     browseport_->setSteps(1, 5);
    00059     browseinterval_->setRange(0, 10000, 1, true);
    00060     browseinterval_->setSteps(1, 10);
    00061     browseinterval_->setSuffix(i18n(" sec"));
    00062     browsetimeout_->setRange(0, 10000, 1, true);
    00063     browsetimeout_->setSteps(1, 10);
    00064     browsetimeout_->setSuffix(i18n(" sec"));
    00065
    00066     QLabel *l1 = new QLabel(i18n("Browse port:"), this);
    00067     QLabel *l2 = new QLabel(i18n("Browse interval:"), this);
    00068     QLabel *l3 = new QLabel(i18n("Browse timeout:"), this);
    00069     QLabel *l4 = new QLabel(i18n("Browse addresses:"), this);
    00070     QLabel *l5 = new QLabel(i18n("Browse order:"), this);
    00071     QLabel *l6 = new QLabel(i18n("Browse options:"), this);
    00072
    00073     QGridLayout *m1 = new QGridLayout(this, 8, 2, 10, 7);
    00074     m1->setRowStretch(7, 1);
    00075     m1->setColStretch(1, 1);
    00076     QHBoxLayout *m2 = new QHBoxLayout(0, 0, 10);
    00077     m1->addMultiCellLayout(m2, 0, 0, 0, 1);
    00078     m2->addWidget(browsing_);
    00079     m2->addWidget(cups_);
    00080     m2->addWidget(slp_);
    00081     m2->addStretch(1);
    00082     m1->addWidget(l1, 1, 0, Qt::AlignRight);
    00083     m1->addWidget(l2, 2, 0, Qt::AlignRight);
    00084     m1->addWidget(l3, 3, 0, Qt::AlignRight);
    00085     m1->addWidget(l4, 4, 0, Qt::AlignRight|Qt::AlignTop);
    00086     m1->addWidget(l5, 5, 0, Qt::AlignRight);
    00087     m1->addWidget(l6, 6, 0, Qt::AlignRight|Qt::AlignTop);
    00088     m1->addWidget(browseport_, 1, 1);
    00089     m1->addWidget(browseinterval_, 2, 1);
    00090     m1->addWidget(browsetimeout_, 3, 1);
    00091     m1->addWidget(browseaddresses_, 4, 1);
    00092     m1->addWidget(browseorder_, 5, 1);
    00093     QGridLayout *m3 = new QGridLayout(0, 2, 2, 0, 5);
    00094     m1->addLayout(m3, 6, 1);
    00095     m3->addWidget(useimplicitclasses_, 0, 0);
    00096     m3->addWidget(useanyclasses_, 0, 1);
    00097     m3->addWidget(hideimplicitmembers_, 1, 0);
    00098     m3->addWidget(useshortnames_, 1, 1);
    00099
    00100     connect(browsing_, SIGNAL(toggled(bool)), cups_, SLOT(setEnabled(bool)));
    00101     connect(browsing_, SIGNAL(toggled(bool)), slp_, SLOT(setEnabled(bool)));
    00102     connect(browsing_, SIGNAL(toggled(bool)), browseport_, SLOT(setEnabled(bool)));
    00103     connect(browsing_, SIGNAL(toggled(bool)), browseinterval_, SLOT(setEnabled(bool)));
    00104     connect(browsing_, SIGNAL(toggled(bool)), browsetimeout_, SLOT(setEnabled(bool)));
    00105     connect(browsing_, SIGNAL(toggled(bool)), browseaddresses_, SLOT(setEnabled(bool)));
    00106     connect(browsing_, SIGNAL(toggled(bool)), browseorder_, SLOT(setEnabled(bool)));
    00107     connect(browsing_, SIGNAL(toggled(bool)), useimplicitclasses_, SLOT(setEnabled(bool)));
    00108     connect(browsing_, SIGNAL(toggled(bool)), useanyclasses_, SLOT(setEnabled(bool)));
    00109     connect(browsing_, SIGNAL(toggled(bool)), hideimplicitmembers_, SLOT(setEnabled(bool)));
    00110     connect(browsing_, SIGNAL(toggled(bool)), useshortnames_, SLOT(setEnabled(bool)));
    00111
    00112     connect(browsing_, SIGNAL(toggled(bool)), l1, SLOT(setEnabled(bool)));
    00113     connect(browsing_, SIGNAL(toggled(bool)), l2, SLOT(setEnabled(bool)));
    00114     connect(browsing_, SIGNAL(toggled(bool)), l3, SLOT(setEnabled(bool)));
    00115     connect(browsing_, SIGNAL(toggled(bool)), l4, SLOT(setEnabled(bool)));
    00116     connect(browsing_, SIGNAL(toggled(bool)), l5, SLOT(setEnabled(bool)));
    00117     connect(browsing_, SIGNAL(toggled(bool)), l6, SLOT(setEnabled(bool)));
    00118
    00119     connect(browseaddresses_, SIGNAL(add()), SLOT(slotAdd()));
    00120     connect(browseaddresses_, SIGNAL(edit(int)), SLOT(slotEdit(int)));
    00121     connect(browseaddresses_, SIGNAL(defaultList()), SLOT(slotDefaultList()));
    00122     connect(browseinterval_, SIGNAL(valueChanged(int)), SLOT(intervalChanged(int)));
    00123     browsing_->setChecked(true);
    00124 }
    00125
    00126 bool CupsdBrowsingPage::loadConfig(CupsdConf *conf, QString&)
    00127 {
    00128     conf_ = conf;
    00129     browsing_->setChecked(conf_->browsing_);
    00130     cups_->setChecked(conf_->browseprotocols_.findIndex("CUPS") != -1);
    00131     slp_->setChecked(conf_->browseprotocols_.findIndex("SLP") != -1);
    00132     browseport_->setValue(conf_->browseport_);
    00133     browseinterval_->setValue(conf_->browseinterval_);
    00134     browsetimeout_->setValue(conf_->browsetimeout_);
    00135     browseaddresses_->insertItems(conf_->browseaddresses_);
    00136     browseorder_->setCurrentItem(conf_->browseorder_);
    00137     useimplicitclasses_->setChecked(conf_->useimplicitclasses_);
    00138     useanyclasses_->setChecked(conf_->useanyclasses_);
    00139     hideimplicitmembers_->setChecked(conf_->hideimplicitmembers_);
    00140     useshortnames_->setChecked(conf_->useshortnames_);
    00141
    00142     return true;
    00143 }
    00144
    00145 bool CupsdBrowsingPage::saveConfig(CupsdConf *conf, QString&)
    00146 {
    00147     conf->browsing_ = browsing_->isChecked();
    00148     QStringList l;
    00149     if (cups_->isChecked()) l << "CUPS";
    00150     if (slp_->isChecked()) l << "SLP";
    00151     conf->browseprotocols_ = l;
    00152     conf->browseport_ = browseport_->value();
    00153     conf->browseinterval_ = browseinterval_->value();
    00154     conf->browsetimeout_ = browsetimeout_->value();
    00155     conf->browseaddresses_ = browseaddresses_->items();
    00156     conf->browseorder_ = browseorder_->currentItem();
    00157     conf->useimplicitclasses_ = useimplicitclasses_->isChecked();
    00158     conf->useanyclasses_ = useanyclasses_->isChecked();
    00159     conf->hideimplicitmembers_ = hideimplicitmembers_->isChecked();
    00160     conf->useshortnames_ = useshortnames_->isChecked();
    00161
    00162     return true;
    00163 }
    00164
    00165 void CupsdBrowsingPage::setInfos(CupsdConf *conf)
    00166 {
    00167     QWhatsThis::add(browsing_, conf->comments_.toolTip("browsing"));
    00168     QWhatsThis::add(cups_, conf->comments_.toolTip("browseprotocols"));
    00169     QWhatsThis::add(slp_, conf->comments_.toolTip("browseprotocols"));
    00170     QWhatsThis::add(browseinterval_, conf->comments_.toolTip("browseinterval"));
    00171     QWhatsThis::add(browseport_, conf->comments_.toolTip("browseport"));
    00172     QWhatsThis::add(browsetimeout_, conf->comments_.toolTip("browsetimeout"));
    00173     QWhatsThis::add(browseaddresses_, conf->comments_.toolTip("browseaddresses"));
    00174     QWhatsThis::add(browseorder_, conf->comments_.toolTip("browseorder"));
    00175     QWhatsThis::add(useimplicitclasses_, conf->comments_.toolTip("implicitclasses"));
    00176     QWhatsThis::add(useanyclasses_, conf->comments_.toolTip("implicitanyclasses"));
    00177     QWhatsThis::add(hideimplicitmembers_, conf->comments_.toolTip("hideimplicitmembers"));
    00178     QWhatsThis::add(useshortnames_, conf->comments_.toolTip("browseshortnames"));
    00179 }
    00180
    00181 void CupsdBrowsingPage::slotAdd()
    00182 {
    00183     QString s = BrowseDialog::newAddress(this, conf_);
    00184     if (!s.isEmpty())
    00185         browseaddresses_->insertItem(s);
    00186 }
    00187
    00188 void CupsdBrowsingPage::slotEdit(int index)
    00189 {
    00190     QString s = browseaddresses_->text(index);
    00191     s = BrowseDialog::editAddress(s, this, conf_);
    00192     if (!s.isEmpty())
    00193         browseaddresses_->setText(index, s);
    00194 }
    00195
    00196 void CupsdBrowsingPage::slotDefaultList()
    00197 {
    00198     browseaddresses_->clear();
    00199     QStringList l;
    00200     l << "Send 255.255.255.255";
    00201     browseaddresses_->insertItems(l);
    00202 }
    00203
    00204 void CupsdBrowsingPage::intervalChanged(int val)
    00205 {
    00206     browsetimeout_->setRange(val, 10000, 1, true);
    00207     browsetimeout_->setSteps(1, 10);
    00208 }
    00209
    00210 #include "cupsdbrowsingpage.moc"

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:00 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003