kdeprint Library API Documentation

cupslocationgeneral.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 "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 //int h = resource_->sizeHint().height(); 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 // resource_->setText(loc->resource_); 00093 // can't change resource name 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 // return !resource_->text().isEmpty(); 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"
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:32:32 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003