printerfilter.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "printerfilter.h"
00021 #include "kmprinter.h"
00022 #include "kmfactory.h"
00023 
00024 #include <kconfig.h>
00025 #include <kglobal.h>
00026 #include <kdebug.h>
00027 
00028 PrinterFilter::PrinterFilter(QObject *parent, const char *name)
00029 : QObject(parent, name)
00030 {
00031     m_locationRe.setWildcard(true);
00032     update();
00033 }
00034 
00035 PrinterFilter::~PrinterFilter()
00036 {
00037 }
00038 
00039 void PrinterFilter::update()
00040 {
00041     KConfig *conf = KMFactory::self()->printConfig();
00042     conf->setGroup("Filter");
00043     m_locationRe.setPattern(conf->readEntry("LocationRe"));
00044     m_printers = conf->readListEntry("Printers");
00045     
00046     
00047     conf = KGlobal::config();
00048     conf->setGroup("KPrinter Settings");
00049     m_enabled = conf->readBoolEntry("FilterEnabled", false);
00050 }
00051 
00052 void PrinterFilter::setEnabled(bool on)
00053 {
00054     m_enabled = on;
00055     KConfig *conf = KGlobal::config();
00056     conf->setGroup("KPrinter Settings");
00057     conf->writeEntry("FilterEnabled", m_enabled);
00058 }
00059 
00060 bool PrinterFilter::filter(KMPrinter *prt)
00061 {
00062     if (m_enabled)
00063     {
00064         if ((!m_locationRe.isEmpty() && m_locationRe.exactMatch(prt->location())) ||
00065             m_printers.find(prt->printerName()) != m_printers.end())
00066             return true;
00067         else
00068             return false;
00069     }
00070     return true;
00071 }
 
This file is part of the documentation for kdeprint Library Version 3.2.0.