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

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
void ComicApplet::setShowComicUrl(bool show)
{
if (show == mShowComicUrl)
if (show == mShowComicUrl) {
return;
}
mShowComicUrl = show;
......@@ -565,8 +566,9 @@ bool ComicApplet::showComicAuthor() const
void ComicApplet::setShowComicAuthor(bool show)
{
if (show == mShowComicAuthor)
if (show == mShowComicAuthor) {
return;
}
mShowComicAuthor = show;
......@@ -580,8 +582,9 @@ bool ComicApplet::showComicTitle() const
void ComicApplet::setShowComicTitle(bool show)
{
if (show == mShowComicTitle)
if (show == mShowComicTitle) {
return;
}
mShowComicTitle = show;
......@@ -595,8 +598,9 @@ bool ComicApplet::showComicIdentifier() const
void ComicApplet::setShowComicIdentifier(bool show)
{
if (show == mShowComicIdentifier)
if (show == mShowComicIdentifier) {
return;
}
mShowComicIdentifier = show;
......@@ -610,8 +614,9 @@ bool ComicApplet::showErrorPicture() const
void ComicApplet::setShowErrorPicture(bool show)
{
if (show == mShowErrorPicture)
if (show == mShowErrorPicture) {
return;
}
mShowErrorPicture = show;
......@@ -625,8 +630,9 @@ bool ComicApplet::arrowsOnHover() const
void ComicApplet::setArrowsOnHover(bool show)
{
if (show == mArrowsOnHover)
if (show == mArrowsOnHover) {
return;
}
mArrowsOnHover = show;
......@@ -640,8 +646,9 @@ bool ComicApplet::middleClick() const
void ComicApplet::setMiddleClick(bool show)
{
if (show == mMiddleClick)
if (show == mMiddleClick) {
return;
}
mMiddleClick = show;
......@@ -706,8 +713,9 @@ bool ComicApplet::showActualSize() const
void ComicApplet::setShowActualSize(bool show)
{
if (show == mCurrent.scaleComic())
if (show == mCurrent.scaleComic()) {
return;
}
mCurrent.setScaleComic(show);
......
......@@ -36,8 +36,9 @@ QVariant DictionariesModel::data(const QModelIndex &index, int role) const
int DictionariesModel::rowCount(const QModelIndex &index) const
{
if (index.isValid())
if (index.isValid()) {
return 0; // flat model
}
return m_availableDicts.size();
}
......
......@@ -53,8 +53,9 @@ QPixmap FifteenImageProvider::requestPixmap(const QString &id, QSize *size, cons
update = true;
}
if (update)
if (update) {
updatePixmaps();
}
int number = idParts.at(1).toInt();
......
......@@ -33,14 +33,16 @@ void DocumentHandler::setTarget(QQuickItem *target)
{
m_doc = nullptr;
m_target = target;
if (!m_target)
if (!m_target) {
return;
}
QVariant doc = m_target->property("textDocument");
if (doc.canConvert<QQuickTextDocument *>()) {
QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument *>();
if (qqdoc)
if (qqdoc) {
m_doc = qqdoc->textDocument();
}
}
emit targetChanged();
}
......@@ -61,16 +63,19 @@ void DocumentHandler::setDocumentTitle(QString arg)
void DocumentHandler::pasteWithoutFormatting()
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return;
}
QClipboard *clipboard = QGuiApplication::clipboard();
if (!clipboard)
if (!clipboard) {
return;
}
const QMimeData *mimeData = clipboard->mimeData();
if (!mimeData)
if (!mimeData) {
return;
}
QString content = mimeData->text();
cursor.insertText(content, QTextCharFormat());
......@@ -91,8 +96,9 @@ QString DocumentHandler::text() const
void DocumentHandler::setCursorPosition(int position)
{
if (position == m_cursorPosition)
if (position == m_cursorPosition) {
return;
}
m_cursorPosition = position;
......@@ -129,8 +135,9 @@ QTextCursor DocumentHandler::textCursor() const
void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{
QTextCursor cursor = textCursor();
if (!cursor.hasSelection())
if (!cursor.hasSelection()) {
cursor.select(QTextCursor::WordUnderCursor);
}
cursor.mergeCharFormat(format);
}
......@@ -158,40 +165,45 @@ void DocumentHandler::setAlignment(Qt::Alignment a)
Qt::Alignment DocumentHandler::alignment() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return Qt::AlignLeft;
}
return textCursor().blockFormat().alignment();
}
bool DocumentHandler::bold() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return false;
}
return textCursor().charFormat().fontWeight() == QFont::Bold;
}
bool DocumentHandler::italic() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return false;
}
return textCursor().charFormat().fontItalic();
}
bool DocumentHandler::underline() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return false;
}
return textCursor().charFormat().fontUnderline();
}
bool DocumentHandler::strikeOut() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return false;
}
return textCursor().charFormat().fontStrikeOut();
}
......@@ -230,8 +242,9 @@ void DocumentHandler::setStrikeOut(bool arg)
int DocumentHandler::fontSize() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return 0;
}
QTextCharFormat format = cursor.charFormat();
return format.font().pointSize();
}
......@@ -239,8 +252,9 @@ int DocumentHandler::fontSize() const
void DocumentHandler::setFontSize(int arg)
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return;
}
QTextCharFormat format;
format.setFontPointSize(arg);
mergeFormatOnWordOrSelection(format);
......@@ -250,8 +264,9 @@ void DocumentHandler::setFontSize(int arg)
QColor DocumentHandler::textColor() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return QColor(Qt::black);
}
QTextCharFormat format = cursor.charFormat();
return format.foreground().color();
}
......@@ -259,8 +274,9 @@ QColor DocumentHandler::textColor() const
void DocumentHandler::setTextColor(const QColor &c)
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return;
}
QTextCharFormat format;
format.setForeground(QBrush(c));
mergeFormatOnWordOrSelection(format);
......@@ -270,8 +286,9 @@ void DocumentHandler::setTextColor(const QColor &c)
QString DocumentHandler::fontFamily() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return QString();
}
QTextCharFormat format = cursor.charFormat();
return format.font().family();
}
......@@ -279,8 +296,9 @@ QString DocumentHandler::fontFamily() const
void DocumentHandler::setFontFamily(const QString &arg)
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
if (cursor.isNull()) {
return;
}
QTextCharFormat format;
format.setFontFamily(arg);
mergeFormatOnWordOrSelection(format);
......
......@@ -41,8 +41,9 @@ ComicProvider::IdentifierType CachedProvider::identifierType() const
QImage CachedProvider::image() const
{
if (!QFile::exists(identifierToPath(requestedString())))
if (!QFile::exists(identifierToPath(requestedString()))) {
return QImage();
}
QImage img;
img.load(identifierToPath(requestedString()), "PNG");
......
......@@ -136,8 +136,9 @@ bool ComicEngine::updateSourceEvent(const QString &identifier)
const QString type = pkg.metadata().value(QStringLiteral("X-KDE-PlasmaComicProvider-SuffixType"));
if (type == QLatin1String("Date")) {
QDate date = QDate::fromString(parts[1], Qt::ISODate);
if (!date.isValid())
if (!date.isValid()) {
date = QDate::currentDate();
}
args << QLatin1String("Date") << date;
} else if (type == QLatin1String("Number")) {
......@@ -247,8 +248,9 @@ void ComicEngine::error(ComicProvider *provider)
* set initially, so we have to remove the 'faked' suffix
* here again to not confuse the applet.
*/
if (provider->isCurrent())
if (provider->isCurrent()) {
identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1);
}
setData(identifier, QLatin1String("Identifier"), identifier);
setData(identifier, QLatin1String("Error"), true);
......@@ -278,8 +280,9 @@ void ComicEngine::setComicData(ComicProvider *provider)
* set initially, so we have to remove the 'faked' suffix
* here again to not confuse the applet.
*/
if (provider->isCurrent())
if (provider->isCurrent()) {
identifier = identifier.left(identifier.indexOf(QLatin1Char(':')) + 1);
}
setData(identifier, QLatin1String("Image"), provider->image());
setData(identifier, QLatin1String("Website Url"), provider->websiteUrl());
......
......@@ -86,11 +86,11 @@ ComicProvider::ComicProvider(QObject *parent, const QVariantList &args)
Q_ASSERT(args.count() >= 2);
const QString type = args[0].toString();
if (type == QLatin1String("Date"))
if (type == QLatin1String("Date")) {
d->mRequestedDate = args[1].toDate();
else if (type == QLatin1String("Number"))
} else if (type == QLatin1String("Number")) {
d->mRequestedNumber = args[1].toInt();
else if (type == QLatin1String("String")) {
} else if (type == QLatin1String("String")) {
d->mRequestedId = args[1].toString();
int index = d->mRequestedId.indexOf(QLatin1Char(':'));
......@@ -113,16 +113,18 @@ ComicProvider::~ComicProvider()
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 QString();
}
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 QString();
}
......
......@@ -41,8 +41,9 @@ QString DictionaryMatchEngine::lookupWord(const QString &word)
QMetaObject::invokeMethod(this, "sourceAdded", Qt::QueuedConnection, Q_ARG(const QString &, word));
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 << ")";
}
locker.unlock();
QMetaObject::invokeMethod(this, "sourceRemoved", Qt::QueuedConnection, Q_ARG(const QString &, word));
......@@ -70,8 +71,9 @@ void DictionaryMatchEngine::sourceRemoved(const QString &source)
void DictionaryMatchEngine::dataUpdated(const QString &source, const Plasma::DataEngine::Data &result)
{
if (!result.contains(QLatin1String("text")))
if (!result.contains(QLatin1String("text"))) {
return;
}
QString definition(result[QLatin1String("text")].toString());
......
......@@ -42,20 +42,24 @@ void DictionaryRunner::reloadConfiguration()
void DictionaryRunner::match(Plasma::RunnerContext &context)
{
QString query = context.query();
if (query.startsWith(m_triggerWord, Qt::CaseInsensitive))
if (query.startsWith(m_triggerWord, Qt::CaseInsensitive)) {
query.remove(0, m_triggerWord.length());
if (query.isEmpty())
}
if (query.isEmpty()) {
return;
}
QString returnedQuery = m_engine->lookupWord(query);
static const QRegExp removeHtml(QLatin1String("<[^>]*>"));
QString definitions(returnedQuery);
definitions.remove(QLatin1Char('\r')).remove(removeHtml);
while (definitions.contains(QLatin1String(" ")))
while (definitions.contains(QLatin1String(" "))) {
definitions.replace(QLatin1String(" "), QLatin1String(" "));
}
QStringList lines = definitions.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
if (lines.length() < 2)
if (lines.length() < 2) {
return;
}
lines.removeFirst();
QList<Plasma::QueryMatch> matches;
......@@ -63,10 +67,12 @@ void DictionaryRunner::match(Plasma::RunnerContext &context)
static const QRegExp partOfSpeech(QLatin1String("(?: ([a-z]{1,5})){0,1} [0-9]{1,2}: (.*)"));
QString lastPartOfSpeech;
foreach (const QString &line, lines) {
if (partOfSpeech.indexIn(line) == -1)
if (partOfSpeech.indexIn(line) == -1) {
continue;
if (!partOfSpeech.cap(1).isEmpty())
}
if (!partOfSpeech.cap(1).isEmpty()) {
lastPartOfSpeech = partOfSpeech.cap(1);
}
Plasma::QueryMatch match(this);
match.setText(query + QLatin1String(": ") + lastPartOfSpeech);
match.setRelevance(1 - (static_cast<double>(++item) / static_cast<double>(lines.length())));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment