20#include "cupsdserverpage.h" 
   23#include <tqlineedit.h> 
   25#include <tqcheckbox.h> 
   26#include <tqcombobox.h> 
   28#include <tqwhatsthis.h> 
   32int findComboItem(TQComboBox *cb, 
const TQString& str)
 
   34    for (
int i=0; i<cb->count(); i++)
 
   35        if (cb->text(i) == str)
 
   40CupsdServerPage::CupsdServerPage(TQWidget *parent, 
const char *name)
 
   41    : CupsdPage(parent, name)
 
   43    setPageLabel(i18n(
"Server"));
 
   44    setHeader(i18n(
"Server Settings"));
 
   47    servername_ = 
new TQLineEdit(
this);
 
   48    serveradmin_ = 
new TQLineEdit(
this);
 
   49    otherclassname_ = 
new TQLineEdit(
this);
 
   50    language_ = 
new TQLineEdit(
this);
 
   51    printcap_ = 
new TQLineEdit(
this);
 
   52    classification_ = 
new TQComboBox(
this);
 
   53    charset_ = 
new TQComboBox(
this);
 
   54    printcapformat_ = 
new TQComboBox(
this);
 
   55    classoverride_ = 
new TQCheckBox(i18n(
"Allow overrides"), 
this);
 
   57    classification_->insertItem(i18n(
"None"));
 
   58    classification_->insertItem(i18n(
"Classified"));
 
   59    classification_->insertItem(i18n(
"Confidential"));
 
   60    classification_->insertItem(i18n(
"Secret"));
 
   61    classification_->insertItem(i18n(
"Top Secret"));
 
   62    classification_->insertItem(i18n(
"Unclassified"));
 
   63    classification_->insertItem(i18n(
"Other"));
 
   65    charset_->insertItem(
"UTF-8");
 
   66    charset_->insertItem(
"ISO-8859-1");
 
   67    charset_->insertItem(
"ISO-8859-2");
 
   68    charset_->insertItem(
"ISO-8859-3");
 
   69    charset_->insertItem(
"ISO-8859-4");
 
   70    charset_->insertItem(
"ISO-8859-5");
 
   71    charset_->insertItem(
"ISO-8859-6");
 
   72    charset_->insertItem(
"ISO-8859-7");
 
   73    charset_->insertItem(
"ISO-8859-8");
 
   74    charset_->insertItem(
"ISO-8859-9");
 
   75    charset_->insertItem(
"ISO-8859-10");
 
   76    charset_->insertItem(
"ISO-8859-13");
 
   77    charset_->insertItem(
"ISO-8859-14");
 
   78    charset_->insertItem(
"ISO-8859-15");
 
   80    printcapformat_->insertItem(
"BSD");
 
   81    printcapformat_->insertItem(
"SOLARIS");
 
   83    TQLabel *l1 = 
new TQLabel(i18n(
"Server name:"), 
this);
 
   84    TQLabel *l2 = 
new TQLabel(i18n(
"Server administrator:"), 
this);
 
   85    TQLabel *l3 = 
new TQLabel(i18n(
"Classification:"), 
this);
 
   86    TQLabel *l4 = 
new TQLabel(i18n(
"Default character set:"), 
this);
 
   87    TQLabel *l5 = 
new TQLabel(i18n(
"Default language:"), 
this);
 
   88    TQLabel *l6 = 
new TQLabel(i18n(
"Printcap file:"), 
this);
 
   89    TQLabel *l7 = 
new TQLabel(i18n(
"Printcap format:"), 
this);
 
   91    connect(classification_, TQ_SIGNAL(activated(
int)), TQ_SLOT(classChanged(
int)));
 
   92    classification_->setCurrentItem(0);
 
   93    charset_->setCurrentItem(0);
 
   94    printcapformat_->setCurrentItem(0);
 
   97    TQGridLayout    *m1 = 
