summaryrefslogtreecommitdiffstats
path: root/tdeprint/management/kmwend.cpp
blob: 2881b4ea010c4641cf2ccbded1463ebf2a89c6ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 *  This file is part of the KDE libraries
 *  Copyright (c) 2001 Michael Goffioul <[email protected]>
 *
 *  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 "kmwend.h"
#include "kmprinter.h"
#include "kmwizard.h"
#include "util.h"

#include <tqtextview.h>
#include <klocale.h>
#include <tqlayout.h>

KMWEnd::KMWEnd(TQWidget *parent, const char *name)
: KMWizardPage(parent,name)
{
	m_ID = KMWizard::End;
	m_title = i18n("Confirmation");
	m_nextpage = KMWizard::Error;

	m_view = new TQTextView(this);

	TQVBoxLayout	*lay = new TQVBoxLayout(this, 0, 0);
	lay->addWidget(m_view,1);
}

void KMWEnd::initPrinter(KMPrinter *p)
{
	TQString	txt;
	TQString	s(TQString::fromLatin1("<li><u>%1</u>: %2</li>"));
	int	ID = p->option("kde-backend").toInt();

	// general information
	txt.append(TQString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("General")));
	txt.append(s.arg(i18n("Type")).arg(p->option("kde-backend-description")));
	txt.append(s.arg(i18n("Name")).arg(p->name()));
	txt.append(s.arg(i18n("Location")).arg(p->location()));
	txt.append(s.arg(i18n("Description")).arg(p->description()));
	txt.append("</ul><br>");

	if (ID == KMWizard::Class)
	{
		// class members
		txt.append(TQString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Members")));
		TQStringList	m(p->members());
		TQString		s1(TQString::fromLatin1("<li>%1</li>"));
		for (TQStringList::ConstIterator it=m.begin(); it!=m.end(); ++it)
			txt.append(s1.arg(*it));
		txt.append("</ul><br>");
	}
	else
	{
		// backend information
		txt.append(TQString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Backend")));
		KURL url ( p->device() );
		switch (ID)
		{
			case KMWizard::Local:
				txt.append(s.arg(i18n("Device")).arg(url.path()));
				break;
			case KMWizard::TCP:
				txt.append(s.arg(i18n("Printer IP")).arg(url.host()));
				txt.append(s.arg(i18n("Port")).arg(url.port()));
				break;
			case KMWizard::LPD:
				txt.append(s.arg(i18n("Host")).arg(url.host()));
				txt.append(s.arg(i18n("Queue")).arg(url.path().right(url.path().length()-1)));
				break;
			case KMWizard::File:
				txt.append(s.arg(i18n("File")).arg(url.path()));
				break;
			case KMWizard::IPP:
				txt.append(s.arg(i18n("Host")).arg(url.host()));
				txt.append(s.arg(i18n("Port")).arg(url.port()));
				txt.append(s.arg(i18n("Printer")).arg(url.path().right(url.path().length()-1)));
				if (url.hasUser()) txt.append(s.arg(i18n("Account")).arg(url.user()));
				break;
			default:
				// double decoding in case the printer name contains chars like '#' that are
				// not decoded by "prettyURL".
				txt.append(s.arg(i18n("URI")).arg(KURL( p->device()).prettyURL()));
				break;
		}
		txt.append("</ul><br>");

		if (p->option("kde-driver") == "raw" || p->driver())
		{
			// driver information
			txt.append(TQString::fromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Driver")));
			if (p->option("kde-driver") == "raw")
				txt.append(s.arg(i18n("Type")).arg(i18n("Raw printer")));
			else
			{
				txt.append(s.arg(i18n("Type")).arg((p->dbEntry() ? i18n("DB driver") : i18n("External driver"))));
				txt.append(s.arg(i18n("Manufacturer")).arg(p->manufacturer()));
				txt.append(s.arg(i18n("Model")).arg(p->model()));
				txt.append(s.arg(i18n("Description")).arg(p->driverInfo()));
			}
			txt.append("</ul><br>");
		}
	}

	m_view->setText(txt);
}