summaryrefslogtreecommitdiffstats
path: root/kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp
blob: a47fae05b840a208de90e12872e2757dce63d201 (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
/*
 *  This file is part of the KDE libraries
 *  Copyright (c) 2001 Michael Goffioul <kdeprint@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 "cupsdfilterpage.h"
#include "cupsdconf.h"
#include "sizewidget.h"

#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqlayout.h>
#include <tqwhatsthis.h>
#include <tqcombobox.h>

#include <klocale.h>
#include <knuminput.h>

CupsdFilterPage::CupsdFilterPage(TQWidget *parent, const char *name)
	: CupsdPage(parent, name)
{
	setPageLabel(i18n("Filter"));
	setHeader(i18n("Filter Settings"));
	setPixmap("filter");

	user_ = new TQLineEdit(this);
	group_ = new TQLineEdit(this);
	ripcache_ = new SizeWidget(this);
	filterlimit_ = new KIntNumInput(this);

	filterlimit_->setRange(0, 1000, 1, true);
	filterlimit_->setSpecialValueText(i18n("Unlimited"));
	filterlimit_->setSteps(1, 10);

	TQLabel *l1 = new TQLabel(i18n("User:"), this);
	TQLabel *l2 = new TQLabel(i18n("Group:"), this);
	TQLabel *l3 = new TQLabel(i18n("RIP cache:"), this);
	TQLabel *l4 = new TQLabel(i18n("Filter limit:"), this);

	TQGridLayout	*m1 = new TQGridLayout(this, 5, 2, 10, 7);
	m1->setRowStretch(4, 1);
	m1->setColStretch(1, 1);
	m1->addWidget(l1, 0, 0, Qt::AlignRight);
	m1->addWidget(l2, 1, 0, Qt::AlignRight);
	m1->addWidget(l3, 2, 0, Qt::AlignRight);
	m1->addWidget(l4, 3, 0, Qt::AlignRight);
	m1->addWidget(user_, 0, 1);
	m1->addWidget(group_, 1, 1);
	m1->addWidget(ripcache_, 2, 1);
	m1->addWidget(filterlimit_, 3, 1);
}

bool CupsdFilterPage::loadConfig(CupsdConf *conf, TQString&)
{
	conf_ = conf;
	user_->setText(conf_->user_);
	group_->setText(conf_->group_);
	ripcache_->setSizeString(conf_->ripcache_);
	filterlimit_->setValue(conf_->filterlimit_);

	return true;
}

bool CupsdFilterPage::saveConfig(CupsdConf *conf, TQString&)
{
	conf->user_ = user_->text();
	conf->group_ = group_->text();
	conf->ripcache_ = ripcache_->sizeString();
	conf->filterlimit_ = filterlimit_->value();

	return true;
}

void CupsdFilterPage::setInfos(CupsdConf *conf)
{
	TQWhatsThis::add(user_, conf->comments_.toolTip("user"));
	TQWhatsThis::add(group_, conf->comments_.toolTip("group"));
	TQWhatsThis::add(ripcache_, conf->comments_.toolTip("ripcache"));
	TQWhatsThis::add(filterlimit_, conf->comments_.toolTip("filterlimit"));
}