Commit d674bee1 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

clang-tidy: Force braces around statements

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 039f7d90
...@@ -550,8 +550,9 @@ bool ComicApplet::showComicUrl() const ...@@ -550,8 +550,9 @@ bool ComicApplet::showComicUrl() const
void ComicApplet::setShowComicUrl(bool show) void ComicApplet::setShowComicUrl(bool show)
{ {
if (show == mShowComicUrl) if (show == mShowComicUrl) {
return; return;
}
mShowComicUrl = show; mShowComicUrl = show;
...@@ -565,8 +566,9 @@ bool ComicApplet::showComicAuthor() const ...@@ -565,8 +566,9 @@ bool ComicApplet::showComicAuthor() const
void ComicApplet::setShowComicAuthor(bool show) void ComicApplet::setShowComicAuthor(bool show)
{ {
if (show == mShowComicAuthor) if (show == mShowComicAuthor) {
return; return;
}
mShowComicAuthor = show; mShowComicAuthor = show;
...@@ -580,8 +582,9 @@ bool ComicApplet::showComicTitle() const ...@@ -580,8 +582,9 @@ bool ComicApplet::showComicTitle() const
void ComicApplet::setShowComicTitle(bool show) void ComicApplet::setShowComicTitle(bool show)
{ {
if (show == mShowComicTitle) if (show == mShowComicTitle) {
return; return;
}
mShowComicTitle = show; mShowComicTitle = show;
...@@ -595,8 +598,9 @@ bool ComicApplet::showComicIdentifier() const ...@@ -595,8 +598,9 @@ bool ComicApplet::showComicIdentifier() const
void ComicApplet::setShowComicIdentifier(bool show) void ComicApplet::setShowComicIdentifier(bool show)
{ {
if (show == mShowComicIdentifier) if (show == mShowComicIdentifier) {
return; return;
}
mShowComicIdentifier = show; mShowComicIdentifier = show;
...@@ -610,8 +614,9 @@ bool ComicApplet::showErrorPicture() const ...@@ -610,8 +614,9 @@ bool ComicApplet::showErrorPicture() const
void ComicApplet::setShowErrorPicture(bool show) void ComicApplet::setShowErrorPicture(bool show)
{ {
if (show == mShowErrorPicture) if (show == mShowErrorPicture) {
return; return;
}
mShowErrorPicture = show; mShowErrorPicture = show;
...@@ -625,8 +630,9 @@ bool ComicApplet::arrowsOnHover() const ...@@ -625,8 +630,9 @@ bool ComicApplet::arrowsOnHover() const
void ComicApplet::setArrowsOnHover(bool show) void ComicApplet::setArrowsOnHover(bool show)
{ {
if (show == mArrowsOnHover) if (show == mArrowsOnHover) {
return; return;
}
mArrowsOnHover = show; mArrowsOnHover = show;
...@@ -640,8 +646,9 @@ bool ComicApplet::middleClick() const ...@@ -640,8 +646,9 @@ bool ComicApplet::middleClick() const
void ComicApplet::setMiddleClick(bool show) void ComicApplet::setMiddleClick(bool show)
{ {
if (show == mMiddleClick) if (show == mMiddleClick) {
return; return;
}
mMiddleClick = show; mMiddleClick = show;
...@@ -706,8 +713,9 @@ bool ComicApplet::showActualSize() const ...@@ -706,8 +713,9 @@ bool ComicApplet::showActualSize() const
void ComicApplet::setShowActualSize(bool show) void ComicApplet::setShowActualSize(bool show)
{ {
if (show == mCurrent.scaleComic()) if (show == mCurrent.scaleComic()) {
return; return;
}
mCurrent.setScaleComic(show); mCurrent.setScaleComic(show);
......
...@@ -36,8 +36,9 @@ QVariant DictionariesModel::data(const QModelIndex &index, int role) const ...@@ -36,8 +36,9 @@ QVariant DictionariesModel::data(const QModelIndex &index, int role) const
int DictionariesModel::rowCount(const QModelIndex &index) const int DictionariesModel::rowCount(const QModelIndex &index) const
{ {
if (index.isValid()) if (index.isValid()) {
return 0; // flat model return 0; // flat model
}
return m_availableDicts.size(); return m_availableDicts.size();
} }
......
...@@ -53,8 +53,9 @@ QPixmap FifteenImageProvider::requestPixmap(const QString &id, QSize *size, cons ...@@ -53,8 +53,9 @@ QPixmap FifteenImageProvider::requestPixmap(const QString &id, QSize *size, cons
update = true; update = true;
} }
if (update) if (update) {
updatePixmaps(); updatePixmaps();
}
int number = idParts.at(1).toInt(); int number = idParts.at(1).toInt();
......
...@@ -33,14 +33,16 @@ void DocumentHandler::setTarget(QQuickItem *target) ...@@ -33,14 +33,16 @@ void DocumentHandler::setTarget(QQuickItem *target)
{ {
m_doc = nullptr; m_doc = nullptr;
m_target = target; m_target = target;
if (!m_target) if (!m_target) {
return; return;
}
QVariant doc = m_target->property("textDocument"); QVariant doc = m_target->property("textDocument");
if (doc.canConvert<QQuickTextDocument *>()) { if (doc.canConvert<QQuickTextDocument *>()) {
QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument *>(); QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument *>();
if (qqdoc) if (qqdoc) {
m_doc = qqdoc->textDocument(); m_doc = qqdoc->textDocument();
}
} }
emit targetChanged(); emit targetChanged();
} }
...@@ -61,16 +63,19 @@ void DocumentHandler::setDocumentTitle(QString arg) ...@@ -61,16 +63,19 @@ void DocumentHandler::setDocumentTitle(QString arg)
void DocumentHandler::pasteWithoutFormatting() void DocumentHandler::pasteWithoutFormatting()
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return; return;
}
QClipboard *clipboard = QGuiApplication::clipboard(); QClipboard *clipboard = QGuiApplication::clipboard();
if (!clipboard) if (!clipboard) {
return; return;
}
const QMimeData *mimeData = clipboard->mimeData(); const QMimeData *mimeData = clipboard->mimeData();
if (!mimeData) if (!mimeData) {
return; return;
}
QString content = mimeData->text(); QString content = mimeData->text();
cursor.insertText(content, QTextCharFormat()); cursor.insertText(content, QTextCharFormat());
...@@ -91,8 +96,9 @@ QString DocumentHandler::text() const ...@@ -91,8 +96,9 @@ QString DocumentHandler::text() const
void DocumentHandler::setCursorPosition(int position) void DocumentHandler::setCursorPosition(int position)
{ {
if (position == m_cursorPosition) if (position == m_cursorPosition) {
return; return;
}
m_cursorPosition = position; m_cursorPosition = position;
...@@ -129,8 +135,9 @@ QTextCursor DocumentHandler::textCursor() const ...@@ -129,8 +135,9 @@ QTextCursor DocumentHandler::textCursor() const
void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format) void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (!cursor.hasSelection()) if (!cursor.hasSelection()) {
cursor.select(QTextCursor::WordUnderCursor); cursor.select(QTextCursor::WordUnderCursor);
}
cursor.mergeCharFormat(format); cursor.mergeCharFormat(format);
} }
...@@ -158,40 +165,45 @@ void DocumentHandler::setAlignment(Qt::Alignment a) ...@@ -158,40 +165,45 @@ void DocumentHandler::setAlignment(Qt::Alignment a)
Qt::Alignment DocumentHandler::alignment() const Qt::Alignment DocumentHandler::alignment() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return Qt::AlignLeft; return Qt::AlignLeft;
}
return textCursor().blockFormat().alignment(); return textCursor().blockFormat().alignment();
} }
bool DocumentHandler::bold() const bool DocumentHandler::bold() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return false; return false;
}
return textCursor().charFormat().fontWeight() == QFont::Bold; return textCursor().charFormat().fontWeight() == QFont::Bold;
} }
bool DocumentHandler::italic() const bool DocumentHandler::italic() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return false; return false;
}
return textCursor().charFormat().fontItalic(); return textCursor().charFormat().fontItalic();
} }
bool DocumentHandler::underline() const bool DocumentHandler::underline() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return false; return false;
}
return textCursor().charFormat().fontUnderline(); return textCursor().charFormat().fontUnderline();
} }
bool DocumentHandler::strikeOut() const bool DocumentHandler::strikeOut() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return false; return false;
}
return textCursor().charFormat().fontStrikeOut(); return textCursor().charFormat().fontStrikeOut();
} }
...@@ -230,8 +242,9 @@ void DocumentHandler::setStrikeOut(bool arg) ...@@ -230,8 +242,9 @@ void DocumentHandler::setStrikeOut(bool arg)
int DocumentHandler::fontSize() const int DocumentHandler::fontSize() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return 0; return 0;
}
QTextCharFormat format = cursor.charFormat(); QTextCharFormat format = cursor.charFormat();
return format.font().pointSize(); return format.font().pointSize();
} }
...@@ -239,8 +252,9 @@ int DocumentHandler::fontSize() const ...@@ -239,8 +252,9 @@ int DocumentHandler::fontSize() const
void DocumentHandler::setFontSize(int arg) void DocumentHandler::setFontSize(int arg)
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return; return;
}
QTextCharFormat format; QTextCharFormat format;
format.setFontPointSize(arg); format.setFontPointSize(arg);
mergeFormatOnWordOrSelection(format); mergeFormatOnWordOrSelection(format);
...@@ -250,8 +264,9 @@ void DocumentHandler::setFontSize(int arg) ...@@ -250,8 +264,9 @@ void DocumentHandler::setFontSize(int arg)
QColor DocumentHandler::textColor() const QColor DocumentHandler::textColor() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return QColor(Qt::black); return QColor(Qt::black);
}
QTextCharFormat format = cursor.charFormat(); QTextCharFormat format = cursor.charFormat();
return format.foreground().color(); return format.foreground().color();
} }
...@@ -259,8 +274,9 @@ QColor DocumentHandler::textColor() const ...@@ -259,8 +274,9 @@ QColor DocumentHandler::textColor() const
void DocumentHandler::setTextColor(const QColor &c) void DocumentHandler::setTextColor(const QColor &c)
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return; return;
}
QTextCharFormat format; QTextCharFormat format;
format.setForeground(QBrush(c)); format.setForeground(QBrush(c));
mergeFormatOnWordOrSelection(format); mergeFormatOnWordOrSelection(format);
...@@ -270,8 +286,9 @@ void DocumentHandler::setTextColor(const QColor &c) ...@@ -270,8 +286,9 @@ void DocumentHandler::setTextColor(const QColor &c)
QString DocumentHandler::fontFamily() const QString DocumentHandler::fontFamily() const
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return QString(); return QString();
}
QTextCharFormat format = cursor.charFormat(); QTextCharFormat format = cursor.charFormat();
return format.font().family(); return format.font().family();
} }
...@@ -279,8 +296,9 @@ QString DocumentHandler::fontFamily() const ...@@ -279,8 +296,9 @@ QString DocumentHandler::fontFamily() const
void DocumentHandler::setFontFamily(const QString &arg) void DocumentHandler::setFontFamily(const QString &arg)
{ {
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
if (cursor.isNull()) if (cursor.isNull()) {
return; return;
}
QTextCharFormat format; QTextCharFormat format;
format.setFontFamily(arg); format.setFontFamily(arg);
mergeFormatOnWordOrSelection(format); mergeFormatOnWordOrSelection(format);
......
...@@ -41,8 +41,9 @@ ComicProvider::IdentifierType CachedProvider::identifierType() const ...@@ -41,8 +41,9 @@ ComicProvider::IdentifierType CachedProvider::identifierType() const
QImage CachedProvider::image() const QImage CachedProvider::image() const
{ {
if (!QFile::exists(identifierToPath(requestedString()))) if (!QFile::exists(identifierToPath(requestedString()))) {
return QImage(); return QImage();
}
QImage img; QImage img;
img.load(identifierToPath(requestedString()), "PNG"); img.load(identifierToPath(requestedString()), "PNG");
......
...@@ -136,8 +136,9 @@ bool ComicEngine::updateSourceEvent(const QString &identifier) ...@@ -136,8 +136,9 @@ bool ComicEngine::updateSourceEvent(const QString &identifier)
const QString type = pkg.metadata().value(QStringLiteral("X-KDE-PlasmaComicProvider-SuffixType")); const QString type = pkg.metadata().value(QStringLiteral("X-KDE-PlasmaComicProvider-SuffixType"));
if (type == QLatin1String("Date")) { if (type == QLatin1String("Date")) {
QDate date = QDate::fromString(parts[1], Qt::ISODate); QDate date = QDate::fromString(parts[1], Qt::ISODate);
if (!date.isValid()) if (!date.isValid()) {
date = QDate::currentDate(); date = QDate::currentDate();
}
args << QLatin1String("Date") << date; args << QLatin1String("Date") << date;
} else if (type == QLatin1String("Number")) { } else if (type == QLatin1String("Number")) {
...@@ -247,8 +248,9 @@ void ComicEngine::error(ComicProvider *provider) ...@@ -247,8 +248,9 @@ void ComicEngine::error(ComicProvider *provider)
* set initially, so we have to remove the 'faked' suffix * set initially, so we have to remove the 'faked' suffix
* here again to not confuse the applet. * here again to not confuse the applet.
*/ */
if (provider->isCurrent()) if (provider->isCurrent()) {
identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1); identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1);
}
setData(identifier, QLatin1String("Identifier"), identifier); setData(identifier, QLatin1String("Identifier"), identifier);
setData(identifier, QLatin1String("Error"), true); setData(identifier, QLatin1String("Error"), true);
...@@ -278,8 +280,9 @@ void ComicEngine::setComicData(ComicProvider *provider) ...@@ -278,8 +280,9 @@ void ComicEngine::setComicData(ComicProvider *provider)
* set initially, so we have to remove the 'faked' suffix * set initially, so we have to remove the 'faked' suffix
* here again to not confuse the applet. * here again to not confuse the applet.
*/ */
if (provider->isCurrent()) if (provider->isCurrent()) {
identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1); identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1);
}
setData(identifier, QLatin1String("Image"), provider->image()); setData(identifier, QLatin1String("Image"), provider->image());
setData(identifier, QLatin1String("Website Url"), provider->websiteUrl()); setData(identifier, QLatin1String("Website Url"), provider->websiteUrl());
......
...@@ -86,11 +86,11 @@ ComicProvider::ComicProvider(QObject *parent, const QVariantList &args) ...@@ -86,11 +86,11 @@ ComicProvider::ComicProvider(QObject *parent, const QVariantList &args)
Q_ASSERT(args.count() >= 2); Q_ASSERT(args.count() >= 2);
const QString type = args[0].toString(); const QString type = args[0].toString();
if (type == QLatin1String("Date")) if (type == QLatin1String("Date")) {
d->mRequestedDate = args[1].toDate(); d->mRequestedDate = args[1].toDate();
else if (type == QLatin1String("Number")) } else if (type == QLatin1String("Number")) {
d->mRequestedNumber = args[1].toInt(); d->mRequestedNumber = args[1].toInt();
else if (type == QLatin1String("String")) { } else if (type == QLatin1String("String")) {
d->mRequestedId = args[1].toString(); d->mRequestedId = args[1].toString();
int index = d->mRequestedId.indexOf(QLatin1Char(':')); int index = d->mRequestedId.indexOf(QLatin1Char(':'));
...@@ -113,16 +113,18 @@ ComicProvider::~ComicProvider() ...@@ -113,16 +113,18 @@ ComicProvider::~ComicProvider()
QString ComicProvider::nextIdentifier() const QString ComicProvider::nextIdentifier() const
{ {
if (identifierType() == DateIdentifier && d->mRequestedDate != QDate::currentDate()) if (identifierType() == DateIdentifier && d->mRequestedDate != QDate::currentDate()) {
return d->mRequestedDate.addDays(1).toString(Qt::ISODate); return d->mRequestedDate.addDays(1).toString(Qt::ISODate);
}
return QString(); return QString();
} }
QString ComicProvider::previousIdentifier() const QString ComicProvider::previousIdentifier() const
{ {
if ((identifierType() == DateIdentifier) && (!firstStripDate().isValid() || d->mRequestedDate > firstStripDate())) if ((identifierType() == DateIdentifier) && (!firstStripDate().isValid() || d->mRequestedDate > firstStripDate())) {
return d->mRequestedDate.addDays(-1).toString(Qt::ISODate); return d->mRequestedDate.addDays(-1).toString(Qt::ISODate);
}
return QString(); return QString();
} }
......
...@@ -41,8 +41,9 @@ QString DictionaryMatchEngine::lookupWord(const QString &word) ...@@ -41,8 +41,9 @@ QString DictionaryMatchEngine::lookupWord(const QString &word)
QMetaObject::invokeMethod(this, "sourceAdded", Qt::QueuedConnection, Q_ARG(const QString &, word)); QMetaObject::invokeMethod(this, "sourceAdded", Qt::QueuedConnection, Q_ARG(const QString &, word));
QMutexLocker locker(&data.mutex); QMutexLocker locker(&data.mutex);
if (!data.waitCondition.wait(&data.mutex, QDeadlineTimer(30 * 1000))) // Timeout after 30 seconds if (!data.waitCondition.wait(&data.mutex, QDeadlineTimer(30 * 1000))) { // Timeout after 30 seconds
qDebug() << "The dictionary data engine timed out (word:" << word << ")"; qDebug() << "The dictionary data engine timed out (word:" << word << ")";
}
locker.unlock(); locker.unlock();
QMetaObject::invokeMethod(this, "sourceRemoved", Qt::QueuedConnection, Q_ARG(const QString &, word)); QMetaObject::invokeMethod(this, "sourceRemoved", Qt::QueuedConnection, Q_ARG(const QString &, word));
...@@ -70,8 +71,9 @@ void DictionaryMatchEngine::sourceRemoved(const QString &source) ...@@ -70,8 +71,9 @@ void DictionaryMatchEngine::sourceRemoved(const QString &source)
void DictionaryMatchEngine::dataUpdated(const QString &source, const Plasma::DataEngine::Data &result) void DictionaryMatchEngine::dataUpdated(const QString &source, const Plasma::DataEngine::Data &result)
{ {
if (!result.contains(QLatin1String("text"))) if (!result.contains(QLatin1String("text"))) {
return; return;
}
QString definition(result[QLatin1String("text")].toString()); QString definition(result[QLatin1String("text")].toString());
......
...@@ -42,20 +42,24 @@ void DictionaryRunner::reloadConfiguration() ...@@ -42,20 +42,24 @@ void DictionaryRunner::reloadConfiguration()
void DictionaryRunner::match(Plasma::RunnerContext &context) void DictionaryRunner::match(Plasma::RunnerContext &context)
{ {
QString query = context.query(); QString query = context.query();
if (query.startsWith(m_triggerWord, Qt::CaseInsensitive)) if (query.startsWith(m_triggerWord, Qt::CaseInsensitive)) {
query.remove(0, m_triggerWord.length()); query.remove(0, m_triggerWord.length());
if (query.isEmpty()) }
if (query.isEmpty()) {
return; return;
}
QString returnedQuery = m_engine->lookupWord(query); QString returnedQuery = m_engine->lookupWord(query);
static const QRegExp removeHtml(QLatin1String("<[^>]*>")); static const QRegExp removeHtml(QLatin1String("<[^>]*>"));
QString definitions(returnedQuery); QString definitions(returnedQuery);