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.
|
the macro event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class IMacroHandler::IMacroHandlerPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IMacroHandlerPrivate();
|
|
||||||
|
|
||||||
Macro *currentMacro;
|
|
||||||
};
|
|
||||||
|
|
||||||
IMacroHandler::IMacroHandlerPrivate::IMacroHandlerPrivate() :
|
|
||||||
currentMacro(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ---------- IMacroHandler ------------
|
// ---------- IMacroHandler ------------
|
||||||
|
|
||||||
IMacroHandler::IMacroHandler():
|
|
||||||
d(new IMacroHandlerPrivate)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IMacroHandler::~IMacroHandler()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMacroHandler::startRecording(Macro* macro)
|
void IMacroHandler::startRecording(Macro* macro)
|
||||||
{
|
{
|
||||||
d->currentMacro = macro;
|
m_currentMacro = macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMacroHandler::endRecordingMacro(Macro* macro)
|
void IMacroHandler::endRecordingMacro(Macro* macro)
|
||||||
{
|
{
|
||||||
Q_UNUSED(macro)
|
Q_UNUSED(macro)
|
||||||
d->currentMacro = 0;
|
m_currentMacro = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMacroHandler::addMacroEvent(const MacroEvent& event)
|
void IMacroHandler::addMacroEvent(const MacroEvent& event)
|
||||||
{
|
{
|
||||||
if (d->currentMacro)
|
if (m_currentMacro)
|
||||||
d->currentMacro->append(event);
|
m_currentMacro->append(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMacroHandler::setCurrentMacro(Macro *macro)
|
void IMacroHandler::setCurrentMacro(Macro *macro)
|
||||||
{
|
{
|
||||||
d->currentMacro = macro;
|
m_currentMacro = macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IMacroHandler::isRecording() const
|
bool IMacroHandler::isRecording() const
|
||||||
{
|
{
|
||||||
return d->currentMacro != 0;
|
return m_currentMacro != nullptr;
|
||||||
}
|
}
|
||||||
|
@@ -39,9 +39,6 @@ class IMacroHandler: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMacroHandler();
|
|
||||||
~IMacroHandler();
|
|
||||||
|
|
||||||
virtual void startRecording(Macro* macro);
|
virtual void startRecording(Macro* macro);
|
||||||
virtual void endRecordingMacro(Macro* macro);
|
virtual void endRecordingMacro(Macro* macro);
|
||||||
|
|
||||||
@@ -58,8 +55,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
friend class MacroManager;
|
friend class MacroManager;
|
||||||
|
|
||||||
class IMacroHandlerPrivate;
|
Macro *m_currentMacro = nullptr;
|
||||||
IMacroHandlerPrivate *d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -96,8 +96,8 @@ public:
|
|||||||
MacroManager *q;
|
MacroManager *q;
|
||||||
QMap<QString, Macro *> macros;
|
QMap<QString, Macro *> macros;
|
||||||
QMap<QString, QAction *> actions;
|
QMap<QString, QAction *> actions;
|
||||||
Macro *currentMacro;
|
Macro *currentMacro = nullptr;
|
||||||
bool isRecording;
|
bool isRecording = false;
|
||||||
|
|
||||||
QList<IMacroHandler*> handlers;
|
QList<IMacroHandler*> handlers;
|
||||||
|
|
||||||
@@ -115,9 +115,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
MacroManager::MacroManagerPrivate::MacroManagerPrivate(MacroManager *qq):
|
MacroManager::MacroManagerPrivate::MacroManagerPrivate(MacroManager *qq):
|
||||||
q(qq),
|
q(qq)
|
||||||
currentMacro(0),
|
|
||||||
isRecording(false)
|
|
||||||
{
|
{
|
||||||
// Load existing macros
|
// Load existing macros
|
||||||
initialize();
|
initialize();
|
||||||
@@ -179,7 +177,7 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
|||||||
// Remove macro from the map
|
// Remove macro from the map
|
||||||
Macro *macro = macros.take(name);
|
Macro *macro = macros.take(name);
|
||||||
if (macro == currentMacro)
|
if (macro == currentMacro)
|
||||||
currentMacro = 0;
|
currentMacro = nullptr;
|
||||||
delete macro;
|
delete macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +241,7 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
|||||||
|
|
||||||
|
|
||||||
// ---------- MacroManager ------------
|
// ---------- MacroManager ------------
|
||||||
MacroManager *MacroManager::m_instance = 0;
|
MacroManager *MacroManager::m_instance = nullptr;
|
||||||
|
|
||||||
MacroManager::MacroManager(QObject *parent) :
|
MacroManager::MacroManager(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
@@ -48,10 +48,6 @@
|
|||||||
|
|
||||||
using namespace Macros::Internal;
|
using namespace Macros::Internal;
|
||||||
|
|
||||||
MacrosPlugin::MacrosPlugin() : m_macroManager(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MacrosPlugin::~MacrosPlugin()
|
MacrosPlugin::~MacrosPlugin()
|
||||||
{
|
{
|
||||||
delete m_macroManager;
|
delete m_macroManager;
|
||||||
|
@@ -38,14 +38,13 @@ class MacrosPlugin : public ExtensionSystem::IPlugin
|
|||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Macros.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Macros.json")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacrosPlugin();
|
|
||||||
~MacrosPlugin();
|
~MacrosPlugin();
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MacroManager *m_macroManager;
|
MacroManager *m_macroManager = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -53,8 +53,7 @@ static quint8 AUTOREP = 4;
|
|||||||
static quint8 COUNT = 5;
|
static quint8 COUNT = 5;
|
||||||
|
|
||||||
|
|
||||||
TextEditorMacroHandler::TextEditorMacroHandler():
|
TextEditorMacroHandler::TextEditorMacroHandler()
|
||||||
IMacroHandler()
|
|
||||||
{
|
{
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
connect(editorManager, &Core::EditorManager::currentEditorChanged,
|
connect(editorManager, &Core::EditorManager::currentEditorChanged,
|
||||||
@@ -140,5 +139,5 @@ void TextEditorMacroHandler::closeEditor(Core::IEditor *editor)
|
|||||||
Q_UNUSED(editor);
|
Q_UNUSED(editor);
|
||||||
if (isRecording() && m_currentEditor && m_currentEditor->widget())
|
if (isRecording() && m_currentEditor && m_currentEditor->widget())
|
||||||
m_currentEditor->widget()->removeEventFilter(this);
|
m_currentEditor->widget()->removeEventFilter(this);
|
||||||
m_currentEditor = 0;
|
m_currentEditor = nullptr;
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ public:
|
|||||||
void closeEditor(Core::IEditor *editor);
|
void closeEditor(Core::IEditor *editor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::BaseTextEditor *m_currentEditor;
|
TextEditor::BaseTextEditor *m_currentEditor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user