From 4c0328418f552cccfb043655d531cf52613d1e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Sun, 14 Apr 2024 17:38:21 +0200 Subject: [PATCH] chore: ensure proper string format to use with conversion --- src/gamecontroller/gamecontrollerset.cpp | 16 +++--- src/inputdevicecalibration.cpp | 10 ++-- src/joycontrolstick.cpp | 25 ++++----- src/joysensor.cpp | 14 ++--- src/xml/inputdevicexml.cpp | 50 +++++++++--------- src/xml/joyaxisxml.cpp | 14 ++--- src/xml/joybuttonslotxml.cpp | 37 ++++++------- src/xml/joybuttonxml.cpp | 66 ++++++++++++------------ src/xml/joydpadxml.cpp | 10 ++-- src/xml/setjoystickxml.cpp | 18 +++---- src/xmlconfigreader.cpp | 2 +- 11 files changed, 132 insertions(+), 130 deletions(-) diff --git a/src/gamecontroller/gamecontrollerset.cpp b/src/gamecontroller/gamecontrollerset.cpp index 1aaa12c8a..346c23b95 100644 --- a/src/gamecontroller/gamecontrollerset.cpp +++ b/src/gamecontroller/gamecontrollerset.cpp @@ -122,28 +122,28 @@ template void readConf(T *x, QXmlStreamReader *xml) void GameControllerSet::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == "set")) + if (xml->isStartElement() && (xml->name().toString() == "set")) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "set")) + while (!xml->atEnd() && (!xml->isEndElement() && xml->name().toString() != "set")) { - if ((xml->name() == "button") && xml->isStartElement()) + if ((xml->name().toString() == "button") && xml->isStartElement()) { getElemFromXml("button", xml); - } else if ((xml->name() == "trigger") && xml->isStartElement()) + } else if ((xml->name().toString() == "trigger") && xml->isStartElement()) { getElemFromXml("trigger", xml); - } else if ((xml->name() == "stick") && xml->isStartElement()) + } else if ((xml->name().toString() == "stick") && xml->isStartElement()) { getElemFromXml("stick", xml); - } else if ((xml->name() == "sensor") && xml->isStartElement()) + } else if ((xml->name().toString() == "sensor") && xml->isStartElement()) { getElemFromXml("sensor", xml); - } else if ((xml->name() == "dpad") && xml->isStartElement()) + } else if ((xml->name().toString() == "dpad") && xml->isStartElement()) { getElemFromXml("dpad", xml); - } else if ((xml->name() == "name") && xml->isStartElement()) + } else if ((xml->name().toString() == "name") && xml->isStartElement()) { QString temptext = xml->readElementText(); diff --git a/src/inputdevicecalibration.cpp b/src/inputdevicecalibration.cpp index a0ab38939..2f4985f0b 100644 --- a/src/inputdevicecalibration.cpp +++ b/src/inputdevicecalibration.cpp @@ -135,17 +135,17 @@ void InputDeviceCalibration::applyCalibrations() const */ void InputDeviceCalibration::readConfig(QXmlStreamReader *xml) { - while (xml->isStartElement() && (xml->name() == "calibration")) + while (xml->isStartElement() && (xml->name().toString() == "calibration")) { QString id = xml->attributes().value("device").toString(); if (id.isEmpty()) id = m_device->getUniqueIDString(); xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "calibration"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "calibration"))) { CalibrationData calibration; - if ((xml->name() == "stick")) + if ((xml->name().toString() == "stick")) { calibration.type = CALIBRATION_DATA_STICK; calibration.stick.index = xml->attributes().value("index").toString().toInt(); @@ -154,14 +154,14 @@ void InputDeviceCalibration::readConfig(QXmlStreamReader *xml) calibration.stick.offsetY = xml->attributes().value("offsety").toString().toDouble(); calibration.stick.gainY = xml->attributes().value("gainy").toString().toDouble(); setCalibration(id, calibration); - } else if ((xml->name() == "accelerometer")) + } else if ((xml->name().toString() == "accelerometer")) { calibration.type = CALIBRATION_DATA_ACCELEROMETER; calibration.accelerometer.orientationX = xml->attributes().value("orientationx").toString().toDouble(); calibration.accelerometer.orientationY = xml->attributes().value("orientationy").toString().toDouble(); calibration.accelerometer.orientationZ = xml->attributes().value("orientationz").toString().toDouble(); setCalibration(id, calibration); - } else if ((xml->name() == "gyroscope")) + } else if ((xml->name().toString() == "gyroscope")) { calibration.type = CALIBRATION_DATA_GYROSCOPE; calibration.gyroscope.offsetX = xml->attributes().value("offsetx").toString().toDouble(); diff --git a/src/joycontrolstick.cpp b/src/joycontrolstick.cpp index a5ae421c4..cb941131e 100644 --- a/src/joycontrolstick.cpp +++ b/src/joycontrolstick.cpp @@ -989,38 +989,38 @@ void JoyControlStick::setDiagonalRange(int value) */ void JoyControlStick::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == "stick")) + if (xml->isStartElement() && (xml->name().toString() == "stick")) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "stick"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "stick"))) { - if ((xml->name() == "deadZone") && xml->isStartElement()) + if ((xml->name().toString() == "deadZone") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); this->setDeadZone(tempchoice); - } else if ((xml->name() == "maxZone") && xml->isStartElement()) + } else if ((xml->name().toString() == "maxZone") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); this->setMaxZone(tempchoice); - } else if ((xml->name() == "modifierZone") && xml->isStartElement()) + } else if ((xml->name().toString() == "modifierZone") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); setModifierZone(tempchoice); - } else if ((xml->name() == "modifierZoneInverted") && xml->isStartElement()) + } else if ((xml->name().toString() == "modifierZoneInverted") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); setModifierZoneInverted(tempchoice); - } else if ((xml->name() == "diagonalRange") && xml->isStartElement()) + } else if ((xml->name().toString() == "diagonalRange") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); this->setDiagonalRange(tempchoice); - } else if ((xml->name() == "mode") && xml->isStartElement()) + } else if ((xml->name().toString() == "mode") && xml->isStartElement()) { QString temptext = xml->readElementText(); @@ -1034,13 +1034,13 @@ void JoyControlStick::readConfig(QXmlStreamReader *xml) { this->setJoyMode(FourWayDiagonal); } - } else if ((xml->name() == "squareStick") && xml->isStartElement()) + } else if ((xml->name().toString() == "squareStick") && xml->isStartElement()) { int tempchoice = xml->readElementText().toInt(); if ((tempchoice > 0) && (tempchoice <= 100)) this->setCircleAdjust(tempchoice / 100.0); - } else if ((xml->name() == GlobalVariables::JoyControlStickButton::xmlName) && xml->isStartElement()) + } else if ((xml->name().toString() == GlobalVariables::JoyControlStickButton::xmlName) && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); JoyControlStickButton *button = buttons.value(static_cast(index)); @@ -1053,11 +1053,12 @@ void JoyControlStick::readConfig(QXmlStreamReader *xml) if (!joyButtonXml.isNull()) delete joyButtonXml; - } else if ((xml->name() == GlobalVariables::JoyControlStickModifierButton::xmlName) && xml->isStartElement()) + } else if ((xml->name().toString() == GlobalVariables::JoyControlStickModifierButton::xmlName) && + xml->isStartElement()) { JoyButtonXml *joyButtonXml = new JoyButtonXml(modifierButton); joyButtonXml->readConfig(xml); - } else if ((xml->name() == "stickDelay") && xml->isStartElement()) + } else if ((xml->name().toString() == "stickDelay") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); diff --git a/src/joysensor.cpp b/src/joysensor.cpp index 7141d7245..b656a41a1 100644 --- a/src/joysensor.cpp +++ b/src/joysensor.cpp @@ -681,28 +681,28 @@ void JoySensor::establishPropertyUpdatedConnection() */ void JoySensor::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == "sensor")) + if (xml->isStartElement() && (xml->name().toString() == "sensor")) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "sensor"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "sensor"))) { - if ((xml->name() == "deadZone") && xml->isStartElement()) + if ((xml->name().toString() == "deadZone") && xml->isStartElement()) { QString temptext = xml->readElementText(); float tempchoice = temptext.toFloat(); setDeadZone(tempchoice); - } else if ((xml->name() == "maxZone") && xml->isStartElement()) + } else if ((xml->name().toString() == "maxZone") && xml->isStartElement()) { QString temptext = xml->readElementText(); float tempchoice = temptext.toFloat(); setMaxZone(tempchoice); - } else if ((xml->name() == "diagonalRange") && xml->isStartElement()) + } else if ((xml->name().toString() == "diagonalRange") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); setDiagonalRange(tempchoice); - } else if ((xml->name() == GlobalVariables::JoySensorButton::xmlName) && xml->isStartElement()) + } else if ((xml->name().toString() == GlobalVariables::JoySensorButton::xmlName) && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); JoySensorButton *button = m_buttons.value(static_cast(index)); @@ -715,7 +715,7 @@ void JoySensor::readConfig(QXmlStreamReader *xml) if (!joyButtonXml.isNull()) delete joyButtonXml; - } else if ((xml->name() == "sensorDelay") && xml->isStartElement()) + } else if ((xml->name().toString() == "sensorDelay") && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); diff --git a/src/xml/inputdevicexml.cpp b/src/xml/inputdevicexml.cpp index f8bb45375..f3e77ef13 100644 --- a/src/xml/inputdevicexml.cpp +++ b/src/xml/inputdevicexml.cpp @@ -60,20 +60,20 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) m_mutex_read_config.unlock(); return; } - if (xml->isStartElement() && (xml->name() == m_inputDevice->getXmlName())) + if (xml->isStartElement() && (xml->name().toString() == m_inputDevice->getXmlName())) { m_inputDevice->transferReset(); xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != m_inputDevice->getXmlName()))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != m_inputDevice->getXmlName()))) { - if ((xml->name() == "sets") && xml->isStartElement()) + if ((xml->name().toString() == "sets") && xml->isStartElement()) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "sets"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "sets"))) { - if ((xml->name() == "set") && xml->isStartElement()) + if ((xml->name().toString() == "set") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); index = index - 1; @@ -88,7 +88,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) xml->readNextStartElement(); } - } else if ((xml->name() == "stickAxisAssociation") && xml->isStartElement()) + } else if ((xml->name().toString() == "stickAxisAssociation") && xml->isStartElement()) { int stickIndex = xml->attributes().value("index").toString().toInt(); int xAxis = xml->attributes().value("xAxis").toString().toInt(); @@ -120,7 +120,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { xml->skipCurrentElement(); } - } else if ((xml->name() == "vdpadButtonAssociations") && xml->isStartElement()) + } else if ((xml->name().toString() == "vdpadButtonAssociations") && xml->isStartElement()) { int vdpadIndex = xml->attributes().value("index").toString().toInt(); @@ -142,9 +142,9 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "vdpadButtonAssociations"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "vdpadButtonAssociations"))) { - if ((xml->name() == "vdpadButtonAssociation") && xml->isStartElement()) + if ((xml->name().toString() == "vdpadButtonAssociation") && xml->isStartElement()) { int vdpadAxisIndex = xml->attributes().value("axis").toString().toInt(); int vdpadButtonIndex = xml->attributes().value("button").toString().toInt(); @@ -222,13 +222,13 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) (*currJoy)->removeVDPad(currVDPad - VDPadLists.begin()); } } - } else if ((xml->name() == "names") && xml->isStartElement()) + } else if ((xml->name().toString() == "names") && xml->isStartElement()) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "names"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "names"))) { - if ((xml->name() == "buttonname") && xml->isStartElement()) + if ((xml->name().toString() == "buttonname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); @@ -238,7 +238,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setButtonName(index, temp); } - } else if ((xml->name() == "axisbuttonname") && xml->isStartElement()) + } else if ((xml->name().toString() == "axisbuttonname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); @@ -250,7 +250,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setAxisButtonName(index, buttonIndex, temp); } - } else if ((xml->name() == "controlstickbuttonname") && xml->isStartElement()) + } else if ((xml->name().toString() == "controlstickbuttonname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); @@ -261,7 +261,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setStickButtonName(index, buttonIndex, temp); } - } else if ((xml->name() == "sensorbuttonname") && xml->isStartElement()) + } else if ((xml->name().toString() == "sensorbuttonname") && xml->isStartElement()) { int type = xml->attributes().value("type").toString().toInt(); int direction = xml->attributes().value("button").toString().toInt(); @@ -269,7 +269,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) if (!temp.isEmpty()) m_inputDevice->setSensorButtonName(static_cast(type), static_cast(direction), temp); - } else if ((xml->name() == "dpadbuttonname") && xml->isStartElement()) + } else if ((xml->name().toString() == "dpadbuttonname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); @@ -280,7 +280,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setDPadButtonName(index, buttonIndex, temp); } - } else if ((xml->name() == "vdpadbuttonname") && xml->isStartElement()) + } else if ((xml->name().toString() == "vdpadbuttonname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); @@ -291,7 +291,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setVDPadButtonName(index, buttonIndex, temp); } - } else if ((xml->name() == "axisname") && xml->isStartElement()) + } else if ((xml->name().toString() == "axisname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); @@ -301,7 +301,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setAxisName(index, temp); } - } else if ((xml->name() == "controlstickname") && xml->isStartElement()) + } else if ((xml->name().toString() == "controlstickname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); @@ -311,13 +311,13 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setStickName(index, temp); } - } else if ((xml->name() == "sensorname") && xml->isStartElement()) + } else if ((xml->name().toString() == "sensorname") && xml->isStartElement()) { int type = xml->attributes().value("type").toString().toInt(); QString temp = xml->readElementText(); if (!temp.isEmpty()) m_inputDevice->setSensorName(static_cast(type), temp); - } else if ((xml->name() == "dpadname") && xml->isStartElement()) + } else if ((xml->name().toString() == "dpadname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); @@ -327,7 +327,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setDPadName(index, temp); } - } else if ((xml->name() == "vdpadname") && xml->isStartElement()) + } else if ((xml->name().toString() == "vdpadname") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); @@ -345,11 +345,11 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) xml->readNextStartElement(); } - } else if ((xml->name() == "calibration") && xml->isStartElement()) + } else if ((xml->name().toString() == "calibration") && xml->isStartElement()) { m_inputDevice->getCalibrationBackend()->readConfig(xml); m_inputDevice->getCalibrationBackend()->applyCalibrations(); - } else if ((xml->name() == "keyPressTime") && xml->isStartElement()) + } else if ((xml->name().toString() == "keyPressTime") && xml->isStartElement()) { int tempchoice = xml->readElementText().toInt(); @@ -357,7 +357,7 @@ void InputDeviceXml::readConfig(QXmlStreamReader *xml) { m_inputDevice->setDeviceKeyPressTime(tempchoice); } - } else if ((xml->name() == "profilename") && xml->isStartElement()) + } else if ((xml->name().toString() == "profilename") && xml->isStartElement()) { m_inputDevice->setProfileName(xml->readElementText()); } else diff --git a/src/xml/joyaxisxml.cpp b/src/xml/joyaxisxml.cpp index 18e6df619..5053e33b1 100644 --- a/src/xml/joyaxisxml.cpp +++ b/src/xml/joyaxisxml.cpp @@ -44,15 +44,15 @@ JoyAxisXml::~JoyAxisXml() void JoyAxisXml::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == m_joyAxis->getXmlName())) + if (xml->isStartElement() && (xml->name().toString() == m_joyAxis->getXmlName())) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != m_joyAxis->getXmlName()))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != m_joyAxis->getXmlName()))) { bool found = readMainConfig(xml); - if (!found && (xml->name() == m_joyAxis->getNAxisButton()->getXmlName()) && xml->isStartElement()) + if (!found && (xml->name().toString() == m_joyAxis->getNAxisButton()->getXmlName()) && xml->isStartElement()) { found = true; readButtonConfig(xml); @@ -128,7 +128,7 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml) { bool found = false; - if ((xml->name() == "deadZone") && xml->isStartElement()) + if ((xml->name().toString() == "deadZone") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -137,7 +137,7 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml) qDebug() << "From xml config dead zone is: " << tempchoice; m_joyAxis->setDeadZone(tempchoice); - } else if ((xml->name() == "maxZone") && xml->isStartElement()) + } else if ((xml->name().toString() == "maxZone") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -146,7 +146,7 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml) qDebug() << "From xml config max zone is: " << tempchoice; m_joyAxis->setMaxZoneValue(tempchoice); - } else if ((xml->name() == "throttle") && xml->isStartElement()) + } else if ((xml->name().toString() == "throttle") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -180,7 +180,7 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml) m_joyAxis->setCurrentRawValue(m_joyAxis->getCurrentThrottledDeadValue()); m_joyAxis->updateCurrentThrottledValue(m_joyAxis->calculateThrottledValue(m_joyAxis->getCurrentRawValue())); - } else if ((xml->name() == "hapticTrigger") && xml->isStartElement()) + } else if ((xml->name().toString() == "hapticTrigger") && xml->isStartElement()) { found = true; m_joyAxis->setHapticTriggerMode(HapticTriggerPs5::from_string(xml->readElementText())); diff --git a/src/xml/joybuttonslotxml.cpp b/src/xml/joybuttonslotxml.cpp index becf9dcbb..91e756c52 100644 --- a/src/xml/joybuttonslotxml.cpp +++ b/src/xml/joybuttonslotxml.cpp @@ -44,9 +44,9 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml) if (!result && timeoutWrite > 0) xmlLock.tryLockForWrite(timeoutWrite); - qDebug() << "START OF READ CONFIG NAME: " << xml->name(); + qDebug() << "START OF READ CONFIG NAME: " << xml->name().toString(); - if (xml->isStartElement() && (xml->name() == "slot")) + if (xml->isStartElement() && (xml->name().toString() == "slot")) { QString profile = QString(); QString tempStringData = QString(); @@ -54,10 +54,10 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml) xml->readNextStartElement(); - qDebug() << "NEXT TO THE START TAG NAME: " << xml->name(); + qDebug() << "NEXT TO THE START TAG NAME: " << xml->name().toString(); // so it must be JoyMix - if (!xml->atEnd() && (!xml->isEndElement() && (xml->name() == "slots"))) + if (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() == "slots"))) { qDebug() << "Detected mix slots"; @@ -68,27 +68,27 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml) int i = 0; - while (xml->name() == "slot") + while (xml->name().toString() == "slot") { qDebug() << "Found mini slot in xml file"; xml->readNextStartElement(); // skip to minislot within slots list - qDebug() << "Now xml name after read next is: " << xml->name(); + qDebug() << "Now xml name after read next is: " << xml->name().toString(); // we don't want to add empty slot to minislots // skip again and check name of next tag - if (xml->name() == "slot") + if (xml->name().toString() == "slot") xml->readNextStartElement(); // if reached the end of mini slots, read next elem, that should be mode JoyMix and break loop - if (xml->name() == "slots") + if (xml->name().toString() == "slots") { xml->readNextStartElement(); break; } - qDebug() << "And now xml name after read next is: " << xml->name(); + qDebug() << "And now xml name after read next is: " << xml->name().toString(); JoyButtonSlot *minislot = new JoyButtonSlot(); @@ -108,13 +108,14 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml) qDebug() << "Added mini slot string and mode and code: " << minislot->getSlotString() << " and " << minislot->getSlotMode() << " and " << minislot->getSlotCode(); - qDebug() << "After readEachSlot for JoyMix now should be \"slot\" again or \"mode\": " << xml->name(); + qDebug() << "After readEachSlot for JoyMix now should be \"slot\" again or \"mode\": " + << xml->name().toString(); qDebug() << "It it start element? :" << (xml->isStartElement() ? "yes" : "no"); } i = 0; - if (xml->name() == "mode" && xml->readElementText() == "mix") + if (xml->name().toString() == "mode" && xml->readElementText() == "mix") { qDebug() << "slot text data for joy mix is: " << slotMixString; @@ -148,9 +149,9 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml) void JoyButtonSlotXml::readEachSlot(QXmlStreamReader *xml, JoyButtonSlot *joyBtnSlot, QString &profile, QString &tempStringData, QString &extraStringData) { - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "slot"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "slot"))) { - if ((xml->name() == "code") && xml->isStartElement()) + if ((xml->name().toString() == "code") && xml->isStartElement()) { QString temptext = xml->readElementText(); bool ok = false; @@ -158,23 +159,23 @@ void JoyButtonSlotXml::readEachSlot(QXmlStreamReader *xml, JoyButtonSlot *joyBtn if (ok) joyBtnSlot->setSlotCode(tempchoice); - } else if ((xml->name() == "profile") && xml->isStartElement()) + } else if ((xml->name().toString() == "profile") && xml->isStartElement()) { QString temptext = xml->readElementText(); profile = temptext; - } else if ((xml->name() == "text") && xml->isStartElement()) + } else if ((xml->name().toString() == "text") && xml->isStartElement()) { QString temptext = xml->readElementText(); tempStringData = temptext; - } else if ((xml->name() == "path") && xml->isStartElement()) + } else if ((xml->name().toString() == "path") && xml->isStartElement()) { QString temptext = xml->readElementText(); tempStringData = temptext; - } else if ((xml->name() == "arguments") && xml->isStartElement()) + } else if ((xml->name().toString() == "arguments") && xml->isStartElement()) { QString temptext = xml->readElementText(); extraStringData = temptext; - } else if ((xml->name() == "mode") && xml->isStartElement()) + } else if ((xml->name().toString() == "mode") && xml->isStartElement()) { QString temptext = xml->readElementText(); diff --git a/src/xml/joybuttonxml.cpp b/src/xml/joybuttonxml.cpp index 79e64090b..65538e703 100644 --- a/src/xml/joybuttonxml.cpp +++ b/src/xml/joybuttonxml.cpp @@ -33,20 +33,20 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) { bool found = false; - if ((xml->name() == "toggle") && xml->isStartElement()) + if ((xml->name().toString() == "toggle") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (temptext == "true") m_joyButton->setToggle(true); - } else if ((xml->name() == "turbointerval") && xml->isStartElement()) + } else if ((xml->name().toString() == "turbointerval") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setTurboInterval(tempchoice); - } else if ((xml->name() == "turbomode") && xml->isStartElement()) + } else if ((xml->name().toString() == "turbomode") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -57,33 +57,33 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) m_joyButton->setTurboMode(JoyButton::GradientTurbo); else if (temptext == "pulse") m_joyButton->setTurboMode(JoyButton::PulseTurbo); - } else if ((xml->name() == "useturbo") && xml->isStartElement()) + } else if ((xml->name().toString() == "useturbo") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (temptext == "true") m_joyButton->setUseTurbo(true); - } else if ((xml->name() == "mousespeedx") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousespeedx") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setMouseSpeedX(tempchoice); - } else if ((xml->name() == "mousespeedy") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousespeedy") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setMouseSpeedY(tempchoice); - } else if ((xml->name() == "cycleresetactive") && xml->isStartElement()) + } else if ((xml->name().toString() == "cycleresetactive") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (temptext == "true") m_joyButton->setCycleResetStatus(true); - } else if ((xml->name() == "cycleresetinterval") && xml->isStartElement()) + } else if ((xml->name().toString() == "cycleresetinterval") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -91,14 +91,14 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) if (tempchoice >= GlobalVariables::JoyButton::MINCYCLERESETTIME) m_joyButton->setCycleResetTime(tempchoice); - } else if ((xml->name() == "slots") && xml->isStartElement()) + } else if ((xml->name().toString() == "slots") && xml->isStartElement()) { found = true; xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "slots"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "slots"))) { - if ((xml->name() == "slot") && xml->isStartElement()) + if ((xml->name().toString() == "slot") && xml->isStartElement()) { JoyButtonSlot *buttonslot = new JoyButtonSlot(m_joyButton); JoyButtonSlotXml *buttonSlotXml = new JoyButtonSlotXml(buttonslot); @@ -143,7 +143,7 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) xml->readNextStartElement(); } - } else if ((xml->name() == "setselect") && xml->isStartElement()) + } else if ((xml->name().toString() == "setselect") && xml->isStartElement()) { if (!m_joyButton->isModifierButton()) { @@ -154,7 +154,7 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) if ((tempchoice >= 0) && (tempchoice <= GlobalVariables::InputDevice::NUMBER_JOYSETS)) m_joyButton->setChangeSetSelection(tempchoice - 1, false); } - } else if ((xml->name() == "setselectcondition") && xml->isStartElement()) + } else if ((xml->name().toString() == "setselectcondition") && xml->isStartElement()) { if (!m_joyButton->isModifierButton()) { @@ -172,7 +172,7 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) if (tempcondition != JoyButton::SetChangeDisabled) m_joyButton->setChangeSetCondition(tempcondition, false, false); } - } else if ((xml->name() == "mousemode") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousemode") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -181,7 +181,7 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) m_joyButton->setMouseMode(JoyButton::MouseCursor); else if (temptext == "spring") m_joyButton->setMouseMode(JoyButton::MouseSpring); - } else if ((xml->name() == "mouseacceleration") && xml->isStartElement()) + } else if ((xml->name().toString() == "mouseacceleration") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -202,94 +202,94 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) m_joyButton->setMouseCurve(JoyButton::EasingQuadraticCurve); else if (temptext == "easing-cubic") m_joyButton->setMouseCurve(JoyButton::EasingCubicCurve); - } else if ((xml->name() == "mousespringwidth") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousespringwidth") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setSpringWidth(tempchoice); - } else if ((xml->name() == "mousespringheight") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousespringheight") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setSpringHeight(tempchoice); - } else if ((xml->name() == "mousesensitivity") && xml->isStartElement()) + } else if ((xml->name().toString() == "mousesensitivity") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setSensitivity(tempchoice); - } else if ((xml->name() == "actionname") && xml->isStartElement()) + } else if ((xml->name().toString() == "actionname") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (!temptext.isEmpty()) m_joyButton->setActionName(temptext); - } else if ((xml->name() == "wheelspeedx") && xml->isStartElement()) + } else if ((xml->name().toString() == "wheelspeedx") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setWheelSpeed(tempchoice, 'X'); - } else if ((xml->name() == "wheelspeedy") && xml->isStartElement()) + } else if ((xml->name().toString() == "wheelspeedy") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); m_joyButton->setWheelSpeed(tempchoice, 'Y'); - } else if ((xml->name() == "relativespring") && xml->isStartElement()) + } else if ((xml->name().toString() == "relativespring") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (temptext == "true") m_joyButton->setSpringRelativeStatus(true); - } else if ((xml->name() == "easingduration") && xml->isStartElement()) + } else if ((xml->name().toString() == "easingduration") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setEasingDuration(tempchoice); - } else if ((xml->name() == "extraacceleration") && xml->isStartElement()) + } else if ((xml->name().toString() == "extraacceleration") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); if (temptext == "true") m_joyButton->setExtraAccelerationStatus(true); - } else if ((xml->name() == "accelerationmultiplier") && xml->isStartElement()) + } else if ((xml->name().toString() == "accelerationmultiplier") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setExtraAccelerationMultiplier(tempchoice); - } else if ((xml->name() == "startaccelmultiplier") && xml->isStartElement()) + } else if ((xml->name().toString() == "startaccelmultiplier") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setStartAccelMultiplier(tempchoice); - } else if ((xml->name() == "minaccelthreshold") && xml->isStartElement()) + } else if ((xml->name().toString() == "minaccelthreshold") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setMinAccelThreshold(tempchoice); - } else if ((xml->name() == "maxaccelthreshold") && xml->isStartElement()) + } else if ((xml->name().toString() == "maxaccelthreshold") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setMaxAccelThreshold(tempchoice); - } else if ((xml->name() == "accelextraduration") && xml->isStartElement()) + } else if ((xml->name().toString() == "accelextraduration") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); double tempchoice = temptext.toDouble(); m_joyButton->setAccelExtraDuration(tempchoice); - } else if ((xml->name() == "extraaccelerationcurve") && xml->isStartElement()) + } else if ((xml->name().toString() == "extraaccelerationcurve") && xml->isStartElement()) { found = true; @@ -306,7 +306,7 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) tempcurve = JoyButton::EaseOutCubicAccelCurve; m_joyButton->setExtraAccelerationCurve(tempcurve); - } else if ((xml->name() == "springreleaseradius") && xml->isStartElement()) + } else if ((xml->name().toString() == "springreleaseradius") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -321,11 +321,11 @@ bool JoyButtonXml::readButtonConfig(QXmlStreamReader *xml) void JoyButtonXml::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == m_joyButton->getXmlName())) + if (xml->isStartElement() && (xml->name().toString() == m_joyButton->getXmlName())) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != m_joyButton->getXmlName()))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != m_joyButton->getXmlName()))) { bool found = readButtonConfig(xml); diff --git a/src/xml/joydpadxml.cpp b/src/xml/joydpadxml.cpp index 6a425fece..04502f8cb 100644 --- a/src/xml/joydpadxml.cpp +++ b/src/xml/joydpadxml.cpp @@ -22,10 +22,10 @@ JoyDPadXml::JoyDPadXml(T *joydpad, QObject *parent) template void JoyDPadXml::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == m_joydpad->getXmlName())) + if (xml->isStartElement() && (xml->name().toString() == m_joydpad->getXmlName())) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != m_joydpad->getXmlName()))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != m_joydpad->getXmlName()))) { bool found = readMainConfig(xml); if (!found) @@ -77,7 +77,7 @@ template bool JoyDPadXml::readMainConfig(QXmlStreamReader *xml) { bool found = false; - if ((xml->name() == "dpadbutton") && xml->isStartElement()) + if ((xml->name().toString() == "dpadbutton") && xml->isStartElement()) { found = true; int index_local = xml->attributes().value("index").toString().toInt(); @@ -91,7 +91,7 @@ template bool JoyDPadXml::readMainConfig(QXmlStreamReader *xml) { xml->skipCurrentElement(); } - } else if ((xml->name() == "mode") && xml->isStartElement()) + } else if ((xml->name().toString() == "mode") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); @@ -106,7 +106,7 @@ template bool JoyDPadXml::readMainConfig(QXmlStreamReader *xml) { m_joydpad->setJoyMode(JoyDPad::FourWayDiagonal); } - } else if ((xml->name() == "dpadDelay") && xml->isStartElement()) + } else if ((xml->name().toString() == "dpadDelay") && xml->isStartElement()) { found = true; QString temptext = xml->readElementText(); diff --git a/src/xml/setjoystickxml.cpp b/src/xml/setjoystickxml.cpp index 49045e892..b5796850a 100644 --- a/src/xml/setjoystickxml.cpp +++ b/src/xml/setjoystickxml.cpp @@ -49,13 +49,13 @@ SetJoystickXml::SetJoystickXml(SetJoystick *setJoystick, QObject *parent) */ void SetJoystickXml::readConfig(QXmlStreamReader *xml) { - if (xml->isStartElement() && (xml->name() == "set")) + if (xml->isStartElement() && (xml->name().toString() == "set")) { xml->readNextStartElement(); - while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "set"))) + while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "set"))) { - if ((xml->name() == "button") && xml->isStartElement()) + if ((xml->name().toString() == "button") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); JoyButton *button = m_setJoystick->getJoyButton(index - 1); @@ -65,7 +65,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) joyButtonXml->readConfig(xml); else xml->skipCurrentElement(); - } else if ((xml->name() == "axis") && xml->isStartElement()) + } else if ((xml->name().toString() == "axis") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); JoyAxis *axis = m_setJoystick->getJoyAxis(index - 1); @@ -75,7 +75,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) joyAxisXml->readConfig(xml); else xml->skipCurrentElement(); - } else if ((xml->name() == "dpad") && xml->isStartElement()) + } else if ((xml->name().toString() == "dpad") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); JoyDPad *dpad = m_setJoystick->getJoyDPad(index - 1); @@ -85,7 +85,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) joydpadXml->readConfig(xml); else xml->skipCurrentElement(); - } else if ((xml->name() == "stick") && xml->isStartElement()) + } else if ((xml->name().toString() == "stick") && xml->isStartElement()) { int stickIndex = xml->attributes().value("index").toString().toInt(); @@ -102,7 +102,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) { xml->skipCurrentElement(); } - } else if ((xml->name() == "sensor") && xml->isStartElement()) + } else if ((xml->name().toString() == "sensor") && xml->isStartElement()) { int type = xml->attributes().value("type").toString().toInt(); JoySensor *sensor = m_setJoystick->getSensor(static_cast(type)); @@ -111,7 +111,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) sensor->readConfig(xml); else xml->skipCurrentElement(); - } else if ((xml->name() == "vdpad") && xml->isStartElement()) + } else if ((xml->name().toString() == "vdpad") && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); VDPad *vdpad = m_setJoystick->getVDPad(index - 1); @@ -121,7 +121,7 @@ void SetJoystickXml::readConfig(QXmlStreamReader *xml) joydpadXml->readConfig(xml); else xml->skipCurrentElement(); - } else if ((xml->name() == "name") && xml->isStartElement()) + } else if ((xml->name().toString() == "name") && xml->isStartElement()) { QString temptext = xml->readElementText(); diff --git a/src/xmlconfigreader.cpp b/src/xmlconfigreader.cpp index c4c4475e9..e22591668 100644 --- a/src/xmlconfigreader.cpp +++ b/src/xmlconfigreader.cpp @@ -115,7 +115,7 @@ bool XMLConfigReader::read() if (!deviceTypes.contains(xml->name().toString())) { xml->raiseError("Root node is not a joystick or controller"); - } else if (xml->name() == GlobalVariables::Joystick::xmlName) + } else if (xml->name().toString() == GlobalVariables::Joystick::xmlName) { XMLConfigMigration migration(xml);