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

coding style

parent 39538ba1
......@@ -28,12 +28,10 @@
RichTextComposerActionsTest::RichTextComposerActionsTest(QObject *parent)
: QObject(parent)
{
}
RichTextComposerActionsTest::~RichTextComposerActionsTest()
{
}
void RichTextComposerActionsTest::shouldHaveDefaultValue()
......
......@@ -26,12 +26,10 @@
RichTextComposerControlerTest::RichTextComposerControlerTest(QObject *parent)
: QObject(parent)
{
}
RichTextComposerControlerTest::~RichTextComposerControlerTest()
{
}
void RichTextComposerControlerTest::shouldAlignLeft()
......@@ -150,7 +148,6 @@ void RichTextComposerControlerTest::shouldTextUnderline()
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
}
void RichTextComposerControlerTest::shouldTextStrikeOut()
......@@ -165,7 +162,6 @@ void RichTextComposerControlerTest::shouldTextStrikeOut()
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO text format.
}
void RichTextComposerControlerTest::shouldFontFamily()
......@@ -188,7 +184,6 @@ void RichTextComposerControlerTest::shouldFontSize()
composer.show();
QTest::qWaitForWindowExposed(&composer);
//TODO
}
void RichTextComposerControlerTest::shouldFont()
......@@ -200,7 +195,6 @@ void RichTextComposerControlerTest::shouldFont()
composer.show();
QTest::qWaitForWindowExposed(&composer);
//TODO
}
void RichTextComposerControlerTest::shouldTextSuperScript()
......@@ -215,7 +209,6 @@ void RichTextComposerControlerTest::shouldTextSuperScript()
QVERIFY(controler.richTextComposer()->hasFocus());
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO
}
void RichTextComposerControlerTest::shouldTextSubScript()
......@@ -231,7 +224,6 @@ void RichTextComposerControlerTest::shouldTextSubScript()
QVERIFY(controler.richTextComposer()->acceptRichText());
//TODO
}
QTEST_MAIN(RichTextComposerControlerTest)
......@@ -46,7 +46,6 @@ private Q_SLOTS:
void shouldFont();
void shouldTextSuperScript();
void shouldTextSubScript();
};
#endif // RICHTEXTCOMPOSERCONTROLERTEST_H
......@@ -23,12 +23,10 @@
RichTextComposerImagesTest::RichTextComposerImagesTest(QObject *parent)
: QObject(parent)
{
}
RichTextComposerImagesTest::~RichTextComposerImagesTest()
{
}
QTEST_MAIN(RichTextComposerImagesTest)
......@@ -25,12 +25,10 @@
RichTextComposerWidgetTest::RichTextComposerWidgetTest(QObject *parent)
: QObject(parent)
{
}
RichTextComposerWidgetTest::~RichTextComposerWidgetTest()
{
}
void RichTextComposerWidgetTest::shouldHaveDefaultValue()
......
......@@ -25,12 +25,10 @@
RichTextExternalComposerTest::RichTextExternalComposerTest(QObject *parent)
: QObject(parent)
{
}
RichTextExternalComposerTest::~RichTextExternalComposerTest()
{
}
void RichTextExternalComposerTest::shouldHaveDefaultValue()
......
......@@ -48,7 +48,8 @@ public:
//@endcond
KLinkDialog::KLinkDialog(QWidget *parent)
: QDialog(parent), d(new KLinkDialog::KLinkDialogPrivate)
: QDialog(parent)
, d(new KLinkDialog::KLinkDialogPrivate)
{
setWindowTitle(i18n("Manage Link"));
setModal(true);
......
......@@ -27,8 +27,7 @@
#include <QDialog>
class QString;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
/**
@short Dialog to allow user to configure a hyperlink.
@author Stephen Kelly
......
......@@ -41,16 +41,16 @@ bool NestedListHelper::handleBeforeKeyPressEvent(QKeyEvent *event)
// Only attempt to handle Backspace while on a list
if ((event->key() != Qt::Key_Backspace)
|| (!cursor.currentList())) {
|| (!cursor.currentList())) {
return false;
}
bool handled = false;
if (!cursor.hasSelection()
&& cursor.currentList()
&& event->key() == Qt::Key_Backspace
&& cursor.atBlockStart()) {
&& cursor.currentList()
&& event->key() == Qt::Key_Backspace
&& cursor.atBlockStart()) {
handleOnIndentLess();
handled = true;
}
......@@ -62,7 +62,7 @@ bool NestedListHelper::canIndent() const
{
if ((textEdit->textCursor().block().isValid())
// && ( textEdit->textCursor().block().previous().isValid() )
) {
) {
QTextBlock block = textEdit->textCursor().block();
QTextBlock prevBlock = textEdit->textCursor().block().previous();
if (block.textList()) {
......@@ -94,14 +94,13 @@ bool NestedListHelper::canDedent() const
}
}
return false;
}
bool NestedListHelper::handleAfterKeyPressEvent(QKeyEvent *event)
{
// Only attempt to handle Backspace and Return
if ((event->key() != Qt::Key_Backspace)
&& (event->key() != Qt::Key_Return)) {
&& (event->key() != Qt::Key_Return)) {
return false;
}
......@@ -109,7 +108,6 @@ bool NestedListHelper::handleAfterKeyPressEvent(QKeyEvent *event)
bool handled = false;
if (!cursor.hasSelection() && cursor.currentList()) {
// Check if we're on the last list item.
// itemNumber is zero indexed
QTextBlock currentBlock = cursor.block();
......@@ -151,7 +149,6 @@ bool NestedListHelper::handleAfterDropEvent(QDropEvent *dropEvent)
while (droppedBlock.next().position() < endOfDrop) {
droppedBlock = droppedBlock.next();
if (droppedBlock.textList()->format().indent() != firstDroppedItemIndent) {
// new list?
}
list->add(droppedBlock);
......@@ -170,7 +167,7 @@ void NestedListHelper::processList(QTextList *list)
QTextCursor cursor = QTextCursor(block);
list = cursor.createList(list->format());
bool processingSubList = false;
bool processingSubList = false;
while (block.next().textList() != nullptr) {
block = block.next();
......@@ -196,7 +193,7 @@ void NestedListHelper::processList(QTextList *list)
void NestedListHelper::reformatList(QTextBlock block)
{
if (block.textList()) {
int minimumIndent = block.textList()->format().indent();
int minimumIndent = block.textList()->format().indent();
// Start at the top of the list
while (block.previous().textList() != nullptr) {
......@@ -207,7 +204,6 @@ void NestedListHelper::reformatList(QTextBlock block)
}
processList(block.textList());
}
}
......@@ -243,14 +239,12 @@ void NestedListHelper::handleOnIndentMore()
QTextListFormat listFmt;
if (!cursor.currentList()) {
QTextListFormat::Style style;
cursor = topOfSelection();
cursor.movePosition(QTextCursor::PreviousBlock);
if (cursor.currentList()) {
style = cursor.currentList()->format().style();
} else {
cursor = bottomOfSelection();
cursor.movePosition(QTextCursor::NextBlock);
......@@ -354,7 +348,6 @@ void NestedListHelper::reformatBoundingItemSpacing(QTextBlock block)
if (nextBlockValid && !block.next().textList()) {
thisBlockBottomMargin = listNoMargin;
}
}
QTextBlockFormat fmt;
QTextCursor cursor;
......
......@@ -31,8 +31,7 @@ class QDropEvent;
class QTextCursor;
class QTextList;
class QTextBlock;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
/**
*
* @short Helper class for automatic handling of nested lists in a text edit
......@@ -137,7 +136,6 @@ private:
int listBottomMargin;
int listTopMargin;
int listNoMargin;
};
}
//@endcond
......
......@@ -45,9 +45,9 @@ class Q_DECL_HIDDEN RichTextComposer::RichTextComposerPrivate
{
public:
RichTextComposerPrivate(RichTextComposer *qq)
: q(qq),
forcePlainTextMarkup(false),
mode(RichTextComposer::Plain)
: q(qq)
, forcePlainTextMarkup(false)
, mode(RichTextComposer::Plain)
{
composerControler = new RichTextComposerControler(q, q);
richTextComposerActions = new RichTextComposerActions(composerControler, q);
......@@ -55,8 +55,8 @@ public:
q->connect(externalComposer, &RichTextExternalComposer::externalEditorClosed, qq, &RichTextComposer::externalEditorClosed);
q->connect(externalComposer, &RichTextExternalComposer::externalEditorStarted, qq, &RichTextComposer::externalEditorStarted);
q->connect(q, &RichTextComposer::textModeChanged, q, &RichTextComposer::slotTextModeChanged);
}
QString quotePrefix;
RichTextComposerControler *composerControler;
RichTextComposerActions *richTextComposerActions;
......@@ -67,8 +67,8 @@ public:
};
RichTextComposer::RichTextComposer(QWidget *parent)
: KPIMTextEdit::RichTextEditor(parent),
d(new RichTextComposerPrivate(this))
: KPIMTextEdit::RichTextEditor(parent)
, d(new RichTextComposerPrivate(this))
{
setAcceptRichText(false);
}
......@@ -116,7 +116,6 @@ void RichTextComposer::updateHighLighter()
if (hlighter) {
hlighter->toggleSpellHighlighting(checkSpellingEnabled());
}
}
void RichTextComposer::clearDecorator()
......@@ -194,7 +193,6 @@ int RichTextComposer::linePosition() const
// If the current block has the cursor in it, iterate over all its lines
if (block == cursor.block()) {
// Special case: Cursor at end of single non-wrapped line, exit early
// in this case as the logic below can't handle it
if (block.lineCount() == layout->lineCount()) {
......@@ -205,8 +203,8 @@ int RichTextComposer::linePosition() const
const int numberOfLine(layout->lineCount());
for (int i = 0; i < numberOfLine; ++i) {
QTextLine line = layout->lineAt(i);
if (cursorBasePosition >= line.textStart() &&
cursorBasePosition < line.textStart() + line.textLength()) {
if (cursorBasePosition >= line.textStart()
&& cursorBasePosition < line.textStart() + line.textLength()) {
break;
}
lineCount++;
......@@ -302,7 +300,7 @@ void RichTextComposer::setTextOrHtml(const QString &text)
void RichTextComposer::evaluateReturnKeySupport(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return) {
if (event->key() == Qt::Key_Return) {
QTextCursor cursor = textCursor();
int oldPos = cursor.position();
int blockPos = cursor.block().position();
......@@ -311,13 +309,13 @@ void RichTextComposer::evaluateReturnKeySupport(QKeyEvent *event)
cursor.movePosition(QTextCursor::StartOfBlock);
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
QString lineText = cursor.selectedText();
if (((oldPos - blockPos) > 0) &&
((oldPos - blockPos) < int(lineText.length()))) {
if (((oldPos - blockPos) > 0)
&& ((oldPos - blockPos) < int(lineText.length()))) {
bool isQuotedLine = false;
int bot = 0; // bot = begin of text after quote indicators
while (bot < lineText.length()) {
if ((lineText[bot] == QChar::fromLatin1('>')) ||
(lineText[bot] == QChar::fromLatin1('|'))) {
if ((lineText[bot] == QChar::fromLatin1('>'))
|| (lineText[bot] == QChar::fromLatin1('|'))) {
isQuotedLine = true;
++bot;
} else if (lineText[bot].isSpace()) {
......@@ -330,9 +328,9 @@ void RichTextComposer::evaluateReturnKeySupport(QKeyEvent *event)
// duplicate quote indicators of the previous line before the new
// line if the line actually contained text (apart from the quote
// indicators) and the cursor is behind the quote indicators
if (isQuotedLine &&
(bot != lineText.length()) &&
((oldPos - blockPos) >= int(bot))) {
if (isQuotedLine
&& (bot != lineText.length())
&& ((oldPos - blockPos) >= int(bot))) {
// The cursor position might have changed unpredictably if there was selected
// text which got replaced by a new line, so we query it again:
cursor.movePosition(QTextCursor::StartOfBlock);
......@@ -342,8 +340,8 @@ void RichTextComposer::evaluateReturnKeySupport(QKeyEvent *event)
// remove leading white space from the new line and instead
// add the quote indicators of the previous line
int leadingWhiteSpaceCount = 0;
while ((leadingWhiteSpaceCount < newLine.length()) &&
newLine[leadingWhiteSpaceCount].isSpace()) {
while ((leadingWhiteSpaceCount < newLine.length())
&& newLine[leadingWhiteSpaceCount].isSpace()) {
++leadingWhiteSpaceCount;
}
newLine = newLine.replace(0, leadingWhiteSpaceCount, lineText.left(bot));
......@@ -381,24 +379,24 @@ void RichTextComposer::evaluateListSupport(QKeyEvent *event)
bool RichTextComposer::processKeyEvent(QKeyEvent *e)
{
if (d->externalComposer->useExternalEditor() &&
(e->key() != Qt::Key_Shift) &&
(e->key() != Qt::Key_Control) &&
(e->key() != Qt::Key_Meta) &&
(e->key() != Qt::Key_CapsLock) &&
(e->key() != Qt::Key_NumLock) &&
(e->key() != Qt::Key_ScrollLock) &&
(e->key() != Qt::Key_Alt) &&
(e->key() != Qt::Key_AltGr)) {
if (d->externalComposer->useExternalEditor()
&& (e->key() != Qt::Key_Shift)
&& (e->key() != Qt::Key_Control)
&& (e->key() != Qt::Key_Meta)
&& (e->key() != Qt::Key_CapsLock)
&& (e->key() != Qt::Key_NumLock)
&& (e->key() != Qt::Key_ScrollLock)
&& (e->key() != Qt::Key_Alt)
&& (e->key() != Qt::Key_AltGr)) {
if (!d->externalComposer->isInProgress()) {
d->externalComposer->startExternalEditor();
}
return true;
}
if (e->key() == Qt::Key_Up && e->modifiers() != Qt::ShiftModifier &&
textCursor().block().position() == 0 &&
textCursor().block().layout()->lineForTextPosition(textCursor().position()).lineNumber() == 0) {
if (e->key() == Qt::Key_Up && e->modifiers() != Qt::ShiftModifier
&& textCursor().block().position() == 0
&& textCursor().block().layout()->lineForTextPosition(textCursor().position()).lineNumber() == 0) {
textCursor().clearSelection();
Q_EMIT focusUp();
} else if (e->key() == Qt::Key_Backtab && e->modifiers() == Qt::ShiftModifier) {
......
......@@ -25,8 +25,7 @@
#include <kpimtextedit/richtexteditor.h>
class KActionCollection;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class RichTextComposerSignatures;
class RichTextComposerControler;
class RichTextComposerActions;
......
......@@ -36,42 +36,43 @@ class Q_DECL_HIDDEN RichTextComposerActions::RichTextComposerActionsPrivate
{
public:
RichTextComposerActionsPrivate(KPIMTextEdit::RichTextComposerControler *controler)
: composerControler(controler),
action_align_left(nullptr),
action_align_right(nullptr),
action_align_center(nullptr),
action_align_justify(nullptr),
action_direction_ltr(nullptr),
action_direction_rtl(nullptr),
action_text_superscript(nullptr),
action_text_subscript(nullptr),
action_text_bold(nullptr),
action_text_italic(nullptr),
action_text_underline(nullptr),
action_text_strikeout(nullptr),
action_font_family(nullptr),
action_font_size(nullptr),
action_insert_horizontal_rule(nullptr),
action_text_foreground_color(nullptr),
action_text_background_color(nullptr),
action_manage_link(nullptr),
action_list_indent(nullptr),
action_list_dedent(nullptr),
action_list_style(nullptr),
action_paste_quotation(nullptr),
action_add_quote_chars(nullptr),
action_remove_quote_chars(nullptr),
action_paste_without_formatting(nullptr),
action_add_image(nullptr),
action_add_emoticon(nullptr),
action_insert_html(nullptr),
action_add_table(nullptr),
action_delete_line(nullptr),
action_format_reset(nullptr),
action_format_painter(nullptr),
richTextEnabled(false)
: composerControler(controler)
, action_align_left(nullptr)
, action_align_right(nullptr)
, action_align_center(nullptr)
, action_align_justify(nullptr)
, action_direction_ltr(nullptr)
, action_direction_rtl(nullptr)
, action_text_superscript(nullptr)
, action_text_subscript(nullptr)
, action_text_bold(nullptr)
, action_text_italic(nullptr)
, action_text_underline(nullptr)
, action_text_strikeout(nullptr)
, action_font_family(nullptr)
, action_font_size(nullptr)
, action_insert_horizontal_rule(nullptr)
, action_text_foreground_color(nullptr)
, action_text_background_color(nullptr)
, action_manage_link(nullptr)
, action_list_indent(nullptr)
, action_list_dedent(nullptr)
, action_list_style(nullptr)
, action_paste_quotation(nullptr)
, action_add_quote_chars(nullptr)
, action_remove_quote_chars(nullptr)
, action_paste_without_formatting(nullptr)
, action_add_image(nullptr)
, action_add_emoticon(nullptr)
, action_insert_html(nullptr)
, action_add_table(nullptr)
, action_delete_line(nullptr)
, action_format_reset(nullptr)
, action_format_painter(nullptr)
, richTextEnabled(false)
{
}
QList<QAction *> richTextActionList;
KPIMTextEdit::RichTextComposerControler *composerControler;
......@@ -122,10 +123,9 @@ public:
};
RichTextComposerActions::RichTextComposerActions(KPIMTextEdit::RichTextComposerControler *controler, QObject *parent)
: QObject(parent),
d(new RichTextComposerActions::RichTextComposerActionsPrivate(controler))
: QObject(parent)
, d(new RichTextComposerActions::RichTextComposerActionsPrivate(controler))
{
}
RichTextComposerActions::~RichTextComposerActions()
......@@ -147,7 +147,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
{
//Alignment
d->action_align_left = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-justify-left")),
i18nc("@action", "Align &Left"), this);
i18nc("@action", "Align &Left"), this);
d->action_align_left->setIconText(i18nc("@label left justify", "Left"));
d->richTextActionList.append((d->action_align_left));
d->action_align_left->setObjectName(QStringLiteral("format_align_left"));
......@@ -158,7 +158,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
}
d->action_align_center = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-justify-center")),
i18nc("@action", "Align &Center"), this);
i18nc("@action", "Align &Center"), this);
d->action_align_center->setIconText(i18nc("@label center justify", "Center"));
d->richTextActionList.append((d->action_align_center));
d->action_align_center->setObjectName(QStringLiteral("format_align_center"));
......@@ -169,7 +169,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
}
d->action_align_right = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-justify-right")),
i18nc("@action", "Align &Right"), this);
i18nc("@action", "Align &Right"), this);
d->action_align_right->setIconText(i18nc("@label right justify", "Right"));
d->richTextActionList.append((d->action_align_right));
d->action_align_right->setObjectName(QStringLiteral("format_align_right"));
......@@ -180,7 +180,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
}
d->action_align_justify = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-justify-fill")),
i18nc("@action", "&Justify"), this);
i18nc("@action", "&Justify"), this);
d->action_align_justify->setIconText(i18nc("@label justify fill", "Justify"));
d->richTextActionList.append((d->action_align_justify));
d->action_align_justify->setObjectName(QStringLiteral("format_align_justify"));
......@@ -198,7 +198,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
//Align text
d->action_direction_ltr = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-direction-ltr")),
i18nc("@action", "Left-to-Right"), this);
i18nc("@action", "Left-to-Right"), this);
d->action_direction_ltr->setIconText(i18nc("@label left-to-right", "Left-to-Right"));
d->richTextActionList.append(d->action_direction_ltr);
d->action_direction_ltr->setObjectName(QStringLiteral("direction_ltr"));
......@@ -209,7 +209,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
}
d->action_direction_rtl = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-direction-rtl")),
i18nc("@action", "Right-to-Left"), this);
i18nc("@action", "Right-to-Left"), this);
d->action_direction_rtl->setIconText(i18nc("@label right-to-left", "Right-to-Left"));
d->richTextActionList.append(d->action_direction_rtl);
d->action_direction_rtl->setObjectName(QStringLiteral("direction_rtl"));
......@@ -225,7 +225,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
// Sub/Super script
d->action_text_subscript = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-subscript")),
i18nc("@action", "Subscript"), this);
i18nc("@action", "Subscript"), this);
d->richTextActionList.append((d->action_text_subscript));
d->action_text_subscript->setObjectName(QStringLiteral("format_text_subscript"));
connect(d->action_text_subscript, &KToggleAction::triggered,
......@@ -235,7 +235,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
}
d->action_text_superscript = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-superscript")),
i18nc("@action", "Superscript"), this);
i18nc("@action", "Superscript"), this);
d->richTextActionList.append((d->action_text_superscript));
d->action_text_superscript->setObjectName(QStringLiteral("format_text_superscript"));
connect(d->action_text_superscript, &KToggleAction::triggered,
......@@ -258,7 +258,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
connect(d->action_text_bold, &KToggleAction::triggered, d->composerControler, &RichTextComposerControler::setTextBold);
d->action_text_italic = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-italic")),
i18nc("@action italicize selected text", "&Italic"), this);
i18nc("@action italicize selected text", "&Italic"), this);
QFont italic;
italic.setItalic(true);
d->action_text_italic->setFont(italic);
......@@ -271,7 +271,7 @@ void RichTextComposerActions::createActions(KActionCollection *ac)
connect(d->action_text_italic, &KToggleAction::triggered, d->composerControler, &RichTextComposerControler::setTextItalic);
d->action_text_underline = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-underline")),
i18nc("@action underline selected text", "&Underline"), this);
i18nc("@action underline selected text", "&Underline"), this);
QFont underline;