-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed58be5
commit fdd6a3c
Showing
15 changed files
with
256 additions
and
47 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.installer.yaml
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.locale.en-US.yaml
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
manifests/e/EmptyFlow/ArdorQuery/0.0.12/EmptyFlow.ArdorQuery.yaml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
ArdorQuery http tester | ||
Copyright (C) 2022-2024 Roman Vladimirov | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <QList> | ||
#include "cssformatter.h" | ||
|
||
CssFormatter::CssFormatter() | ||
{ | ||
|
||
} | ||
|
||
QString CssFormatter::format(const QString &data) | ||
{ | ||
m_stackSize = 0; | ||
QString currentOpenBlock = ""; | ||
m_result.clear(); | ||
|
||
for(auto character: data) { | ||
auto latinCharacter = character.toLatin1(); | ||
|
||
if (latinCharacter == m_blockStart) { | ||
setOffset(m_stackSize); | ||
m_result.append("<font color=\"#8812a1\">" + currentOpenBlock.trimmed() + "</font> {\n"); | ||
currentOpenBlock.clear(); | ||
m_stackSize += 1; | ||
continue; | ||
} | ||
if (latinCharacter == m_blockEnd) { | ||
if (m_stackSize > 0) m_stackSize -= 1; | ||
setOffset(m_stackSize); | ||
m_result.append("}\n"); | ||
currentOpenBlock.clear(); | ||
continue; | ||
} | ||
|
||
if (latinCharacter == m_endField) { | ||
setOffset(m_stackSize); | ||
auto trimmedValue = currentOpenBlock.trimmed(); | ||
if (trimmedValue.indexOf(":") > -1) { | ||
auto parts = trimmedValue.split(":"); | ||
m_result.append("<font color=\"#008000\">" + parts.first().trimmed() + "</font>: "); | ||
m_result.append(parts.last().trimmed() + ";\n"); | ||
} else { | ||
m_result.append(currentOpenBlock.trimmed() + ";\n"); | ||
} | ||
currentOpenBlock.clear(); | ||
continue; | ||
} | ||
|
||
currentOpenBlock += latinCharacter; | ||
} | ||
|
||
return m_result; | ||
} | ||
|
||
void CssFormatter::setOffset(int stackSize) noexcept | ||
{ | ||
for (auto i = 0; i < stackSize; i++) { | ||
m_result.append(m_cssTab); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
ArdorQuery http tester | ||
Copyright (C) 2022-2024 Roman Vladimirov | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef CSSFORMATTER_H | ||
#define CSSFORMATTER_H | ||
|
||
#include "outputformatter.h" | ||
|
||
class CssFormatter : public OutputFormatter | ||
{ | ||
private: | ||
const QString m_blockStart { "{" }; | ||
const QString m_blockEnd { "}" }; | ||
const QString m_separator { ":" }; | ||
const QString m_atRules { "@" }; | ||
const QString m_endField { ";" }; | ||
const QString m_import { "@import" }; | ||
const QString m_newline { "\n" }; | ||
const QString m_caretBack { "\r" }; | ||
const QString m_cssTab { " " }; | ||
int m_stackSize { -1 }; | ||
QString m_result { "" }; | ||
|
||
public: | ||
CssFormatter(); | ||
|
||
QString format(const QString& data) override; | ||
|
||
private: | ||
void setOffset(int stackSize) noexcept; | ||
|
||
}; | ||
|
||
#endif // CSSFORMATTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
ArdorQuery http tester | ||
Copyright (C) 2022-2024 Roman Vladimirov | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <QtTest/QtTest> | ||
#include "cssformatterunittests.h" | ||
#include "../Formatters/cssformatter.h" | ||
|
||
CssFormatterUnitTests::CssFormatterUnitTests(QObject *parent) | ||
: QObject{parent} | ||
{ | ||
|
||
} | ||
|
||
void CssFormatterUnitTests::simplestyle_completed() | ||
{ | ||
CssFormatter formatter; | ||
auto result = formatter.format(".myclass {property: value;}"); | ||
auto expectedResult = QString(R"a(<font color="#8812a1">.myclass</font> { | ||
<font color="#008000">property</font>: value; | ||
} | ||
)a"); | ||
QCOMPARE(result, expectedResult); | ||
} | ||
|
||
void CssFormatterUnitTests::simplestyle_multiplevalues_completed() | ||
{ | ||
CssFormatter formatter; | ||
auto result = formatter.format(".myclass {property: value; property2: lalala ; purupu : vallll ;}"); | ||
auto expectedResult = QString(R"a(<font color="#8812a1">.myclass</font> { | ||
<font color="#008000">property</font>: value; | ||
<font color="#008000">property2</font>: lalala; | ||
<font color="#008000">purupu</font>: vallll; | ||
} | ||
)a"); | ||
QCOMPARE(result, expectedResult); | ||
} | ||
|
||
void CssFormatterUnitTests::multiplestyles_multiplevalues_completed() | ||
{ | ||
CssFormatter formatter; | ||
auto result = formatter.format(".myclass {property: value; property2: lalala ; purupu : vallll;} .myclass2 { muhers: pruher; muhers2: pruher2; }"); | ||
auto expectedResult = QString(R"a(<font color="#8812a1">.myclass</font> { | ||
<font color="#008000">property</font>: value; | ||
<font color="#008000">property2</font>: lalala; | ||
<font color="#008000">purupu</font>: vallll; | ||
} | ||
<font color="#8812a1">.myclass2</font> { | ||
<font color="#008000">muhers</font>: pruher; | ||
<font color="#008000">muhers2</font>: pruher2; | ||
} | ||
)a"); | ||
QCOMPARE(result, expectedResult); | ||
} | ||
|
||
void CssFormatterUnitTests::nestedstyles_completed() | ||
{ | ||
CssFormatter formatter; | ||
auto result = formatter.format(".myclass {property: value; .nestedclass { nestedproperty: nestedvalue; } }"); | ||
auto expectedResult = QString(R"a(<font color="#8812a1">.myclass</font> { | ||
<font color="#008000">property</font>: value; | ||
<font color="#8812a1">.nestedclass</font> { | ||
<font color="#008000">nestedproperty</font>: nestedvalue; | ||
} | ||
} | ||
)a"); | ||
QCOMPARE(result, expectedResult); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
ArdorQuery http tester | ||
Copyright (C) 2022-2024 Roman Vladimirov | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef CSSFORMATTERUNITTESTS_H | ||
#define CSSFORMATTERUNITTESTS_H | ||
|
||
#include <QObject> | ||
|
||
class CssFormatterUnitTests : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit CssFormatterUnitTests(QObject *parent = nullptr); | ||
|
||
private slots: | ||
void simplestyle_completed(); | ||
void simplestyle_multiplevalues_completed(); | ||
void multiplestyles_multiplevalues_completed(); | ||
void nestedstyles_completed(); | ||
|
||
}; | ||
|
||
#endif // CSSFORMATTERUNITTESTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.