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

« back to all changes in this revision

Viewing changes to libs/kephal/service/xml/configurations_xml.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
 *   Copyright 2008 Aike J Sommer <dev@aikesommer.name>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU General Public License as
 
6
 *   published by the Free Software Foundation; either version 2,
 
7
 *   or (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
 
 
21
#include "configurations_xml.h"
 
22
 
 
23
#include <QDebug>
 
24
#include "xmlnodehandler.h"
 
25
 
 
26
 
 
27
namespace Kephal {
 
28
 
 
29
    class ScreenXMLFactory : public XMLFactory {
 
30
        protected:
 
31
            virtual XMLType * newInstance() { return new ScreenXML(); }
 
32
            virtual void schema() {
 
33
                INT_ATTRIBUTE("id", ScreenXML, id, setId);
 
34
                BOOL_ELEMENT("privacy", ScreenXML, privacy, setPrivacy);
 
35
                INT_ELEMENT("right-of", ScreenXML, rightOf, setRightOf);
 
36
                INT_ELEMENT("bottom-of", ScreenXML, bottomOf, setBottomOf);
 
37
            }
 
38
    };
 
39
 
 
40
 
 
41
    class ConfigurationXMLFactory : public XMLFactory {
 
42
        protected:
 
43
            virtual XMLType * newInstance() { return new ConfigurationXML(); }
 
44
            virtual void schema() {
 
45
                STRING_ATTRIBUTE("name", ConfigurationXML, name, setName);
 
46
                INT_ATTRIBUTE("primary", ConfigurationXML, primaryScreen, setPrimaryScreen);
 
47
                BOOL_ATTRIBUTE("modifiable", ConfigurationXML, modifiable, setModifiable);
 
48
                COMPLEX_ELEMENT_LIST("screen", ConfigurationXML, screens, new ScreenXMLFactory(), ScreenXML);
 
49
            }
 
50
    };
 
51
 
 
52
 
 
53
    class OutputXMLFactory : public XMLFactory {
 
54
        protected:
 
55
            virtual XMLType * newInstance() { return new OutputXML(); }
 
56
            virtual void schema() {
 
57
                STRING_ATTRIBUTE("name", OutputXML, name, setName);
 
58
                INT_ATTRIBUTE("screen", OutputXML, screen, setScreen);
 
59
                STRING_ELEMENT("vendor", OutputXML, vendor, setVendor);
 
60
                INT_ELEMENT("product", OutputXML, product, setProduct);
 
61
                UINT_ELEMENT("serial", OutputXML, serial, setSerial);
 
62
                INT_ELEMENT("width", OutputXML, width, setWidth);
 
63
                INT_ELEMENT("height", OutputXML, height, setHeight);
 
64
                INT_ELEMENT("rotation", OutputXML, rotation, setRotation);
 
65
                BOOL_ELEMENT("reflect-x", OutputXML, reflectX, setReflectX);
 
66
                BOOL_ELEMENT("reflect-y", OutputXML, reflectY, setReflectY);
 
67
                DOUBLE_ELEMENT("refresh-rate", OutputXML, rate, setRate);
 
68
            }
 
69
    };
 
70
 
 
71
 
 
72
    class OutputsXMLFactory : public XMLFactory {
 
73
        protected:
 
74
            virtual XMLType * newInstance() { return new OutputsXML(); }
 
75
            virtual void schema() {
 
76
                STRING_ATTRIBUTE("configuration", OutputsXML, configuration, setConfiguration);
 
77
                COMPLEX_ELEMENT_LIST("output", OutputsXML, outputs, new OutputXMLFactory(), OutputXML);
 
78
            }
 
79
    };
 
80
 
 
81
    ScreenXML::ScreenXML(QObject * parent)
 
82
        : XMLType(parent), m_rightOf(-1), m_bottomOf(-1)
 
83
    {
 
84
    }
 
85
 
 
86
    ScreenXML::~ScreenXML()
 
87
    {
 
88
    }
 
89
 
 
90
    OutputXML::OutputXML(QObject * parent)
 
91
        : XMLType(parent), m_screen(-1), m_product(-1), m_serial(0),
 
92
                m_width(-1), m_height(-1), m_rotation(0),
 
93
                m_reflectX(false), m_reflectY(false), m_rate(0)
 
94
    { }
 
95
 
 
96
    OutputXML::~OutputXML()
 
97
    {}
 
98
 
 
99
    ConfigurationXML::ConfigurationXML(QObject * parent)
 
100
        : XMLType(parent), m_modifiable(true), m_primaryScreen(0)
 
101
    { }
 
102
 
 
103
    ConfigurationXML::~ConfigurationXML()
 
104
    {
 
105
    }
 
106
 
 
107
    OutputsXML::OutputsXML(QObject * parent)
 
108
        : XMLType(parent)
 
109
    {
 
110
 
 
111
    }
 
112
    OutputsXML::~OutputsXML()
 
113
    {
 
114
    }
 
115
 
 
116
    QList<ScreenXML *> & ConfigurationXML::screens() { return m_screens; }
 
117
 
 
118
    ConfigurationsXML::ConfigurationsXML(QObject * parent)
 
119
            : XMLType(parent), m_polling(false)
 
120
    {
 
121
    }
 
122
 
 
123
    ConfigurationsXML::~ConfigurationsXML()
 
124
    {
 
125
    }
 
126
 
 
127
    QList<ConfigurationXML *> & ConfigurationsXML::configurations() { return m_configurations; }
 
128
    QList<OutputsXML *> & ConfigurationsXML::outputs() { return m_outputs; }
 
129
 
 
130
    ConfigurationsXMLFactory::ConfigurationsXMLFactory() : XMLRootFactory("configurations") {
 
131
    }
 
132
    ConfigurationsXMLFactory::~ConfigurationsXMLFactory()
 
133
    {
 
134
    }
 
135
 
 
136
    XMLType * ConfigurationsXMLFactory::newInstance() {
 
137
        return new ConfigurationsXML();
 
138
    }
 
139
 
 
140
    void ConfigurationsXMLFactory::schema() {
 
141
        BOOL_ELEMENT("polling", ConfigurationsXML, polling, setPolling);
 
142
        COMPLEX_ELEMENT_LIST("configuration", ConfigurationsXML, configurations, new ConfigurationXMLFactory(), ConfigurationXML);
 
143
        COMPLEX_ELEMENT_LIST("outputs", ConfigurationsXML, outputs, new OutputsXMLFactory(), OutputsXML);
 
144
    }
 
145
 
 
146
}
 
147