• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDEPrint

addressdialog.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "addressdialog.h"
00021 
00022 #include <QtGui/QComboBox>
00023 #include <QtGui/QLineEdit>
00024 #include <QtGui/QLabel>
00025 #include <QtGui/QLayout>
00026 
00027 #include <klocale.h>
00028 
00029 AddressDialog::AddressDialog(QWidget *parent, const char *name)
00030         : KDialog(parent)
00031 {
00032     setCaption(i18n("ACL Address"));
00033     setButtons(Ok | Cancel);
00034     setDefaultButton(Ok);
00035     setObjectName(name);
00036     setModal(true);
00037     showButtonSeparator(true);
00038 
00039     QWidget *w = new QWidget(this);
00040     type_ = new QComboBox(w);
00041     address_ = new QLineEdit(w);
00042 
00043     type_->addItem(i18n("Allow"));
00044     type_->addItem(i18n("Deny"));
00045 
00046     QLabel *l1 = new QLabel(i18n("Type:"), w);
00047     QLabel *l2 = new QLabel(i18n("Address:"), w);
00048 
00049     QGridLayout *m1 = new QGridLayout(w);
00050     m1->setMargin(0);
00051     m1->setSpacing(5);
00052     m1->setColumnStretch(1, 1);
00053     m1->addWidget(l1, 0, 0, Qt::AlignRight);
00054     m1->addWidget(l2, 1, 0, Qt::AlignRight);
00055     m1->addWidget(type_, 0, 1);
00056     m1->addWidget(address_, 1, 1);
00057 
00058     setMainWidget(w);
00059     resize(300, 100);
00060 }
00061 
00062 QString AddressDialog::addressString()
00063 {
00064     QString s;
00065     if (type_->currentIndex() == 0)
00066         s.append("Allow ");
00067     else
00068         s.append("Deny ");
00069     if (address_->text().isEmpty())
00070         s.append("All");
00071     else
00072         s.append(address_->text());
00073     return s;
00074 }
00075 
00076 QString AddressDialog::newAddress(QWidget *parent)
00077 {
00078     AddressDialog dlg(parent);
00079     if (dlg.exec())
00080         return dlg.addressString();
00081     else
00082         return QString();
00083 }
00084 
00085 QString AddressDialog::editAddress(const QString& addr, QWidget *parent)
00086 {
00087     AddressDialog dlg(parent);
00088     int p = addr.indexOf(' ');
00089     if (p != -1) {
00090         dlg.type_->setCurrentIndex(addr.left(p).toLower() == "deny" ? 1 : 0);
00091         dlg.address_->setText(addr.mid(p + 1));
00092     }
00093     if (dlg.exec())
00094         return dlg.addressString();
00095     else
00096         return QString();
00097 }

KDEPrint

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

API Reference

Skip menu "API Reference"
  •   KDEPrint
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal