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

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
locationdialog.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 "locationdialog.h"
21 #include "cupsdconf.h"
22 #include "editlist.h"
23 #include "addressdialog.h"
24 
25 #include <tqlineedit.h>
26 #include <tqcombobox.h>
27 #include <tqlayout.h>
28 #include <tqlabel.h>
29 #include <tqpushbutton.h>
30 #include <tqwhatsthis.h>
31 
32 #include <tdelocale.h>
33 #include <kiconloader.h>
34 
35 LocationDialog::LocationDialog(TQWidget *parent, const char *name)
36  : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true)
37 {
38  TQWidget *dummy = new TQWidget(this);
39  setMainWidget(dummy);
40  resource_ = new TQComboBox(dummy);
41  authtype_ = new TQComboBox(dummy);
42  authclass_ = new TQComboBox(dummy);
43  authname_ = new TQLineEdit(dummy);
44  encryption_ = new TQComboBox(dummy);
45  satisfy_ = new TQComboBox(dummy);
46  order_ = new TQComboBox(dummy);
47  addresses_ = new EditList(dummy);
48 
49  authtype_->insertItem(i18n("None"));
50  authtype_->insertItem(i18n("Basic"));
51  authtype_->insertItem(i18n("Digest"));
52 
53  authclass_->insertItem(i18n("None"));
54  authclass_->insertItem(i18n("User"));
55  authclass_->insertItem(i18n("System"));
56  authclass_->insertItem(i18n("Group"));
57 
58  encryption_->insertItem(i18n("Always"));
59  encryption_->insertItem(i18n("Never"));
60  encryption_->insertItem(i18n("Required"));
61  encryption_->insertItem(i18n("If Requested"));
62 
63  satisfy_->insertItem(i18n("All"));
64  satisfy_->insertItem(i18n("Any"));
65 
66  order_->insertItem(i18n("Allow, Deny"));
67  order_->insertItem(i18n("Deny, Allow"));
68 
69  connect(authclass_, TQ_SIGNAL(activated(int)), TQ_SLOT(slotClassChanged(int)));
70  connect(authtype_, TQ_SIGNAL(activated(int)), TQ_SLOT(slotTypeChanged(int)));
71 
72  TQLabel *l1 = new TQLabel(i18n("Resource:"), dummy);
73  TQLabel *l2 = new TQLabel(i18n("Authentication:"), dummy);
74  TQLabel *l3 = new TQLabel(i18n("Class:"), dummy);
75  TQLabel *l4 = new TQLabel(i18n("Names:"), dummy);
76  TQLabel *l5 = new TQLabel(i18n("Encryption:"), dummy);
77  TQLabel *l6 = new TQLabel(i18n("Satisfy:"), dummy);
78  TQLabel *l7 = new TQLabel(i18n("ACL order:"), dummy);
79  TQLabel *l8 = new TQLabel(i18n("ACL addresses:"),dummy);
80 
81  TQGridLayout *m1 = new TQGridLayout(dummy, 8, 2, 0, 5);
82  m1->setColStretch(1, 1);
83  m1->addWidget(l1, 0, 0, TQt::AlignRight);
84  m1->addWidget(l2, 1, 0, TQt::AlignRight);
85  m1->addWidget(l3, 2, 0, TQt::AlignRight);
86  m1->addWidget(l4, 3, 0, TQt::AlignRight);
87  m1->addWidget(l5, 4, 0, TQt::AlignRight);
88  m1->addWidget(l6, 5, 0, TQt::AlignRight);
89  m1->addWidget(l7, 6, 0, TQt::AlignRight);
90  m1->addWidget(l8, 7, 0, TQt::AlignRight|TQt::AlignTop);
91  m1->addWidget(resource_, 0, 1);
92  m1->addWidget(authtype_, 1, 1);
93  m1->addWidget(authclass_, 2, 1);
94  m1->addWidget(authname_, 3, 1);
95  m1->addWidget(encryption_, 4, 1);
96  m1->addWidget(satisfy_, 5, 1);
97  m1->addWidget(order_, 6, 1);
98  m1->addWidget(addresses_, 7, 1);
99 
100  setCaption(i18n("Location"));
101  resize(400, 100);
102 
103  slotTypeChanged(AUTHTYPE_NONE);
104  slotClassChanged(AUTHCLASS_ANONYMOUS);
105  encryption_->setCurrentItem(ENCRYPT_IFREQUESTED);
106 
107  connect(addresses_, TQ_SIGNAL(add()), TQ_SLOT(slotAdd()));
108  connect(addresses_, TQ_SIGNAL(edit(int)), TQ_SLOT(slotEdit(int)));
109  connect(addresses_, TQ_SIGNAL(defaultList()), TQ_SLOT(slotDefaultList()));
110 }
111 
112 void LocationDialog::setInfos(CupsdConf *conf)
113 {
114  conf_ = conf;
115 
116  TQPtrListIterator<CupsResource> it(conf->resources_);
117  for (; it.current(); ++it)
118  resource_->insertItem(SmallIcon(it.current()->typeToIconName(it.current()->type_)), it.current()->text_);
119 
120  TQWhatsThis::add(encryption_, conf_->comments_.toolTip("encryption"));
121  TQWhatsThis::add(order_, conf_->comments_.toolTip("order"));
122  TQWhatsThis::add(authclass_, conf_->comments_.toolTip("authclass"));
123  TQWhatsThis::add(authtype_, conf_->comments_.toolTip("authtype"));
124  TQWhatsThis::add(authname_, conf_->comments_.toolTip("authname"));
125  TQWhatsThis::add(satisfy_, conf_->comments_.toolTip("satisfy"));
126  TQWhatsThis::add(addresses_, conf_->comments_.toolTip("allowdeny"));
127 }
128 
129 void LocationDialog::fillLocation(CupsLocation *loc)
130 {
131  loc->resource_ = conf_->resources_.at(resource_->currentItem());
132  loc->resourcename_ = loc->resource_->path_;
133  loc->authtype_ = authtype_->currentItem();
134  loc->authclass_ = (loc->authtype_ == AUTHTYPE_NONE ? AUTHCLASS_ANONYMOUS : authclass_->currentItem());
135  loc->authname_ = (loc->authclass_ == AUTHCLASS_USER || loc->authclass_ == AUTHCLASS_GROUP ? authname_->text() : TQString::null);
136  loc->encryption_ = encryption_->currentItem();
137  loc->satisfy_ = satisfy_->currentItem();
138  loc->order_ = order_->currentItem();
139  loc->addresses_ = addresses_->items();
140 }
141 
142 void LocationDialog::setLocation(CupsLocation *loc)
143 {
144  int index = conf_->resources_.findRef(loc->resource_);
145  resource_->setCurrentItem(index);
146  authtype_->setCurrentItem(loc->authtype_);
147  authclass_->setCurrentItem(loc->authclass_);
148  authname_->setText(loc->authname_);
149  encryption_->setCurrentItem(loc->encryption_);
150  satisfy_->setCurrentItem(loc->satisfy_);
151  order_->setCurrentItem(loc->order_);
152  addresses_->insertItems(loc->addresses_);
153 
154  slotTypeChanged(loc->authtype_);
155  slotClassChanged(loc->authclass_);
156 }
157 
158 void LocationDialog::slotTypeChanged(int index)
159 {
160  authclass_->setEnabled(index != AUTHTYPE_NONE);
161  if (index != AUTHTYPE_NONE)
162  slotClassChanged(authclass_->currentItem());
163  else
164  authname_->setEnabled(false);
165 }
166 
167 void LocationDialog::slotClassChanged(int index)
168 {
169  authname_->setEnabled((index == AUTHCLASS_USER || index == AUTHCLASS_GROUP));
170 }
171 
172 bool LocationDialog::newLocation(CupsLocation *loc, TQWidget *parent, CupsdConf *conf)
173 {
174  LocationDialog dlg(parent);
175  if (conf)
176  dlg.setInfos(conf);
177  if (dlg.exec())
178  {
179  dlg.fillLocation(loc);
180  return true;
181  }
182  else
183  return false;
184 }
185 
186 bool LocationDialog::editLocation(CupsLocation *loc, TQWidget *parent, CupsdConf *conf)
187 {
188  LocationDialog dlg(parent);
189  if (conf)
190  dlg.setInfos(conf);
191  dlg.setLocation(loc);
192  dlg.resource_->setEnabled(false);
193  if (dlg.exec())
194  {
195  dlg.fillLocation(loc);
196  return true;
197  }
198  else
199  return false;
200 }
201 
202 void LocationDialog::slotAdd()
203 {
204  TQString addr = AddressDialog::newAddress(this);
205  if (!addr.isEmpty())
206  addresses_->insertItem(addr);
207 }
208 
209 void LocationDialog::slotEdit(int index)
210 {
211  TQString addr = addresses_->text(index);
212  addr = AddressDialog::editAddress(addr, this);
213  if (!addr.isEmpty())
214  addresses_->insertItem(addr);
215 }
216 
217 void LocationDialog::slotDefaultList()
218 {
219  addresses_->clear();
220 }
221 
222 #include "locationdialog.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.1
This website is maintained by Timothy Pearson.