kmpropusers.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "kmpropusers.h"
00021 #include "kmprinter.h"
00022 #include "kmwizard.h"
00023 
00024 #include <qtextview.h>
00025 #include <qlayout.h>
00026 #include <klocale.h>
00027 
00028 KMPropUsers::KMPropUsers(QWidget *parent, const char *name)
00029 : KMPropWidget(parent,name)
00030 {
00031     m_text = new QTextView(this);
00032     m_text->setPaper(colorGroup().background());
00033     m_text->setFrameStyle(QFrame::NoFrame);
00034 
00035     QVBoxLayout *l0 = new QVBoxLayout(this, 10, 0);
00036     l0->addWidget(m_text, 1);
00037 
00038     m_title = i18n("Users");
00039     m_header = i18n("Users Access Settings");
00040     m_pixmap = "kdeprint_printer_users";
00041 }
00042 
00043 KMPropUsers::~KMPropUsers()
00044 {
00045 }
00046 
00047 void KMPropUsers::setPrinter(KMPrinter *p)
00048 {
00049     if (p && p->isPrinter())
00050     {
00051         QString txt("<p>%1:<ul>%1</ul></p>");
00052         QStringList users;
00053         if (!p->option("requesting-user-name-denied").isEmpty())
00054         {
00055             txt = txt.arg(i18n("Denied users"));
00056             users = QStringList::split(",", p->option("requesting-user-name-denied"), false);
00057             if (users.count() == 1 && users[0] == "none")
00058                 users.clear();
00059         }
00060         else if (!p->option("requesting-user-name-allowed").isEmpty())
00061         {
00062             txt = txt.arg(i18n("Allowed users"));
00063             users = QStringList::split(",", p->option("requesting-user-name-allowed"), false);
00064             if (users.count() == 1 && users[0] == "all")
00065                 users.clear();
00066         }
00067         if (users.count() > 0)
00068         {
00069             QString s;
00070             for (QStringList::ConstIterator it=users.begin(); it!=users.end(); ++it)
00071                 s.append("<li>").append(*it).append("</li>");
00072             txt = txt.arg(s);
00073             m_text->setText(txt);
00074         }
00075         else
00076             m_text->setText(i18n("All users allowed"));
00077         emit enable(true);
00078         emit enableChange(p->isLocal());
00079     }
00080     else
00081     {
00082         emit enable(false);
00083         m_text->setText("");
00084     }
00085 }
00086 
00087 void KMPropUsers::configureWizard(KMWizard *w)
00088 {
00089     w->configure(KMWizard::Custom+4,KMWizard::Custom+4,true);
00090 }
 
This file is part of the documentation for kdeprint Library Version 3.2.0.