Run clang-format on all cpp/h files
NO_CHANGELOG
This commit is contained in:
parent
5df331acf2
commit
fe594e8742
@ -143,4 +143,4 @@ kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||
# Remove these 3 lines when the ECM version is bumped to 5.80
|
||||
include(KDEClangFormat)
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
|
||||
kde_clang_format()
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
||||
@ -19,9 +19,9 @@
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <QStandardPaths>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
#include "testhelpers.h"
|
||||
|
||||
@ -55,8 +55,7 @@ class DupeTest : public QObject
|
||||
QString line;
|
||||
while (proc.canReadLine() || proc.waitForReadyRead()) {
|
||||
line = proc.readLine();
|
||||
failListContent(splitOnUnescapedSpace(line.simplified()),
|
||||
"The following files are duplicates but not links:\n");
|
||||
failListContent(splitOnUnescapedSpace(line.simplified()), "The following files are duplicates but not links:\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,11 +63,7 @@ class DupeTest : public QObject
|
||||
{
|
||||
QProcess proc;
|
||||
proc.setProgram(QStringLiteral("fdupes"));
|
||||
proc.setArguments(QStringList()
|
||||
<< QStringLiteral("--recurse")
|
||||
<< QStringLiteral("--sameline")
|
||||
<< QStringLiteral("--nohidden")
|
||||
<< path);
|
||||
proc.setArguments(QStringList() << QStringLiteral("--recurse") << QStringLiteral("--sameline") << QStringLiteral("--nohidden") << path);
|
||||
proc.start();
|
||||
proc.waitForStarted();
|
||||
readLines(proc);
|
||||
|
||||
@ -33,19 +33,15 @@ private Q_SLOTS:
|
||||
void test_whitespace()
|
||||
{
|
||||
QList<QString> brokenFiles;
|
||||
QDirIterator it(PROJECT_SOURCE_DIR,
|
||||
QDir::Files | QDir::System,
|
||||
QDirIterator::Subdirectories);
|
||||
QDirIterator it(PROJECT_SOURCE_DIR, QDir::Files | QDir::System, QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.fileName().simplified() != it.fileName()) {
|
||||
brokenFiles << it.filePath();
|
||||
}
|
||||
}
|
||||
failListContent(brokenFiles,
|
||||
QStringLiteral("Found file with bad characters (http://doc.qt.io/qt-5/qstring.html#simplified):\n"));
|
||||
failListContent(brokenFiles, QStringLiteral("Found file with bad characters (http://doc.qt.io/qt-5/qstring.html#simplified):\n"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(NewlineTest)
|
||||
|
||||
@ -19,17 +19,17 @@
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <QDirIterator>
|
||||
|
||||
#include <QSettings> // parsing the ini files as desktop files
|
||||
#include "testhelpers.h"
|
||||
#include <QSettings> // parsing the ini files as desktop files
|
||||
|
||||
// lift a bit of code from KIconLoader to get the unit test running without tier 3 libraries
|
||||
class KIconLoaderDummy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Context {
|
||||
Any,
|
||||
@ -55,7 +55,6 @@ public:
|
||||
Q_ENUM(Type)
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Represents icon directory to conduct simple icon lookup within.
|
||||
*/
|
||||
@ -63,8 +62,7 @@ class Dir
|
||||
{
|
||||
public:
|
||||
Dir(const QSettings &cg, const QString &themeDir_)
|
||||
:
|
||||
themeDir(themeDir_)
|
||||
: themeDir(themeDir_)
|
||||
, path(cg.group())
|
||||
, size(cg.value("Size", 0).toInt())
|
||||
, contextString(cg.value("Context", QString()).toString())
|
||||
@ -74,7 +72,10 @@ public:
|
||||
QVERIFY2(!contextString.isEmpty(),
|
||||
QString("Missing 'Context' key in file %1, config group '[%2]'").arg(cg.fileName(), cg.group()).toLatin1().constData());
|
||||
QVERIFY2(context != -1,
|
||||
QString("Don't know how to handle 'Context=%1' in file %2, config group '[%3]'").arg(contextString, cg.fileName(), cg.group()).toLatin1().constData());
|
||||
QString("Don't know how to handle 'Context=%1' in file %2, config group '[%3]'")
|
||||
.arg(contextString, cg.fileName(), cg.group())
|
||||
.toLatin1()
|
||||
.constData());
|
||||
}
|
||||
|
||||
static QMetaEnum findEnum(const char *name)
|
||||
@ -99,17 +100,17 @@ public:
|
||||
static KIconLoaderDummy::Context parseContext(const QString &string)
|
||||
{
|
||||
// Can't use QMetaEnum as the enum names are singular, the entry values are plural though.
|
||||
static QHash<QString, int> hash {
|
||||
{ QStringLiteral("Actions"), KIconLoaderDummy::Action },
|
||||
{ QStringLiteral("Animations"), KIconLoaderDummy::Animation },
|
||||
{ QStringLiteral("Applications"), KIconLoaderDummy::Application },
|
||||
{ QStringLiteral("Categories"), KIconLoaderDummy::Category },
|
||||
{ QStringLiteral("Devices"), KIconLoaderDummy::Device },
|
||||
{ QStringLiteral("Emblems"), KIconLoaderDummy::Emblem },
|
||||
{ QStringLiteral("Emotes"), KIconLoaderDummy::Emote },
|
||||
{ QStringLiteral("MimeTypes"), KIconLoaderDummy::MimeType },
|
||||
{ QStringLiteral("Places"), KIconLoaderDummy::Place },
|
||||
{ QStringLiteral("Status"), KIconLoaderDummy::StatusIcon },
|
||||
static QHash<QString, int> hash{
|
||||
{QStringLiteral("Actions"), KIconLoaderDummy::Action},
|
||||
{QStringLiteral("Animations"), KIconLoaderDummy::Animation},
|
||||
{QStringLiteral("Applications"), KIconLoaderDummy::Application},
|
||||
{QStringLiteral("Categories"), KIconLoaderDummy::Category},
|
||||
{QStringLiteral("Devices"), KIconLoaderDummy::Device},
|
||||
{QStringLiteral("Emblems"), KIconLoaderDummy::Emblem},
|
||||
{QStringLiteral("Emotes"), KIconLoaderDummy::Emote},
|
||||
{QStringLiteral("MimeTypes"), KIconLoaderDummy::MimeType},
|
||||
{QStringLiteral("Places"), KIconLoaderDummy::Place},
|
||||
{QStringLiteral("Status"), KIconLoaderDummy::StatusIcon},
|
||||
};
|
||||
const auto value = hash.value(string, -1);
|
||||
return static_cast<KIconLoaderDummy::Context>(value); // the caller will check that it wasn't -1
|
||||
@ -179,8 +180,12 @@ private Q_SLOTS:
|
||||
QVERIFY(!directoryPaths.isEmpty());
|
||||
for (auto directoryPath : directoryPaths) {
|
||||
config.beginGroup(directoryPath);
|
||||
QVERIFY2(keys.contains(directoryPath+"/Size"),QString("The theme %1 has an entry 'Directories' which specifies '%2' as directory, but there's no"
|
||||
" have no associated entry '%2/Size'").arg(themeDir + "/index.theme", directoryPath).toLatin1().constData());
|
||||
QVERIFY2(keys.contains(directoryPath + "/Size"),
|
||||
QString("The theme %1 has an entry 'Directories' which specifies '%2' as directory, but there's no"
|
||||
" have no associated entry '%2/Size'")
|
||||
.arg(themeDir + "/index.theme", directoryPath)
|
||||
.toLatin1()
|
||||
.constData());
|
||||
auto dir = QSharedPointer<Dir>::create(config, themeDir);
|
||||
config.endGroup();
|
||||
contextHash[dir->context].append(dir);
|
||||
@ -261,9 +266,7 @@ private Q_SLOTS:
|
||||
return;
|
||||
}
|
||||
notScalableIcons.removeDuplicates();
|
||||
QFAIL(QString("The following icons are not available in a scalable directory:\n %1")
|
||||
.arg(notScalableIcons.join("\n "))
|
||||
.toLatin1().constData());
|
||||
QFAIL(QString("The following icons are not available in a scalable directory:\n %1").arg(notScalableIcons.join("\n ")).toLatin1().constData());
|
||||
}
|
||||
|
||||
void test_scalableDuplicates_data()
|
||||
@ -297,7 +300,7 @@ private Q_SLOTS:
|
||||
}
|
||||
|
||||
QHash<QString, QList<QFileInfo>> duplicatedScalableIcons;
|
||||
for (auto icon: scalableIcons.keys()) {
|
||||
for (auto icon : scalableIcons.keys()) {
|
||||
auto list = scalableIcons[icon];
|
||||
if (list.size() > 1) {
|
||||
duplicatedScalableIcons[icon] = list;
|
||||
|
||||
@ -40,9 +40,7 @@ private Q_SLOTS:
|
||||
// By default broken symlinks are not listed unless the System filter
|
||||
// is used. System may however also include pipes and the like, so we
|
||||
// still manually need to filter for symlinks afterwards.
|
||||
QDirIterator it(PROJECT_SOURCE_DIR,
|
||||
QDir::System,
|
||||
QDirIterator::Subdirectories);
|
||||
QDirIterator it(PROJECT_SOURCE_DIR, QDir::System, QDirIterator::Subdirectories);
|
||||
QList<QFileInfo> brokenSymLinks;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
@ -57,29 +55,25 @@ private Q_SLOTS:
|
||||
}
|
||||
brokenSymLinks << info;
|
||||
}
|
||||
failSymlinkList(brokenSymLinks,
|
||||
QStringLiteral("Found broken symlinks:\n"));
|
||||
failSymlinkList(brokenSymLinks, QStringLiteral("Found broken symlinks:\n"));
|
||||
}
|
||||
|
||||
// Symlinks should never point to something outside the tree, even if valid!
|
||||
void test_outOfTree()
|
||||
{
|
||||
QDirIterator it(PROJECT_SOURCE_DIR,
|
||||
QDir::AllEntries,
|
||||
QDirIterator::Subdirectories);
|
||||
QDirIterator it(PROJECT_SOURCE_DIR, QDir::AllEntries, QDirIterator::Subdirectories);
|
||||
QList<QFileInfo> OOTSymLinks;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
auto info = it.fileInfo();
|
||||
if (!info.isSymLink() ||
|
||||
info.symLinkTarget().startsWith(PROJECT_SOURCE_DIR)) {
|
||||
if (!info.isSymLink() || info.symLinkTarget().startsWith(PROJECT_SOURCE_DIR)) {
|
||||
continue;
|
||||
}
|
||||
OOTSymLinks << info;
|
||||
}
|
||||
failSymlinkList(OOTSymLinks,
|
||||
QStringLiteral("Found out-of-tree symlinks:\n"));
|
||||
failSymlinkList(OOTSymLinks, QStringLiteral("Found out-of-tree symlinks:\n"));
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_buildDir;
|
||||
};
|
||||
|
||||
22
qrcAlias.cpp
22
qrcAlias.cpp
@ -16,13 +16,13 @@
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
#include <QRegularExpression>
|
||||
#include <QDebug>
|
||||
#include <QCommandLineParser>
|
||||
#include <QString>
|
||||
|
||||
QString link(const QString &path, const QString &fileName)
|
||||
{
|
||||
@ -46,11 +46,11 @@ QString link(const QString &path, const QString &fileName)
|
||||
QFileInfo linkInfo(path + QLatin1Char('/') + match.captured(1));
|
||||
QString aliasLink = link(linkInfo.path(), linkInfo.fileName());
|
||||
if (!aliasLink.isEmpty()) {
|
||||
//qDebug() << fileName << "=" << match.captured(1) << "=" << aliasLink;
|
||||
// qDebug() << fileName << "=" << match.captured(1) << "=" << aliasLink;
|
||||
return aliasLink;
|
||||
}
|
||||
|
||||
return path + QLatin1Char('/') + match.captured(1);
|
||||
return path + QLatin1Char('/') + match.captured(1);
|
||||
}
|
||||
|
||||
int parseFile(const QString &infile, const QString &outfile)
|
||||
@ -72,7 +72,7 @@ int parseFile(const QString &infile, const QString &outfile)
|
||||
QString line = QString::fromLocal8Bit(in.readLine());
|
||||
QRegularExpressionMatch match = imageReg.match(line);
|
||||
if (!match.hasMatch()) {
|
||||
//qDebug() << "No Match: " << line;
|
||||
// qDebug() << "No Match: " << line;
|
||||
out.write(qPrintable(line));
|
||||
continue;
|
||||
}
|
||||
@ -81,13 +81,13 @@ int parseFile(const QString &infile, const QString &outfile)
|
||||
|
||||
QString aliasLink = link(info.path(), info.fileName());
|
||||
if (aliasLink.isEmpty()) {
|
||||
//qDebug() << "No alias: " << line;
|
||||
// qDebug() << "No alias: " << line;
|
||||
out.write(qPrintable(line));
|
||||
continue;
|
||||
}
|
||||
|
||||
QString newLine = QStringLiteral("<file alias=\"%1\">%2</file>\n").arg(match.captured(1), aliasLink);
|
||||
//qDebug() << newLine;
|
||||
// qDebug() << newLine;
|
||||
out.write(qPrintable(newLine));
|
||||
}
|
||||
return 0;
|
||||
@ -103,9 +103,9 @@ int main(int argc, char *argv[])
|
||||
QCommandLineOption outOption(QStringList() << QLatin1String("o") << QLatin1String("outfile"), QStringLiteral("Output qrc file"), QStringLiteral("outfile"));
|
||||
parser.setApplicationDescription(
|
||||
QLatin1String("On Windows git handles symbolic links by converting them "
|
||||
"to text files containing the links to the actual file. This application "
|
||||
"takes a .qrc file as input and outputs a .qrc file with the symbolic "
|
||||
"links converted to qrc-aliases."));
|
||||
"to text files containing the links to the actual file. This application "
|
||||
"takes a .qrc file as input and outputs a .qrc file with the symbolic "
|
||||
"links converted to qrc-aliases."));
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.addOption(inOption);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user