new TQGridLayout(
this, 9, 2, 10, 7);
 
   98    m1->setRowStretch(8, 1);
 
   99    m1->setColStretch(1, 1);
 
  100    m1->addWidget(l1, 0, 0, TQt::AlignRight);
 
  101    m1->addWidget(l2, 1, 0, TQt::AlignRight);
 
  102    m1->addWidget(l3, 2, 0, TQt::AlignRight);
 
  103    m1->addWidget(l4, 4, 0, TQt::AlignRight);
 
  104    m1->addWidget(l5, 5, 0, TQt::AlignRight);
 
  105    m1->addWidget(l6, 6, 0, TQt::AlignRight);
 
  106    m1->addWidget(l7, 7, 0, TQt::AlignRight);
 
  107    m1->addWidget(servername_, 0, 1);
 
  108    m1->addWidget(serveradmin_, 1, 1);
 
  109    m1->addWidget(charset_, 4, 1);
 
  110    m1->addWidget(language_, 5, 1);
 
  111    m1->addWidget(printcap_, 6, 1);
 
  112    m1->addWidget(printcapformat_, 7, 1);
 
  113    TQHBoxLayout    *m2 = 
new TQHBoxLayout(0, 0, 5);
 
  114    m1->addLayout(m2, 2, 1);
 
  115    m2->addWidget(classification_);
 
  116    m2->addWidget(otherclassname_);
 
  117    TQWidget    *w = 
new TQWidget(
this);
 
  118    w->setFixedWidth(20);
 
  119    TQHBoxLayout    *m3 = 
new TQHBoxLayout(0, 0, 0);
 
  120    m1->addLayout(m3, 3, 1);
 
  122    m3->addWidget(classoverride_);
 
  125bool CupsdServerPage::loadConfig(CupsdConf *conf, TQString&)
 
  128    servername_->setText(conf_->servername_);
 
  129    serveradmin_->setText(conf_->serveradmin_);
 
  130    classification_->setCurrentItem(conf_->classification_);
 
  131    classChanged(conf_->classification_);
 
  132    if (conf->classification_ != CLASS_NONE)
 
  133        classoverride_->setChecked(conf_->classoverride_);
 
  134    if (conf->classification_ == CLASS_OTHER)
 
  135        otherclassname_->setText(conf_->otherclassname_);
 
  136    int index = findComboItem(charset_, conf_->charset_.upper());
 
  138        charset_->setCurrentItem(index);
 
  139    language_->setText(conf_->language_);
 
  140    printcap_->setText(conf_->printcap_);
 
  141    printcapformat_->setCurrentItem(conf_->printcapformat_);
 
  146bool CupsdServerPage::saveConfig(CupsdConf *conf, TQString&)
 
  148    conf->servername_ = servername_->text();
 
  149    conf->serveradmin_ = serveradmin_->text();
 
  150    conf->classification_ = classification_->currentItem();
 
  151    if (conf->classification_ != CLASS_NONE)
 
  152        conf->classoverride_ = classoverride_->isChecked();
 
  153    if (conf->classification_ == CLASS_OTHER)
 
  154        conf->otherclassname_ = otherclassname_->text();
 
  155    conf->charset_ = charset_->currentText();
 
  156    conf->language_ = language_->text();
 
  157    conf->printcap_ = printcap_->text();
 
  158    conf->printcapformat_ = printcapformat_->currentItem();
 
  163void CupsdServerPage::setInfos(CupsdConf *conf)
 
  165    TQWhatsThis::add(servername_, conf->comments_.toolTip(
"servername"));
 
  166    TQWhatsThis::add(serveradmin_, conf->comments_.toolTip(
"serveradmin"));
 
  167    TQWhatsThis::add(classification_, conf->comments_.toolTip(
"classification"));
 
  168    TQWhatsThis::add(classoverride_, conf->comments_.toolTip(
"classifyoverride"));
 
  169    TQWhatsThis::add(charset_, conf->comments_.toolTip(
"defaultcharset"));
 
  170    TQWhatsThis::add(language_, conf->comments_.toolTip(
"defaultlanguage"));
 
  171    TQWhatsThis::add(printcap_, conf->comments_.toolTip(
"printcap"));
 
  172    TQWhatsThis::add(printcapformat_, conf->comments_.toolTip(
"printcapformat"));
 
  175void CupsdServerPage::classChanged(
int index)
 
  177    classoverride_->setEnabled(index != 0);
 
  178    otherclassname_->setEnabled(index == CLASS_OTHER);
 
  181#include "cupsdserverpage.moc"