forked from qt-creator/qt-creator
Macros: Modernize
* Replace 0 with nullptr * Remove redundant pimpl * Use inline member initialization Started-by: Laurent Montel <laurent.montel@kdab.com> Change-Id: I15ace2581c13ecf24b7c947972b9435fbcaa12ab Reviewed-by: Laurent Montel <laurent.montel@kdab.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
e99b86e8ca
commit
0269bf537b
@@ -67,55 +67,31 @@ using namespace Macros::Internal;
|
||||
the macro event.
|
||||
*/
|
||||
|
||||
class IMacroHandler::IMacroHandlerPrivate
|
||||
{
|
||||
public:
|
||||
IMacroHandlerPrivate();
|
||||
|
||||
Macro *currentMacro;
|
||||
};
|
||||
|
||||
IMacroHandler::IMacroHandlerPrivate::IMacroHandlerPrivate() :
|
||||
currentMacro(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------- IMacroHandler ------------
|
||||
|
||||
IMacroHandler::IMacroHandler():
|
||||
d(new IMacroHandlerPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
IMacroHandler::~IMacroHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void IMacroHandler::startRecording(Macro* macro)
|
||||
{
|
||||
d->currentMacro = macro;
|
||||
m_currentMacro = macro;
|
||||
}
|
||||
|
||||
void IMacroHandler::endRecordingMacro(Macro* macro)
|
||||
{
|
||||
Q_UNUSED(macro)
|
||||
d->currentMacro = 0;
|
||||
m_currentMacro = nullptr;
|
||||
}
|
||||
|
||||
void IMacroHandler::addMacroEvent(const MacroEvent& event)
|
||||
{
|
||||
if (d->currentMacro)
|
||||
d->currentMacro->append(event);
|
||||
if (m_currentMacro)
|
||||
m_currentMacro->append(event);
|
||||
}
|
||||
|
||||
void IMacroHandler::setCurrentMacro(Macro *macro)
|
||||
{
|
||||
d->currentMacro = macro;
|
||||
m_currentMacro = macro;
|
||||
}
|
||||
|
||||
bool IMacroHandler::isRecording() const
|
||||
{
|
||||
return d->currentMacro != 0;
|
||||
return m_currentMacro != nullptr;
|
||||
}
|
||||
|
@@ -39,9 +39,6 @@ class IMacroHandler: public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IMacroHandler();
|
||||
~IMacroHandler();
|
||||
|
||||
virtual void startRecording(Macro* macro);
|
||||
virtual void endRecordingMacro(Macro* macro);
|
||||
|
||||
@@ -58,8 +55,7 @@ protected:
|
||||
private:
|
||||
friend class MacroManager;
|
||||
|
||||
class IMacroHandlerPrivate;
|
||||
IMacroHandlerPrivate *d;
|
||||
Macro *m_currentMacro = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -96,8 +96,8 @@ public:
|
||||
MacroManager *q;
|
||||
QMap<QString, Macro *> macros;
|
||||
QMap<QString, QAction *> actions;
|
||||
Macro *currentMacro;
|
||||
bool isRecording;
|
||||
Macro *currentMacro = nullptr;
|
||||
bool isRecording = false;
|
||||
|
||||
QList<IMacroHandler*> handlers;
|
||||
|
||||
@@ -115,9 +115,7 @@ public:
|
||||
};
|
||||
|
||||
MacroManager::MacroManagerPrivate::MacroManagerPrivate(MacroManager *qq):
|
||||
q(qq),
|
||||
currentMacro(0),
|
||||
isRecording(false)
|
||||
q(qq)
|
||||
{
|
||||
// Load existing macros
|
||||
initialize();
|
||||
@@ -179,7 +177,7 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
||||
// Remove macro from the map
|
||||
Macro *macro = macros.take(name);
|
||||
if (macro == currentMacro)
|
||||
currentMacro = 0;
|
||||
currentMacro = nullptr;
|
||||
delete macro;
|
||||
}
|
||||
|
||||
@@ -243,7 +241,7 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
||||
|
||||
|
||||
// ---------- MacroManager ------------
|
||||
MacroManager *MacroManager::m_instance = 0;
|
||||
MacroManager *MacroManager::m_instance = nullptr;
|
||||
|
||||
MacroManager::MacroManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
|
@@ -48,10 +48,6 @@
|
||||
|
||||
using namespace Macros::Internal;
|
||||
|
||||
MacrosPlugin::MacrosPlugin() : m_macroManager(0)
|
||||
{
|
||||
}
|
||||
|
||||
MacrosPlugin::~MacrosPlugin()
|
||||
{
|
||||
delete m_macroManager;
|
||||
|
@@ -38,14 +38,13 @@ class MacrosPlugin : public ExtensionSystem::IPlugin
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Macros.json")
|
||||
|
||||
public:
|
||||
MacrosPlugin();
|
||||
~MacrosPlugin();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||
void extensionsInitialized();
|
||||
|
||||
private:
|
||||
MacroManager *m_macroManager;
|
||||
MacroManager *m_macroManager = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -53,8 +53,7 @@ static quint8 AUTOREP = 4;
|
||||
static quint8 COUNT = 5;
|
||||
|
||||
|
||||
TextEditorMacroHandler::TextEditorMacroHandler():
|
||||
IMacroHandler()
|
||||
TextEditorMacroHandler::TextEditorMacroHandler()
|
||||
{
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
connect(editorManager, &Core::EditorManager::currentEditorChanged,
|
||||
@@ -140,5 +139,5 @@ void TextEditorMacroHandler::closeEditor(Core::IEditor *editor)
|
||||
Q_UNUSED(editor);
|
||||
if (isRecording() && m_currentEditor && m_currentEditor->widget())
|
||||
m_currentEditor->widget()->removeEventFilter(this);
|
||||
m_currentEditor = 0;
|
||||
m_currentEditor = nullptr;
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
void closeEditor(Core::IEditor *editor);
|
||||
|
||||
private:
|
||||
TextEditor::BaseTextEditor *m_currentEditor;
|
||||
TextEditor::BaseTextEditor *m_currentEditor = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user