forked from qt-creator/qt-creator
EmacsKeys: Modernize
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-equals-default Change-Id: Icdd470c27bfaef1ff4d8af20103c8d2a22043bbe Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -58,13 +58,9 @@ namespace Internal {
|
|||||||
// EmacsKeysPlugin
|
// EmacsKeysPlugin
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
EmacsKeysPlugin::EmacsKeysPlugin(): m_currentEditorWidget(0)
|
EmacsKeysPlugin::EmacsKeysPlugin() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
EmacsKeysPlugin::~EmacsKeysPlugin()
|
EmacsKeysPlugin::~EmacsKeysPlugin() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EmacsKeysPlugin::initialize(const QStringList &arguments, QString *errorString)
|
bool EmacsKeysPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||||
{
|
{
|
||||||
@@ -141,7 +137,7 @@ ExtensionSystem::IPlugin::ShutdownFlag EmacsKeysPlugin::aboutToShutdown()
|
|||||||
|
|
||||||
void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
|
void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
|
||||||
{
|
{
|
||||||
QPlainTextEdit *w = qobject_cast<QPlainTextEdit*>(editor->widget());
|
auto w = qobject_cast<QPlainTextEdit*>(editor->widget());
|
||||||
if (!w)
|
if (!w)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -154,7 +150,7 @@ void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
|
|||||||
void EmacsKeysPlugin::currentEditorChanged(IEditor *editor)
|
void EmacsKeysPlugin::currentEditorChanged(IEditor *editor)
|
||||||
{
|
{
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
m_currentEditorWidget = 0;
|
m_currentEditorWidget = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_currentEditorWidget = qobject_cast<QPlainTextEdit*>(editor->widget());
|
m_currentEditorWidget = qobject_cast<QPlainTextEdit*>(editor->widget());
|
||||||
@@ -314,7 +310,7 @@ void EmacsKeysPlugin::insertLineAndIndent()
|
|||||||
QTextCursor cursor = m_currentEditorWidget->textCursor();
|
QTextCursor cursor = m_currentEditorWidget->textCursor();
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
cursor.insertBlock();
|
cursor.insertBlock();
|
||||||
if (m_currentBaseTextEditorWidget != 0)
|
if (m_currentBaseTextEditorWidget)
|
||||||
m_currentBaseTextEditorWidget->textDocument()->autoIndent(cursor);
|
m_currentBaseTextEditorWidget->textDocument()->autoIndent(cursor);
|
||||||
cursor.endEditBlock();
|
cursor.endEditBlock();
|
||||||
m_currentEditorWidget->setTextCursor(cursor);
|
m_currentEditorWidget->setTextCursor(cursor);
|
||||||
@@ -324,7 +320,7 @@ void EmacsKeysPlugin::insertLineAndIndent()
|
|||||||
QAction *EmacsKeysPlugin::registerAction(Id id, void (EmacsKeysPlugin::*callback)(),
|
QAction *EmacsKeysPlugin::registerAction(Id id, void (EmacsKeysPlugin::*callback)(),
|
||||||
const QString &title)
|
const QString &title)
|
||||||
{
|
{
|
||||||
QAction *result = new QAction(title, this);
|
auto result = new QAction(title, this);
|
||||||
ActionManager::registerAction(result, id, Context(Core::Constants::C_GLOBAL), true);
|
ActionManager::registerAction(result, id, Context(Core::Constants::C_GLOBAL), true);
|
||||||
connect(result, &QAction::triggered, this, callback);
|
connect(result, &QAction::triggered, this, callback);
|
||||||
return result;
|
return result;
|
||||||
@@ -339,7 +335,7 @@ void EmacsKeysPlugin::genericGoto(QTextCursor::MoveOperation op, bool abortAssis
|
|||||||
cursor.movePosition(op, m_currentState->mark() != -1 ?
|
cursor.movePosition(op, m_currentState->mark() != -1 ?
|
||||||
QTextCursor::KeepAnchor : QTextCursor::MoveAnchor);
|
QTextCursor::KeepAnchor : QTextCursor::MoveAnchor);
|
||||||
m_currentEditorWidget->setTextCursor(cursor);
|
m_currentEditorWidget->setTextCursor(cursor);
|
||||||
if (abortAssist && m_currentBaseTextEditorWidget != 0)
|
if (abortAssist && m_currentBaseTextEditorWidget)
|
||||||
m_currentBaseTextEditorWidget->abortAssist();
|
m_currentBaseTextEditorWidget->abortAssist();
|
||||||
m_currentState->endOwnAction(KeysActionOther);
|
m_currentState->endOwnAction(KeysActionOther);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ class EmacsKeysPlugin : public ExtensionSystem::IPlugin
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EmacsKeysPlugin();
|
EmacsKeysPlugin();
|
||||||
~EmacsKeysPlugin();
|
~EmacsKeysPlugin() override;
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorString);
|
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||||
void extensionsInitialized();
|
void extensionsInitialized() override;
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
@@ -93,9 +93,9 @@ private:
|
|||||||
void genericVScroll(int direction);
|
void genericVScroll(int direction);
|
||||||
|
|
||||||
QHash<QPlainTextEdit*, EmacsKeysState*> m_stateMap;
|
QHash<QPlainTextEdit*, EmacsKeysState*> m_stateMap;
|
||||||
QPlainTextEdit *m_currentEditorWidget;
|
QPlainTextEdit *m_currentEditorWidget = nullptr;
|
||||||
EmacsKeysState *m_currentState;
|
EmacsKeysState *m_currentState = nullptr;
|
||||||
TextEditor::TextEditorWidget *m_currentBaseTextEditorWidget;
|
TextEditor::TextEditorWidget *m_currentBaseTextEditorWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ EmacsKeysState::EmacsKeysState(QPlainTextEdit *edit):
|
|||||||
this, &EmacsKeysState::selectionChanged);
|
this, &EmacsKeysState::selectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmacsKeysState::~EmacsKeysState() {}
|
EmacsKeysState::~EmacsKeysState() = default;
|
||||||
|
|
||||||
void EmacsKeysState::setLastAction(EmacsKeysAction action)
|
void EmacsKeysState::setLastAction(EmacsKeysAction action)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class EmacsKeysState : public QObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EmacsKeysState(QPlainTextEdit *edit);
|
EmacsKeysState(QPlainTextEdit *edit);
|
||||||
~EmacsKeysState();
|
~EmacsKeysState() override;
|
||||||
void setLastAction(EmacsKeysAction action);
|
void setLastAction(EmacsKeysAction action);
|
||||||
void beginOwnAction() { m_ignore3rdParty = true; }
|
void beginOwnAction() { m_ignore3rdParty = true; }
|
||||||
void endOwnAction(EmacsKeysAction action) {
|
void endOwnAction(EmacsKeysAction action) {
|
||||||
|
|||||||
Reference in New Issue
Block a user