22 #include "kmfactory.h"
23 #include "kmmanager.h"
24 #include "kmprinter.h"
28 #include <tqtoolbutton.h>
29 #include <tdelistbox.h>
30 #include <tdelocale.h>
31 #include <kiconloader.h>
33 KMWClass::KMWClass(TQWidget *parent,
const char *name)
34 : KMWizardPage(parent,name)
36 m_ID = KMWizard::Class;
37 m_title = i18n(
"Class Composition");
38 m_nextpage = KMWizard::Name;
40 m_list1 =
new TDEListBox(
this);
41 m_list1->setSelectionMode(TQListBox::Extended);
42 m_list2 =
new TDEListBox(
this);
43 m_list2->setSelectionMode(TQListBox::Extended);
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()));
52 TQLabel *l1 =
new TQLabel(i18n(
"Available printers:"),
this);
53 TQLabel *l2 =
new TQLabel(i18n(
"Class printers:"),
this);
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);
64 lay2->addWidget(add, 0);
65 lay2->addWidget(remove, 0);
67 lay4->addWidget(l2, 0);
68 lay4->addWidget(m_list2, 1);
75 bool KMWClass::isValid(TQString& msg)
77 if (m_list2->count() == 0)
79 msg = i18n(
"You must select at least one printer.");
85 void KMWClass::initPrinter(KMPrinter *p)
87 TQStringList members = p->members();
88 KMManager *mgr = KMFactory::self()->manager();
91 TQPtrList<KMPrinter> *list = mgr->printerList(
false);
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());
104 for (TQStringList::ConstIterator it=members.begin(); it!=members.end(); ++it)
106 KMPrinter *pr = mgr->findPrinter(*it);
107 if (pr) m_list2->insertItem(SmallIcon(pr->pixmap()), *it);
112 void KMWClass::updatePrinter(KMPrinter *p)
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);
120 void KMWClass::slotAdd()
122 for (uint i=0;i<m_list1->count();i++)
123 if (m_list1->isSelected(i))
125 m_list2->insertItem(*(m_list1->pixmap(i)), m_list1->text(i));
126 m_list1->removeItem(i--);
131 void KMWClass::slotRemove()
133 for (uint i=0;i<m_list2->count();i++)
134 if (m_list2->isSelected(i))
136 m_list1->insertItem(*(m_list2->pixmap(i)), m_list2->text(i));
137 m_list2->removeItem(i--);
141 #include "kmwclass.moc"