Commit b152c6ee authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent 0442edd8
......@@ -6,8 +6,8 @@
#include "editorutiltest.h"
#include "../src/editorutil.h"
#include <QTextDocument>
#include <QTest>
#include <QTextDocument>
EditorUtilTest::EditorUtilTest(QObject *parent)
: QObject(parent)
......@@ -24,9 +24,9 @@ void EditorUtilTest::testUpperCase_data()
QTest::addColumn<QString>("result");
QTest::addColumn<int>("startcursorposition");
QTest::addColumn<int>("endcursorposition");
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("FOO") << 0 << 3;
QTest::newRow("onelinewithselectionuppercase") << QStringLiteral("FOO") << QStringLiteral("FOO") << 0 << 3;
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("FOO") << 0 << 3;
QTest::newRow("onelinewithselectionuppercase") << QStringLiteral("FOO") << QStringLiteral("FOO") << 0 << 3;
}
void EditorUtilTest::testUpperCase()
......@@ -54,9 +54,9 @@ void EditorUtilTest::testLowerCase_data()
QTest::addColumn<QString>("result");
QTest::addColumn<int>("startcursorposition");
QTest::addColumn<int>("endcursorposition");
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("foo") << 0 << 3;
QTest::newRow("onelinewithselectionuppercase") << QStringLiteral("FOO") << QStringLiteral("foo") << 0 << 3;
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("foo") << 0 << 3;
QTest::newRow("onelinewithselectionuppercase") << QStringLiteral("FOO") << QStringLiteral("foo") << 0 << 3;
}
void EditorUtilTest::testLowerCase()
......@@ -84,9 +84,9 @@ void EditorUtilTest::testSentenceCase_data()
QTest::addColumn<QString>("result");
QTest::addColumn<int>("startcursorposition");
QTest::addColumn<int>("endcursorposition");
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("Foo") << 0 << 3;
QTest::newRow("bigline") << QStringLiteral("foo bla foo.\nddd") << QStringLiteral("Foo bla foo.\nDdd") << 0 << 16;
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("Foo") << 0 << 3;
QTest::newRow("bigline") << QStringLiteral("foo bla foo.\nddd") << QStringLiteral("Foo bla foo.\nDdd") << 0 << 16;
}
void EditorUtilTest::testSentenceCase()
......@@ -114,10 +114,10 @@ void EditorUtilTest::testReverseCase_data()
QTest::addColumn<QString>("result");
QTest::addColumn<int>("startcursorposition");
QTest::addColumn<int>("endcursorposition");
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("FOO") << 0 << 3;
QTest::newRow("reverseCase") << QStringLiteral("fOo bla\tfOO") << QStringLiteral("FoO BLA\tFoo") << 0 << 12;
QTest::newRow("notallineselected") << QStringLiteral("fOo bla\tfOO") << QStringLiteral("FoO bla\tfOO") << 0 << 3;
QTest::newRow("onelinewithoutselection") << QStringLiteral("foo") << QStringLiteral("foo") << -1 << -1;
QTest::newRow("onelinewithselection") << QStringLiteral("foo") << QStringLiteral("FOO") << 0 << 3;
QTest::newRow("reverseCase") << QStringLiteral("fOo bla\tfOO") << QStringLiteral("FoO BLA\tFoo") << 0 << 12;
QTest::newRow("notallineselected") << QStringLiteral("fOo bla\tfOO") << QStringLiteral("FoO bla\tfOO") << 0 << 3;
}
void EditorUtilTest::testReverseCase()
......
......@@ -11,10 +11,10 @@ SPDX-License-Identifier: GPL-2.0-or-later
// Local
#include "kpimtextedit/slidecontainer.h"
#include <QSignalSpy>
#include <QTest>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QSignalSpy>
using namespace KPIMTextEdit;
......
......@@ -35,15 +35,17 @@ void TextUtilsTest::test_flowText_data()
QTest::addColumn<QString>("quotedString");
QTest::addColumn<QString>("indent");
QTest::newRow("Empty string ") << "" << "" << "";
QTest::newRow("Empty string ") << ""
<< ""
<< "";
QTest::newRow("Indent == Maxlenght ") << "A line"
<< ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>A\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>l\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>i\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>n\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>e"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>l\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>i\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>n\n"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>e"
<< ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
// 40
// ↓
......@@ -53,12 +55,12 @@ void TextUtilsTest::test_flowText_data()
QTest::newRow("Two non-wrapping lines") << "A long line that is right on the border.\n"
"A long line that is right on the border."
<< "A long line that is right on the border.\n"
"A long line that is right on the border."
"A long line that is right on the border."
<< "";
// 40
// ↓
QTest::newRow("Two wrapping lines") << "A long line that is right over the border"
<< "A long line that is right over the\n"
"border"
"border"
<< "";
}
......@@ -18,4 +18,4 @@ private Q_SLOTS:
void test_flowText();
};
#endif //TEXTUTILSTEST_H
#endif // TEXTUTILSTEST_H
......@@ -5,9 +5,9 @@
*/
#include "richtextcomposeractionstest.h"
#include "../richtextcomposercontroler.h"
#include "../richtextcomposeractions.h"
#include "../richtextcomposer.h"
#include "../richtextcomposeractions.h"
#include "../richtextcomposercontroler.h"
#include <KActionCollection>
#include <QAction>
#include <QTest>
......@@ -46,44 +46,22 @@ void RichTextComposerActionsTest::shouldHaveActions()
composerActions.createActions(actionCollection);
QStringList lst;
lst << QStringLiteral("format_align_left")
<< QStringLiteral("format_align_center")
<< QStringLiteral("format_align_right")
<< QStringLiteral("format_align_justify")
<< QStringLiteral("direction_ltr")
<< QStringLiteral("direction_rtl")
<< QStringLiteral("format_text_subscript")
<< QStringLiteral("format_text_superscript")
<< QStringLiteral("format_text_bold")
<< QStringLiteral("format_text_italic")
<< QStringLiteral("format_text_underline")
<< QStringLiteral("format_text_strikeout")
<< QStringLiteral("format_font_family")
<< QStringLiteral("format_font_size")
<< QStringLiteral("insert_horizontal_rule")
<< QStringLiteral("format_text_foreground_color")
<< QStringLiteral("format_text_background_color")
<< QStringLiteral("manage_link")
<< QStringLiteral("format_list_indent_less")
<< QStringLiteral("format_list_indent_more")
<< QStringLiteral("format_list_style")
<< QStringLiteral("add_image")
<< QStringLiteral("insert_html")
<< QStringLiteral("insert_table")
<< QStringLiteral("delete_line")
<< QStringLiteral("format_reset")
<< QStringLiteral("format_painter")
<< QStringLiteral("format_heading_level")
lst << QStringLiteral("format_align_left") << QStringLiteral("format_align_center") << QStringLiteral("format_align_right")
<< QStringLiteral("format_align_justify") << QStringLiteral("direction_ltr") << QStringLiteral("direction_rtl")
<< QStringLiteral("format_text_subscript") << QStringLiteral("format_text_superscript") << QStringLiteral("format_text_bold")
<< QStringLiteral("format_text_italic") << QStringLiteral("format_text_underline") << QStringLiteral("format_text_strikeout")
<< QStringLiteral("format_font_family") << QStringLiteral("format_font_size") << QStringLiteral("insert_horizontal_rule")
<< QStringLiteral("format_text_foreground_color") << QStringLiteral("format_text_background_color") << QStringLiteral("manage_link")
<< QStringLiteral("format_list_indent_less") << QStringLiteral("format_list_indent_more") << QStringLiteral("format_list_style")
<< QStringLiteral("add_image") << QStringLiteral("insert_html") << QStringLiteral("insert_table") << QStringLiteral("delete_line")
<< QStringLiteral("format_reset") << QStringLiteral("format_painter") << QStringLiteral("format_heading_level")
<< QStringLiteral("format_list_checkbox");
QStringList actionNoRichText;
actionNoRichText << QStringLiteral("paste_quoted")
<< QStringLiteral("tools_quote")
<< QStringLiteral("tools_unquote")
<< QStringLiteral("add_emoticon")
actionNoRichText << QStringLiteral("paste_quoted") << QStringLiteral("tools_quote") << QStringLiteral("tools_unquote") << QStringLiteral("add_emoticon")
<< QStringLiteral("paste_without_formatting");
//QCOMPARE(lst.count(), composerActions.numberOfActions());
// QCOMPARE(lst.count(), composerActions.numberOfActions());
for (QAction *act : actionCollection->actions()) {
const QString actionName = act->objectName();
if (!actionNoRichText.contains(actionName)) {
......@@ -106,10 +84,7 @@ void RichTextComposerActionsTest::shouldChangeEnableState()
composerActions.createActions(actionCollection);
QStringList actionNoRichText;
actionNoRichText << QStringLiteral("paste_quoted")
<< QStringLiteral("tools_quote")
<< QStringLiteral("tools_unquote")
<< QStringLiteral("add_emoticon")
actionNoRichText << QStringLiteral("paste_quoted") << QStringLiteral("tools_quote") << QStringLiteral("tools_unquote") << QStringLiteral("add_emoticon")
<< QStringLiteral("paste_without_formatting");
composerActions.setActionsEnabled(false);
......
......@@ -5,8 +5,8 @@
*/
#include "richtextcomposercontrolertest.h"
#include "../richtextcomposercontroler.h"
#include "../richtextcomposer.h"
#include "../richtextcomposercontroler.h"
#include <KActionCollection>
#include <QTest>
......@@ -94,7 +94,7 @@ void RichTextComposerControlerTest::shouldBoldText()
controler.setTextBold(true);
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
// TODO text format.
}
void RichTextComposerControlerTest::shouldItalicText()
......@@ -108,7 +108,7 @@ void RichTextComposerControlerTest::shouldItalicText()
controler.setTextItalic(true);
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
// TODO text format.
}
void RichTextComposerControlerTest::shouldTextUnderline()
......@@ -122,7 +122,7 @@ void RichTextComposerControlerTest::shouldTextUnderline()
controler.setTextUnderline(true);
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
// TODO text format.
}
void RichTextComposerControlerTest::shouldTextStrikeOut()
......@@ -136,7 +136,7 @@ void RichTextComposerControlerTest::shouldTextStrikeOut()
controler.setTextStrikeOut(true);
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
// TODO text format.
}
void RichTextComposerControlerTest::shouldFontFamily()
......@@ -147,7 +147,7 @@ void RichTextComposerControlerTest::shouldFontFamily()
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
QVERIFY(QTest::qWaitForWindowExposed(&composer));
//TODO
// TODO
}
void RichTextComposerControlerTest::shouldFontSize()
......@@ -158,7 +158,7 @@ void RichTextComposerControlerTest::shouldFontSize()
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
QVERIFY(QTest::qWaitForWindowExposed(&composer));
//TODO
// TODO
}
void RichTextComposerControlerTest::shouldFont()
......@@ -169,7 +169,7 @@ void RichTextComposerControlerTest::shouldFont()
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
QVERIFY(QTest::qWaitForWindowExposed(&composer));
//TODO
// TODO
}
void RichTextComposerControlerTest::shouldTextSuperScript()
......@@ -183,7 +183,7 @@ void RichTextComposerControlerTest::shouldTextSuperScript()
controler.setTextSuperScript(true);
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO
// TODO
}
void RichTextComposerControlerTest::shouldTextSubScript()
......@@ -198,7 +198,7 @@ void RichTextComposerControlerTest::shouldTextSubScript()
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO
// TODO
}
void RichTextComposerControlerTest::shouldRemoveQuote_data()
......@@ -209,7 +209,7 @@ void RichTextComposerControlerTest::shouldRemoveQuote_data()
QTest::newRow("withoutquote") << QStringLiteral("bli\nblo\bla\n") << QStringLiteral("bli\nblo\bla\n");
QTest::newRow("removequote2") << QStringLiteral(">foo\n>bla\n>blo") << QStringLiteral("foo\nbla\nblo");
QTest::newRow("empty") << QString() << QString();
//Bug David, new line with quote
// Bug David, new line with quote
QTest::newRow("removequotewithnewline") << QStringLiteral(">foo\n>\n>bla\n>blo\n") << QStringLiteral("foo\n\nbla\nblo\n");
QTest::newRow("removequote2") << QStringLiteral(">foo\n\nbla\n>blo\nbli") << QStringLiteral("foo\n\nbla\nblo\nbli");
......@@ -269,32 +269,32 @@ void RichTextComposerControlerTest::shouldRemoveQuoteWithSpecificQuote()
void RichTextComposerControlerTest::shouldAddQuote_data()
{
// QTest::addColumn<QString>("input");
// QTest::addColumn<QString>("output");
// QTest::addColumn<QString>("quote");
// QTest::newRow("empty") << QString() << QString() << QString();
// QTest::newRow("empty1") << QString() << QString() << QStringLiteral("QT");
// 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("|");
// QTest::addColumn<QString>("input");
// QTest::addColumn<QString>("output");
// QTest::addColumn<QString>("quote");
// QTest::newRow("empty") << QString() << QString() << QString();
// QTest::newRow("empty1") << QString() << QString() << QStringLiteral("QT");
// 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()
{
// QFETCH(QString, input);
// QFETCH(QString, output);
// QFETCH(QString, quote);
// KPIMTextEdit::RichTextComposer composer;
// composer.setQuotePrefixName(quote);
// KActionCollection *actionCollection = new KActionCollection(&composer);
// composer.createActions(actionCollection);
// KPIMTextEdit::RichTextComposerControler controler(&composer);
// composer.show();
// QVERIFY(QTest::qWaitForWindowExposed(&composer));
// composer.setPlainText(input);
// controler.slotAddQuotes();
// QCOMPARE(composer.toPlainText(), QString(output + QChar::ParagraphSeparator));
// QFETCH(QString, input);
// QFETCH(QString, output);
// QFETCH(QString, quote);
// KPIMTextEdit::RichTextComposer composer;
// composer.setQuotePrefixName(quote);
// KActionCollection *actionCollection = new KActionCollection(&composer);
// composer.createActions(actionCollection);
// KPIMTextEdit::RichTextComposerControler controler(&composer);
// composer.show();
// QVERIFY(QTest::qWaitForWindowExposed(&composer));
// composer.setPlainText(input);
// controler.slotAddQuotes();
// QCOMPARE(composer.toPlainText(), QString(output + QChar::ParagraphSeparator));
}
QTEST_MAIN(RichTextComposerControlerTest)
......@@ -6,21 +6,21 @@
#include "richtextcomposertest.h"
#include "../richtextcomposer.h"
#include <QTest>
#include <QSignalSpy>
#include <KCodecs/KCodecs>
#include <QSignalSpy>
#include <QTest>
#include <KIconLoader>
#include <KActionCollection>
#include <KIconLoader>
#include <QAction>
#include <QTextCursor>
#include <QBuffer>
#include <QStandardPaths>
#include <QTextBlock>
#include <QTextCursor>
#include <kpimtextedit/richtextcomposer.h>
#include <kpimtextedit/richtextcomposercontroler.h>
#include <kpimtextedit/richtextcomposerimages.h>
#include <kpimtextedit/richtextcomposer.h>
#include <QStandardPaths>
using namespace KPIMTextEdit;
......@@ -223,7 +223,8 @@ void RichTextComposerTest::testCleanText()
QString html(QStringLiteral("<html><head></head><body>Heelllo&nbsp;World<br>Bye!</body></html>"));
QString plain(QStringLiteral("Heelllo World\nBye!"));
edit.setTextOrHtml(html);
edit.composerControler()->composerImages()->addImage(QUrl::fromLocalFile(KIconLoader::global()->iconPath(QStringLiteral("folder-new"), KIconLoader::Small, false)));
edit.composerControler()->composerImages()->addImage(
QUrl::fromLocalFile(KIconLoader::global()->iconPath(QStringLiteral("folder-new"), KIconLoader::Small, false)));
QVERIFY(edit.textMode() == KPIMTextEdit::RichTextComposer::Rich);
QCOMPARE(edit.composerControler()->toCleanPlainText(), plain);
......@@ -237,24 +238,12 @@ void RichTextComposerTest::testEnter_data()
QTest::addColumn<QString>("expectedText");
QTest::addColumn<int>("cursorPos");
QTest::newRow("") << QStringLiteral("> Hello World")
<< QStringLiteral("> Hello \n> World")
<< 8;
QTest::newRow("") << QStringLiteral("Hello World")
<< QStringLiteral("Hello \nWorld")
<< 6;
QTest::newRow("") << QStringLiteral("> Hello World")
<< QStringLiteral("> Hello World\n")
<< 13;
QTest::newRow("") << QStringLiteral(">Hello World")
<< QStringLiteral(">Hello \n>World")
<< 7;
QTest::newRow("") << QStringLiteral("> > Hello World")
<< QStringLiteral("> > Hello \n> > World")
<< 10;
QTest::newRow("") << QStringLiteral("| | Hello World")
<< QStringLiteral("| | Hello \n| | World")
<< 10;
QTest::newRow("") << QStringLiteral("> Hello World") << QStringLiteral("> Hello \n> World") << 8;
QTest::newRow("") << QStringLiteral("Hello World") << QStringLiteral("Hello \nWorld") << 6;
QTest::newRow("") << QStringLiteral("> Hello World") << QStringLiteral("> Hello World\n") << 13;
QTest::newRow("") << QStringLiteral(">Hello World") << QStringLiteral(">Hello \n>World") << 7;
QTest::newRow("") << QStringLiteral("> > Hello World") << QStringLiteral("> > Hello \n> > World") << 10;
QTest::newRow("") << QStringLiteral("| | Hello World") << QStringLiteral("| | Hello \n| | World") << 10;
}
void RichTextComposerTest::testEnter()
......@@ -338,7 +327,8 @@ void RichTextComposerTest::testImages()
KPIMTextEdit::EmbeddedImage *image2 = images.last().data();
KPIMTextEdit::ImageWithName *imageWithName1 = imagesWithNames.first().data();
KPIMTextEdit::ImageWithName *imageWithName2 = imagesWithNames.last().data();
QCOMPARE(image1->imageName, QString::fromLatin1("folder-new2.png")); // ### FIXME: should be folder-new.png, but QTextEdit provides no way to remove cached resources!
QCOMPARE(image1->imageName,
QString::fromLatin1("folder-new2.png")); // ### FIXME: should be folder-new.png, but QTextEdit provides no way to remove cached resources!
QCOMPARE(imageWithName1->name, QString::fromLatin1("folder-new2.png"));
QCOMPARE(image2->imageName, QString::fromLatin1("arrow-up.png"));
QCOMPARE(imageWithName2->name, QString::fromLatin1("arrow-up.png"));
......@@ -358,8 +348,7 @@ void RichTextComposerTest::testImageHtmlCode()
KPIMTextEdit::EmbeddedImage *image1 = images.first().data();
KPIMTextEdit::EmbeddedImage *image2 = images.last().data();
QString startHtml = QStringLiteral("<img src=\"arrow-up.png\"><img src=\"folder-new.png\">Bla<b>Blub</b>");
QString endHtml = QStringLiteral("<img src=\"cid:%1\"><img src=\"cid:%2\">Bla<b>Blub</b>")
.arg(image2->contentID, image1->contentID);
QString endHtml = QStringLiteral("<img src=\"cid:%1\"><img src=\"cid:%2\">Bla<b>Blub</b>").arg(image2->contentID, image1->contentID);
QCOMPARE(KPIMTextEdit::RichTextComposerImages::imageNamesToContentIds(startHtml.toLatin1(), images), endHtml.toLatin1());
}
......@@ -369,35 +358,19 @@ void RichTextComposerTest::testDeleteLine_data()
QTest::addColumn<QString>("expectedText");
QTest::addColumn<int>("cursorPos");
QTest::newRow("delete1") << QStringLiteral("line1\nline2\nline3")
<< QStringLiteral("line1\nline3")
<< 6;
QTest::newRow("delete2") << QStringLiteral("line1\nline2\nline3")
<< QStringLiteral("line2\nline3")
<< 5;
QTest::newRow("delete3") << QStringLiteral("line1\nline2\nline3")
<< QStringLiteral("line1\nline3")
<< 11;
QTest::newRow("delete4") << QStringLiteral("line1\nline2\nline3")
<< QStringLiteral("line2\nline3")
<< 0;
QTest::newRow("delete5") << QStringLiteral("line1\nline2\nline3")
<< QStringLiteral("line1\nline2")
<< 17;
QTest::newRow("delete6") << QStringLiteral("line1")
<< QString()
<< 0;
QTest::newRow("delete7") << QStringLiteral("line1")
<< QString()
<< 5;
QTest::newRow("delete1") << QStringLiteral("line1\nline2\nline3") << QStringLiteral("line1\nline3") << 6;
QTest::newRow("delete2") << QStringLiteral("line1\nline2\nline3") << QStringLiteral("line2\nline3") << 5;
QTest::newRow("delete3") << QStringLiteral("line1\nline2\nline3") << QStringLiteral("line1\nline3") << 11;
QTest::newRow("delete4") << QStringLiteral("line1\nline2\nline3") << QStringLiteral("line2\nline3") << 0;
QTest::newRow("delete5") << QStringLiteral("line1\nline2\nline3") << QStringLiteral("line1\nline2") << 17;
QTest::newRow("delete6") << QStringLiteral("line1") << QString() << 0;
QTest::newRow("delete7") << QStringLiteral("line1") << QString() << 5;
// Now, test deletion with word wrapping. The line with the Ms is so long that it will get wrapped
QTest::newRow("delete8") << QStringLiteral("line1\nMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3")
<< QStringLiteral("line1\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3")
<< 6;
<< QStringLiteral("line1\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3") << 6;
QTest::newRow("delete9") << QStringLiteral("line1\nMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3")
<< QStringLiteral("line1\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3")
<< 13;
<< QStringLiteral("line1\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nline3") << 13;
}
void RichTextComposerTest::testDeleteLine()
......@@ -457,15 +430,19 @@ void RichTextComposerTest::testWrappedPlainText_data()
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");
"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") << 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-\ntest-test-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-\ntest-test-test-test-test\n\n");
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-\ntest-test-test-test-test\n\n");
}
void RichTextComposerTest::testWrappedPlainText()
......
......@@ -5,8 +5,8 @@
*/
#include "richtextexternalcomposertest.h"
#include "../richtextexternalcomposer.h"
#include "../richtextcomposer.h"
#include "../richtextexternalcomposer.h"
#include <QTest>
RichTextExternalComposerTest::RichTextExternalComposerTest(QObject *parent)
......
......@@ -11,9 +11,9 @@
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QGridLayout>
#include <QPushButton>
#include <QVBoxLayout>
......
......@@ -16,7 +16,8 @@
class QDialogButtonBox;
class QLabel;
class QLineEdit;
namespace KPIMTextEdit {
namespace KPIMTextEdit
{
/**
@short Dialog to allow user to configure a hyperlink.
@author Stephen Kelly
......
......@@ -9,10 +9,10 @@
#include "nestedlisthelper_p.h"
#include <QKeyEvent>
#include <QTextCursor>
#include <QTextList>
#include <QTextBlock>
#include <QTextCursor>
#include <QTextEdit>
#include <QTextList>
using namespace KPIMTextEdit;
NestedListHelper::NestedListHelper(QTextEdit *te)
{
......@@ -27,17 +27,13 @@ bool NestedListHelper::handleBeforeKeyPressEvent(QKeyEvent *event)
QTextCursor cursor = textEdit->textCursor();
// Only attempt to handle Backspace while on a list
if ((event->key() != Qt::Key_Backspace)
|| (!cursor.currentList())) {
if ((event->key() != Qt::Key_Backspace) || (!cursor.currentList())) {
return false;
}
bool handled = false;
if (!cursor.hasSelection()
&& cursor.currentList()
&& event->key() == Qt::Key_Backspace
&& cursor.atBlockStart()) {
if (!cursor.hasSelection() && cursor.currentList() && event->key() == Qt::Key_Backspace && cursor.atBlockStart()) {
handleOnIndentLess();
handled = true;
}
......@@ -48,8 +44,8 @@ bool NestedListHelper::handleBeforeKeyPressEvent(QKeyEvent *event)
bool NestedListHelper::canIndent() const
{
if ((textEdit->textCursor().block().isValid())
// && ( textEdit->textCursor().block().previous().isValid() )
) {
// && ( textEdit->textCursor().block().previous().isValid() )