From c383535d5c3f5eb764cb341131b2cbd87ebfb327 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Jun 2015 13:14:34 +0200 Subject: [PATCH] CPaster: Introduce member initialization. Remove/simplify constructors accordingly. Change-Id: I27ac0281a89dfadefb1f7837d99ce185745b7aae Reviewed-by: Eike Ziller --- src/plugins/cpaster/columnindicatortextedit.cpp | 2 +- src/plugins/cpaster/columnindicatortextedit.h | 2 +- src/plugins/cpaster/cpasterplugin.cpp | 3 +-- src/plugins/cpaster/cpasterplugin.h | 8 ++++---- src/plugins/cpaster/kdepasteprotocol.cpp | 9 --------- src/plugins/cpaster/kdepasteprotocol.h | 12 +++++------- src/plugins/cpaster/pastebindotcaprotocol.cpp | 7 ------- src/plugins/cpaster/pastebindotcaprotocol.h | 10 ++++------ src/plugins/cpaster/pastebindotcomprotocol.cpp | 9 --------- src/plugins/cpaster/pastebindotcomprotocol.h | 12 +++++------- src/plugins/cpaster/pasteview.cpp | 3 +-- src/plugins/cpaster/pasteview.h | 2 +- src/plugins/cpaster/settings.cpp | 4 ---- src/plugins/cpaster/settings.h | 7 +++---- src/plugins/cpaster/urlopenprotocol.cpp | 5 ----- src/plugins/cpaster/urlopenprotocol.h | 4 +--- 16 files changed, 27 insertions(+), 72 deletions(-) diff --git a/src/plugins/cpaster/columnindicatortextedit.cpp b/src/plugins/cpaster/columnindicatortextedit.cpp index a27159bbd61..2304e7bf348 100644 --- a/src/plugins/cpaster/columnindicatortextedit.cpp +++ b/src/plugins/cpaster/columnindicatortextedit.cpp @@ -36,7 +36,7 @@ namespace CodePaster { ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) : - QTextEdit(parent), m_columnIndicator(0) + QTextEdit(parent) { QFont font; font.setFamily(QLatin1String("Courier New")); diff --git a/src/plugins/cpaster/columnindicatortextedit.h b/src/plugins/cpaster/columnindicatortextedit.h index d85695a7a87..93796d92feb 100644 --- a/src/plugins/cpaster/columnindicatortextedit.h +++ b/src/plugins/cpaster/columnindicatortextedit.h @@ -47,7 +47,7 @@ protected: virtual void paintEvent(QPaintEvent *event); private: - int m_columnIndicator; + int m_columnIndicator = 0; QFont m_columnIndicatorFont; }; } // namespace CodePaster diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 083394205ed..462d949ea4f 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -105,8 +105,7 @@ void CodePasterService::postClipboard() CodepasterPlugin *CodepasterPlugin::m_instance = 0; CodepasterPlugin::CodepasterPlugin() : - m_settings(new Settings), - m_postEditorAction(0), m_fetchAction(0) + m_settings(new Settings) { CodepasterPlugin::m_instance = this; } diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h index a7ada6b001b..3ac41a767e3 100644 --- a/src/plugins/cpaster/cpasterplugin.h +++ b/src/plugins/cpaster/cpasterplugin.h @@ -94,12 +94,12 @@ private: static CodepasterPlugin *m_instance; const QSharedPointer m_settings; - QAction *m_postEditorAction; - QAction *m_fetchAction; - QAction *m_fetchUrlAction; + QAction *m_postEditorAction = nullptr; + QAction *m_fetchAction = nullptr; + QAction *m_fetchUrlAction = nullptr; QList m_protocols; QStringList m_fetchedSnippets; - Protocol *m_urlOpen; + Protocol *m_urlOpen = nullptr; }; Q_DECLARE_OPERATORS_FOR_FLAGS(CodepasterPlugin::PasteSources) diff --git a/src/plugins/cpaster/kdepasteprotocol.cpp b/src/plugins/cpaster/kdepasteprotocol.cpp index 498fb98125c..0eaede11406 100644 --- a/src/plugins/cpaster/kdepasteprotocol.cpp +++ b/src/plugins/cpaster/kdepasteprotocol.cpp @@ -56,15 +56,6 @@ static inline QByteArray expiryParameter(int daysRequested) } namespace CodePaster { -StickyNotesPasteProtocol::StickyNotesPasteProtocol() : - m_fetchReply(0), - m_pasteReply(0), - m_listReply(0), - m_fetchId(-1), - m_postId(-1), - m_hostChecked(false) -{ -} void StickyNotesPasteProtocol::setHostUrl(const QString &hostUrl) { diff --git a/src/plugins/cpaster/kdepasteprotocol.h b/src/plugins/cpaster/kdepasteprotocol.h index df3621f8755..76bff75c9d2 100644 --- a/src/plugins/cpaster/kdepasteprotocol.h +++ b/src/plugins/cpaster/kdepasteprotocol.h @@ -39,8 +39,6 @@ class StickyNotesPasteProtocol : public NetworkProtocol { Q_OBJECT public: - StickyNotesPasteProtocol(); - virtual unsigned capabilities() const; virtual void fetch(const QString &id); @@ -68,13 +66,13 @@ protected: private: QString m_hostUrl; - QNetworkReply *m_fetchReply; - QNetworkReply *m_pasteReply; - QNetworkReply *m_listReply; + QNetworkReply *m_fetchReply = nullptr; + QNetworkReply *m_pasteReply = nullptr; + QNetworkReply *m_listReply = nullptr; QString m_fetchId; - int m_postId; - bool m_hostChecked; + int m_postId = -1; + bool m_hostChecked = false; }; class KdePasteProtocol : public StickyNotesPasteProtocol diff --git a/src/plugins/cpaster/pastebindotcaprotocol.cpp b/src/plugins/cpaster/pastebindotcaprotocol.cpp index 8e8a53db85d..cada4df4930 100644 --- a/src/plugins/cpaster/pastebindotcaprotocol.cpp +++ b/src/plugins/cpaster/pastebindotcaprotocol.cpp @@ -63,13 +63,6 @@ static inline QByteArray expiryValue(int expiryDays) } namespace CodePaster { -PasteBinDotCaProtocol::PasteBinDotCaProtocol() : - m_fetchReply(0), - m_listReply(0), - m_pasteReply(0), - m_hostChecked(false) -{ -} QString PasteBinDotCaProtocol::protocolName() { diff --git a/src/plugins/cpaster/pastebindotcaprotocol.h b/src/plugins/cpaster/pastebindotcaprotocol.h index b5440da6f5f..445afa710ce 100644 --- a/src/plugins/cpaster/pastebindotcaprotocol.h +++ b/src/plugins/cpaster/pastebindotcaprotocol.h @@ -38,8 +38,6 @@ class PasteBinDotCaProtocol : public NetworkProtocol { Q_OBJECT public: - explicit PasteBinDotCaProtocol(); - static QString protocolName(); QString name() const { return protocolName(); } @@ -64,11 +62,11 @@ protected: virtual bool checkConfiguration(QString *errorMessage); private: - QNetworkReply *m_fetchReply; - QNetworkReply *m_listReply; - QNetworkReply *m_pasteReply; + QNetworkReply *m_fetchReply = nullptr; + QNetworkReply *m_listReply = nullptr; + QNetworkReply *m_pasteReply = nullptr; QString m_fetchId; - bool m_hostChecked; + bool m_hostChecked = false; }; } // namespace CodePaster diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp index e06ac4f6aeb..d74855fe7d5 100644 --- a/src/plugins/cpaster/pastebindotcomprotocol.cpp +++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp @@ -52,15 +52,6 @@ static const char API_KEY[]="api_dev_key=516686fc461fb7f9341fd7cf2af6f829&"; // static const char PROTOCOL_NAME[] = "Pastebin.Com"; namespace CodePaster { -PasteBinDotComProtocol::PasteBinDotComProtocol() : - m_fetchReply(0), - m_pasteReply(0), - m_listReply(0), - m_fetchId(-1), - m_postId(-1), - m_hostChecked(false) -{ -} QString PasteBinDotComProtocol::protocolName() { diff --git a/src/plugins/cpaster/pastebindotcomprotocol.h b/src/plugins/cpaster/pastebindotcomprotocol.h index a310940808a..f9000e10f5d 100644 --- a/src/plugins/cpaster/pastebindotcomprotocol.h +++ b/src/plugins/cpaster/pastebindotcomprotocol.h @@ -39,8 +39,6 @@ class PasteBinDotComProtocol : public NetworkProtocol { Q_OBJECT public: - PasteBinDotComProtocol(); - static QString protocolName(); QString name() const { return protocolName(); } @@ -61,13 +59,13 @@ public slots: void listFinished(); private: - QNetworkReply *m_fetchReply; - QNetworkReply *m_pasteReply; - QNetworkReply *m_listReply; + QNetworkReply *m_fetchReply = nullptr; + QNetworkReply *m_pasteReply = nullptr; + QNetworkReply *m_listReply = nullptr; QString m_fetchId; - int m_postId; - bool m_hostChecked; + int m_postId = -1; + bool m_hostChecked = false; }; } // namespace CodePaster #endif // PASTEBINDOTCOMPROTOCOL_H diff --git a/src/plugins/cpaster/pasteview.cpp b/src/plugins/cpaster/pasteview.cpp index 3bd9b7f4a43..033bfc84759 100644 --- a/src/plugins/cpaster/pasteview.cpp +++ b/src/plugins/cpaster/pasteview.cpp @@ -49,8 +49,7 @@ PasteView::PasteView(const QList &protocols, QDialog(parent), m_protocols(protocols), m_commentPlaceHolder(tr("")), - m_mimeType(mt), - m_mode(DiffChunkMode) + m_mimeType(mt) { m_ui.setupUi(this); diff --git a/src/plugins/cpaster/pasteview.h b/src/plugins/cpaster/pasteview.h index 13a1b3d3244..dd0abb13216 100644 --- a/src/plugins/cpaster/pasteview.h +++ b/src/plugins/cpaster/pasteview.h @@ -89,7 +89,7 @@ private: Internal::Ui::ViewDialog m_ui; FileDataList m_parts; - Mode m_mode; + Mode m_mode = DiffChunkMode; }; } // namespace CodePaster #endif // VIEW_H diff --git a/src/plugins/cpaster/settings.cpp b/src/plugins/cpaster/settings.cpp index 8c045375f52..3dec2705bc8 100644 --- a/src/plugins/cpaster/settings.cpp +++ b/src/plugins/cpaster/settings.cpp @@ -44,10 +44,6 @@ static const char displayOutputKeyC[] = "DisplayOutput"; namespace CodePaster { -Settings::Settings() : expiryDays(1), copyToClipboard(true), displayOutput(true) -{ -} - bool Settings::equals(const Settings &rhs) const { return copyToClipboard == rhs.copyToClipboard && displayOutput == rhs.displayOutput diff --git a/src/plugins/cpaster/settings.h b/src/plugins/cpaster/settings.h index d8a3f8e95b1..ad2d6e8935f 100644 --- a/src/plugins/cpaster/settings.h +++ b/src/plugins/cpaster/settings.h @@ -40,16 +40,15 @@ QT_END_NAMESPACE namespace CodePaster { struct Settings { - Settings(); void toSettings(QSettings *s) const; void fromSettings(const QSettings *s); bool equals(const Settings &s) const; QString username; QString protocol; - int expiryDays; - bool copyToClipboard; - bool displayOutput; + int expiryDays = 1; + bool copyToClipboard = true; + bool displayOutput = true; }; inline bool operator==(const Settings &s1, const Settings &s2) { return s1.equals(s2); } diff --git a/src/plugins/cpaster/urlopenprotocol.cpp b/src/plugins/cpaster/urlopenprotocol.cpp index 65eda4efe10..1d77569ff80 100644 --- a/src/plugins/cpaster/urlopenprotocol.cpp +++ b/src/plugins/cpaster/urlopenprotocol.cpp @@ -36,11 +36,6 @@ using namespace CodePaster; -UrlOpenProtocol::UrlOpenProtocol() - : m_fetchReply(0) -{ -} - QString UrlOpenProtocol::name() const { return QLatin1String("Open URL"); // unused diff --git a/src/plugins/cpaster/urlopenprotocol.h b/src/plugins/cpaster/urlopenprotocol.h index 397a9e3fdc1..b0da855e656 100644 --- a/src/plugins/cpaster/urlopenprotocol.h +++ b/src/plugins/cpaster/urlopenprotocol.h @@ -39,8 +39,6 @@ class UrlOpenProtocol : public NetworkProtocol { Q_OBJECT public: - UrlOpenProtocol(); - QString name() const; unsigned capabilities() const; void fetch(const QString &url); @@ -50,7 +48,7 @@ private slots: void fetchFinished(); private: - QNetworkReply *m_fetchReply; + QNetworkReply *m_fetchReply = nullptr; }; }