cupsdbrowsingmaskspage.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "cupsdbrowsingmaskspage.h"
00021 
00022 #include <klocale.h>
00023 #include <qlayout.h>
00024 #include <qcombobox.h>
00025 #include <qlabel.h>
00026 #include <qwhatsthis.h>
00027 
00028 #include "cupsdconf.h"
00029 #include "cupsdoption.h"
00030 #include "cupslist.h"
00031 
00032 CupsdBrowsingMasksPage::CupsdBrowsingMasksPage(QWidget *parent, const char *name)
00033     : CupsdPage(parent, name)
00034 {
00035     path_.append(i18n("Browsing"));
00036     path_.append(i18n("Masks"));
00037     header_ = i18n("Browsing Masks Configuration");
00038 
00039     for (int i=0;i<3;i++)
00040         opt_[i] = new CupsdOption(this);
00041 
00042     browseallow_ = new CupsListBox(opt_[0]);
00043     browsedeny_ = new CupsListBox(opt_[1]);
00044     browseorder_ = new QComboBox(opt_[2]);
00045     browseorder_->insertItem(i18n("Allow, Deny"));
00046     browseorder_->insertItem(i18n("Deny, Allow"));
00047 
00048     QLabel  *l1 = new QLabel(i18n("Browse allow:"), this);
00049     QLabel  *l2 = new QLabel(i18n("Browse deny:"), this);
00050     QLabel  *l3 = new QLabel(i18n("Browse order:"), this);
00051 
00052     QGridLayout *main_ = new QGridLayout(this, 7, 2, 10, 10);
00053     main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00054     main_->addMultiCellWidget(opt_[0], 1, 2, 1, 1);
00055     main_->addMultiCellWidget(opt_[1], 3, 4, 1, 1);
00056     main_->addWidget(opt_[2], 5, 1);
00057     main_->addWidget(l1, 1, 0, Qt::AlignLeft|Qt::AlignTop);
00058     main_->addWidget(l2, 3, 0, Qt::AlignLeft|Qt::AlignTop);
00059     main_->addWidget(l3, 5, 0);
00060     main_->setRowStretch(6, 1);
00061 }
00062 
00063 CupsdBrowsingMasksPage::~CupsdBrowsingMasksPage()
00064 {
00065 }
00066 
00067 bool CupsdBrowsingMasksPage::loadConfig(CupsdConf *conf, QString&)
00068 {
00069     conf_ = conf;
00070     QStringList::Iterator   it;
00071     if (conf->browseallow_.count() > 0)
00072     {
00073         opt_[0]->setDefault(false);
00074         for (it=conf->browseallow_.begin();it!=conf->browseallow_.end();++it)
00075             browseallow_->insertItem(*it);
00076     }
00077     if (conf->browsedeny_.count() > 0)
00078     {
00079         opt_[1]->setDefault(false);
00080         for (it=conf->browsedeny_.begin();it!=conf->browsedeny_.end();++it)
00081             browsedeny_->insertItem(*it);
00082     }
00083     if (conf->browseorder_ != -1)
00084     {
00085         opt_[2]->setDefault(false);
00086         browseorder_->setCurrentItem(conf->browseorder_);
00087     }
00088     return true;
00089 }
00090 
00091 bool CupsdBrowsingMasksPage::saveConfig(CupsdConf *conf, QString&)
00092 {
00093     if (!opt_[0]->isDefault() && browseallow_->count() > 0)
00094     {
00095         conf->browseallow_.clear();
00096         for (int i=0;i<browseallow_->count();i++)
00097             conf->browseallow_.append(browseallow_->text(i));
00098     }
00099     if (!opt_[1]->isDefault() && browsedeny_->count() > 0)
00100     {
00101         conf->browsedeny_.clear();
00102         for (int i=0;i<browsedeny_->count();i++)
00103             conf->browsedeny_.append(browsedeny_->text(i));
00104     }
00105     if (!opt_[2]->isDefault()) conf->browseorder_ = browseorder_->currentItem();
00106     return true;
00107 }
00108 
00109 void CupsdBrowsingMasksPage::setDefaults()
00110 {
00111     browseorder_->setCurrentItem(ORDER_DENY_ALLOW);
00112 }
00113 
00114 void CupsdBrowsingMasksPage::setInfos(CupsdConf *conf)
00115 {
00116         QWhatsThis::add(browseorder_, conf->comments_.toolTip(BROWSEORDER_COMM));
00117         QWhatsThis::add(browseallow_, conf->comments_.toolTip(BROWSEALLOWDENY_COMM));
00118         QWhatsThis::add(browsedeny_, conf->comments_.toolTip(BROWSEALLOWDENY_COMM));
00119 }
 
This file is part of the documentation for kdeprint Library Version 3.2.0.