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

tdeprint

  • tdeprint
  • lpr
editentrydialog.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 "editentrydialog.h"
21 
22 #include <tqlineedit.h>
23 #include <tqcheckbox.h>
24 #include <tqspinbox.h>
25 #include <tqcombobox.h>
26 #include <tqlabel.h>
27 #include <tqheader.h>
28 #include <tdelistview.h>
29 #include <tqlayout.h>
30 #include <tqwidgetstack.h>
31 #include <tdelocale.h>
32 #include <kiconloader.h>
33 
34 EditEntryDialog::EditEntryDialog(PrintcapEntry *entry, TQWidget *parent, const char *name)
35 : KDialogBase(parent, name, true, TQString::null, Ok|Cancel)
36 {
37  TQWidget *w = new TQWidget(this);
38  setMainWidget(w);
39 
40  TQLabel *lab0 = new TQLabel(i18n("Aliases:"), w);
41  m_aliases = new TQLineEdit(w);
42  m_view = new TDEListView(w);
43  m_view->addColumn("");
44  m_view->header()->hide();
45  m_type = new TQComboBox(w);
46  m_type->insertItem(i18n("String"));
47  m_type->insertItem(i18n("Number"));
48  m_type->insertItem(i18n("Boolean"));
49  m_stack = new TQWidgetStack(w);
50  m_boolean = new TQCheckBox(i18n("Enabled"), m_stack);
51  m_string = new TQLineEdit(m_stack);
52  m_number = new TQSpinBox(0, 9999, 1, m_stack);
53  m_stack->addWidget(m_string, 0);
54  m_stack->addWidget(m_boolean, 2);
55  m_stack->addWidget(m_number, 1);
56  m_name = new TQLineEdit(w);
57 
58  TQVBoxLayout *l0 = new TQVBoxLayout(w, 0, 10);
59  TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10);
60  TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 5);
61  l0->addLayout(l1);
62  l1->addWidget(lab0);
63  l1->addWidget(m_aliases);
64  l0->addWidget(m_view);
65  l0->addLayout(l2);
66  l2->addWidget(m_name, 0);
67  l2->addWidget(m_type, 0);
68  l2->addWidget(m_stack, 1);
69 
70  if (entry)
71  {
72  setCaption(i18n("Printcap Entry: %1").arg(entry->name));
73  m_fields = entry->fields;
74  m_aliases->setText(entry->aliases.join("|"));
75  TQListViewItem *root = new TQListViewItem(m_view, entry->name), *item = 0;
76  root->setSelectable(false);
77  root->setOpen(true);
78  root->setPixmap(0, SmallIcon("document-print"));
79  for (TQMap<TQString,Field>::ConstIterator it=m_fields.begin(); it!=m_fields.end(); ++it)
80  item = new TQListViewItem(root, item, (*it).toString(), it.key());
81  }
82 
83  m_block = true;
84  enableButton(Ok, false);
85  slotItemSelected(NULL);
86  slotTypeChanged(0);
87  m_block = false;
88 
89  connect(m_view, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotItemSelected(TQListViewItem*)));
90  connect(m_string, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged()));
91  connect(m_boolean, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChanged()));
92  connect(m_number, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotChanged()));
93  connect(m_type, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int)));
94  connect(m_name, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged()));
95 
96  resize(500,400);
97 }
98 
99 Field EditEntryDialog::createField()
100 {
101  Field f;
102  f.name = m_name->text();
103  f.type = (Field::Type)(m_type->currentItem());
104  switch (f.type)
105  {
106  case Field::String: f.value = m_string->text(); break;
107  case Field::Integer: f.value = m_number->cleanText(); break;
108  case Field::Boolean: f.value = (m_boolean->isChecked() ? "1" : "0"); break;
109  }
110  return f;
111 }
112 
113 void EditEntryDialog::slotChanged()
114 {
115  if (!m_block && m_view->currentItem())
116  {
117  Field f = createField();
118  if (f.name != m_current)
119  m_fields.remove(m_current);
120  m_fields[f.name] = f;
121  m_view->currentItem()->setText(0, f.toString());
122  }
123 }
124 
125 void EditEntryDialog::slotItemSelected(TQListViewItem *item)
126 {
127  m_stack->setEnabled(item);
128  m_name->setEnabled(item);
129  m_type->setEnabled(item);
130  if (item)
131  {
132  m_block = true;
133  m_current = item->text(1);
134  Field f = m_fields[m_current];
135  m_name->setText(f.name);
136  m_type->setCurrentItem(f.type);
137  slotTypeChanged(f.type);
138  m_string->setText(f.value);
139  m_number->setValue(f.value.toInt());
140  m_boolean->setChecked(f.value.toInt() == 1);
141  m_block = false;
142  }
143 }
144 
145 void EditEntryDialog::fillEntry(PrintcapEntry *entry)
146 {
147  entry->aliases = TQStringList::split('|', m_aliases->text(), false);
148  entry->fields = m_fields;
149 }
150 
151 void EditEntryDialog::slotTypeChanged(int ID)
152 {
153  m_stack->raiseWidget(ID);
154  slotChanged();
155 }
156 
157 #include "editentrydialog.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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.