Commit 748f181a authored by Filip Gawin's avatar Filip Gawin Committed by Dominik Haumann

Simplify ctors with default member initializer

Moves values into header, making it easier to read variable's
default state. Also compiler checks types more carefully.
parent 876cb4ce
......@@ -35,21 +35,17 @@ public:
/**
* Default constructor => invalid element
*/
BtInfo()
: step(-1)
, line(-1)
, type(Invalid) {
}
BtInfo() = default;
public:
QString original;
QString filename;
QString function;
QString address;
int step;
int line;
int step = -1;
int line = -1;
Type type;
Type type = Invalid;
};
namespace KateBtParser
......
......@@ -67,8 +67,7 @@ class ActionLBItem : public QListWidgetItem
//BEGIN KateFileBrowserConfigPage
KateFileBrowserConfigPage::KateFileBrowserConfigPage( QWidget *parent, KateFileBrowser *kfb )
: KTextEditor::ConfigPage( parent ),
fileBrowser( kfb ),
m_changed( false )
fileBrowser( kfb )
{
QVBoxLayout *lo = new QVBoxLayout( this );
int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
......
......@@ -55,7 +55,7 @@ class KateFileBrowserConfigPage : public KTextEditor::ConfigPage
KateFileBrowser *fileBrowser;
KActionSelector *acSel;
bool m_changed;
bool m_changed = false;
};
#endif //KATE_FILEBROWSER_CONFIG_H
......
......@@ -29,7 +29,7 @@ QTEST_GUILESS_MAIN(FileTreeModelTest)
class ResultNode
{
public:
ResultNode() : name(), dir(true), children() {} // root node
ResultNode() = default; // root node
ResultNode(const ResultNode &other) : name(other.name), dir(other.dir), children(other.children) {}
ResultNode(const char *_name, const bool _dir = false) : ResultNode(QString::fromLatin1(_name), _dir) {}
ResultNode(const QString &_name, const bool _dir = false) : name(_name), dir(_dir), children() {}
......@@ -83,7 +83,7 @@ class ResultNode
}
QString name;
bool dir;
bool dir = true;
QList<ResultNode> children;
};
......
......@@ -50,8 +50,7 @@ view needs to pull default settings from the main plugin config
KateFileTreeConfigPage::KateFileTreeConfigPage(QWidget *parent, KateFileTreePlugin *fl)
: KTextEditor::ConfigPage(parent),
m_plug(fl),
m_changed(false)
m_plug(fl)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
......
......@@ -59,7 +59,7 @@ private:
class QCheckBox *cbShowFullPath;
KateFileTreePlugin *m_plug;
bool m_changed;
bool m_changed = false;
};
#endif /* KATE_FILETREE_CONFIGPAGE_H */
......
......@@ -842,10 +842,9 @@ void KateFileTreeModel::slotDocumentsDeleted(const QList<KTextEditor::Document *
class EditViewCount
{
public:
EditViewCount(): edit(0), view(0)
{}
int edit;
int view;
EditViewCount() = default;
int edit = 0;
int view = 0;
};
void KateFileTreeModel::updateBackgrounds(bool force)
......
......@@ -24,7 +24,7 @@
LocalsView::LocalsView(QWidget *parent)
: QTreeWidget(parent), m_allAdded(true)
: QTreeWidget(parent)
{
QStringList headers;
headers << i18n("Symbol");
......
......@@ -47,7 +47,7 @@ protected:
private:
void createWrappedItem(QTreeWidgetItem *parent, const QString &name, const QString &value);
void createWrappedItem(QTreeWidget *parent, const QString &name, const QString &value);
bool m_allAdded;
bool m_allAdded = true;
QString m_local;
};
......
......@@ -42,7 +42,7 @@ K_PLUGIN_FACTORY_WITH_JSON (KateCTagsPluginFactory, "katectagsplugin.json", regi
/******************************************************************/
KateCTagsPlugin::KateCTagsPlugin(QObject* parent, const QList<QVariant>&):
KTextEditor::Plugin (parent), m_view(nullptr)
KTextEditor::Plugin (parent)
{
// FIXME KF5
//KGlobal::locale()->insertCatalog("kate-ctags-plugin");
......
......@@ -44,11 +44,11 @@ class KateCTagsPlugin : public KTextEditor::Plugin
QObject *createView(KTextEditor::MainWindow *mainWindow) override;
int configPages() const override { return 1; };
int configPages() const override { return 1; }
KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override;
void readConfig();
KateCTagsView *m_view;
KateCTagsView *m_view = nullptr;
};
//******************************************************************/
......
......@@ -34,7 +34,6 @@ using KWallet::Wallet;
SQLManager::SQLManager(QObject *parent)
: QObject(parent)
, m_model(new ConnectionModel(this))
, m_wallet(nullptr)
{
}
......
......@@ -65,7 +65,7 @@ class SQLManager : public QObject
private:
ConnectionModel *m_model;
KWallet::Wallet *m_wallet;
KWallet::Wallet *m_wallet = nullptr;
};
#endif // SQLMANAGER_H
......@@ -170,8 +170,7 @@ struct RevisionGuard {
RevisionGuard(KTextEditor::Document *doc = nullptr)
: m_doc(doc),
m_movingInterface(qobject_cast<KTextEditor::MovingInterface *>(doc)),
m_revision(-1)
m_movingInterface(qobject_cast<KTextEditor::MovingInterface *>(doc))
{
if (m_movingInterface) {
m_revision = m_movingInterface->revision();
......
......@@ -22,7 +22,6 @@
KateProjectCodeAnalysisTool::KateProjectCodeAnalysisTool(QObject *parent)
: QObject(parent)
, m_project(nullptr)
{
}
......
......@@ -38,7 +38,7 @@ protected:
/**
* Current project
*/
KateProject *m_project;
KateProject *m_project = nullptr;
public:
virtual ~KateProjectCodeAnalysisTool();
......
......@@ -28,7 +28,6 @@
KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin *plugin)
: KTextEditor::ConfigPage(parent)
, m_plugin(plugin)
, m_changed(false)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
......
......@@ -49,7 +49,7 @@ private:
QCheckBox *m_cbAutoSubversion;
QCheckBox *m_cbAutoMercurial;
KateProjectPlugin *m_plugin;
bool m_changed;
bool m_changed = false;
};
#endif /* KATE_PROJECT_CONFIGPAGE_H */
......@@ -34,14 +34,14 @@ namespace KTextEditor {
}
struct CompletionMatch {
CompletionMatch() : type(KTextEditor::CodeCompletionModel::NoProperty), depth(0), line(-1), col(-1) {}
CompletionMatch() = default;
QString text;
QIcon icon;
KTextEditor::CodeCompletionModel::CompletionProperty type;
int depth;
KTextEditor::CodeCompletionModel::CompletionProperty type = KTextEditor::CodeCompletionModel::NoProperty;
int depth = 0;
QUrl url;
int line;
int col;
int line = -1;
int col = -1;
};
class KTERustCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
......
......@@ -29,7 +29,6 @@
KTERustCompletionConfigPage::KTERustCompletionConfigPage(QWidget *parent, KTERustCompletionPlugin *plugin)
: KTextEditor::ConfigPage(parent)
, m_changed(false)
, m_plugin(plugin)
{
QVBoxLayout *layout = new QVBoxLayout(this);
......
......@@ -52,7 +52,7 @@ class KTERustCompletionConfigPage : public KTextEditor::ConfigPage
QLineEdit *m_racerCmd;
KUrlRequester *m_rustSrcPath;
bool m_changed;
bool m_changed = false;
KTERustCompletionPlugin *m_plugin;
};
......
......@@ -32,9 +32,7 @@ K_PLUGIN_FACTORY_WITH_JSON(KTERustCompletionPluginFactory, "kterustcompletionplu
KTERustCompletionPlugin::KTERustCompletionPlugin(QObject *parent, const QList<QVariant> &)
: KTextEditor::Plugin(parent),
m_completion(this),
m_rustSrcWatch(nullptr),
m_configOk(false)
m_completion(this)
{
readConfig();
}
......
......@@ -63,9 +63,9 @@ class KTERustCompletionPlugin : public KTextEditor::Plugin
QString m_racerCmd;
QUrl m_rustSrcPath;
KDirWatch *m_rustSrcWatch;
KDirWatch *m_rustSrcWatch{nullptr};
bool m_configOk;
bool m_configOk{false};
};
#endif
......@@ -26,8 +26,6 @@
SearchDiskFiles::SearchDiskFiles(QObject *parent) : QThread(parent)
,m_cancelSearch(true)
,m_matchCount(0)
{}
SearchDiskFiles::~SearchDiskFiles()
......
......@@ -60,8 +60,8 @@ Q_SIGNALS:
private:
QRegularExpression m_regExp;
QStringList m_files;
bool m_cancelSearch;
int m_matchCount;
bool m_cancelSearch = true;
int m_matchCount = 0;
QTime m_statusTime;
};
......
......@@ -110,7 +110,7 @@ private:
}
};
Results::Results(QWidget *parent): QWidget(parent), matches(0), useRegExp(false), searchPlaceIndex(0)
Results::Results(QWidget *parent): QWidget(parent)
{
setupUi(this);
......@@ -121,8 +121,7 @@ Results::Results(QWidget *parent): QWidget(parent), matches(0), useRegExp(false)
K_PLUGIN_FACTORY_WITH_JSON (KatePluginSearchFactory, "katesearch.json", registerPlugin<KatePluginSearch>();)
KatePluginSearch::KatePluginSearch(QObject* parent, const QList<QVariant>&)
: KTextEditor::Plugin (parent),
m_searchCommand(nullptr)
: KTextEditor::Plugin (parent)
{
m_searchCommand = new KateSearchCommand(this);
}
......
......@@ -52,12 +52,12 @@ class Results: public QWidget, public Ui::Results
Q_OBJECT
public:
Results(QWidget *parent = nullptr);
int matches;
int matches = 0;
QRegularExpression regExp;
bool useRegExp;
bool useRegExp = false;
bool matchCase;
QString replaceStr;
int searchPlaceIndex;
int searchPlaceIndex = 0;
QString treeRootText;
};
......@@ -87,7 +87,7 @@ public:
QObject *createView(KTextEditor::MainWindow *mainWindow) override;
private:
KateSearchCommand* m_searchCommand;
KateSearchCommand* m_searchCommand = nullptr;
};
......
......@@ -22,7 +22,7 @@
#include <QTime>
SearchOpenFiles::SearchOpenFiles(QObject *parent) : QObject(parent), m_nextIndex(-1), m_cancelSearch(true)
SearchOpenFiles::SearchOpenFiles(QObject *parent) : QObject(parent)
{
connect(this, &SearchOpenFiles::searchNextFile, this, &SearchOpenFiles::doSearchNextFile, Qt::QueuedConnection);
}
......
......@@ -58,9 +58,9 @@ Q_SIGNALS:
private:
QList<KTextEditor::Document*> m_docList;
int m_nextIndex;
int m_nextIndex = -1;
QRegularExpression m_regExp;
bool m_cancelSearch;
bool m_cancelSearch = true;
QString m_fullDoc;
QVector<int> m_lineStart;
QTime m_statusTime;
......
......@@ -34,7 +34,7 @@
#include <QAction>
Snippet::Snippet()
: QStandardItem(i18n("<empty snippet>")), m_action(nullptr)
: QStandardItem(i18n("<empty snippet>"))
{
setIcon(QIcon::fromTheme(QStringLiteral("text-plain")));
}
......
......@@ -69,7 +69,7 @@ private:
/// the actual snippet contents aka \code<fillin>\endcode
QString m_snippet;
/// the insertion action for this snippet.
QAction* m_action;
QAction* m_action = nullptr;
};
Q_DECLARE_METATYPE ( Snippet* )
......
......@@ -44,9 +44,6 @@ K_PLUGIN_FACTORY_WITH_JSON(TextFilterPluginFactory, "textfilterplugin.json", reg
PluginKateTextFilter::PluginKateTextFilter(QObject *parent, const QList<QVariant> &):
KTextEditor::Plugin(parent)
, m_pFilterProcess(Q_NULLPTR)
, copyResult(false)
, mergeOutput(false)
{
// register command
new PluginKateTextFilterCommand(this);
......
......@@ -48,10 +48,10 @@ class PluginKateTextFilter : public KTextEditor::Plugin
QString m_strFilterOutput;
QString m_stderrOutput;
QString m_last_command;
KProcess * m_pFilterProcess;
KProcess * m_pFilterProcess = nullptr;
QStringList completionList;
bool copyResult;
bool mergeOutput;
bool copyResult = false;
bool mergeOutput = false;
public Q_SLOTS:
void slotEditFilter ();
void slotFilterReceivedStdout();
......
......@@ -42,18 +42,13 @@ public:
enum CustomRoles {RestoreOpeningFailedRole };
public:
KateDocumentInfo()
: modifiedOnDisc(false)
, modifiedOnDiscReason(KTextEditor::ModificationInterface::OnDiskUnmodified)
, openedByUser(false)
, openSuccess(true)
{}
bool modifiedOnDisc;
KTextEditor::ModificationInterface::ModifiedOnDiskReason modifiedOnDiscReason;
bool openedByUser;
bool openSuccess;
KateDocumentInfo() = default;
bool modifiedOnDisc = false;
KTextEditor::ModificationInterface::ModifiedOnDiskReason modifiedOnDiscReason = KTextEditor::ModificationInterface::OnDiskUnmodified;
bool openedByUser = false;
bool openSuccess = true;
};
class KateDocManager : public QObject
......
......@@ -554,7 +554,7 @@ private:
class BarState
{
public:
BarState(): m_bar(nullptr), m_state(false) {}
BarState() = default;
BarState(QWidget *bar): m_bar(bar), m_state(false) {}
~BarState() {}
QWidget *bar() {
......@@ -567,8 +567,8 @@ private:
m_state = state;
}
private:
QWidget *m_bar;
bool m_state;
QWidget *m_bar = nullptr;
bool m_state = false;
};
QHash<KTextEditor::View *, BarState> m_bottomViewBarMapping;
......
......@@ -716,8 +716,6 @@ void Sidebar::saveSession(KConfigGroup &config)
MainWindow::MainWindow(QWidget *parentWidget)
: KParts::MainWindow(parentWidget, Qt::Window)
, m_sidebarsVisible(true)
, m_restoreConfig(nullptr)
, m_guiClient(new GUIClient(this))
{
// init the internal widgets
......
......@@ -432,13 +432,13 @@ private:
/**
* sidebars state.
*/
bool m_sidebarsVisible;
bool m_sidebarsVisible = true;
/**
* config object for session restore, only valid between
* start and finish restore calls
*/
KConfigBase *m_restoreConfig;
KConfigBase *m_restoreConfig = nullptr;
/**
* restore group
......
......@@ -300,28 +300,23 @@ private:
/**
* Default constructor
*/
ViewData()
: active(false)
, lruAge(0)
, activityResource(Q_NULLPTR)
{
}
ViewData() = default;
/**
* view active?
*/
bool active;
bool active = false;
/**
* lru age of the view
* important: smallest age ==> latest used view
*/
qint64 lruAge;
qint64 lruAge = 0;
/**
* activity resource for the view
*/
KActivities::ResourceInstance *activityResource;
KActivities::ResourceInstance *activityResource = nullptr;
};
/**
......
......@@ -59,13 +59,7 @@
#include <QFileOpenEvent>
KWrite::KWrite(KTextEditor::Document *doc, KWriteApplication *app)
: m_view(nullptr)
, m_recentFiles(nullptr)
, m_paShowPath(nullptr)
, m_paShowMenuBar(nullptr)
, m_paShowStatusBar(nullptr)
, m_activityResource(nullptr)
, m_app(app)
: m_app(app)
, m_mainWindow(this)
{
if (!doc) {
......
......@@ -121,14 +121,14 @@ private:
void saveGlobalProperties(KConfig *) override;
private:
KTextEditor::View *m_view;
KTextEditor::View *m_view = nullptr;
KRecentFilesAction *m_recentFiles;
KToggleAction *m_paShowPath;
KToggleAction *m_paShowMenuBar;
KToggleAction *m_paShowStatusBar;
KRecentFilesAction *m_recentFiles = nullptr;
KToggleAction *m_paShowPath = nullptr;
KToggleAction *m_paShowMenuBar = nullptr;
KToggleAction *m_paShowStatusBar = nullptr;
QAction *m_closeAction;
KActivities::ResourceInstance *m_activityResource;
KActivities::ResourceInstance *m_activityResource = nullptr;
KWriteApplication *m_app;
KTextEditor::MainWindow m_mainWindow;
......
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