Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 97dbd42e authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent c775ce3a
......@@ -96,7 +96,6 @@ void RichTextComposerControlerTest::shouldHaveDefaultValue()
QVERIFY(!controler.richTextComposer()->acceptRichText());
}
void RichTextComposerControlerTest::shouldBoldText()
{
KPIMTextEdit::RichTextComposer composer;
......@@ -291,7 +290,6 @@ void RichTextComposerControlerTest::shouldAddQuote_data()
// QTest::newRow("removequote1") << QStringLiteral(">foo\n>bla\n>blo\n") << QStringLiteral("QT>foo\nQT>bla\nQT>blo\n") << QStringLiteral("QT");
// QTest::newRow("removequote2") << QStringLiteral("QTfoo\nQTbla\n>blo\n") << QStringLiteral("QTQTfoo\nQTQTbla\n>QTblo\n") << QStringLiteral("QT");
// QTest::newRow("removequote3") << QStringLiteral("|foo\n|bla\n>blo\n") << QStringLiteral("||foo\n||bla\n|>blo\n") << QStringLiteral("|");
}
void RichTextComposerControlerTest::shouldAddQuote()
......@@ -312,5 +310,4 @@ void RichTextComposerControlerTest::shouldAddQuote()
// QCOMPARE(composer.toPlainText(), QString(output + QChar::ParagraphSeparator));
}
QTEST_MAIN(RichTextComposerControlerTest)
......@@ -50,7 +50,6 @@ RichTextComposerTest::RichTextComposerTest(QObject *parent)
RichTextComposerTest::~RichTextComposerTest()
{
}
void RichTextComposerTest::testFormattingUsed()
......@@ -472,12 +471,16 @@ void RichTextComposerTest::testWrappedPlainText_data()
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("output");
QString defaultStr = QStringLiteral("http://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\n https://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\ntest ftp://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\nftps://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\n ldap://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test");
QString defaultStr = QStringLiteral(
"http://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\n https://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\ntest ftp://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\nftps://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test\n ldap://example.org/test-test-test-test-test-test-test-test-test-test-test-test-test");
QTest::newRow("default") << defaultStr << defaultStr;
QTest::newRow("empty") << QString() << QString();
QTest::newRow("wrap") << QStringLiteral("foosdfsdf sdsf sdfsdfsfs fsf sdfs df sfsdf dsf sdfsdf sf sf sfsdf sdsdf") << QStringLiteral("foosdfsdf sdsf sdfsdfsfs fsf sdfs df sfsdf \ndsf sdfsdf sf sf sfsdf sdsdf");
QTest::newRow("wrap-2") << QStringLiteral("test-test-test-test-test-test-test-test-test-test-test-test-test") << QStringLiteral("test-test-test-test-test-test-test-test-test-\ntest-test-test-test");
QTest::newRow("wrap-3") << QStringLiteral("test-test-test-test-test-test-test-test-test-test-test-test-test\n\n") << QStringLiteral("test-test-test-test-test-test-test-test-test-\ntest-test-test-test\n\n");
QTest::newRow("wrap") << QStringLiteral("foosdfsdf sdsf sdfsdfsfs fsf sdfs df sfsdf dsf sdfsdf sf sf sfsdf sdsdf") << QStringLiteral(
"foosdfsdf sdsf sdfsdfsfs fsf sdfs df sfsdf \ndsf sdfsdf sf sf sfsdf sdsdf");
QTest::newRow("wrap-2") << QStringLiteral("test-test-test-test-test-test-test-test-test-test-test-test-test")
<< QStringLiteral("test-test-test-test-test-test-test-test-test-\ntest-test-test-test");
QTest::newRow("wrap-3") << QStringLiteral("test-test-test-test-test-test-test-test-test-test-test-test-test\n\n") << QStringLiteral(
"test-test-test-test-test-test-test-test-test-\ntest-test-test-test\n\n");
}
void RichTextComposerTest::testWrappedPlainText()
......
......@@ -38,7 +38,8 @@ struct SpellCheckRange
SpellCheckRange(int o, int l)
: offset(o)
, length(l)
{}
{
}
int end() const
{
......@@ -110,8 +111,9 @@ void PlainTextSyntaxSpellCheckingHighlighter::setDefinition(const KSyntaxHighlig
{
const auto needsRehighlight = definition() != def;
AbstractHighlighter::setDefinition(def);
if (needsRehighlight)
if (needsRehighlight) {
rehighlight();
}
}
void PlainTextSyntaxSpellCheckingHighlighter::highlightBlock(const QString &text)
......@@ -135,13 +137,15 @@ void PlainTextSyntaxSpellCheckingHighlighter::highlightBlock(const QString &text
return;
}
if (d->blockState.value(currentBlockState()) == state)
if (d->blockState.value(currentBlockState()) == state) {
return;
}
d->blockState.insert(currentBlockState(), state);
const auto nextBlock = currentBlock().next();
if (nextBlock.isValid())
if (nextBlock.isValid()) {
QMetaObject::invokeMethod(this, "rehighlightBlock", Qt::QueuedConnection, Q_ARG(QTextBlock, nextBlock));
}
}
void PlainTextSyntaxSpellCheckingHighlighter::unsetMisspelled(int start, int count)
......@@ -168,31 +172,39 @@ void PlainTextSyntaxSpellCheckingHighlighter::setMisspelled(int start, int count
void PlainTextSyntaxSpellCheckingHighlighter::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format)
{
if (format.spellCheck() && length > 0) {
if (d->spellCheckRanges.empty())
if (d->spellCheckRanges.empty()) {
d->spellCheckRanges.push_back({offset, length});
else if (d->spellCheckRanges.back().end() + 1 == offset)
} else if (d->spellCheckRanges.back().end() + 1 == offset) {
d->spellCheckRanges.back().length += length;
else
} else {
d->spellCheckRanges.push_back({offset, length});
}
}
if (format.isDefaultTextStyle(theme()) || length == 0)
if (format.isDefaultTextStyle(theme()) || length == 0) {
return;
}
QTextCharFormat tf;
if (format.hasTextColor(theme()))
if (format.hasTextColor(theme())) {
tf.setForeground(format.textColor(theme()));
if (format.hasBackgroundColor(theme()))
}
if (format.hasBackgroundColor(theme())) {
tf.setBackground(format.backgroundColor(theme()));
}
if (format.isBold(theme()))
if (format.isBold(theme())) {
tf.setFontWeight(QFont::Bold);
if (format.isItalic(theme()))
}
if (format.isItalic(theme())) {
tf.setFontItalic(true);
if (format.isUnderline(theme()))
}
if (format.isUnderline(theme())) {
tf.setFontUnderline(true);
if (format.isStrikeThrough(theme()))
}
if (format.isStrikeThrough(theme())) {
tf.setFontStrikeOut(true);
}
QSyntaxHighlighter::setFormat(offset, length, tf);
}
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