kdeprint Library API Documentation

cupsdservermiscpage.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
00018  **/
00019 
00020 #include "cupsdservermiscpage.h"
00021 
00022 #include "qdirlineedit.h"
00023 #include <qlineedit.h>
00024 #include <klocale.h>
00025 #include <qlayout.h>
00026 #include <qlabel.h>
00027 #include <qwhatsthis.h>
00028 
00029 #include "cupsdconf.h"
00030 #include "cupsdoption.h"
00031 
00032 CupsdServerMiscPage::CupsdServerMiscPage(QWidget *parent, const char *name)
00033     : CupsdPage(parent, name)
00034 {
00035     path_.append(i18n("Server"));
00036     path_.append(i18n("Misc"));
00037     header_ = i18n("Server Miscellaneous Configuration");
00038 
00039     for (int i=0;i<2;i++)
00040         opt_[i] = new CupsdOption(this);
00041 
00042     printcap_ = new QDirLineEdit(opt_[0]);
00043     printcap_->setFileEdit(true);
00044     ripcache_ = new QLineEdit(opt_[1]);
00045 
00046     QLabel  *l1 = new QLabel(i18n("Printcap file:"), this);
00047     QLabel  *l2 = new QLabel(i18n("RIP cache:"), this);
00048 
00049     QGridLayout *main_ = new QGridLayout(this, 4, 2, 10, 10);
00050     main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00051     main_->addWidget(opt_[0], 1, 1);
00052     main_->addWidget(opt_[1], 2, 1);
00053     main_->addWidget(l1, 1, 0);
00054     main_->addWidget(l2, 2, 0);
00055     main_->setRowStretch(3, 1);
00056 }
00057 
00058 CupsdServerMiscPage::~CupsdServerMiscPage()
00059 {
00060 }
00061 
00062 bool CupsdServerMiscPage::loadConfig(CupsdConf *conf, QString&)
00063 {
00064     conf_ = conf;
00065     if (!conf->printcap_.isNull())
00066     {
00067         opt_[0]->setDefault(false);
00068         printcap_->setText(conf->printcap_);
00069     }
00070     if (!conf->ripcache_.isNull())
00071     {
00072         opt_[1]->setDefault(false);
00073         ripcache_->setText(conf->ripcache_);
00074     }
00075     return true;
00076 }
00077 
00078 bool CupsdServerMiscPage::saveConfig(CupsdConf *conf, QString& msg)
00079 {
00080     if (!opt_[0]->isDefault() && !printcap_->text().isNull()) conf->printcap_ = printcap_->text();
00081     if (!opt_[1]->isDefault() && !ripcache_->text().isNull()) conf->ripcache_ = ripcache_->text();
00082     return true;
00083 }
00084 
00085 void CupsdServerMiscPage::setDefaults()
00086 {
00087     printcap_->setText("/etc/printcap");
00088     ripcache_->setText("8m");
00089 }
00090 
00091 void CupsdServerMiscPage::setInfos(CupsdConf *conf)
00092 {
00093         QWhatsThis::add(printcap_, conf->comments_.toolTip(PRINTCAP_COMM));
00094         QWhatsThis::add(ripcache_, conf->comments_.toolTip(RIPCACHE_COMM));
00095 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:34:07 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003