Commit 202a5af5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent eef4f87b
Pipeline #100224 passed with stage
in 7 minutes and 1 second
......@@ -14,9 +14,7 @@ EditorUtilTest::EditorUtilTest(QObject *parent)
{
}
EditorUtilTest::~EditorUtilTest()
{
}
EditorUtilTest::~EditorUtilTest() = default;
void EditorUtilTest::testUpperCase_data()
{
......
......@@ -17,9 +17,7 @@ RichTextComposerActionsTest::RichTextComposerActionsTest(QObject *parent)
{
}
RichTextComposerActionsTest::~RichTextComposerActionsTest()
{
}
RichTextComposerActionsTest::~RichTextComposerActionsTest() = default;
void RichTextComposerActionsTest::shouldHaveDefaultValue()
{
......@@ -27,7 +25,7 @@ void RichTextComposerActionsTest::shouldHaveDefaultValue()
KPIMTextEdit::RichTextComposerControler controler(&composer);
KPIMTextEdit::RichTextComposerActions composerActions(&controler);
KActionCollection *actionCollection = new KActionCollection(&composerActions);
auto actionCollection = new KActionCollection(&composerActions);
QVERIFY(actionCollection->actions().isEmpty());
composerActions.createActions(actionCollection);
......@@ -42,7 +40,7 @@ void RichTextComposerActionsTest::shouldHaveActions()
KPIMTextEdit::RichTextComposerControler controler(&composer);
KPIMTextEdit::RichTextComposerActions composerActions(&controler);
KActionCollection *actionCollection = new KActionCollection(&composerActions);
auto actionCollection = new KActionCollection(&composerActions);
composerActions.createActions(actionCollection);
QStringList lst;
......@@ -80,7 +78,7 @@ void RichTextComposerActionsTest::shouldChangeEnableState()
KPIMTextEdit::RichTextComposerControler controler(&composer);
KPIMTextEdit::RichTextComposerActions composerActions(&controler);
KActionCollection *actionCollection = new KActionCollection(&composerActions);
auto actionCollection = new KActionCollection(&composerActions);
composerActions.createActions(actionCollection);
QStringList actionNoRichText;
......
......@@ -15,14 +15,12 @@ RichTextComposerControlerTest::RichTextComposerControlerTest(QObject *parent)
{
}
RichTextComposerControlerTest::~RichTextComposerControlerTest()
{
}
RichTextComposerControlerTest::~RichTextComposerControlerTest() = default;
void RichTextComposerControlerTest::shouldAlignLeft()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -36,7 +34,7 @@ void RichTextComposerControlerTest::shouldAlignLeft()
void RichTextComposerControlerTest::shouldAlignRight()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -50,7 +48,7 @@ void RichTextComposerControlerTest::shouldAlignRight()
void RichTextComposerControlerTest::shouldAlignJustify()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -64,7 +62,7 @@ void RichTextComposerControlerTest::shouldAlignJustify()
void RichTextComposerControlerTest::shouldAlignCenter()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -86,7 +84,7 @@ void RichTextComposerControlerTest::shouldHaveDefaultValue()
void RichTextComposerControlerTest::shouldBoldText()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -100,7 +98,7 @@ void RichTextComposerControlerTest::shouldBoldText()
void RichTextComposerControlerTest::shouldItalicText()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -114,7 +112,7 @@ void RichTextComposerControlerTest::shouldItalicText()
void RichTextComposerControlerTest::shouldTextUnderline()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -128,7 +126,7 @@ void RichTextComposerControlerTest::shouldTextUnderline()
void RichTextComposerControlerTest::shouldTextStrikeOut()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -142,7 +140,7 @@ void RichTextComposerControlerTest::shouldTextStrikeOut()
void RichTextComposerControlerTest::shouldFontFamily()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -153,7 +151,7 @@ void RichTextComposerControlerTest::shouldFontFamily()
void RichTextComposerControlerTest::shouldFontSize()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -164,7 +162,7 @@ void RichTextComposerControlerTest::shouldFontSize()
void RichTextComposerControlerTest::shouldFont()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -175,7 +173,7 @@ void RichTextComposerControlerTest::shouldFont()
void RichTextComposerControlerTest::shouldTextSuperScript()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -189,7 +187,7 @@ void RichTextComposerControlerTest::shouldTextSuperScript()
void RichTextComposerControlerTest::shouldTextSubScript()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -226,7 +224,7 @@ void RichTextComposerControlerTest::shouldRemoveQuote()
QFETCH(QString, input);
QFETCH(QString, output);
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......@@ -256,7 +254,7 @@ void RichTextComposerControlerTest::shouldRemoveQuoteWithSpecificQuote()
QFETCH(QString, quote);
KPIMTextEdit::RichTextComposer composer;
composer.setQuotePrefixName(quote);
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
KPIMTextEdit::RichTextComposerControler controler(&composer);
composer.show();
......
......@@ -12,8 +12,6 @@ RichTextComposerImagesTest::RichTextComposerImagesTest(QObject *parent)
{
}
RichTextComposerImagesTest::~RichTextComposerImagesTest()
{
}
RichTextComposerImagesTest::~RichTextComposerImagesTest() = default;
QTEST_MAIN(RichTextComposerImagesTest)
......@@ -33,9 +33,7 @@ RichTextComposerTest::RichTextComposerTest(QObject *parent)
QStandardPaths::setTestModeEnabled(true);
}
RichTextComposerTest::~RichTextComposerTest()
{
}
RichTextComposerTest::~RichTextComposerTest() = default;
void RichTextComposerTest::testFormattingUsed()
{
......@@ -462,7 +460,7 @@ void RichTextComposerTest::testWrappedPlainText()
void RichTextComposerTest::testEnableDisableActions()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
bool enableAction = true;
composer.setEnableActions(enableAction);
......@@ -480,7 +478,7 @@ void RichTextComposerTest::testEnableDisableActions()
void RichTextComposerTest::shouldHaveDefaultValue()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
QCOMPARE(composer.linePosition(), 0);
QCOMPARE(composer.columnNumber(), 0);
......@@ -492,7 +490,7 @@ void RichTextComposerTest::shouldHaveDefaultValue()
void RichTextComposerTest::shouldChangeMode()
{
KPIMTextEdit::RichTextComposer composer;
KActionCollection *actionCollection = new KActionCollection(&composer);
auto actionCollection = new KActionCollection(&composer);
composer.createActions(actionCollection);
QSignalSpy spy(&composer, &RichTextComposer::textModeChanged);
composer.activateRichText();
......
......@@ -14,14 +14,12 @@ RichTextComposerWidgetTest::RichTextComposerWidgetTest(QObject *parent)
{
}
RichTextComposerWidgetTest::~RichTextComposerWidgetTest()
{
}
RichTextComposerWidgetTest::~RichTextComposerWidgetTest() = default;
void RichTextComposerWidgetTest::shouldHaveDefaultValue()
{
KPIMTextEdit::RichTextComposerWidget w;
auto *composer = w.findChild<KPIMTextEdit::RichTextComposer *>(QStringLiteral("richtextcomposer"));
auto composer = w.findChild<KPIMTextEdit::RichTextComposer *>(QStringLiteral("richtextcomposer"));
QVERIFY(composer);
QVERIFY(w.richTextComposer());
}
......
......@@ -14,9 +14,7 @@ RichTextExternalComposerTest::RichTextExternalComposerTest(QObject *parent)
{
}
RichTextExternalComposerTest::~RichTextExternalComposerTest()
{
}
RichTextExternalComposerTest::~RichTextExternalComposerTest() = default;
void RichTextExternalComposerTest::shouldHaveDefaultValue()
{
......
......@@ -54,9 +54,7 @@ KLinkDialog::KLinkDialog(QWidget *parent)
connect(textLineEdit, &QLineEdit::textChanged, this, &KLinkDialog::slotTextChanged);
}
KLinkDialog::~KLinkDialog()
{
}
KLinkDialog::~KLinkDialog() = default;
void KLinkDialog::slotTextChanged(const QString &text)
{
......
......@@ -130,7 +130,7 @@ void RichTextComposer::clearDecorator()
void RichTextComposer::createHighlighter()
{
KPIMTextEdit::RichTextComposerEmailQuoteHighlighter *highlighter = new KPIMTextEdit::RichTextComposerEmailQuoteHighlighter(this);
auto highlighter = new KPIMTextEdit::RichTextComposerEmailQuoteHighlighter(this);
highlighter->toggleSpellHighlighting(checkSpellingEnabled());
setHighlighterColors(highlighter);
setHighlighter(highlighter);
......@@ -534,7 +534,7 @@ void RichTextComposer::insertFromMimeData(const QMimeData *source)
{
// Add an image if that is on the clipboard
if (textMode() == RichTextComposer::Rich && source->hasImage()) {
const QImage image = qvariant_cast<QImage>(source->imageData());
const auto image = qvariant_cast<QImage>(source->imageData());
QFileInfo fi;
d->composerControler->composerImages()->insertImage(image, fi);
return;
......
......@@ -148,7 +148,7 @@ ImageWithNameList RichTextComposerImages::imagesWithName() const
const QString name = imageFormat.name();
if (!seenImageNames.contains(name)) {
QVariant resourceData = d->composer->document()->resource(QTextDocument::ImageResource, QUrl(name));
QImage image = qvariant_cast<QImage>(resourceData);
auto image = qvariant_cast<QImage>(resourceData);
ImageWithNamePtr newImage(new ImageWithName);
newImage->image = image;
......
......@@ -36,9 +36,9 @@ struct ImageWithName {
QString name; ///< The name of the image as it is available as a resource in the editor
};
typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
typedef QVector<ImageWithNamePtr> ImageWithNameList;
typedef QVector<QSharedPointer<EmbeddedImage>> ImageList;
using ImageWithNamePtr = QSharedPointer<ImageWithName>;
using ImageWithNameList = QVector<ImageWithNamePtr>;
using ImageList = QVector<QSharedPointer<EmbeddedImage>>;
class KPIMTEXTEDIT_EXPORT RichTextComposerImages : public QObject
{
......
......@@ -14,9 +14,7 @@ using namespace KPIMTextEdit;
class Q_DECL_HIDDEN KPIMTextEdit::RichTextComposerWidgetPrivate
{
public:
RichTextComposerWidgetPrivate()
{
}
RichTextComposerWidgetPrivate() = default;
KPIMTextEdit::RichTextComposer *richTextComposer = nullptr;
};
......
......@@ -24,7 +24,7 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.process(app);
auto richtextcomposerwidget = new KPIMTextEdit::RichTextComposer;
KActionCollection *ac = new KActionCollection(richtextcomposerwidget);
auto ac = new KActionCollection(richtextcomposerwidget);
richtextcomposerwidget->createActions(ac);
auto editor = new KPIMTextEdit::RichTextEditorWidget(richtextcomposerwidget);
editor->resize(800, 600);
......
......@@ -7,9 +7,7 @@
#include "editorutil.h"
using namespace KPIMTextEdit;
EditorUtil::EditorUtil()
{
}
EditorUtil::EditorUtil() = default;
void EditorUtil::upperCase(QTextCursor &cursor) const
{
......
......@@ -17,6 +17,4 @@ EmoticonListView::EmoticonListView(QWidget *parent)
});
}
EmoticonListView::~EmoticonListView()
{
}
EmoticonListView::~EmoticonListView() = default;
......@@ -16,9 +16,7 @@ EmoticonRecentListView::EmoticonRecentListView(QWidget *parent)
setContextMenuPolicy(Qt::DefaultContextMenu);
}
EmoticonRecentListView::~EmoticonRecentListView()
{
}
EmoticonRecentListView::~EmoticonRecentListView() = default;
void EmoticonRecentListView::contextMenuEvent(QContextMenuEvent *event)
{
......
......@@ -17,10 +17,7 @@ EmoticonRecentUsedFilterProxyModel::EmoticonRecentUsedFilterProxyModel(QObject *
sort(0);
}
EmoticonRecentUsedFilterProxyModel::~EmoticonRecentUsedFilterProxyModel()
{
}
EmoticonRecentUsedFilterProxyModel::~EmoticonRecentUsedFilterProxyModel() = default;
QStringList EmoticonRecentUsedFilterProxyModel::usedIdentifier() const
{
......
......@@ -37,9 +37,7 @@ EmoticonTextEditSelector::EmoticonTextEditSelector(QWidget *parent)
setMinimumSize(400, 200);
}
EmoticonTextEditSelector::~EmoticonTextEditSelector()
{
}
EmoticonTextEditSelector::~EmoticonTextEditSelector() = default;
void EmoticonTextEditSelector::slotItemSelected(const QString &str)
{
......
......@@ -12,9 +12,7 @@ EmoticonUnicodeModel::EmoticonUnicodeModel(QObject *parent)
{
}
EmoticonUnicodeModel::~EmoticonUnicodeModel()
{
}
EmoticonUnicodeModel::~EmoticonUnicodeModel() = default;
int EmoticonUnicodeModel::rowCount(const QModelIndex &parent) const
{
......
......@@ -14,9 +14,7 @@ EmoticonUnicodeProxyModel::EmoticonUnicodeProxyModel(QObject *parent)
setFilterRole(EmoticonUnicodeModel::UnicodeEmoji);
}
EmoticonUnicodeProxyModel::~EmoticonUnicodeProxyModel()
{
}
EmoticonUnicodeProxyModel::~EmoticonUnicodeProxyModel() = default;
bool EmoticonUnicodeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
......@@ -24,8 +22,7 @@ bool EmoticonUnicodeProxyModel::filterAcceptsRow(int source_row, const QModelInd
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
const QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
const EmoticonUnicodeUtils::EmoticonStruct::EmoticonType category =
sourceIndex.data(EmoticonUnicodeModel::Category).value<EmoticonUnicodeUtils::EmoticonStruct::EmoticonType>();
const auto category = sourceIndex.data(EmoticonUnicodeModel::Category).value<EmoticonUnicodeUtils::EmoticonStruct::EmoticonType>();
if (mCategories == category) {
return true;
}
......
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