kdeprint Library API Documentation

cupsdserverdirpage.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 "cupsdserverdirpage.h" 00021 00022 #include "qdirlineedit.h" 00023 #include <klocale.h> 00024 #include <qlayout.h> 00025 #include <qlabel.h> 00026 #include <qcombobox.h> 00027 #include <qgroupbox.h> 00028 #include <qwhatsthis.h> 00029 00030 #include "cupsdconf.h" 00031 #include "cupsdoption.h" 00032 00033 CupsdServerDirPage::CupsdServerDirPage(QWidget *parent, const char *name) 00034 : CupsdPage(parent, name) 00035 { 00036 path_.append(i18n("Server")); 00037 path_.append(i18n("Directories")); 00038 header_ = i18n("Server Directories Configuration"); 00039 00040 for (int i=0;i<6;i++) 00041 opt_[i] = new CupsdOption(this); 00042 00043 serverbin_ = new QDirLineEdit(opt_[0]); 00044 serverroot_ = new QDirLineEdit(opt_[1]); 00045 datadir_ = new QDirLineEdit(opt_[2]); 00046 tempdir_ = new QDirLineEdit(opt_[3]); 00047 requestroot_ = new QDirLineEdit(opt_[4]); 00048 fontpath_ = new QDirLineEdit(opt_[5]); 00049 00050 QLabel *l1 = new QLabel(i18n("Executables:"), this); 00051 QLabel *l2 = new QLabel(i18n("Configuration:"), this); 00052 QLabel *l3 = new QLabel(i18n("Data:"), this); 00053 QLabel *l4 = new QLabel(i18n("Temporary files:"), this); 00054 QLabel *l5 = new QLabel(i18n("Temporary requests:"), this); 00055 QLabel *l6 = new QLabel(i18n("Font path:"), this); 00056 00057 QGridLayout *main_ = new QGridLayout(this, 10, 2, 10, 10); 00058 main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter); 00059 main_->addWidget(opt_[0], 1, 1); 00060 main_->addWidget(opt_[1], 2, 1); 00061 main_->addWidget(opt_[2], 3, 1); 00062 main_->addWidget(opt_[3], 5, 1); 00063 main_->addWidget(opt_[4], 6, 1); 00064 main_->addWidget(opt_[5], 8, 1); 00065 main_->addWidget(l1, 1, 0); 00066 main_->addWidget(l2, 2, 0); 00067 main_->addWidget(l3, 3, 0); 00068 main_->addWidget(l4, 5, 0); 00069 main_->addWidget(l5, 6, 0); 00070 main_->addWidget(l6, 8, 0); 00071 main_->setRowStretch(9, 1); 00072 main_->addRowSpacing(4, 20); 00073 main_->addRowSpacing(7, 20); 00074 00075 } 00076 00077 CupsdServerDirPage::~CupsdServerDirPage() 00078 { 00079 } 00080 00081 bool CupsdServerDirPage::loadConfig(CupsdConf *conf, QString&) 00082 { 00083 conf_ = conf; 00084 if (!conf->serverbin_.isNull()) 00085 { 00086 opt_[0]->setDefault(false); 00087 serverbin_->setText(conf->serverbin_); 00088 } 00089 if (!conf->serverroot_.isNull()) 00090 { 00091 opt_[1]->setDefault(false); 00092 serverroot_->setText(conf->serverroot_); 00093 } 00094 if (!conf->datadir_.isNull()) 00095 { 00096 opt_[2]->setDefault(false); 00097 datadir_->setText(conf->datadir_); 00098 } 00099 if (!conf->tempdir_.isNull()) 00100 { 00101 opt_[3]->setDefault(false); 00102 tempdir_->setText(conf->tempdir_); 00103 } 00104 if (!conf->requestroot_.isNull()) 00105 { 00106 opt_[4]->setDefault(false); 00107 requestroot_->setText(conf->requestroot_); 00108 } 00109 if (!conf->fontpath_.isNull()) 00110 { 00111 opt_[5]->setDefault(false); 00112 fontpath_->setText(conf->fontpath_); 00113 } 00114 return true; 00115 } 00116 00117 bool CupsdServerDirPage::saveConfig(CupsdConf *conf, QString&) 00118 { 00119 if (!opt_[0]->isDefault() && !serverbin_->text().isNull()) conf->serverbin_ = serverbin_->text(); 00120 if (!opt_[1]->isDefault() && !serverroot_->text().isNull()) conf->serverroot_ = serverroot_->text(); 00121 if (!opt_[2]->isDefault() && !datadir_->text().isNull()) conf->datadir_ = datadir_->text(); 00122 if (!opt_[3]->isDefault() && !tempdir_->text().isNull()) conf->tempdir_ = tempdir_->text(); 00123 if (!opt_[4]->isDefault() && !requestroot_->text().isNull()) conf->requestroot_ = requestroot_->text(); 00124 if (!opt_[5]->isDefault() && !fontpath_->text().isNull()) conf->fontpath_ = fontpath_->text(); 00125 return true; 00126 } 00127 00128 void CupsdServerDirPage::setDefaults() 00129 { 00130 serverbin_->setText("/usr/lib/cups"); 00131 serverroot_->setText("/etc/cups"); 00132 datadir_->setText("/usr/share/cups/data"); 00133 tempdir_->setText("/var/spool/cups/tmp"); 00134 requestroot_->setText("/var/spool/cups"); 00135 fontpath_->setText("/usr/share/cups/fonts"); 00136 } 00137 00138 void CupsdServerDirPage::setInfos(CupsdConf *conf) 00139 { 00140 QWhatsThis::add(serverbin_, conf->comments_.toolTip(SERVERBIN_COMM)); 00141 QWhatsThis::add(serverroot_, conf->comments_.toolTip(SERVERROOT_COMM)); 00142 QWhatsThis::add(datadir_, conf->comments_.toolTip(DATADIR_COMM)); 00143 QWhatsThis::add(tempdir_, conf->comments_.toolTip(TEMPDIR_COMM)); 00144 QWhatsThis::add(requestroot_, conf->comments_.toolTip(REQUESTROOT_COMM)); 00145 QWhatsThis::add(fontpath_, conf->comments_.toolTip(FONTPATH_COMM)); 00146 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 8 11:15:36 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003