cupslocationgeneral.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cupslocationgeneral.h"
00021
00022 #include <qlineedit.h>
00023 #include <qcombobox.h>
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <klocale.h>
00027 #include <kiconloader.h>
00028 #include <qwhatsthis.h>
00029
00030 #include "cupsdconf.h"
00031
00032 CupsLocationGeneral::CupsLocationGeneral(CupsdConf *conf, QWidget *parent, const char *name)
00033 : QWidget(parent, name)
00034 {
00035 conf_ = conf;
00036
00037 resource_ = new QComboBox(this);
00038
00039 for (conf_->resources_.first();conf_->resources_.current();conf_->resources_.next())
00040 resource_->insertItem(SmallIcon(CupsResource::typeToIconName(conf_->resources_.current()->type_)), conf_->resources_.current()->text_);
00041
00042 authtype_ = new QComboBox(this);
00043 authtype_->insertItem(i18n("None"));
00044 authtype_->insertItem(i18n("Basic"));
00045 authtype_->insertItem(i18n("Digest"));
00046 authtype_->setCurrentItem(0);
00047 connect(authtype_, SIGNAL(highlighted(int)), SLOT(authTypeChanged(int)));
00048 authclass_ = new QComboBox(this);
00049 authclass_->insertItem(i18n("Anonymous"));
00050 authclass_->insertItem(i18n("User"));
00051 authclass_->insertItem(i18n("System"));
00052 authclass_->insertItem(i18n("Group"));
00053 authclass_->setCurrentItem(1);
00054 authclass_->setEnabled(false);
00055 connect(authclass_, SIGNAL(highlighted(int)), SLOT(authClassChanged(int)));
00056 authgroupname_ = new QLineEdit(this);
00057 authgroupname_->setEnabled(false);
00058 encryption_ = new QComboBox(this);
00059 encryption_->insertItem(i18n("Always"));
00060 encryption_->insertItem(i18n("Never"));
00061 encryption_->insertItem(i18n("Required"));
00062 encryption_->insertItem(i18n("If Requested"));
00063 encryption_->setCurrentItem(3);
00064
00065 QLabel *l1 = new QLabel(i18n("Resource:"), this);
00066 QLabel *l2 = new QLabel(i18n("Authorization type:"), this);
00067 QLabel *l3 = new QLabel(i18n("Authorization class:"), this);
00068 QLabel *l4 = new QLabel(i18n("Authorization group:"), this);
00069 QLabel *l5 = new QLabel(i18n("Encryption type:"), this);
00070
00071 QGridLayout *main_ = new QGridLayout(this, 7, 2, 10, 10);
00072 main_->addWidget(l1, 0, 0);
00073 main_->addWidget(l2, 2, 0);
00074 main_->addWidget(l3, 3, 0);
00075 main_->addWidget(l4, 4, 0);
00076 main_->addWidget(l5, 5, 0);
00077 main_->addWidget(resource_, 0, 1);
00078 main_->addWidget(authtype_, 2, 1);
00079 main_->addWidget(authclass_, 3, 1);
00080 main_->addWidget(authgroupname_, 4, 1);
00081 main_->addWidget(encryption_, 5, 1);
00082 main_->addRowSpacing(1, 20);
00083 main_->setRowStretch(6, 1);
00084 }
00085
00086 CupsLocationGeneral::~CupsLocationGeneral()
00087 {
00088 }
00089
00090 void CupsLocationGeneral::loadLocation(CupsLocation *loc)
00091 {
00092
00093
00094 resource_->setEnabled(false);
00095 if (!loc->resource_) resource_->setCurrentItem(-1);
00096 else
00097 {
00098 int index = conf_->resources_.findRef(loc->resource_);
00099 resource_->setCurrentItem(index);
00100 }
00101 if (loc->authtype_ != -1)
00102 {
00103 authtype_->setCurrentItem(loc->authtype_);
00104 }
00105 if (loc->authclass_ != -1)
00106 {
00107 authclass_->setCurrentItem(loc->authclass_);
00108 }
00109 if (loc->encryption_ != -1)
00110 {
00111 encryption_->setCurrentItem(loc->encryption_);
00112 }
00113 authgroupname_->setText(loc->authgroupname_);
00114 }
00115
00116 void CupsLocationGeneral::saveLocation(CupsLocation *loc)
00117 {
00118 if (resource_->currentItem() != -1)
00119 {
00120 loc->resource_ = conf_->resources_.at(resource_->currentItem());
00121 loc->resourcename_ = loc->resource_->path_;
00122 }
00123 loc->authtype_ = authtype_->currentItem();
00124 loc->authclass_ = authclass_->currentItem();
00125 loc->authgroupname_ = authgroupname_->text();
00126 loc->encryption_ = encryption_->currentItem();
00127 }
00128
00129 void CupsLocationGeneral::authTypeChanged(int index)
00130 {
00131 if (index != -1)
00132 {
00133 authclass_->setEnabled(index != AUTHTYPE_NONE);
00134 authgroupname_->setEnabled((index != AUTHTYPE_NONE) && (authclass_->currentItem() == AUTHCLASS_GROUP));
00135 }
00136 }
00137
00138 void CupsLocationGeneral::authClassChanged(int index)
00139 {
00140 if (index != -1)
00141 {
00142 authgroupname_->setEnabled(index == AUTHCLASS_GROUP);
00143 }
00144 }
00145
00146 bool CupsLocationGeneral::isValid()
00147 {
00148
00149 return true;
00150 }
00151
00152 void CupsLocationGeneral::setInfos(CupsdConf *conf)
00153 {
00154 QWhatsThis::add(authtype_, conf->comments_.toolTip(LOCAUTHTYPE_COMM));
00155 QWhatsThis::add(authclass_, conf->comments_.toolTip(LOCAUTHCLASS_COMM));
00156 QWhatsThis::add(authgroupname_, conf->comments_.toolTip(LOCAUTHGROUPNAME_COMM));
00157 QWhatsThis::add(encryption_, conf->comments_.toolTip(LOCENCRYPTION_COMM));
00158 }
00159 #include "cupslocationgeneral.moc"
This file is part of the documentation for kdeprint Library Version 3.3.90.