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

tdeprint

kmwclass.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kmwclass.h"
00021 #include "kmwizard.h"
00022 #include "kmfactory.h"
00023 #include "kmmanager.h"
00024 #include "kmprinter.h"
00025 
00026 #include <tqlayout.h>
00027 #include <tqlabel.h>
00028 #include <tqtoolbutton.h>
00029 #include <tdelistbox.h>
00030 #include <tdelocale.h>
00031 #include <kiconloader.h>
00032 
00033 KMWClass::KMWClass(TQWidget *parent, const char *name)
00034 : KMWizardPage(parent,name)
00035 {
00036     m_ID = KMWizard::Class;
00037     m_title = i18n("Class Composition");
00038     m_nextpage = KMWizard::Name;
00039 
00040     m_list1 = new TDEListBox(this);
00041     m_list1->setSelectionMode(TQListBox::Extended);
00042     m_list2 = new TDEListBox(this);
00043     m_list2->setSelectionMode(TQListBox::Extended);
00044 
00045     TQToolButton    *add = new TQToolButton(this);
00046     TQToolButton    *remove = new TQToolButton(this);
00047     add->setIconSet(BarIcon("forward"));
00048     remove->setIconSet(BarIcon("back"));
00049     connect(add,TQT_SIGNAL(clicked()),TQT_SLOT(slotAdd()));
00050     connect(remove,TQT_SIGNAL(clicked()),TQT_SLOT(slotRemove()));
00051 
00052     TQLabel *l1 = new TQLabel(i18n("Available printers:"), this);
00053     TQLabel *l2 = new TQLabel(i18n("Class printers:"), this);
00054 
00055         TQHBoxLayout    *lay1 = new TQHBoxLayout(this, 0, 15);
00056         TQVBoxLayout    *lay2 = new TQVBoxLayout(0, 0, 20);
00057         TQVBoxLayout    *lay3 = new TQVBoxLayout(0, 0, 0), *lay4 = new TQVBoxLayout(0, 0, 0);
00058         lay1->addLayout(lay3, 1);
00059         lay1->addLayout(lay2, 0);
00060     lay1->addLayout(lay4, 1);
00061         lay3->addWidget(l1, 0);
00062         lay3->addWidget(m_list1, 1);
00063         lay2->addStretch(1);
00064         lay2->addWidget(add, 0);
00065         lay2->addWidget(remove, 0);
00066         lay2->addStretch(1);
00067         lay4->addWidget(l2, 0);
00068         lay4->addWidget(m_list2, 1);
00069 }
00070 
00071 KMWClass::~KMWClass()
00072 {
00073 }
00074 
00075 bool KMWClass::isValid(TQString& msg)
00076 {
00077     if (m_list2->count() == 0)
00078     {
00079         msg = i18n("You must select at least one printer.");
00080         return false;
00081     }
00082     return true;
00083 }
00084 
00085 void KMWClass::initPrinter(KMPrinter *p)
00086 {
00087     TQStringList    members = p->members();
00088     KMManager   *mgr = KMFactory::self()->manager();
00089 
00090     // first load available printers
00091     TQPtrList<KMPrinter>    *list = mgr->printerList(false);
00092     m_list1->clear();
00093     if (list)
00094     {
00095         TQPtrListIterator<KMPrinter>    it(*list);
00096         for (;it.current();++it)
00097             if (it.current()->instanceName().isEmpty() && !it.current()->isClass(true) && !it.current()->isSpecial() && !members.contains(it.current()->name()))
00098                 m_list1->insertItem(SmallIcon(it.current()->pixmap()), it.current()->name());
00099         m_list1->sort();
00100     }
00101 
00102     // set class printers
00103     m_list2->clear();
00104     for (TQStringList::ConstIterator it=members.begin(); it!=members.end(); ++it)
00105     {
00106         KMPrinter   *pr = mgr->findPrinter(*it);
00107         if (pr) m_list2->insertItem(SmallIcon(pr->pixmap()), *it);
00108     }
00109     m_list2->sort();
00110 }
00111 
00112 void KMWClass::updatePrinter(KMPrinter *p)
00113 {
00114     TQStringList    members;
00115     for (uint i=0; i<m_list2->count(); i++)
00116         members.append(m_list2->item(i)->text());
00117     p->setMembers(members);
00118 }
00119 
00120 void KMWClass::slotAdd()
00121 {
00122     for (uint i=0;i<m_list1->count();i++)
00123         if (m_list1->isSelected(i))
00124         {
00125             m_list2->insertItem(*(m_list1->pixmap(i)), m_list1->text(i));
00126             m_list1->removeItem(i--);
00127         }
00128     m_list2->sort();
00129 }
00130 
00131 void KMWClass::slotRemove()
00132 {
00133     for (uint i=0;i<m_list2->count();i++)
00134         if (m_list2->isSelected(i))
00135         {
00136             m_list1->insertItem(*(m_list2->pixmap(i)), m_list2->text(i));
00137             m_list2->removeItem(i--);
00138         }
00139     m_list1->sort();
00140 }
00141 #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.7.1
This website is maintained by Timothy Pearson.