kdeprint Library API Documentation

cupsdbrowsingconnpage.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 "cupsdbrowsingconnpage.h" 00021 00022 #include <klocale.h> 00023 #include <kseparator.h> 00024 #include <qlayout.h> 00025 #include <qlineedit.h> 00026 #include <qlabel.h> 00027 #include <qwhatsthis.h> 00028 #include <qcombobox.h> 00029 00030 #include "cupsdconf.h" 00031 #include "cupsdoption.h" 00032 #include "cupslist.h" 00033 00034 CupsdBrowsingConnPage::CupsdBrowsingConnPage(QWidget *parent, const char *name) 00035 : CupsdPage(parent, name) 00036 { 00037 path_.append(i18n("Browsing")); 00038 path_.append(i18n("Connection")); 00039 header_ = i18n("Browsing Connection Configuration"); 00040 00041 for (int i=0;i<4;i++) 00042 opt_[i] = new CupsdOption(this); 00043 00044 browseaddress_ = new CupsListBox(opt_[0]); 00045 browseport_ = new QLineEdit(opt_[1]); 00046 browsepoll_ = new CupsListBox(opt_[2]); 00047 browseprotocols_ = new QComboBox(opt_[3]); 00048 browseprotocols_->insertItem(i18n("All")); 00049 browseprotocols_->insertItem(i18n("CUPS")); 00050 browseprotocols_->insertItem(i18n("SLPv2")); 00051 00052 KSeparator* sep = new KSeparator( KSeparator::HLine, this); 00053 KSeparator* sep1 = new KSeparator( KSeparator::HLine, this); 00054 00055 QLabel *l1 = new QLabel(i18n("Broadcast addresses:"), this); 00056 QLabel *l2 = new QLabel(i18n("Broadcast port:"), this); 00057 QLabel *l3 = new QLabel(i18n("Poll addresses:"), this); 00058 QLabel *l4 = new QLabel(i18n("Browse protocol:"), this); 00059 00060 QGridLayout *main_ = new QGridLayout(this, 10, 2, 10, 10); 00061 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter); 00062 main_->addWidget(opt_[3], 1, 1); 00063 main_->addWidget(l4, 1, 0); 00064 main_->addMultiCellWidget(sep1, 2, 2, 0, 1); 00065 main_->addMultiCellWidget(opt_[0], 3, 4, 1, 1); 00066 main_->addMultiCellWidget(opt_[2], 7, 8, 1, 1); 00067 main_->addWidget(opt_[1], 5, 1); 00068 main_->addWidget(sep, 6, 1); 00069 main_->addRowSpacing(6, 10); 00070 main_->addWidget(l1, 3, 0, Qt::AlignLeft|Qt::AlignTop); 00071 main_->addWidget(l2, 5, 0); 00072 main_->addWidget(l3, 7, 0, Qt::AlignLeft|Qt::AlignTop); 00073 main_->setRowStretch(9, 1); 00074 } 00075 00076 CupsdBrowsingConnPage::~CupsdBrowsingConnPage() 00077 { 00078 } 00079 00080 bool CupsdBrowsingConnPage::loadConfig(CupsdConf *conf, QString&) 00081 { 00082 conf_ = conf; 00083 QStringList::Iterator it; 00084 if (conf->browseaddress_.count() > 0) 00085 { 00086 opt_[0]->setDefault(false); 00087 for (it=conf->browseaddress_.begin();it!=conf->browseaddress_.end();++it) 00088 browseaddress_->insertItem(*it); 00089 } 00090 if (conf->browseport_ != -1) 00091 { 00092 opt_[1]->setDefault(false); 00093 browseport_->setText(QString::number(conf->browseport_)); 00094 } 00095 if (conf->browsepoll_.count() > 0) 00096 { 00097 opt_[2]->setDefault(false); 00098 for (it=conf->browsepoll_.begin();it!=conf->browsepoll_.end();++it) 00099 browsepoll_->insertItem(*it); 00100 } 00101 if (conf->browseprotocols_ != -1) 00102 { 00103 opt_[3]->setDefault(false); 00104 browseprotocols_->setCurrentItem(conf->browseprotocols_); 00105 } 00106 return true; 00107 } 00108 00109 bool CupsdBrowsingConnPage::saveConfig(CupsdConf *conf, QString& msg) 00110 { 00111 if (!opt_[0]->isDefault() && browseaddress_->count() > 0) 00112 { 00113 conf->browseaddress_.clear(); 00114 for (int i=0;i<browseaddress_->count();i++) 00115 conf->browseaddress_.append(browseaddress_->text(i)); 00116 } 00117 if (!opt_[1]->isDefault() && !browseport_->text().isNull()) 00118 { 00119 bool ok; 00120 int val = browseport_->text().toInt(&ok); 00121 if (ok) conf->browseport_ = val; 00122 else 00123 { 00124 msg = i18n("%1 wrong argument").arg(i18n("Browse port:")); 00125 return false; 00126 } 00127 } 00128 if (!opt_[2]->isDefault() && browsepoll_->count() > 0) 00129 { 00130 conf->browsepoll_.clear(); 00131 for (int i=0;i<browsepoll_->count();i++) 00132 conf->browsepoll_.append(browsepoll_->text(i)); 00133 } 00134 if (!opt_[3]->isDefault()) conf->browseprotocols_ = browseprotocols_->currentItem(); 00135 return true; 00136 } 00137 00138 void CupsdBrowsingConnPage::setDefaults() 00139 { 00140 browseport_->setText(QString::number(631)); 00141 browseprotocols_->setCurrentItem(1); 00142 } 00143 00144 void CupsdBrowsingConnPage::setInfos(CupsdConf *conf) 00145 { 00146 QWhatsThis::add(browseport_, conf->comments_.toolTip(BROWSEPORT_COMM)); 00147 QWhatsThis::add(browseaddress_, conf->comments_.toolTip(BROWSEADDRESS_COMM)); 00148 QWhatsThis::add(browsepoll_, conf->comments_.toolTip(BROWSEPOLL_COMM)); 00149 QWhatsThis::add(browseprotocols_, conf->comments_.toolTip(BROWSEPROTOCOLS_COMM)); 00150 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:49:58 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003