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

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
editlist.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 "editlist.h"
21 
22 #include <tdelistbox.h>
23 #include <kpushbutton.h>
24 #include <tqlayout.h>
25 #include <tdelocale.h>
26 #include <kiconloader.h>
27 #include <kguiitem.h>
28 
29 EditList::EditList(TQWidget *parent, const char *name)
30  : TQWidget(parent, name)
31 {
32  list_ = new TDEListBox(this);
33  addbtn_ = new KPushButton(KGuiItem(i18n("Add..."), "document-new"), this);
34  editbtn_ = new KPushButton(KGuiItem(i18n("Edit..."), "edit"), this);
35  delbtn_ = new KPushButton(KGuiItem(i18n("Delete"), "edit-delete"), this);
36  defbtn_ = new KPushButton(KGuiItem(i18n("Default List"), "history"), this);
37 
38  TQGridLayout *m1 = new TQGridLayout(this, 4, 2, 0, 0);
39  m1->setColStretch(0, 1);
40  m1->addMultiCellWidget(list_, 0, 3, 0, 1);
41  m1->addWidget(addbtn_, 0, 1);
42  m1->addWidget(editbtn_, 1, 1);
43  m1->addWidget(delbtn_, 2, 1);
44  m1->addWidget(defbtn_, 3, 1);
45 
46  connect(addbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(add()));
47  connect(editbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotEdit()));
48  connect(delbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotDelete()));
49  connect(defbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(defaultList()));
50  connect(list_, TQT_SIGNAL(highlighted(int)), TQT_SLOT(slotSelected(int)));
51  slotSelected(-1);
52 }
53 
54 void EditList::slotEdit()
55 {
56  int index = list_->currentItem();
57  if (index >= 0)
58  emit edit(index);
59 }
60 
61 void EditList::slotDelete()
62 {
63  int index = list_->currentItem();
64  list_->removeItem(index);
65  slotSelected((list_->count() > 0 ? list_->currentItem() : -1));
66  emit deleted(index);
67 }
68 
69 void EditList::slotSelected(int index)
70 {
71  editbtn_->setEnabled(index >= 0);
72  delbtn_->setEnabled(index >= 0);
73 }
74 
75 TQString EditList::text(int index)
76 {
77  return list_->text(index);
78 }
79 
80 void EditList::setText(int index, const TQString& s)
81 {
82  if (list_->text(index) != s)
83  {
84  TQListBoxItem *it = list_->findItem(s, TQt::ExactMatch);
85  if (!it)
86  list_->changeItem(s, index);
87  else
88  list_->removeItem(index);
89  }
90 }
91 
92 void EditList::clear()
93 {
94  list_->clear();
95  slotSelected(-1);
96 }
97 
98 void EditList::insertItem(const TQString& s)
99 {
100  if (!list_->findItem(s, TQt::ExactMatch))
101  list_->insertItem(s);
102 }
103 
104 void EditList::insertItem(const TQPixmap& icon, const TQString& s)
105 {
106  if (!list_->findItem(s, TQt::ExactMatch))
107  list_->insertItem(icon, s);
108 }
109 
110 void EditList::insertItems(const TQStringList& l)
111 {
112  for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it)
113  insertItem(*it);
114 }
115 
116 TQStringList EditList::items()
117 {
118  TQStringList l;
119  for (uint i=0; i<list_->count(); i++)
120  l << list_->text(i);
121  return l;
122 }
123 
124 #include "editlist.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.