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

tdeprint

  • tdeprint
  • management
kmwclass.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 "kmwclass.h"
21#include "kmwizard.h"
22#include "kmfactory.h"
23#include "kmmanager.h"
24#include "kmprinter.h"
25
26#include <tqlayout.h>
27#include <tqlabel.h>
28#include <tqtoolbutton.h>
29#include <tdelistbox.h>
30#include <tdelocale.h>
31#include <kiconloader.h>
32
33KMWClass::KMWClass(TQWidget *parent, const char *name)
34: KMWizardPage(parent,name)
35{
36 m_ID = KMWizard::Class;
37 m_title = i18n("Class Composition");
38 m_nextpage = KMWizard::Name;
39
40 m_list1 = new TDEListBox(this);
41 m_list1->setSelectionMode(TQListBox::Extended);
42 m_list2 = new TDEListBox(this);
43 m_list2->setSelectionMode(TQListBox::Extended);
44
45 TQToolButton *add = new TQToolButton(this);
46 TQToolButton *remove = new TQToolButton(this);
47 add->setIconSet(BarIcon("forward"));
48 remove->setIconSet(BarIcon("back"));
49 connect(add,TQ_SIGNAL(clicked()),TQ_SLOT(slotAdd()));
50 connect(remove,TQ_SIGNAL(clicked()),TQ_SLOT(slotRemove()));
51
52 TQLabel *l1 = new TQLabel(i18n("Available printers:"), this);
53 TQLabel *l2 = new TQLabel(i18n("Class printers:"), this);
54
55 TQHBoxLayout *lay1 = new TQHBoxLayout(this, 0, 15);
56 TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 20);
57 TQVBoxLayout *lay3 = new TQVBoxLayout(0, 0, 0), *lay4 = new TQVBoxLayout(0, 0, 0);
58 lay1->addLayout(lay3, 1);
59 lay1->addLayout(lay2, 0);
60 lay1->addLayout(lay4, 1);
61 lay3->addWidget(l1, 0);
62 lay3->addWidget(m_list1, 1);
63 lay2->addStretch(1);
64 lay2->addWidget(add, 0);
65 lay2->addWidget(remove, 0);
66 lay2->addStretch(1);
67 lay4->addWidget(l2, 0);
68 lay4->addWidget(m_list2, 1);
69}
70
71KMWClass::~KMWClass()
72{
73}
74
75bool KMWClass::isValid(TQString& msg)
76{
77 if (m_list2->count() == 0)
78 {
79 msg = i18n("You must select at least one printer.");
80 return false;
81 }
82 return true;
83}
84
85void KMWClass::initPrinter(KMPrinter *p)
86{
87 TQStringList members = p->members();
88 KMManager *mgr = KMFactory::self()->manager();
89
90 // first load available printers
91 TQPtrList<KMPrinter> *list = mgr->printerList(false);
92 m_list1->clear();
93 if (list)
94 {
95 TQPtrListIterator<KMPrinter> it(*list);
96 for (;it.current();++it)
97 if (it.current()->instanceName().isEmpty() && !it.current()->isClass(true) && !it.current()->isSpecial() && !members.contains(it.current()->name()))
98 m_list1->insertItem(SmallIcon(it.current()->pixmap()), it.current()->name());
99 m_list1->sort();
100 }
101
102 // set class printers
103 m_list2->clear();
104 for (TQStringList::ConstIterator it=members.begin(); it!=members.end(); ++it)
105 {
106 KMPrinter *pr = mgr->findPrinter(*it);
107 if (pr) m_list2->insertItem(SmallIcon(pr->pixmap()), *it);
108 }
109 m_list2->sort();
110}
111
112void KMWClass::updatePrinter(KMPrinter *p)
113{
114 TQStringList members;
115 for (uint i=0; i<m_list2->count(); i++)
116 members.append(m_list2->item(i)->text());
117 p->setMembers(members);
118}
119
120void KMWClass::slotAdd()
121{
122 for (uint i=0;i<m_list1->count();i++)
123 if (m_list1->isSelected(i))
124 {
125 m_list2->insertItem(*(m_list1->pixmap(i)), m_list1->text(i));
126 m_list1->removeItem(i--);
127 }
128 m_list2->sort();
129}
130
131void KMWClass::slotRemove()
132{
133 for (uint i=0;i<m_list2->count();i++)
134 if (m_list2->isSelected(i))
135 {
136 m_list1->insertItem(*(m_list2->pixmap(i)), m_list2->text(i));
137 m_list2->removeItem(i--);
138 }
139 m_list1->sort();
140}
141#include "kmwclass.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.