00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "cupsdserverpage.h"
00021
#include "cupsdconf.h"
00022
00023
#include <qlineedit.h>
00024
#include <qlabel.h>
00025
#include <qcheckbox.h>
00026
#include <qcombobox.h>
00027
#include <qlayout.h>
00028
#include <qwhatsthis.h>
00029
00030
#include <klocale.h>
00031
00032
int findComboItem(
QComboBox *cb,
const QString& str)
00033 {
00034
for (
int i=0; i<cb->count(); i++)
00035
if (cb->text(i) == str)
00036
return i;
00037
return (-1);
00038 }
00039
00040 CupsdServerPage::CupsdServerPage(
QWidget *parent,
const char *name)
00041 : CupsdPage(parent, name)
00042 {
00043 setPageLabel(i18n(
"Server"));
00044 setHeader(i18n(
"Server Settings"));
00045 setPixmap(
"gear");
00046
00047 servername_ =
new QLineEdit(
this);
00048 serveradmin_ =
new QLineEdit(
this);
00049 otherclassname_ =
new QLineEdit(
this);
00050 language_ =
new QLineEdit(
this);
00051 printcap_ =
new QLineEdit(
this);
00052 classification_ =
new QComboBox(
this);
00053 charset_ =
new QComboBox(
this);
00054 printcapformat_ =
new QComboBox(
this);
00055 classoverride_ =
new QCheckBox(i18n(
"Allow overrides"),
this);
00056
00057 classification_->insertItem(i18n(
"None"));
00058 classification_->insertItem(i18n(
"Classified"));
00059 classification_->insertItem(i18n(
"Confidential"));
00060 classification_->insertItem(i18n(
"Secret"));
00061 classification_->insertItem(i18n(
"Top Secret"));
00062 classification_->insertItem(i18n(
"Unclassified"));
00063 classification_->insertItem(i18n(
"Other"));
00064
00065 charset_->insertItem(
"UTF-8");
00066 charset_->insertItem(
"ISO-8859-1");
00067 charset_->insertItem(
"ISO-8859-2");
00068 charset_->insertItem(
"ISO-8859-3");
00069 charset_->insertItem(
"ISO-8859-4");
00070 charset_->insertItem(
"ISO-8859-5");
00071 charset_->insertItem(
"ISO-8859-6");
00072 charset_->insertItem(
"ISO-8859-7");
00073 charset_->insertItem(
"ISO-8859-8");
00074 charset_->insertItem(
"ISO-8859-9");
00075 charset_->insertItem(
"ISO-8859-10");
00076 charset_->insertItem(
"ISO-8859-13");
00077 charset_->insertItem(
"ISO-8859-14");
00078 charset_->insertItem(
"ISO-8859-15");
00079
00080 printcapformat_->insertItem(
"BSD");
00081 printcapformat_->insertItem(
"SOLARIS");
00082
00083
QLabel *l1 =
new QLabel(i18n(
"Server name:"),
this);
00084
QLabel *l2 =
new QLabel(i18n(
"Server administrator:"),
this);
00085
QLabel *l3 =
new QLabel(i18n(
"Classification:"),
this);
00086
QLabel *l4 =
new QLabel(i18n(
"Default character set:"),
this);
00087
QLabel *l5 =
new QLabel(i18n(
"Default language:"),
this);
00088
QLabel *l6 =
new QLabel(i18n(
"Printcap file:"),
this);
00089
QLabel *l7 =
new QLabel(i18n(
"Printcap format:"),
this);
00090
00091 connect(classification_, SIGNAL(activated(
int)), SLOT(classChanged(
int)));
00092 classification_->setCurrentItem(0);
00093 charset_->setCurrentItem(0);
00094 printcapformat_->setCurrentItem(0);
00095 classChanged(0);
00096
00097
QGridLayout *m1 =
new QGridLayout(
this, 9, 2, 10, 7);
00098 m1->setRowStretch(8, 1);
00099 m1->setColStretch(1, 1);
00100 m1->addWidget(l1, 0, 0, Qt::AlignRight);
00101 m1->addWidget(l2, 1, 0, Qt::AlignRight);
00102 m1->addWidget(l3, 2, 0, Qt::AlignRight);
00103 m1->addWidget(l4, 4, 0, Qt::AlignRight);
00104 m1->addWidget(l5, 5, 0, Qt::AlignRight);
00105 m1->addWidget(l6, 6, 0, Qt::AlignRight);
00106 m1->addWidget(l7, 7, 0, Qt::AlignRight);
00107 m1->addWidget(servername_, 0, 1);
00108 m1->addWidget(serveradmin_, 1, 1);
00109 m1->addWidget(charset_, 4, 1);
00110 m1->addWidget(language_, 5, 1);
00111 m1->addWidget(printcap_, 6, 1);
00112 m1->addWidget(printcapformat_, 7, 1);
00113
QHBoxLayout *m2 =
new QHBoxLayout(0, 0, 5);
00114 m1->addLayout(m2, 2, 1);
00115 m2->addWidget(classification_);
00116 m2->addWidget(otherclassname_);
00117
QWidget *w =
new QWidget(
this);
00118 w->setFixedWidth(20);
00119
QHBoxLayout *m3 =
new QHBoxLayout(0, 0, 0);
00120 m1->addLayout(m3, 3, 1);
00121 m3->addWidget(w);
00122 m3->addWidget(classoverride_);
00123 }
00124
00125
bool CupsdServerPage::loadConfig(CupsdConf *conf,
QString&)
00126 {
00127 conf_ = conf;
00128 servername_->setText(conf_->servername_);
00129 serveradmin_->setText(conf_->serveradmin_);
00130 classification_->setCurrentItem(conf_->classification_);
00131 classChanged(conf_->classification_);
00132
if (conf->classification_ != CLASS_NONE)
00133 classoverride_->setChecked(conf_->classoverride_);
00134
if (conf->classification_ == CLASS_OTHER)
00135 otherclassname_->setText(conf_->otherclassname_);
00136
int index = findComboItem(charset_, conf_->charset_.upper());
00137
if (index != -1)
00138 charset_->setCurrentItem(index);
00139 language_->setText(conf_->language_);
00140 printcap_->setText(conf_->printcap_);
00141 printcapformat_->setCurrentItem(conf_->printcapformat_);
00142
00143
return true;
00144 }
00145
00146
bool CupsdServerPage::saveConfig(CupsdConf *conf,
QString&)
00147 {
00148 conf->servername_ = servername_->text();
00149 conf->serveradmin_ = serveradmin_->text();
00150 conf->classification_ = classification_->currentItem();
00151
if (conf->classification_ != CLASS_NONE)
00152 conf->classoverride_ = classoverride_->isChecked();
00153
if (conf->classification_ == CLASS_OTHER)
00154 conf->otherclassname_ = otherclassname_->text();
00155 conf->charset_ = charset_->currentText();
00156 conf->language_ = language_->text();
00157 conf->printcap_ = printcap_->text();
00158 conf->printcapformat_ = printcapformat_->currentItem();
00159
00160
return true;
00161 }
00162
00163
void CupsdServerPage::setInfos(CupsdConf *conf)
00164 {
00165 QWhatsThis::add(servername_, conf->comments_.toolTip(
"servername"));
00166 QWhatsThis::add(serveradmin_, conf->comments_.toolTip(
"serveradmin"));
00167 QWhatsThis::add(classification_, conf->comments_.toolTip(
"classification"));
00168 QWhatsThis::add(classoverride_, conf->comments_.toolTip(
"classifyoverride"));
00169 QWhatsThis::add(charset_, conf->comments_.toolTip(
"defaultcharset"));
00170 QWhatsThis::add(language_, conf->comments_.toolTip(
"defaultlanguage"));
00171 QWhatsThis::add(printcap_, conf->comments_.toolTip(
"printcap"));
00172 QWhatsThis::add(printcapformat_, conf->comments_.toolTip(
"printcapformat"));
00173 }
00174
00175
void CupsdServerPage::classChanged(
int index)
00176 {
00177 classoverride_->setEnabled(index != 0);
00178 otherclassname_->setEnabled(index == CLASS_OTHER);
00179 }
00180
00181
#include "cupsdserverpage.moc"