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

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;
......
This diff is collapsed.
......@@ -26,8 +26,7 @@
class KActionCollection;
class QTextCharFormat;
class QAction;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class RichTextComposerControler;
class KPIMTEXTEDIT_EXPORT RichTextComposerActions : public QObject
{
......
......@@ -46,17 +46,19 @@ class Q_DECL_HIDDEN RichTextComposerControler::RichTextComposerControlerPrivate
{
public:
RichTextComposerControlerPrivate(RichTextComposer *composer, RichTextComposerControler *qq)
: painterActive(false),
richtextComposer(composer),
q(qq)
: painterActive(false)
, richtextComposer(composer)
, q(qq)
{
nestedListHelper = new NestedListHelper(composer);
richTextImages = new RichTextComposerImages(richtextComposer, q);
}
~RichTextComposerControlerPrivate()
{
delete nestedListHelper;
}
QColor linkColor()
{
if (mLinkColor.isValid()) {
......@@ -65,6 +67,7 @@ public:
mLinkColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color();
return mLinkColor;
}
void selectLinkText(QTextCursor *cursor) const;
void fixupTextEditString(QString &text) const;
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
......@@ -109,7 +112,6 @@ void RichTextComposerControler::RichTextComposerControlerPrivate::selectLinkText
if (oldPosition == cursor->position()) {
break;
}
}
if (cursor->charFormat().anchorHref() != aHref) {
cursor->setPosition(cursor->position() - 1, QTextCursor::KeepAnchor);
......@@ -142,9 +144,9 @@ void RichTextComposerControler::RichTextComposerControlerPrivate::mergeFormatOnW
}
RichTextComposerControler::RichTextComposerControler(RichTextComposer *richtextComposer, QObject *parent)
: QObject(parent), d(new RichTextComposerControlerPrivate(richtextComposer, this))
: QObject(parent)
, d(new RichTextComposerControlerPrivate(richtextComposer, this))
{
}
RichTextComposerControler::~RichTextComposerControler()
......@@ -422,7 +424,6 @@ void RichTextComposerControler::manageLink()
}
delete linkDialog;
}
void RichTextComposerControler::RichTextComposerControler::updateLink(const QString &linkUrl, const QString &linkText)
......@@ -496,25 +497,25 @@ QString RichTextComposerControler::toCleanHtml() const
QString result = richTextComposer()->toHtml();
static const QString EMPTYLINEHTML = QStringLiteral(
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
"margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \">&nbsp;</p>");
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
"margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \">&nbsp;</p>");
// Qt inserts various style properties based on the current mode of the editor (underline,
// bold, etc), but only empty paragraphs *also* have qt-paragraph-type set to 'empty'.
static const QString EMPTYLINEREGEX = QStringLiteral(
"<p style=\"-qt-paragraph-type:empty;(.*)</p>");
"<p style=\"-qt-paragraph-type:empty;(.*)</p>");
static const QString OLLISTPATTERNQT = QStringLiteral(
"<ol style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;");
"<ol style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;");
static const QString ULLISTPATTERNQT = QStringLiteral(
"<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;");
"<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;");
static const QString ORDEREDLISTHTML = QStringLiteral(
"<ol style=\"margin-top: 0px; margin-bottom: 0px;");
"<ol style=\"margin-top: 0px; margin-bottom: 0px;");
static const QString UNORDEREDLISTHTML = QStringLiteral(
"<ul style=\"margin-top: 0px; margin-bottom: 0px;");
"<ul style=\"margin-top: 0px; margin-bottom: 0px;");
// fix 1 - empty lines should show as empty lines - MS Outlook treats margin-top:0px; as
// a non-existing line.
......@@ -773,8 +774,8 @@ void RichTextComposerControler::slotDeleteLine()
// When deleting the last line in the document,
// remove the newline of the line before the last line instead
if (deleteStart + deleteLength >= richTextComposer()->document()->characterCount() &&
deleteStart > 0) {
if (deleteStart + deleteLength >= richTextComposer()->document()->characterCount()
&& deleteStart > 0) {
deleteStart--;
}
......@@ -915,9 +916,9 @@ QString RichTextComposerControler::toWrappedPlainText(QTextDocument *doc) const
QTextLine line = layout->lineAt(i);
QString lineText = block.text().mid(line.textStart(), line.textLength());
if (lineText.contains(rx) ||
(urlStart && !lineText.contains(QLatin1Char(' ')) &&
lineText.endsWith(QLatin1Char('-')))) {
if (lineText.contains(rx)
|| (urlStart && !lineText.contains(QLatin1Char(' '))
&& lineText.endsWith(QLatin1Char('-')))) {
// don't insert line break in URL
temp += lineText;
urlStart = true;
......
......@@ -24,8 +24,7 @@
#include "richtextcomposer.h"
#include "kpimtextedit_export.h"
class QTextCursor;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class RichTextComposer;
class NestedListHelper;
class RichTextComposerImages;
......
......@@ -27,16 +27,15 @@ public:
RichTextComposerEmailQuoteDecoratorPrivate(RichTextComposer *textEdit)
: composerEditor(textEdit)
{
}
RichTextComposer *composerEditor;
};
RichTextComposerEmailQuoteDecorator::RichTextComposerEmailQuoteDecorator(RichTextComposer *textEdit)
: Sonnet::SpellCheckDecorator(textEdit),
d(new RichTextComposerEmailQuoteDecorator::RichTextComposerEmailQuoteDecoratorPrivate(textEdit))
: Sonnet::SpellCheckDecorator(textEdit)
, d(new RichTextComposerEmailQuoteDecorator::RichTextComposerEmailQuoteDecoratorPrivate(textEdit))
{
}
RichTextComposerEmailQuoteDecorator::~RichTextComposerEmailQuoteDecorator()
......
......@@ -23,8 +23,7 @@
#include <sonnet/spellcheckdecorator.h>
#include "kpimtextedit_export.h"
namespace KPIMTextEdit
{
namespace KPIMTextEdit {