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

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
browsedialog.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "browsedialog.h"
21#include "cupsdconf.h"
22
23#include <tqlineedit.h>
24#include <tqpushbutton.h>
25#include <tqcombobox.h>
26#include <tqlabel.h>
27#include <tqlayout.h>
28#include <tqwhatsthis.h>
29#include <tqregexp.h>
30
31#include <tdelocale.h>
32
33BrowseDialog::BrowseDialog(TQWidget *parent, const char *name)
34 : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true)
35{
36 TQWidget *dummy = new TQWidget(this);
37 setMainWidget(dummy);
38 type_ = new TQComboBox(dummy);
39 from_ = new TQLineEdit(dummy);
40 to_ = new TQLineEdit(dummy);
41 type_->insertItem(i18n("Send"));
42 type_->insertItem(i18n("Allow"));
43 type_->insertItem(i18n("Deny"));
44 type_->insertItem(i18n("Relay"));
45 type_->insertItem(i18n("Poll"));
46
47 TQLabel *l1 = new TQLabel(i18n("Type:"), dummy);
48 TQLabel *l2 = new TQLabel(i18n("From:"), dummy);
49 TQLabel *l3 = new TQLabel(i18n("To:"), dummy);
50
51 TQGridLayout *m1 = new TQGridLayout(dummy, 3, 2, 0, 5);
52 m1->addWidget(l1, 0, 0, TQt::AlignRight);
53 m1->addWidget(l2, 1, 0, TQt::AlignRight);
54 m1->addWidget(l3, 2, 0, TQt::AlignRight);
55 m1->addWidget(type_, 0, 1);
56 m1->addWidget(from_, 1, 1);
57 m1->addWidget(to_, 2, 1);
58
59 connect(type_, TQ_SIGNAL(activated(int)), TQ_SLOT(slotTypeChanged(int)));
60 slotTypeChanged(type_->currentItem());
61
62 setCaption(i18n("Browse Address"));
63 resize(250, 100);
64}
65
66TQString BrowseDialog::addressString()
67{
68 TQString s;
69 switch (type_->currentItem())
70 {
71 case 0:
72 s.append("Send");
73 break;
74 case 1:
75 s.append("Allow");
76 break;
77 case 2:
78 s.append("Deny");
79 break;
80 case 3:
81 s.append("Relay");
82 break;
83 case 4:
84 s.append("Poll");
85 break;
86 }
87 if (from_->isEnabled())
88 s.append(" ").append(from_->text());
89 if (to_->isEnabled())
90 s.append(" ").append(to_->text());
91 return s;
92}
93
94void BrowseDialog::setInfos(CupsdConf *conf)
95{
96 TQWhatsThis::add(type_, conf->comments_.toolTip("browsetype"));
97}
98
99TQString BrowseDialog::newAddress(TQWidget *parent, CupsdConf *conf)
100{
101 BrowseDialog dlg(parent);
102 dlg.setInfos(conf);
103 if (dlg.exec())
104 {
105 return dlg.addressString();
106 }
107 return TQString::null;
108}
109
110TQString BrowseDialog::editAddress(const TQString& s, TQWidget *parent, CupsdConf *conf)
111{
112 BrowseDialog dlg(parent);
113 dlg.setInfos(conf);
114 TQStringList l = TQStringList::split(TQRegExp("\\s"), s, false);
115 if (l.count() > 1)
116 {
117 if (l[0] == "Send") dlg.type_->setCurrentItem(0);
118 else if (l[0] == "Allow") dlg.type_->setCurrentItem(1);
119 else if (l[0] == "Deny") dlg.type_->setCurrentItem(2);
120 else if (l[0] == "Relay") dlg.type_->setCurrentItem(3);
121 else if (l[0] == "Poll") dlg.type_->setCurrentItem(4);
122 dlg.slotTypeChanged(dlg.type_->currentItem());
123 int index(1);
124 if (dlg.from_->isEnabled())
125 dlg.from_->setText(l[index++]);
126 if (dlg.to_->isEnabled())
127 dlg.to_->setText(l[index]);
128 }
129 if (dlg.exec())
130 {
131 return dlg.addressString();
132 }
133 return TQString::null;
134}
135
136void BrowseDialog::slotTypeChanged(int index)
137{
138 bool useFrom(true), useTo(true);
139 switch (index)
140 {
141 case 0: useFrom = false; break;
142 case 1:
143 case 4:
144 case 2: useTo = false; break;
145 }
146 from_->setEnabled(useFrom);
147 to_->setEnabled(useTo);
148}
149
150#include "browsedialog.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.9.4
This website is maintained by Timothy Pearson.