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

tdeprint

kmconfigfilter.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 "kmconfigfilter.h"
00021 #include "kmmanager.h"
00022 #include "kmfactory.h"
00023 
00024 #include <tqgroupbox.h>
00025 #include <tqlineedit.h>
00026 #include <tqtoolbutton.h>
00027 #include <tqlayout.h>
00028 #include <tqlabel.h>
00029 #include <tqapplication.h>
00030 
00031 #include <tdelocale.h>
00032 #include <tdeconfig.h>
00033 #include <kiconloader.h>
00034 #include <tdelistbox.h>
00035 #include <kdialog.h>
00036 
00037 KMConfigFilter::KMConfigFilter(TQWidget *parent, const char *name)
00038 : KMConfigPage(parent, name)
00039 {
00040     setPageName(i18n("Filter"));
00041     setPageHeader(i18n("Printer Filtering Settings"));
00042     setPagePixmap("filter");
00043 
00044     TQGroupBox  *box = new TQGroupBox(0, Qt::Vertical, i18n("Printer Filter"), this);
00045 
00046     m_list1 = new TDEListBox(box);
00047     m_list1->setSelectionMode(TDEListBox::Extended);
00048     m_list2 = new TDEListBox(box);
00049     m_list2->setSelectionMode(TDEListBox::Extended);
00050     m_add = new TQToolButton( box );
00051     m_add->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "back" ) : SmallIconSet( "forward" ));
00052     m_remove = new TQToolButton( box );
00053     m_remove->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "forward" ) : SmallIconSet( "back" ));
00054     m_locationre = new TQLineEdit(box);
00055     TQLabel *lab = new TQLabel(box);
00056     lab->setText(i18n("The printer filtering allows you to view only a specific set of "
00057                       "printers instead of all of them. This may be useful when there are a "
00058               "lot of printers available but you only use a few ones. Select the "
00059               "printers you want to see from the list on the left or enter a <b>Location</b> "
00060               "filter (ex: Group_1*). Both are cumulative and ignored if empty."));
00061     lab->setTextFormat(TQt::RichText);
00062     TQLabel *lab1 = new TQLabel(i18n("Location filter:"), box);
00063 
00064     TQVBoxLayout    *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
00065     l0->addWidget(box, 1);
00066     TQVBoxLayout    *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint());
00067     l1->addWidget(lab);
00068     TQGridLayout    *l2 = new TQGridLayout(0, 4, 3, 0, KDialog::spacingHint());
00069     l1->addLayout(TQT_TQLAYOUT(l2));
00070     l2->setRowStretch(0, 1);
00071     l2->setRowStretch(3, 1);
00072     l2->setColStretch(0, 1);
00073     l2->setColStretch(2, 1);
00074     l2->addMultiCellWidget(m_list1, 0, 3, 0, 0);
00075     l2->addMultiCellWidget(m_list2, 0, 3, 2, 2);
00076     l2->addWidget(m_add, 1, 1);
00077     l2->addWidget(m_remove, 2, 1);
00078     TQHBoxLayout    *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
00079     l1->addLayout(l3, 0);
00080     l3->addWidget(lab1, 0);
00081     l3->addWidget(m_locationre, 1);
00082 
00083     connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddClicked()));
00084     connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveClicked()));
00085     connect(m_list1, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged()));
00086     connect(m_list2, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged()));
00087     m_add->setEnabled(false);
00088     m_remove->setEnabled(false);
00089 }
00090 
00091 void KMConfigFilter::loadConfig(TDEConfig *conf)
00092 {
00093     conf->setGroup("Filter");
00094     TQStringList    m_plist = conf->readListEntry("Printers");
00095     TQPtrListIterator<KMPrinter>    it(*(KMManager::self()->printerListComplete(false)));
00096     for (; it.current(); ++it)
00097     {
00098         if (!it.current()->isSpecial() && !it.current()->isVirtual())
00099         {
00100             TDEListBox  *lb = (m_plist.find(it.current()->printerName()) == m_plist.end() ? m_list1 : m_list2);
00101             lb->insertItem(SmallIcon(it.current()->pixmap()), it.current()->printerName());
00102         }
00103     }
00104     m_list1->sort();
00105     m_list2->sort();
00106     m_locationre->setText(conf->readEntry("LocationRe"));
00107 }
00108 
00109 void KMConfigFilter::saveConfig(TDEConfig *conf)
00110 {
00111     conf->setGroup("Filter");
00112     TQStringList    plist;
00113     for (uint i=0; i<m_list2->count(); i++)
00114         plist << m_list2->text(i);
00115     conf->writeEntry("Printers", plist);
00116     conf->writeEntry("LocationRe", m_locationre->text());
00117 }
00118 
00119 void KMConfigFilter::transfer(TDEListBox *from, TDEListBox *to)
00120 {
00121     for (uint i=0; i<from->count();)
00122     {
00123         if (from->isSelected(i))
00124         {
00125             to->insertItem(*(from->pixmap(i)), from->text(i));
00126             from->removeItem(i);
00127         }
00128         else
00129             i++;
00130     }
00131     to->sort();
00132 }
00133 
00134 void KMConfigFilter::slotAddClicked()
00135 {
00136     transfer(m_list1, m_list2);
00137 }
00138 
00139 void KMConfigFilter::slotRemoveClicked()
00140 {
00141     transfer(m_list2, m_list1);
00142 }
00143 
00144 void KMConfigFilter::slotSelectionChanged()
00145 {
00146     const TDEListBox    *lb = static_cast<const TDEListBox*>(sender());
00147     if (!lb)
00148         return;
00149     TQToolButton    *pb = (lb == m_list1 ? m_add : m_remove);
00150     for (uint i=0; i<lb->count(); i++)
00151         if (lb->isSelected(i))
00152         {
00153             pb->setEnabled(true);
00154             return;
00155         }
00156     pb->setEnabled(false);
00157 }
00158 
00159 #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.7.6.1
This website is maintained by Timothy Pearson.