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

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
qdirmultilineedit.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001-2002 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 "qdirmultilineedit.h"
21 
22 #include <tqlayout.h>
23 #include <tqheader.h>
24 #include <tqpushbutton.h>
25 #include <tdelistview.h>
26 #include <tdelocale.h>
27 #include <tdefiledialog.h>
28 #include <kiconloader.h>
29 
30 QDirMultiLineEdit::QDirMultiLineEdit(TQWidget *parent, const char *name)
31 : TQWidget(parent, name)
32 {
33  m_view = new TDEListView(this);
34  m_view->header()->hide();
35  m_view->addColumn("");
36  m_view->setFullWidth(true);
37  connect(m_view, TQ_SIGNAL(selectionChanged(TQListViewItem*)), TQ_SLOT(slotSelected(TQListViewItem*)));
38 
39  m_add = new TQPushButton(this);
40  m_add->setPixmap(SmallIcon("folder-new"));
41  connect(m_add, TQ_SIGNAL(clicked()), TQ_SLOT(slotAddClicked()));
42  m_remove = new TQPushButton(this);
43  m_remove->setPixmap(SmallIcon("edit-delete"));
44  connect(m_remove, TQ_SIGNAL(clicked()), TQ_SLOT(slotRemoveClicked()));
45  m_remove->setEnabled(false);
46 
47  m_view->setFixedHeight(TQMAX(m_view->fontMetrics().lineSpacing()*3+m_view->lineWidth()*2, m_add->sizeHint().height()*2));
48 
49  TQHBoxLayout *l0 = new TQHBoxLayout(this, 0, 3);
50  TQVBoxLayout *l1 = new TQVBoxLayout(0, 0, 0);
51  l0->addWidget(m_view);
52  l0->addLayout(l1);
53  l1->addWidget(m_add);
54  l1->addWidget(m_remove);
55  l1->addStretch(1);
56 }
57 
58 QDirMultiLineEdit::~QDirMultiLineEdit()
59 {
60 }
61 
62 void QDirMultiLineEdit::setURLs(const TQStringList& urls)
63 {
64  m_view->clear();
65  for (TQStringList::ConstIterator it=urls.begin(); it!=urls.end(); ++it)
66  addURL(*it);
67 }
68 
69 TQStringList QDirMultiLineEdit::urls()
70 {
71  TQListViewItem *item = m_view->firstChild();
72  TQStringList l;
73  while (item)
74  {
75  l << item->text(0);
76  item = item->nextSibling();
77  }
78  return l;
79 }
80 
81 void QDirMultiLineEdit::addURL(const TQString& url)
82 {
83  TQListViewItem *item = new TQListViewItem(m_view, url);
84  item->setRenameEnabled(0, true);
85 }
86 
87 void QDirMultiLineEdit::slotAddClicked()
88 {
89  TQString dirname = KFileDialog::getExistingDirectory(TQString::null, this);
90  if (!dirname.isEmpty())
91  addURL(dirname);
92 }
93 
94 void QDirMultiLineEdit::slotRemoveClicked()
95 {
96  TQListViewItem *item = m_view->currentItem();
97  if (item)
98  {
99  delete item;
100  slotSelected(m_view->currentItem());
101  }
102 }
103 
104 void QDirMultiLineEdit::slotSelected(TQListViewItem *item)
105 {
106  m_remove->setEnabled((item != NULL));
107 }
108 
109 #include "qdirmultilineedit.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.