You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
3.8 KiB
126 lines
3.8 KiB
15 years ago
|
/*
|
||
|
* This file is part of the KDE libraries
|
||
13 years ago
|
* Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
|
||
15 years ago
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License version 2 as published by the Free Software Foundation.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
**/
|
||
|
|
||
|
#include "kmwother.h"
|
||
|
#include "kmwizard.h"
|
||
|
#include "kmprinter.h"
|
||
|
#include "kmmanager.h"
|
||
|
#include "cupsinfos.h"
|
||
|
|
||
14 years ago
|
#include <tqlabel.h>
|
||
|
#include <tqlayout.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqheader.h>
|
||
|
#include <tqdict.h>
|
||
15 years ago
|
|
||
|
#include <klocale.h>
|
||
|
#include <klistview.h>
|
||
|
#include <kiconloader.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
14 years ago
|
KMWOther::KMWOther(TQWidget *parent, const char *name)
|
||
15 years ago
|
: KMWizardPage(parent,name)
|
||
|
{
|
||
|
m_ID = KMWizard::Custom+5;
|
||
|
m_title = i18n("URI Selection");
|
||
|
m_nextpage = KMWizard::Driver;
|
||
|
|
||
14 years ago
|
m_uri = new TQLineEdit(this);
|
||
14 years ago
|
TQLabel *l1 = new TQLabel(this);
|
||
15 years ago
|
l1->setText(i18n("<p>Enter the URI corresponding to the printer to be installed. "
|
||
|
"Examples:</p><ul>"
|
||
|
"<li>smb://[login[:passwd]@]server/printer</li>"
|
||
|
"<li>lpd://server/queue</li>"
|
||
|
"<li>parallel:/dev/lp0</li></ul>"));
|
||
14 years ago
|
TQLabel *l2 = new TQLabel(i18n("URI:"), this);
|
||
15 years ago
|
m_uriview = new KListView( this );
|
||
|
m_uriview->addColumn( "" );
|
||
|
m_uriview->header()->hide();
|
||
|
m_uriview->setSorting( -1 );
|
||
14 years ago
|
connect( m_uriview, TQT_SIGNAL( pressed( TQListViewItem* ) ), TQT_SLOT( slotPressed( TQListViewItem* ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 15);
|
||
|
TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 5);
|
||
15 years ago
|
lay1->addWidget(l1);
|
||
|
lay1->addLayout(lay2);
|
||
|
lay1->addWidget( m_uriview );
|
||
|
lay2->addWidget(l2);
|
||
|
lay2->addWidget(m_uri);
|
||
|
}
|
||
|
|
||
|
void KMWOther::initPrinter(KMPrinter *p)
|
||
|
{
|
||
|
m_uri->setText(p->device());
|
||
|
|
||
|
if ( m_uriview->childCount() == 0 )
|
||
|
{
|
||
14 years ago
|
TQStringList l = KMManager::self()->detectLocalPrinters();
|
||
15 years ago
|
if ( l.isEmpty() || l.count() % 4 != 0 )
|
||
|
return;
|
||
|
|
||
14 years ago
|
TQListViewItem *item = 0, *lastparent = 0, *root;
|
||
|
root = new TQListViewItem( m_uriview, i18n( "CUPS Server %1:%2" ).arg( CupsInfos::self()->host() ).arg( CupsInfos::self()->port() ) );
|
||
15 years ago
|
root->setPixmap( 0, SmallIcon( "gear" ) );
|
||
|
root->setOpen( true );
|
||
14 years ago
|
TQDict<TQListViewItem> parents, last;
|
||
15 years ago
|
parents.setAutoDelete( false );
|
||
|
last.setAutoDelete( false );
|
||
14 years ago
|
for ( TQStringList::Iterator it=l.begin(); it!=l.end(); ++it )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString cl = *it;
|
||
|
TQString uri = *( ++it );
|
||
|
TQString desc = *( ++it );
|
||
|
TQString prt = *( ++it );
|
||
15 years ago
|
if ( !prt.isEmpty() )
|
||
|
desc.append( " [" + prt + "]" );
|
||
13 years ago
|
TQListViewItem *parent = parents.find( cl );
|
||
15 years ago
|
if ( !parent )
|
||
|
{
|
||
14 years ago
|
parent = new TQListViewItem( root, lastparent, cl );
|
||
15 years ago
|
parent->setOpen( true );
|
||
|
if ( cl == "network" )
|
||
|
parent->setPixmap( 0, SmallIcon( "network" ) );
|
||
|
else if ( cl == "direct" )
|
||
13 years ago
|
parent->setPixmap( 0, SmallIcon( "tdeprint_computer" ) );
|
||
15 years ago
|
else if ( cl == "serial" )
|
||
|
parent->setPixmap( 0, SmallIcon( "usb" ) );
|
||
|
else
|
||
|
parent->setPixmap( 0, SmallIcon( "package" ) );
|
||
|
lastparent = parent;
|
||
|
parents.insert( cl, parent );
|
||
|
}
|
||
13 years ago
|
item = new TQListViewItem( parent, last.find( cl ), desc, uri);
|
||
15 years ago
|
last.insert( cl, item );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KMWOther::updatePrinter(KMPrinter *p)
|
||
|
{
|
||
|
p->setDevice( m_uri->text() );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KMWOther::slotPressed( TQListViewItem *item )
|
||
15 years ago
|
{
|
||
|
if ( item && !item->text( 1 ).isEmpty() )
|
||
|
m_uri->setText( item->text( 1 ) );
|
||
|
}
|
||
|
|
||
|
#include "kmwother.moc"
|