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

tdeprint

  • tdeprint
  • cups
kmwbanners.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 "kmwbanners.h"
21 #include "kmwizard.h"
22 #include "kmprinter.h"
23 #include "kmfactory.h"
24 #include "kmmanager.h"
25 
26 #include <tqcombobox.h>
27 #include <tqlabel.h>
28 #include <tqlayout.h>
29 #include <tqmap.h>
30 #include <tdelocale.h>
31 
32 TQStringList defaultBanners()
33 {
34  TQStringList bans;
35  TQPtrList<KMPrinter> *list = KMFactory::self()->manager()->printerList(false);
36  if (list && list->count() > 0)
37  {
38  TQPtrListIterator<KMPrinter> it(*list);
39  for (;it.current() && !it.current()->isPrinter(); ++it) ;
40  if (it.current() && KMFactory::self()->manager()->completePrinter(it.current()))
41  {
42  TQString s = list->getFirst()->option("kde-banners-supported");
43  bans = TQStringList::split(',',s,false);
44  }
45  }
46  if (bans.count() == 0)
47  bans.append("none");
48  return bans;
49 }
50 
51 static struct
52 {
53  const char *banner;
54  const char *name;
55 } bannermap[] =
56 {
57  { "none", I18N_NOOP( "No Banner" ) },
58  { "classified", I18N_NOOP( "Classified" ) },
59  { "confidential", I18N_NOOP( "Confidential" ) },
60  { "secret", I18N_NOOP( "Secret" ) },
61  { "standard", I18N_NOOP( "Standard" ) },
62  { "topsecret", I18N_NOOP( "Top Secret" ) },
63  { "unclassified", I18N_NOOP( "Unclassified" ) },
64  { 0, 0 }
65 };
66 
67 TQString mapBanner( const TQString& ban )
68 {
69  static TQMap<TQString,TQString> map;
70  if ( map.size() == 0 )
71  for ( int i=0; bannermap[ i ].banner; i++ )
72  map[ bannermap[ i ].banner ] = bannermap[ i ].name;
73  TQMap<TQString,TQString>::ConstIterator it = map.find( ban );
74  if ( it == map.end() )
75  return ban;
76  else
77  return it.data();
78 }
79 
80 //**************************************************************************************************************
81 
82 KMWBanners::KMWBanners(TQWidget *parent, const char *name)
83 : KMWizardPage(parent,name)
84 {
85  m_ID = KMWizard::Banners;
86  m_title = i18n("Banner Selection");
87  m_nextpage = KMWizard::Custom+3;
88 
89  m_start = new TQComboBox(this);
90  m_end = new TQComboBox(this);
91 
92  TQLabel *l1 = new TQLabel(i18n("&Starting banner:"),this);
93  TQLabel *l2 = new TQLabel(i18n("&Ending banner:"),this);
94 
95  l1->setBuddy(m_start);
96  l2->setBuddy(m_end);
97 
98  TQLabel *l0 = new TQLabel(this);
99  l0->setText(i18n("<p>Select the default banners associated with this printer. These "
100  "banners will be inserted before and/or after each print job sent "
101  "to the printer. If you don't want to use banners, select <b>No Banner</b>.</p>"));
102 
103  TQGridLayout *lay = new TQGridLayout(this, 5, 2, 0, 10);
104  lay->setColStretch(1,1);
105  lay->addRowSpacing(1,20);
106  lay->setRowStretch(4,1);
107  lay->addMultiCellWidget(l0,0,0,0,1);
108  lay->addWidget(l1,2,0);
109  lay->addWidget(l2,3,0);
110  lay->addWidget(m_start,2,1);
111  lay->addWidget(m_end,3,1);
112 }
113 
114 void KMWBanners::initPrinter(KMPrinter *p)
115 {
116  if (p)
117  {
118  if (m_start->count() == 0)
119  {
120  m_bans = TQStringList::split(',',p->option("kde-banners-supported"),false);
121  if (m_bans.count() == 0)
122  m_bans = defaultBanners();
123  if (m_bans.find("none") == m_bans.end())
124  m_bans.prepend("none");
125  for ( TQStringList::Iterator it=m_bans.begin(); it!=m_bans.end(); ++it )
126  {
127  m_start->insertItem( i18n( mapBanner(*it).utf8() ) );
128  m_end->insertItem( i18n( mapBanner(*it).utf8() ) );
129  }
130  }
131  TQStringList l = TQStringList::split(',',p->option("kde-banners"),false);
132  while (l.count() < 2)
133  l.append("none");
134  m_start->setCurrentItem(m_bans.findIndex(l[0]));
135  m_end->setCurrentItem(m_bans.findIndex(l[1]));
136  }
137 }
138 
139 void KMWBanners::updatePrinter(KMPrinter *p)
140 {
141  if (m_start->count() > 0)
142  {
143  p->setOption("kde-banners",m_bans[m_start->currentItem()]+","+m_bans[m_end->currentItem()]);
144  }
145 }

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.1
This website is maintained by Timothy Pearson.