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

tdeprint

  • tdeprint
  • management
kmconfigfilter.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 "kmconfigfilter.h"
21#include "kmmanager.h"
22#include "kmfactory.h"
23
24#include <tqgroupbox.h>
25#include <tqlineedit.h>
26#include <tqtoolbutton.h>
27#include <tqlayout.h>
28#include <tqlabel.h>
29#include <tqapplication.h>
30
31#include <tdelocale.h>
32#include <tdeconfig.h>
33#include <kiconloader.h>
34#include <tdelistbox.h>
35#include <kdialog.h>
36
37KMConfigFilter::KMConfigFilter(TQWidget *parent, const char *name)
38: KMConfigPage(parent, name)
39{
40 setPageName(i18n("Filter"));
41 setPageHeader(i18n("Printer Filtering Settings"));
42 setPagePixmap("filter");
43
44 TQGroupBox *box = new TQGroupBox(0, TQt::Vertical, i18n("Printer Filter"), this);
45
46 m_list1 = new TDEListBox(box);
47 m_list1->setSelectionMode(TDEListBox::Extended);
48 m_list2 = new TDEListBox(box);
49 m_list2->setSelectionMode(TDEListBox::Extended);
50 m_add = new TQToolButton( box );
51 m_add->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "back" ) : SmallIconSet( "forward" ));
52 m_remove = new TQToolButton( box );
53 m_remove->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "forward" ) : SmallIconSet( "back" ));
54 m_locationre = new TQLineEdit(box);
55 TQLabel *lab = new TQLabel(box);
56 lab->setText(i18n("The printer filtering allows you to view only a specific set of "
57 "printers instead of all of them. This may be useful when there are a "
58 "lot of printers available but you only use a few ones. Select the "
59 "printers you want to see from the list on the left or enter a <b>Location</b> "
60 "filter (ex: Group_1*). Both are cumulative and ignored if empty."));
61 lab->setTextFormat(TQt::RichText);
62 TQLabel *lab1 = new TQLabel(i18n("Location filter:"), box);
63
64 TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
65 l0->addWidget(box, 1);
66 TQVBoxLayout *l1 = new TQVBoxLayout(box->layout(), KDialog::spacingHint());
67 l1->addWidget(lab);
68 TQGridLayout *l2 = new TQGridLayout(0, 4, 3, 0, KDialog::spacingHint());
69 l1->addLayout(l2);
70 l2->setRowStretch(0, 1);
71 l2->setRowStretch(3, 1);
72 l2->setColStretch(0, 1);
73 l2->setColStretch(2, 1);
74 l2->addMultiCellWidget(m_list1, 0, 3, 0, 0);
75 l2->addMultiCellWidget(m_list2, 0, 3, 2, 2);
76 l2->addWidget(m_add, 1, 1);
77 l2->addWidget(m_remove, 2, 1);
78 TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
79 l1->addLayout(l3, 0);
80 l3->addWidget(lab1, 0);
81 l3->addWidget(m_locationre, 1);
82
83 connect(m_add, TQ_SIGNAL(clicked()), TQ_SLOT(slotAddClicked()));
84 connect(m_remove, TQ_SIGNAL(clicked()), TQ_SLOT(slotRemoveClicked()));
85 connect(m_list1, TQ_SIGNAL(selectionChanged()), TQ_SLOT(slotSelectionChanged()));
86 connect(m_list2, TQ_SIGNAL(selectionChanged()), TQ_SLOT(slotSelectionChanged()));
87 m_add->setEnabled(false);
88 m_remove->setEnabled(false);
89}
90
91void KMConfigFilter::loadConfig(TDEConfig *conf)
92{
93 conf->setGroup("Filter");
94 TQStringList m_plist = conf->readListEntry("Printers");
95 TQPtrListIterator<KMPrinter> it(*(KMManager::self()->printerListComplete(false)));
96 for (; it.current(); ++it)
97 {
98 if (!it.current()->isSpecial() && !it.current()->isVirtual())
99 {
100 TDEListBox *lb = (m_plist.find(it.current()->printerName()) == m_plist.end() ? m_list1 : m_list2);
101 lb->insertItem(SmallIcon(it.current()->pixmap()), it.current()->printerName());
102 }
103 }
104 m_list1->sort();
105 m_list2->sort();
106 m_locationre->setText(conf->readEntry("LocationRe"));
107}
108
109void KMConfigFilter::saveConfig(TDEConfig *conf)
110{
111 conf->setGroup("Filter");
112 TQStringList plist;
113 for (uint i=0; i<m_list2->count(); i++)
114 plist << m_list2->text(i);
115 conf->writeEntry("Printers", plist);
116 conf->writeEntry("LocationRe", m_locationre->text());
117}
118
119void KMConfigFilter::transfer(TDEListBox *from, TDEListBox *to)
120{
121 for (uint i=0; i<from->count();)
122 {
123 if (from->isSelected(i))
124 {
125 to->insertItem(*(from->pixmap(i)), from->text(i));
126 from->removeItem(i);
127 }
128 else
129 i++;
130 }
131 to->sort();
132}
133
134void KMConfigFilter::slotAddClicked()
135{
136 transfer(m_list1, m_list2);
137}
138
139void KMConfigFilter::slotRemoveClicked()
140{
141 transfer(m_list2, m_list1);
142}
143
144void KMConfigFilter::slotSelectionChanged()
145{
146 const TDEListBox *lb = static_cast<const TDEListBox*>(sender());
147 if (!lb)
148 return;
149 TQToolButton *pb = (lb == m_list1 ? m_add : m_remove);
150 for (uint i=0; i<lb->count(); i++)
151 if (lb->isSelected(i))
152 {
153 pb->setEnabled(true);
154 return;
155 }
156 pb->setEnabled(false);
157}
158
159#include "kmconfigfilter.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.