clang-format fixes
This commit is contained in:
parent
a4e6530513
commit
ddf0c28b1b
@ -189,18 +189,18 @@ struct TextFormatter {
|
|||||||
QPair<bool, bool> is_linked = { false, false };
|
QPair<bool, bool> is_linked = { false, false };
|
||||||
QPair<QString, bool> link_url = { "", false };
|
QPair<QString, bool> link_url = { "", false };
|
||||||
|
|
||||||
void setColor(const QString& new_color, bool written) { color = { new_color, written}; }
|
void setColor(const QString& new_color, bool written) { color = { new_color, written }; }
|
||||||
void setBold(bool new_bold, bool written) { bold = { new_bold, written}; }
|
void setBold(bool new_bold, bool written) { bold = { new_bold, written }; }
|
||||||
void setItalic(bool new_italic, bool written) { italic = { new_italic, written}; }
|
void setItalic(bool new_italic, bool written) { italic = { new_italic, written }; }
|
||||||
void setUnderlined(bool new_underlined, bool written) { underlined = { new_underlined, written}; }
|
void setUnderlined(bool new_underlined, bool written) { underlined = { new_underlined, written }; }
|
||||||
void setStrikethrough(bool new_strikethrough, bool written) { strikethrough = { new_strikethrough, written}; }
|
void setStrikethrough(bool new_strikethrough, bool written) { strikethrough = { new_strikethrough, written }; }
|
||||||
void setIsLinked(bool new_is_linked, bool written) { is_linked = { new_is_linked, written}; }
|
void setIsLinked(bool new_is_linked, bool written) { is_linked = { new_is_linked, written }; }
|
||||||
void setLinkURL(const QString& new_url, bool written) { link_url = { new_url, written}; }
|
void setLinkURL(const QString& new_url, bool written) { link_url = { new_url, written }; }
|
||||||
|
|
||||||
void overrideFrom(const TextFormatter& child)
|
void overrideFrom(const TextFormatter& child)
|
||||||
{
|
{
|
||||||
if (child.color.second)
|
if (child.color.second)
|
||||||
color.first = child.color.first;
|
color.first = child.color.first;
|
||||||
if (child.bold.second)
|
if (child.bold.second)
|
||||||
bold.first = child.bold.first;
|
bold.first = child.bold.first;
|
||||||
if (child.italic.second)
|
if (child.italic.second)
|
||||||
@ -282,7 +282,7 @@ bool processComponent(const QJsonValue& value, QString& result, const TextFormat
|
|||||||
result.append(formatter.format(value.toBool() ? "true" : "false"));
|
result.append(formatter.format(value.toBool() ? "true" : "false"));
|
||||||
} else if (value.isDouble()) {
|
} else if (value.isDouble()) {
|
||||||
result.append(formatter.format(QString::number(value.toDouble())));
|
result.append(formatter.format(QString::number(value.toDouble())));
|
||||||
} else if (value.isObject()) {
|
} else if (value.isObject()) {
|
||||||
auto obj = value.toObject();
|
auto obj = value.toObject();
|
||||||
|
|
||||||
if (not formatter.readFormat(obj))
|
if (not formatter.readFormat(obj))
|
||||||
@ -294,7 +294,7 @@ bool processComponent(const QJsonValue& value, QString& result, const TextFormat
|
|||||||
mixed = *parentFormat;
|
mixed = *parentFormat;
|
||||||
|
|
||||||
mixed.overrideFrom(formatter);
|
mixed.overrideFrom(formatter);
|
||||||
|
|
||||||
result.append(mixed.format(Json::ensureString(obj, "text")));
|
result.append(mixed.format(Json::ensureString(obj, "text")));
|
||||||
|
|
||||||
// process any 'extra' children with this format
|
// process any 'extra' children with this format
|
||||||
@ -310,7 +310,7 @@ bool processComponent(const QJsonValue& value, QString& result, const TextFormat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Invalid component type!";
|
qWarning() << "Invalid component type!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ bool process(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
|
|||||||
bool processZIP(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
|
bool processZIP(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
|
||||||
bool processFolder(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
|
bool processFolder(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full);
|
||||||
|
|
||||||
|
|
||||||
struct TextFormatter;
|
struct TextFormatter;
|
||||||
bool processComponent(const QJsonValue& value, QString& result, const TextFormatter* parentFormat = nullptr);
|
bool processComponent(const QJsonValue& value, QString& result, const TextFormatter* parentFormat = nullptr);
|
||||||
bool processMCMeta(ResourcePack& pack, QByteArray&& raw_data);
|
bool processMCMeta(ResourcePack& pack, QByteArray&& raw_data);
|
||||||
|
@ -33,11 +33,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QTest>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
#include <QTest>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
|
||||||
@ -76,31 +76,12 @@ class MetaComponentParseTest : public QObject {
|
|||||||
QVERIFY(valid == true);
|
QVERIFY(valid == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void test_parseComponentBasic()
|
void test_parseComponentBasic() { doTest("component_basic.json"); }
|
||||||
{
|
void test_parseComponentWithFormat() { doTest("component_with_format.json"); }
|
||||||
doTest("component_basic.json");
|
void test_parseComponentWithExtra() { doTest("component_with_extra.json"); }
|
||||||
}
|
void test_parseComponentWithLink() { doTest("component_with_link.json"); }
|
||||||
|
void test_parseComponentWithMixed() { doTest("component_with_mixed.json"); }
|
||||||
void test_parseComponentWithFormat()
|
|
||||||
{
|
|
||||||
doTest("component_with_format.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_parseComponentWithExtra()
|
|
||||||
{
|
|
||||||
doTest("component_with_extra.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_parseComponentWithLink()
|
|
||||||
{
|
|
||||||
doTest("component_with_link.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_parseComponentWithMixed()
|
|
||||||
{
|
|
||||||
doTest("component_with_mixed.json");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(MetaComponentParseTest)
|
QTEST_GUILESS_MAIN(MetaComponentParseTest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user