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

« back to all changes in this revision

Viewing changes to kdetv/libkdetv/miscmanager.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
 *
 
3
 * Copyright (C) 2002 George Staikos <staikos@kde.org>
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Library General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Library General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Library General Public License
 
16
 * along with this library; see the file COPYING.LIB.  If not, write to
 
17
 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
 
 
22
#include "miscmanager.h"
 
23
 
 
24
#include "kdetvmiscplugin.h"
 
25
#include "pluginfactory.h"
 
26
#include <kdebug.h>
 
27
 
 
28
 
 
29
MiscManager::MiscManager(PluginFactory *pf, QWidget* view)
 
30
    : _view(view),
 
31
      _pf(pf)
 
32
{
 
33
    scanPlugins();
 
34
}
 
35
 
 
36
MiscManager::~MiscManager()
 
37
{
 
38
    while (KdetvMiscPlugin *p = _plugs.first()) {
 
39
        p->destroy();
 
40
        _plugs.remove(p);
 
41
    }
 
42
}
 
43
 
 
44
void MiscManager::scanPlugins()
 
45
{
 
46
    if (!_view) {
 
47
        //        kdDebug() << "MiscManager: Info: No screenwidget set. Cannot scan Misc plugins." << endl;
 
48
        return;
 
49
    }
 
50
 
 
51
    QPtrList<PluginDesc>& miscPlugins(_pf->miscPlugins());
 
52
    
 
53
    for (PluginDesc *plug = miscPlugins.first(); plug;
 
54
         plug = miscPlugins.next()) {
 
55
        bool skip = false;
 
56
        for (KdetvMiscPlugin *p = _plugs.first(); p; p = _plugs.next()) {
 
57
            if (p->pluginDescription() == plug) {
 
58
                if (!plug->enabled) {
 
59
                    _plugs.remove(p);
 
60
                    p->destroy();
 
61
                }
 
62
                skip = true;
 
63
                break;
 
64
            }
 
65
        }
 
66
        
 
67
        if (skip)
 
68
            continue;
 
69
 
 
70
        kdDebug() << "MiscManager: Found a plugin: " << plug->name << endl;
 
71
        if (plug->enabled) {
 
72
            KdetvMiscPlugin *p = _pf->getMiscPlugin(plug, _view);
 
73
            if (p)
 
74
                _plugs.append(p);
 
75
        } else
 
76
            kdDebug() << "MiscManager: The plugin is disabled" << endl;
 
77
    }
 
78
}
 
79
 
 
80
bool MiscManager::filterNumberKey(int key)
 
81
{
 
82
    for (KdetvMiscPlugin *p = _plugs.first(); p; p = _plugs.next())
 
83
        if (p->filterNumberKey(key))
 
84
            return true;
 
85
    return false;
 
86
}
 
87
 
 
88
void MiscManager::setScreen(QWidget* screen)
 
89
{
 
90
    _view = screen;
 
91
    scanPlugins();
 
92
}
 
93
 
 
94
#include "miscmanager.moc"
 
95
 
 
96
// vim: sw=4 ts=4