forked from qt-creator/qt-creator
CodePaster: Modernize
modernize-use-auto modernize-use-nullptr modernize-use-equals-default Change-Id: I3d9fffef3bccc1a64e24acd0846da57b224ba801 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ namespace CodePaster {
|
||||
class Service
|
||||
{
|
||||
public:
|
||||
virtual ~Service() {}
|
||||
virtual ~Service() = default;
|
||||
|
||||
virtual void postText(const QString &text, const QString &mimeType) = 0;
|
||||
virtual void postCurrentEditor() = 0;
|
||||
|
||||
@@ -116,7 +116,7 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
|
||||
// Create the settings Page
|
||||
m_settings->fromSettings(ICore::settings());
|
||||
SettingsPage *settingsPage = new SettingsPage(m_settings, this);
|
||||
auto settingsPage = new SettingsPage(m_settings, this);
|
||||
|
||||
// Create the protocols and append them to the Settings
|
||||
Protocol *protos[] = {new PasteBinDotComProtocol,
|
||||
@@ -191,7 +191,7 @@ static inline void textFromCurrentEditor(QString *text, QString *mimeType)
|
||||
return;
|
||||
const IDocument *document = editor->document();
|
||||
QString data;
|
||||
if (const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor))
|
||||
if (auto textEditor = qobject_cast<const BaseTextEditor *>(editor))
|
||||
data = textEditor->selectedText();
|
||||
if (data.isEmpty()) {
|
||||
if (auto textDocument = qobject_cast<const TextDocument *>(document)) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class CodePasterServiceImpl : public QObject, public CodePaster::Service
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(CodePaster::Service)
|
||||
public:
|
||||
explicit CodePasterServiceImpl(QObject *parent = 0);
|
||||
explicit CodePasterServiceImpl(QObject *parent = nullptr);
|
||||
|
||||
void postText(const QString &text, const QString &mimeType) override;
|
||||
void postCurrentEditor() override;
|
||||
|
||||
@@ -143,7 +143,7 @@ void FileShareProtocol::fetch(const QString &id)
|
||||
fi = QFileInfo(m_settings->path + QLatin1Char('/') + id);
|
||||
QString errorMessage;
|
||||
QString text;
|
||||
if (parse(fi.absoluteFilePath(), &errorMessage, 0, 0, &text))
|
||||
if (parse(fi.absoluteFilePath(), &errorMessage, nullptr, nullptr, &text))
|
||||
emit fetchDone(id, text, false);
|
||||
else
|
||||
emit fetchDone(id, errorMessage, true);
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
bool hasSettings() const override;
|
||||
Core::IOptionsPage *settingsPage() const override;
|
||||
|
||||
bool checkConfiguration(QString *errorMessage = 0) override;
|
||||
bool checkConfiguration(QString *errorMessage = nullptr) override;
|
||||
void fetch(const QString &id) override;
|
||||
void list() override;
|
||||
void paste(const QString &text,
|
||||
|
||||
@@ -57,7 +57,7 @@ inline bool operator!=(const FileShareProtocolSettings &s1, const FileShareProto
|
||||
class FileShareProtocolSettingsWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileShareProtocolSettingsWidget(QWidget *parent = 0);
|
||||
explicit FileShareProtocolSettingsWidget(QWidget *parent = nullptr);
|
||||
|
||||
void setSettings(const FileShareProtocolSettings &);
|
||||
FileShareProtocolSettings settings() const;
|
||||
@@ -72,7 +72,7 @@ class FileShareProtocolSettingsPage : public Core::IOptionsPage
|
||||
|
||||
public:
|
||||
explicit FileShareProtocolSettingsPage(const QSharedPointer<FileShareProtocolSettings> &s,
|
||||
QObject *parent = 0);
|
||||
QObject *parent = nullptr);
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
|
||||
@@ -169,7 +169,7 @@ void StickyNotesPasteProtocol::pasteFinished()
|
||||
}
|
||||
|
||||
m_pasteReply->deleteLater();
|
||||
m_pasteReply = 0;
|
||||
m_pasteReply = nullptr;
|
||||
}
|
||||
|
||||
void StickyNotesPasteProtocol::fetch(const QString &id)
|
||||
@@ -207,7 +207,7 @@ void StickyNotesPasteProtocol::fetchFinished()
|
||||
content.remove(QLatin1Char('\r'));
|
||||
}
|
||||
m_fetchReply->deleteLater();
|
||||
m_fetchReply = 0;
|
||||
m_fetchReply = nullptr;
|
||||
emit fetchDone(title, content, error);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
void setHostUrl(const QString &hostUrl);
|
||||
|
||||
protected:
|
||||
bool checkConfiguration(QString *errorMessage = 0) override;
|
||||
bool checkConfiguration(QString *errorMessage = nullptr) override;
|
||||
|
||||
private:
|
||||
void fetchFinished();
|
||||
|
||||
@@ -135,7 +135,7 @@ void PasteBinDotComProtocol::pasteFinished()
|
||||
emit pasteDone(QString::fromLatin1(m_pasteReply->readAll()));
|
||||
|
||||
m_pasteReply->deleteLater();
|
||||
m_pasteReply = 0;
|
||||
m_pasteReply = nullptr;
|
||||
}
|
||||
|
||||
void PasteBinDotComProtocol::fetch(const QString &id)
|
||||
|
||||
@@ -60,9 +60,7 @@ PasteSelectDialog::PasteSelectDialog(const QList<Protocol*> &protocols,
|
||||
m_ui.listWidget->setFont(listFont);
|
||||
}
|
||||
|
||||
PasteSelectDialog::~PasteSelectDialog()
|
||||
{
|
||||
}
|
||||
PasteSelectDialog::~PasteSelectDialog() = default;
|
||||
|
||||
QString PasteSelectDialog::pasteId() const
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ class PasteSelectDialog : public QDialog
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PasteSelectDialog(const QList<Protocol*> &protocols,
|
||||
QWidget *parent = 0);
|
||||
QWidget *parent = nullptr);
|
||||
~PasteSelectDialog() override;
|
||||
|
||||
QString pasteId() const;
|
||||
|
||||
@@ -57,9 +57,7 @@ PasteView::PasteView(const QList<Protocol *> &protocols,
|
||||
this, &PasteView::protocolChanged);
|
||||
}
|
||||
|
||||
PasteView::~PasteView()
|
||||
{
|
||||
}
|
||||
PasteView::~PasteView() = default;
|
||||
|
||||
QString PasteView::user() const
|
||||
{
|
||||
@@ -150,7 +148,7 @@ int PasteView::show(const QString &user, const QString &description,
|
||||
m_mode = DiffChunkMode;
|
||||
QString content;
|
||||
foreach (const FileData &part, parts) {
|
||||
QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList);
|
||||
auto itm = new QListWidgetItem(part.filename, m_ui.uiPatchList);
|
||||
itm->setCheckState(Qt::Checked);
|
||||
itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
content += part.content;
|
||||
|
||||
@@ -59,9 +59,7 @@ Protocol::Protocol()
|
||||
{
|
||||
}
|
||||
|
||||
Protocol::~Protocol()
|
||||
{
|
||||
}
|
||||
Protocol::~Protocol() = default;
|
||||
|
||||
bool Protocol::hasSettings() const
|
||||
{
|
||||
@@ -75,7 +73,7 @@ bool Protocol::checkConfiguration(QString *)
|
||||
|
||||
Core::IOptionsPage *Protocol::settingsPage() const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Protocol::list()
|
||||
@@ -216,9 +214,7 @@ NetworkProtocol::NetworkProtocol()
|
||||
this, &NetworkProtocol::authenticationRequired);
|
||||
}
|
||||
|
||||
NetworkProtocol::~NetworkProtocol()
|
||||
{
|
||||
}
|
||||
NetworkProtocol::~NetworkProtocol() = default;
|
||||
|
||||
void NetworkProtocol::requestAuthentication(const QUrl &url, QNetworkReply *reply, QAuthenticator *authenticator)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
virtual bool hasSettings() const;
|
||||
virtual Core::IOptionsPage *settingsPage() const;
|
||||
|
||||
virtual bool checkConfiguration(QString *errorMessage = 0);
|
||||
virtual bool checkConfiguration(QString *errorMessage = nullptr);
|
||||
virtual void fetch(const QString &id) = 0;
|
||||
virtual void list();
|
||||
virtual void paste(const QString &text,
|
||||
@@ -80,11 +80,11 @@ public:
|
||||
// Return true when settings changed.
|
||||
static bool showConfigurationError(const Protocol *p,
|
||||
const QString &message,
|
||||
QWidget *parent = 0,
|
||||
QWidget *parent = nullptr,
|
||||
bool showConfig = true);
|
||||
// Ensure configuration is correct
|
||||
static bool ensureConfiguration(Protocol *p,
|
||||
QWidget *parent = 0);
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void pasteDone(const QString &link);
|
||||
|
||||
@@ -73,9 +73,7 @@ SettingsPage::SettingsPage(const QSharedPointer<Settings> &settings, QObject *pa
|
||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||
}
|
||||
|
||||
SettingsPage::~SettingsPage()
|
||||
{
|
||||
}
|
||||
SettingsPage::~SettingsPage() = default;
|
||||
|
||||
QWidget *SettingsPage::widget()
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class SettingsWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsWidget(const QStringList &protocols, QWidget *parent = 0);
|
||||
explicit SettingsWidget(const QStringList &protocols, QWidget *parent = nullptr);
|
||||
|
||||
void setSettings(const Settings &);
|
||||
Settings settings();
|
||||
|
||||
Reference in New Issue
Block a user