kdeprint Library API Documentation

cupsdserverlogpage.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 "cupsdserverlogpage.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 CupsdServerLogPage::CupsdServerLogPage(QWidget *parent, const char *name)
00034     : CupsdPage(parent, name)
00035 {
00036     path_.append(i18n("Server"));
00037     path_.append(i18n("Log"));
00038     header_ = i18n("Server Logging Configuration");
00039 
00040     for (int i=0;i<5;i++)
00041         opt_[i] = new CupsdOption(this);
00042 
00043     accesslog_ = new QDirLineEdit(opt_[0]);
00044     accesslog_->setFileEdit(true);
00045     errorlog_ = new QDirLineEdit(opt_[1]);
00046     errorlog_->setFileEdit(true);
00047     pagelog_ = new QDirLineEdit(opt_[2]);
00048     pagelog_->setFileEdit(true);
00049     loglevel_ = new QComboBox(opt_[3]);
00050     loglevel_->insertItem(i18n("Complete Debug (everything)"));
00051     loglevel_->insertItem(i18n("Partial Debug (almost everything)"));
00052     loglevel_->insertItem(i18n("Info (normal)"));
00053     loglevel_->insertItem(i18n("Warning (errors and warnings)"));
00054     loglevel_->insertItem(i18n("Error (errors only)"));
00055     loglevel_->insertItem(i18n("None"));
00056     maxlogsize_ = new QLineEdit(opt_[4]);
00057 
00058     QLabel  *l1 = new QLabel(i18n("Access log file:"), this);
00059     QLabel  *l2 = new QLabel(i18n("Error log file:"), this);
00060     QLabel  *l3 = new QLabel(i18n("Page log file:"), this);
00061     QLabel  *l4 = new QLabel(i18n("Log level:"), this);
00062     QLabel  *l5 = new QLabel(i18n("Max log file size:"), this);
00063 
00064     QGridLayout *main_ = new QGridLayout(this, 8, 2, 10, 10);
00065     main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00066     main_->addWidget(opt_[0], 1, 1);
00067     main_->addWidget(opt_[1], 2, 1);
00068     main_->addWidget(opt_[2], 3, 1);
00069     main_->addWidget(opt_[3], 5, 1);
00070     main_->addWidget(opt_[4], 6, 1);
00071     main_->addWidget(l1, 1, 0);
00072     main_->addWidget(l2, 2, 0);
00073     main_->addWidget(l3, 3, 0);
00074     main_->addWidget(l4, 5, 0);
00075     main_->addWidget(l5, 6, 0);
00076     main_->setRowStretch(7, 1);
00077     main_->addRowSpacing(4, 20);
00078 
00079 }
00080 
00081 CupsdServerLogPage::~CupsdServerLogPage()
00082 {
00083 }
00084 
00085 bool CupsdServerLogPage::loadConfig(CupsdConf *conf, QString&)
00086 {
00087     conf_ = conf;
00088     if (!conf->accesslog_.isNull())
00089     {
00090         opt_[0]->setDefault(false);
00091         accesslog_->setText(conf->accesslog_);
00092     }
00093     if (!conf->errorlog_.isNull())
00094     {
00095         opt_[1]->setDefault(false);
00096         errorlog_->setText(conf->errorlog_);
00097     }
00098     if (!conf->pagelog_.isNull())
00099     {
00100         opt_[2]->setDefault(false);
00101         pagelog_->setText(conf->pagelog_);
00102     }
00103     if (conf->maxlogsize_ != -1)
00104     {
00105         opt_[4]->setDefault(false);
00106         maxlogsize_->setText(QString::number(conf->maxlogsize_));
00107     }
00108     if (conf->loglevel_ != -1)
00109     {
00110         opt_[3]->setDefault(false);
00111         loglevel_->setCurrentItem(conf->loglevel_);
00112     }
00113     return true;
00114 }
00115 
00116 bool CupsdServerLogPage::saveConfig(CupsdConf *conf, QString& msg)
00117 {
00118     if (!opt_[0]->isDefault() && !accesslog_->text().isNull()) conf->accesslog_ = accesslog_->text();
00119     if (!opt_[1]->isDefault() && !errorlog_->text().isNull()) conf->errorlog_ = errorlog_->text();
00120     if (!opt_[2]->isDefault() && !pagelog_->text().isNull()) conf->pagelog_ = pagelog_->text();
00121     if (!opt_[4]->isDefault() && !maxlogsize_->text().isNull())
00122     {
00123         bool    ok;
00124         conf->maxlogsize_ = maxlogsize_->text().toInt(&ok);
00125         if (!ok)
00126         {
00127             msg = i18n("Max log size: wrong argument");
00128             return false;
00129         }
00130     }
00131     if (!opt_[3]->isDefault()) conf->loglevel_ = loglevel_->currentItem();
00132     return true;
00133 }
00134 
00135 void CupsdServerLogPage::setDefaults()
00136 {
00137     accesslog_->setText("/var/log/cups/access_log");
00138     errorlog_->setText("/var/log/cups/error_log");
00139     pagelog_->setText("/var/log/cups/page_log");
00140     maxlogsize_->setText("1048576");
00141     loglevel_->setCurrentItem(1);
00142 }
00143 
00144 void CupsdServerLogPage::setInfos(CupsdConf *conf)
00145 {
00146         QWhatsThis::add(accesslog_, conf->comments_.toolTip(ACCESSLOG_COMM));
00147         QWhatsThis::add(errorlog_, conf->comments_.toolTip(ERRORLOG_COMM));
00148         QWhatsThis::add(pagelog_, conf->comments_.toolTip(PAGELOG_COMM));
00149         QWhatsThis::add(maxlogsize_, conf->comments_.toolTip(MAXLOGSIZE_COMM));
00150         QWhatsThis::add(loglevel_, conf->comments_.toolTip(LOGLEVEL_COMM));
00151 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 12 09:08:47 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003