| # kdeprint Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# portdialog.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 "portdialog.h"
    00021 #include "cupsdconf.h"
    00022
    00023 #include <qlineedit.h>
    00024 #include <qspinbox.h>
    00025 #include <qcheckbox.h>
    00026 #include <qpushbutton.h>
    00027 #include <qlabel.h>
    00028 #include <qlayout.h>
    00029 #include <qwhatsthis.h>
    00030
    00031 #include <klocale.h>
    00032
    00033 PortDialog::PortDialog(QWidget *parent, const char *name)
    00034     : KDialogBase(parent, name, true, QString::null, Ok|Cancel, Ok, true)
    00035 {
    00036     QWidget *dummy = new QWidget(this);
    00037     setMainWidget(dummy);
    00038     address_ = new QLineEdit(dummy);
    00039     port_ = new QSpinBox(0, 9999, 1, dummy);
    00040     port_->setValue(631);
    00041     usessl_ = new QCheckBox(i18n("Use SSL encryption"), dummy);
    00042
    00043     QLabel  *l1 = new QLabel(i18n("Address:"), dummy);
    00044     QLabel  *l2 = new QLabel(i18n("Port:"), dummy);
    00045
    00046     QVBoxLayout *m1 = new QVBoxLayout(dummy, 0, 10);
    00047     QGridLayout *m2 = new QGridLayout(0, 3, 2, 0, 5);
    00048     m1->addLayout(m2);
    00049     m2->addWidget(l1, 0, 0, Qt::AlignRight);
    00050     m2->addWidget(l2, 1, 0, Qt::AlignRight);
    00051     m2->addMultiCellWidget(usessl_, 2, 2, 0, 1);
    00052     m2->addWidget(address_, 0, 1);
    00053     m2->addWidget(port_, 1, 1);
    00054
    00055     setCaption(i18n("Listen To"));
    00056     resize(250, 100);
    00057 }
    00058
    00059 QString PortDialog::listenString()
    00060 {
    00061     QString s;
    00062     if (usessl_->isChecked())
    00063         s.append("SSLListen ");
    00064     else
    00065         s.append("Listen ");
    00066     if (!address_->text().isEmpty())
    00067         s.append(address_->text());
    00068     else
    00069         s.append("*");
    00070     s.append(":").append(port_->text());
    00071     return s;
    00072 }
    00073
    00074 void PortDialog::setInfos(CupsdConf *conf)
    00075 {
    00076     QWhatsThis::add(address_, conf->comments_.toolTip("address"));
    00077     QWhatsThis::add(port_, conf->comments_.toolTip("port"));
    00078     QWhatsThis::add(usessl_, conf->comments_.toolTip("usessl"));
    00079 }
    00080
    00081 QString PortDialog::newListen(QWidget *parent, CupsdConf *conf)
    00082 {
    00083     PortDialog  dlg(parent);
    00084     dlg.setInfos(conf);
    00085     if (dlg.exec())
    00086     {
    00087         return dlg.listenString();
    00088     }
    00089     return QString::null;
    00090 }
    00091
    00092 QString PortDialog::editListen(const QString& s, QWidget *parent, CupsdConf *conf)
    00093 {
    00094     PortDialog  dlg(parent);
    00095     dlg.setInfos(conf);
    00096     int p = s.find(' ');
    00097     if (p != -1)
    00098     {
    00099         dlg.usessl_->setChecked(s.left(p).startsWith("SSL"));
    00100         QString addr = s.mid(p+1).stripWhiteSpace();
    00101         int p1 = addr.find(':');
    00102         if (p1 == -1)
    00103         {
    00104             dlg.address_->setText(addr);
    00105             dlg.port_->setValue(631);
    00106         }
    00107         else
    00108         {
    00109             dlg.address_->setText(addr.left(p1));
    00110             dlg.port_->setValue(addr.mid(p1+1).toInt());
    00111         }
    00112     }
    00113     if (dlg.exec())
    00114     {
    00115         return dlg.listenString();
    00116     }
    00117     return QString::null;
    00118 }

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:05 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003