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

tdeprint

  • tdeprint
  • cups
kmwother.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 "kmwother.h"
21 #include "kmwizard.h"
22 #include "kmprinter.h"
23 #include "kmmanager.h"
24 #include "cupsinfos.h"
25 
26 #include <tqlabel.h>
27 #include <tqlayout.h>
28 #include <tqlineedit.h>
29 #include <tqheader.h>
30 #include <tqdict.h>
31 
32 #include <tdelocale.h>
33 #include <tdelistview.h>
34 #include <kiconloader.h>
35 #include <kdebug.h>
36 
37 KMWOther::KMWOther(TQWidget *parent, const char *name)
38 : KMWizardPage(parent,name)
39 {
40  m_ID = KMWizard::Custom+5;
41  m_title = i18n("URI Selection");
42  m_nextpage = KMWizard::Driver;
43 
44  m_uri = new TQLineEdit(this);
45  TQLabel *l1 = new TQLabel(this);
46  l1->setText(i18n("<p>Enter the URI corresponding to the printer to be installed. "
47  "Examples:</p><ul>"
48  "<li>smb://[login[:passwd]@]server/printer</li>"
49  "<li>lpd://server/queue</li>"
50  "<li>parallel:/dev/lp0</li></ul>"));
51  TQLabel *l2 = new TQLabel(i18n("URI:"), this);
52  m_uriview = new TDEListView( this );
53  m_uriview->addColumn( "" );
54  m_uriview->header()->hide();
55  m_uriview->setSorting( -1 );
56  connect( m_uriview, TQ_SIGNAL( pressed( TQListViewItem* ) ), TQ_SLOT( slotPressed( TQListViewItem* ) ) );
57 
58  TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 15);
59  TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 5);
60  lay1->addWidget(l1);
61  lay1->addLayout(lay2);
62  lay1->addWidget( m_uriview );
63  lay2->addWidget(l2);
64  lay2->addWidget(m_uri);
65 }
66 
67 void KMWOther::initPrinter(KMPrinter *p)
68 {
69  m_uri->setText(p->device());
70 
71  if ( m_uriview->childCount() == 0 )
72  {
73  TQStringList l = KMManager::self()->detectLocalPrinters();
74  if ( l.isEmpty() || l.count() % 4 != 0 )
75  return;
76 
77  TQListViewItem *item = 0, *lastparent = 0, *root;
78  root = new TQListViewItem( m_uriview, i18n( "CUPS Server %1:%2" ).arg( CupsInfos::self()->host() ).arg( CupsInfos::self()->port() ) );
79  root->setPixmap( 0, SmallIcon( "gear" ) );
80  root->setOpen( true );
81  TQDict<TQListViewItem> parents, last;
82  parents.setAutoDelete( false );
83  last.setAutoDelete( false );
84  for ( TQStringList::Iterator it=l.begin(); it!=l.end(); ++it )
85  {
86  TQString cl = *it;
87  TQString uri = *( ++it );
88  TQString desc = *( ++it );
89  TQString prt = *( ++it );
90  if ( !prt.isEmpty() )
91  desc.append( " [" + prt + "]" );
92  TQListViewItem *parent = parents.find( cl );
93  if ( !parent )
94  {
95  parent = new TQListViewItem( root, lastparent, cl );
96  parent->setOpen( true );
97  if ( cl == "network" )
98  parent->setPixmap( 0, SmallIcon( "network" ) );
99  else if ( cl == "direct" )
100  parent->setPixmap( 0, SmallIcon( "tdeprint_computer" ) );
101  else if ( cl == "serial" )
102  parent->setPixmap( 0, SmallIcon( "usb" ) );
103  else
104  parent->setPixmap( 0, SmallIcon( "package" ) );
105  lastparent = parent;
106  parents.insert( cl, parent );
107  }
108  item = new TQListViewItem( parent, last.find( cl ), desc, uri);
109  last.insert( cl, item );
110  }
111  }
112 }
113 
114 void KMWOther::updatePrinter(KMPrinter *p)
115 {
116  p->setDevice( m_uri->text() );
117 }
118 
119 void KMWOther::slotPressed( TQListViewItem *item )
120 {
121  if ( item && !item->text( 1 ).isEmpty() )
122  m_uri->setText( item->text( 1 ) );
123 }
124 
125 #include "kmwother.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.1
This website is maintained by Timothy Pearson.