~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/libkdetv/filtermanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                           filtermanager.cpp
 
3
                           -----------------
 
4
    begin                : Sun Jun 13 2004
 
5
    copyright            : (C) 2004 by Dirk Ziegelmeier
 
6
    email                : dziegel@gmx.de
 
7
 ***************************************************************************/
 
8
 
 
9
/*
 
10
 * This library is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU Library General Public
 
12
 * License as published by the Free Software Foundation; either
 
13
 * version 2 of the License, or (at your option) any later version.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
 * Library General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Library General Public License
 
21
 * along with this library; see the file COPYING.LIB.  If not, write to
 
22
 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 
23
 * Boston, MA 02110-1301, USA.
 
24
 */
 
25
 
 
26
#include <kdebug.h>
 
27
 
 
28
#include "filtermanager.h"
 
29
#include "kdetvfilterplugin.h"
 
30
#include "pluginfactory.h"
 
31
#include "kdetvvideo/kdetvimagefilter.h"
 
32
 
 
33
FilterManager::FilterManager(PluginFactory* pf)
 
34
    : QObject(),
 
35
      _pf(pf)
 
36
{
 
37
    _chain = new KdetvImageFilterChain();
 
38
    _plugs.setAutoDelete(false);
 
39
    scanPlugins();
 
40
}
 
41
 
 
42
FilterManager::~FilterManager()
 
43
{
 
44
    clear();
 
45
    delete _chain;
 
46
}
 
47
 
 
48
void FilterManager::clear()
 
49
{
 
50
    _chain->clear();
 
51
 
 
52
    while (KdetvFilterPlugin *p = _plugs.first()) {
 
53
        p->destroy();
 
54
        _plugs.remove(p);
 
55
    }
 
56
}
 
57
 
 
58
void FilterManager::scanPlugins()
 
59
{
 
60
    clear();
 
61
 
 
62
        QPtrList<PluginDesc>& filterPlugins(_pf->filterPlugins());
 
63
        for (PluginDesc* plug = filterPlugins.first();
 
64
                        plug;
 
65
                        plug = filterPlugins.next()) {
 
66
                if (plug->enabled) {
 
67
            KdetvFilterPlugin* p = _pf->getFilterPlugin(plug);
 
68
            _plugs.append(p);
 
69
            _chain->append(p->getFilter());
 
70
            break; // There must be only one enabled filter plugin
 
71
                }
 
72
        }
 
73
 
 
74
        QPtrList<PluginDesc>& postProcessPlugins(_pf->postProcessPlugins());
 
75
        for (PluginDesc* plug = postProcessPlugins.first();
 
76
                        plug;
 
77
                        plug = postProcessPlugins.next()) {
 
78
                if (plug->enabled) {
 
79
            KdetvFilterPlugin* p = _pf->getPostProcessPlugin(plug);
 
80
            _plugs.append(p);
 
81
            _chain->append(p->getFilter());
 
82
                }
 
83
        }
 
84
}
 
85
 
 
86
#include "filtermanager.moc"
 
87
 
 
88
// vim: sw=4 ts=4 noet