~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kinfocenter/Modules/info/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * main.cpp
 
3
 *
 
4
 * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
 
5
 *
 
6
 * Requires the Qt widget libraries, available at no cost at
 
7
 * http://www.troll.no/
 
8
 *
 
9
 *  This program is free software; you can redistribute it and/or modify
 
10
 *  it under the terms of the GNU General Public License as published by
 
11
 *  the Free Software Foundation; either version 2 of the License, or
 
12
 *  (at your option) any later version.
 
13
 *
 
14
 *  This program is distributed in the hope that it will be useful,
 
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 *  GNU General Public License for more details.
 
18
 *
 
19
 *  You should have received a copy of the GNU General Public License
 
20
 *  along with this program; if not, write to the Free Software
 
21
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
22
 */
 
23
 
 
24
#include <kcomponentdata.h>
 
25
#include <KPluginFactory>
 
26
#include <KPluginLoader>
 
27
 
 
28
/* we have to include the info.cpp-file, to get the DEFINES about possible properties.
 
29
   example: we need the "define INFO_DMA_AVAILABLE" */
 
30
#include "info.h"
 
31
 
 
32
#include "os_current.h"
 
33
 
 
34
class KInfoModulesFactory : public KPluginFactory
 
35
{
 
36
    public:
 
37
        KInfoModulesFactory(const char *componentName);
 
38
        static KComponentData componentData();
 
39
 
 
40
    private:
 
41
        static KPluginFactory *s_instance;
 
42
};
 
43
KPluginFactory *KInfoModulesFactory::s_instance = 0;
 
44
 
 
45
#define CREATE_FACTORY(type, name) \
 
46
class K##type##InfoWidget : public KInfoListWidget \
 
47
{ \
 
48
    public: \
 
49
        K##type##InfoWidget(QWidget *parent, const QVariantList &) \
 
50
            : KInfoListWidget(KInfoModulesFactory::componentData(), \
 
51
                    name, parent, GetInfo_##type) \
 
52
        { \
 
53
        } \
 
54
}; \
 
55
 
 
56
#ifdef INFO_IRQ_AVAILABLE
 
57
CREATE_FACTORY(IRQ, i18n("Interrupt"))
 
58
#endif
 
59
#ifdef INFO_IOPORTS_AVAILABLE
 
60
CREATE_FACTORY(IO_Ports, i18n("I/O-Port"))
 
61
#endif
 
62
#ifdef INFO_SCSI_AVAILABLE
 
63
CREATE_FACTORY(SCSI, i18n("SCSI"))
 
64
#endif
 
65
#ifdef INFO_DMA_AVAILABLE
 
66
CREATE_FACTORY(DMA, i18n("DMA-Channel"))
 
67
#endif
 
68
#ifdef INFO_XSERVER_AVAILABLE
 
69
CREATE_FACTORY(XServer_and_Video, i18n("X-Server"))
 
70
#endif
 
71
 
 
72
KInfoModulesFactory::KInfoModulesFactory(const char *componentName)
 
73
    : KPluginFactory(componentName)
 
74
{
 
75
    s_instance = this;
 
76
 
 
77
#ifdef INFO_IRQ_AVAILABLE
 
78
    registerPlugin<KIRQInfoWidget>("irq");
 
79
#endif
 
80
#ifdef INFO_IOPORTS_AVAILABLE
 
81
    registerPlugin<KIO_PortsInfoWidget>("ioports");
 
82
#endif
 
83
#ifdef INFO_SCSI_AVAILABLE
 
84
    registerPlugin<KSCSIInfoWidget>("scsi");
 
85
#endif
 
86
#ifdef INFO_DMA_AVAILABLE
 
87
    registerPlugin<KDMAInfoWidget>("dma");
 
88
#endif
 
89
#ifdef INFO_XSERVER_AVAILABLE
 
90
    registerPlugin<KXServer_and_VideoInfoWidget>("xserver");
 
91
#endif
 
92
}
 
93
 
 
94
KComponentData KInfoModulesFactory::componentData()
 
95
{
 
96
    Q_ASSERT(s_instance);
 
97
    return s_instance->componentData();
 
98
}
 
99
 
 
100
K_EXPORT_PLUGIN(KInfoModulesFactory("kcminfo"))