kdeprint Library API Documentation

cupsdserverhttppage.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 "cupsdserverhttppage.h" 00021 00022 #include "qdirlineedit.h" 00023 #include <qlineedit.h> 00024 #include <klocale.h> 00025 #include <qlayout.h> 00026 #include <qlabel.h> 00027 #include <qcombobox.h> 00028 #include <qwhatsthis.h> 00029 00030 #include "cupsdconf.h" 00031 #include "cupsdoption.h" 00032 00033 CupsdServerHTTPPage::CupsdServerHTTPPage(QWidget *parent, const char *name) 00034 : CupsdPage(parent, name) 00035 { 00036 path_.append(i18n("Server")); 00037 path_.append(i18n("HTTP")); 00038 header_ = i18n("Server HTTP Configuration"); 00039 00040 for (int i=0;i<3;i++) 00041 opt_[i] = new CupsdOption(this); 00042 00043 defaultcharset_ = new QLineEdit(opt_[0]); 00044 defaultlanguage_ = new QLineEdit(opt_[1]); 00045 documentroot_ = new QDirLineEdit(opt_[2]); 00046 00047 QLabel *l1 = new QLabel(i18n("Document directory:"), this); 00048 QLabel *l2 = new QLabel(i18n("Default language:"), this); 00049 QLabel *l3 = new QLabel(i18n("Default charset:"), this); 00050 00051 QGridLayout *main_ = new QGridLayout(this, 5, 2, 10, 10); 00052 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter); 00053 main_->addWidget(opt_[2], 1, 1); 00054 main_->addWidget(opt_[1], 2, 1); 00055 main_->addWidget(opt_[0], 3, 1); 00056 main_->addWidget(l1, 1, 0); 00057 main_->addWidget(l2, 2, 0); 00058 main_->addWidget(l3, 3, 0); 00059 main_->setRowStretch(4, 1); 00060 } 00061 00062 CupsdServerHTTPPage::~CupsdServerHTTPPage() 00063 { 00064 } 00065 00066 bool CupsdServerHTTPPage::loadConfig(CupsdConf *conf, QString&) 00067 { 00068 conf_ = conf; 00069 if (!conf->defaultcharset_.isNull()) 00070 { 00071 opt_[0]->setDefault(0); 00072 defaultcharset_->setText(conf->defaultcharset_); 00073 } 00074 if (!conf->defaultlanguage_.isNull()) 00075 { 00076 opt_[1]->setDefault(0); 00077 defaultlanguage_->setText(conf->defaultlanguage_); 00078 } 00079 if (!conf->documentroot_.isNull()) 00080 { 00081 opt_[2]->setDefault(0); 00082 documentroot_->setText(conf->documentroot_); 00083 } 00084 return true; 00085 } 00086 00087 bool CupsdServerHTTPPage::saveConfig(CupsdConf *conf, QString&) 00088 { 00089 if (!opt_[0]->isDefault() && !defaultcharset_->text().isNull()) conf->defaultcharset_ = defaultcharset_->text(); 00090 if (!opt_[1]->isDefault() && !defaultlanguage_->text().isNull()) conf->defaultlanguage_ = defaultlanguage_->text(); 00091 if (!opt_[2]->isDefault() && !documentroot_->text().isNull()) conf->documentroot_ = documentroot_->text(); 00092 return true; 00093 } 00094 00095 void CupsdServerHTTPPage::setDefaults() 00096 { 00097 defaultcharset_->setText("utf-8"); 00098 defaultlanguage_->setText("en"); 00099 documentroot_->setText("/usr/share/cups/doc"); 00100 } 00101 00102 void CupsdServerHTTPPage::setInfos(CupsdConf *conf) 00103 { 00104 QWhatsThis::add(defaultcharset_, conf->comments_.toolTip(DEFAULTCHARSET_COMM)); 00105 QWhatsThis::add(defaultlanguage_, conf->comments_.toolTip(DEFAULTLANG_COMM)); 00106 QWhatsThis::add(documentroot_, conf->comments_.toolTip(DOCUMENTROOT_COMM)); 00107 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:41:49 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003