summaryrefslogtreecommitdiffstats
path: root/tdeprint/management/kmprinterview.cpp
blob: 025a1812c91b35e2889ba6aa7a598ce7399482d6 (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
/*
 *  This file is part of the KDE libraries
 *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
 *
 *  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 "kmprinterview.h"
#include "kmprinter.h"
#include "kmiconview.h"
#include "kmlistview.h"
#include "kmtimer.h"
#include "kmmanager.h"

#include <tqlayout.h>
#include <tqpopupmenu.h>
#include <kaction.h>
#include <klocale.h>

KMPrinterView::KMPrinterView(TQWidget *parent, const char *name)
: TQWidgetStack(parent,name), m_type(KMPrinterView::Icons)
{
	m_iconview = new KMIconView(this);
	addWidget(m_iconview,0);
	m_listview = new KMListView(this);
	addWidget(m_listview,1);
	m_current = TQString();
	m_listset = false;

	connect(m_iconview,TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)),TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)));
	connect(m_listview,TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)),TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)));
	connect(m_iconview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SIGNAL(printerSelected(const TQString&)));
	connect(m_listview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SIGNAL(printerSelected(const TQString&)));
	connect(m_iconview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&)));
	connect(m_listview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&)));

	setViewType(m_type);
	tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ) );
}

KMPrinterView::~KMPrinterView()
{
}

void KMPrinterView::setPrinterList(TQPtrList<KMPrinter> *list)
{
	if (m_type != KMPrinterView::Tree || list == 0)
		m_iconview->setPrinterList(list);
	if (m_type == KMPrinterView::Tree || list == 0)
		m_listview->setPrinterList(list);
	m_listset = ( list != 0 );
}

void KMPrinterView::setPrinter( KMPrinter *p )
{
	if ( m_type == KMPrinterView::Tree )
		m_listview->setPrinter( p );
	else
		m_iconview->setPrinter( p );
}

void KMPrinterView::setViewType(ViewType t)
{
	m_type = t;
	switch (m_type)
	{
		case KMPrinterView::Icons:
			m_iconview->setViewMode(KMIconView::Big);
			break;
		case KMPrinterView::List:
			m_iconview->setViewMode(KMIconView::Small);
			break;
		default:
			break;
	}
	QString	oldcurrent = m_current;
	if ( m_listset )
		setPrinterList(KMManager::self()->printerList(false));
	if (m_type == KMPrinterView::Tree)
	{
		raiseWidget(m_listview);
		m_listview->setPrinter(oldcurrent);
	}
	else
	{
		raiseWidget(m_iconview);
		m_iconview->setPrinter(oldcurrent);
	}
}

void KMPrinterView::slotPrinterSelected(const TQString& p)
{
	m_current = p;
}

TQSize KMPrinterView::minimumSizeHint() const
{
	return TQWidgetStack::minimumSizeHint();
}

#include "kmprinterview.moc"