AntiMicroX
xmlconfigreader.h
Go to the documentation of this file.
1 /* antimicrox Gamepad to KB+M event mapper
2  * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
3  * Copyright (C) 2020 Jagoda Górska <juliagoda.pl@protonmail>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program 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
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef XMLCONFIGREADER_H
20 #define XMLCONFIGREADER_H
21 
22 #include <QObject>
23 #include <QStringList>
24 
25 class InputDevice;
26 class QXmlStreamReader;
27 class InputDeviceXml;
28 class QFile;
29 
33 class XMLConfigReader : public QObject
34 {
35  Q_OBJECT
36 
37  public:
38  explicit XMLConfigReader(QObject *parent = nullptr);
40  void setJoystick(InputDevice *joystick);
41  void setFileName(QString filename);
42  const QString getErrorString();
43  bool hasError();
44  bool read();
45 
46  const QXmlStreamReader *getXml();
47  QString const &getFileName();
48  const QFile *getConfigFile();
49  const InputDevice *getJoystick();
50  QStringList const &getDeviceTypes();
51 
52  protected:
53  void initDeviceTypes();
54 
55  public slots:
56  void configJoystick(InputDevice *joystick);
57 
58  private:
59  QXmlStreamReader *xml;
60  QString fileName;
61  QFile *configFile;
63  QStringList deviceTypes;
64 };
65 
66 #endif // XMLCONFIGREADER_H
XMLConfigReader::m_joystick
InputDevice * m_joystick
Definition: xmlconfigreader.h:62
XMLConfigReader::~XMLConfigReader
~XMLConfigReader()
Definition: xmlconfigreader.cpp:50
XMLConfigReader::fileName
QString fileName
Definition: xmlconfigreader.h:60
XMLConfigReader::getErrorString
const QString getErrorString()
Definition: xmlconfigreader.cpp:177
xmlconfigreader.h
gamecontroller.h
XMLConfigReader::setJoystick
void setJoystick(InputDevice *joystick)
Definition: xmlconfigreader.cpp:68
xmlconfigmigration.h
globalvariables.h
XMLConfigReader::getJoystick
const InputDevice * getJoystick()
Definition: xmlconfigreader.cpp:202
InputDevice
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition: inputdevice.h:50
XMLConfigReader::getConfigFile
const QFile * getConfigFile()
Definition: xmlconfigreader.cpp:200
XMLConfigReader::read
bool read()
Definition: xmlconfigreader.cpp:97
xmlconfigwriter.h
XMLConfigReader::getDeviceTypes
const QStringList & getDeviceTypes()
Definition: xmlconfigreader.cpp:204
XMLConfigReader::getFileName
const QString & getFileName()
Definition: xmlconfigreader.cpp:198
inputdevicexml.h
XMLConfigReader::configJoystick
void configJoystick(InputDevice *joystick)
Read input device config from the current XML file into the InputDevice object.
Definition: xmlconfigreader.cpp:91
InputDeviceXml
Generic InputDevice XML serialization/deserialization helper class Reads data from the supplied Input...
Definition: inputdevicexml.h:37
XMLConfigReader::deviceTypes
QStringList deviceTypes
Definition: xmlconfigreader.h:63
XMLConfigMigration
Definition: xmlconfigmigration.h:26
joystick.h
XMLConfigReader::setFileName
void setFileName(QString filename)
Sets the filename of the to be read XML file.
Definition: xmlconfigreader.cpp:73
XMLConfigReader::initDeviceTypes
void initDeviceTypes()
Definition: xmlconfigreader.cpp:189
XMLConfigReader::xml
QXmlStreamReader * xml
Definition: xmlconfigreader.h:59
InputDeviceXml::readConfig
void readConfig(QXmlStreamReader *xml)
Deserializes the given XML stream into an InputDevice object.
Definition: inputdevicexml.cpp:47
XMLConfigMigration::migrate
QString migrate()
Definition: xmlconfigmigration.cpp:56
XMLConfigReader
Main XML config reader class.
Definition: xmlconfigreader.h:33
XMLConfigMigration::requiresMigration
bool requiresMigration()
Definition: xmlconfigmigration.cpp:44
inputdevice.h
XMLConfigReader::XMLConfigReader
XMLConfigReader(QObject *parent=nullptr)
Main XML config writer class.
Definition: xmlconfigreader.cpp:41
common.h
GlobalVariables::GameController::xmlName
static const QString xmlName
Definition: globalvariables.h:155
WARN
#define WARN()
Definition: logger.h:44
XMLConfigReader::configFile
QFile * configFile
Definition: xmlconfigreader.h:61
GlobalVariables::Joystick::xmlName
static const QString xmlName
Definition: globalvariables.h:201
XMLConfigReader::hasError
bool hasError()
Definition: xmlconfigreader.cpp:187
XMLConfigReader::getXml
const QXmlStreamReader * getXml()
Definition: xmlconfigreader.cpp:196