forked from qt-creator/qt-creator
FakeVim: Modernize
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using modernize-use-equals-default Change-Id: I320a08a99a1d18ab87aec207ec1e03190009b592 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -255,7 +255,7 @@ struct FakeVimPlugin::TestData
|
|||||||
int lines() const
|
int lines() const
|
||||||
{
|
{
|
||||||
QTextDocument *doc = editor()->document();
|
QTextDocument *doc = editor()->document();
|
||||||
Q_ASSERT(doc != 0);
|
Q_ASSERT(doc != nullptr);
|
||||||
return doc->lineCount();
|
return doc->lineCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ void FakeVimSettings::writeSettings(QSettings *settings)
|
|||||||
|
|
||||||
FakeVimAction *FakeVimSettings::item(int code)
|
FakeVimAction *FakeVimSettings::item(int code)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_items.value(code, 0), qDebug() << "CODE: " << code; return 0);
|
QTC_ASSERT(m_items.value(code, 0), qDebug() << "CODE: " << code; return nullptr);
|
||||||
return m_items.value(code, 0);
|
return m_items.value(code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ void FakeVimSettings::createAction(int code, const QVariant &value,
|
|||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
const QString &shortKey)
|
const QString &shortKey)
|
||||||
{
|
{
|
||||||
FakeVimAction *item = new FakeVimAction(0);
|
auto item = new FakeVimAction(nullptr);
|
||||||
item->setValue(value);
|
item->setValue(value);
|
||||||
item->setSettingsKey("FakeVim", settingsKey);
|
item->setSettingsKey("FakeVim", settingsKey);
|
||||||
item->setDefaultValue(value);
|
item->setDefaultValue(value);
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef FAKEVIM_STANDALONE
|
#ifdef FAKEVIM_STANDALONE
|
||||||
typedef DummyAction FakeVimAction;
|
using FakeVimAction = DummyAction;
|
||||||
#else
|
#else
|
||||||
typedef Utils::SavedAction FakeVimAction;
|
using FakeVimAction = Utils::SavedAction;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum FakeVimSettingsCode
|
enum FakeVimSettingsCode
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ enum EventResult
|
|||||||
|
|
||||||
struct CursorPosition
|
struct CursorPosition
|
||||||
{
|
{
|
||||||
CursorPosition() {}
|
CursorPosition() = default;
|
||||||
CursorPosition(int block, int column) : line(block), column(column) {}
|
CursorPosition(int block, int column) : line(block), column(column) {}
|
||||||
explicit CursorPosition(const QTextCursor &tc)
|
explicit CursorPosition(const QTextCursor &tc)
|
||||||
: line(tc.block().blockNumber()), column(tc.positionInBlock()) {}
|
: line(tc.block().blockNumber()), column(tc.positionInBlock()) {}
|
||||||
@@ -320,12 +320,12 @@ private:
|
|||||||
CursorPosition m_position;
|
CursorPosition m_position;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
};
|
};
|
||||||
typedef QHash<QChar, Mark> Marks;
|
using Marks = QHash<QChar, Mark>;
|
||||||
typedef QHashIterator<QChar, Mark> MarksIterator;
|
using MarksIterator = QHashIterator<QChar, Mark>;
|
||||||
|
|
||||||
struct State
|
struct State
|
||||||
{
|
{
|
||||||
State() {}
|
State() = default;
|
||||||
State(int revision, const CursorPosition &position, const Marks &marks,
|
State(int revision, const CursorPosition &position, const Marks &marks,
|
||||||
VisualMode lastVisualMode, bool lastVisualModeInverted) : revision(revision),
|
VisualMode lastVisualMode, bool lastVisualModeInverted) : revision(revision),
|
||||||
position(position), marks(marks), lastVisualMode(lastVisualMode),
|
position(position), marks(marks), lastVisualMode(lastVisualMode),
|
||||||
@@ -354,7 +354,7 @@ QDebug operator<<(QDebug ts, const Column &col)
|
|||||||
|
|
||||||
struct Register
|
struct Register
|
||||||
{
|
{
|
||||||
Register() {}
|
Register() = default;
|
||||||
Register(const QString &c) : contents(c) {}
|
Register(const QString &c) : contents(c) {}
|
||||||
Register(const QString &c, RangeMode m) : contents(c), rangemode(m) {}
|
Register(const QString &c, RangeMode m) : contents(c), rangemode(m) {}
|
||||||
QString contents;
|
QString contents;
|
||||||
@@ -982,7 +982,7 @@ public:
|
|||||||
return m & ~Qt::KeypadModifier;
|
return m & ~Qt::KeypadModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
Input() {}
|
Input() = default;
|
||||||
explicit Input(QChar x)
|
explicit Input(QChar x)
|
||||||
: m_key(x.unicode()), m_xkey(x.unicode()), m_text(x)
|
: m_key(x.unicode()), m_xkey(x.unicode()), m_text(x)
|
||||||
{
|
{
|
||||||
@@ -1252,7 +1252,7 @@ QDebug operator<<(QDebug ts, const Input &input) { return input.dump(ts); }
|
|||||||
class Inputs : public QVector<Input>
|
class Inputs : public QVector<Input>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Inputs() {}
|
Inputs() = default;
|
||||||
|
|
||||||
explicit Inputs(const QString &str, bool noremap = true, bool silent = false)
|
explicit Inputs(const QString &str, bool noremap = true, bool silent = false)
|
||||||
: m_noremap(noremap), m_silent(silent)
|
: m_noremap(noremap), m_silent(silent)
|
||||||
@@ -1521,7 +1521,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Mappings for all modes
|
// Mappings for all modes
|
||||||
typedef QHash<char, ModeMapping> Mappings;
|
using Mappings = QHash<char, ModeMapping>;
|
||||||
|
|
||||||
// Iterator for mappings
|
// Iterator for mappings
|
||||||
class MappingsIterator : public QVector<ModeMapping::Iterator>
|
class MappingsIterator : public QVector<ModeMapping::Iterator>
|
||||||
@@ -1641,7 +1641,7 @@ private:
|
|||||||
|
|
||||||
// state of current mapping
|
// state of current mapping
|
||||||
struct MappingState {
|
struct MappingState {
|
||||||
MappingState() {}
|
MappingState() = default;
|
||||||
MappingState(bool noremap, bool silent, bool editBlock)
|
MappingState(bool noremap, bool silent, bool editBlock)
|
||||||
: noremap(noremap), silent(silent), editBlock(editBlock) {}
|
: noremap(noremap), silent(silent), editBlock(editBlock) {}
|
||||||
bool noremap = false;
|
bool noremap = false;
|
||||||
@@ -2037,7 +2037,7 @@ public:
|
|||||||
int position() const { return m_cursor.position(); }
|
int position() const { return m_cursor.position(); }
|
||||||
|
|
||||||
// Transform text selected by cursor in current visual mode.
|
// Transform text selected by cursor in current visual mode.
|
||||||
typedef std::function<QString(const QString &)> Transformation;
|
using Transformation = std::function<QString(const QString &)>;
|
||||||
void transformText(const Range &range, QTextCursor &tc, const std::function<void()> &transform) const;
|
void transformText(const Range &range, QTextCursor &tc, const std::function<void()> &transform) const;
|
||||||
void transformText(const Range &range, const Transformation &transform);
|
void transformText(const Range &range, const Transformation &transform);
|
||||||
|
|
||||||
@@ -2119,7 +2119,7 @@ public:
|
|||||||
QString registerContents(int reg) const;
|
QString registerContents(int reg) const;
|
||||||
void setRegister(int reg, const QString &contents, RangeMode mode);
|
void setRegister(int reg, const QString &contents, RangeMode mode);
|
||||||
RangeMode registerRangeMode(int reg) const;
|
RangeMode registerRangeMode(int reg) const;
|
||||||
void getRegisterType(int *reg, bool *isClipboard, bool *isSelection, bool *append = 0) const;
|
void getRegisterType(int *reg, bool *isClipboard, bool *isSelection, bool *append = nullptr) const;
|
||||||
|
|
||||||
void recordJump(int position = -1);
|
void recordJump(int position = -1);
|
||||||
void jump(int distance);
|
void jump(int distance);
|
||||||
@@ -2207,7 +2207,7 @@ public:
|
|||||||
QPointer<FakeVimHandler::Private> currentHandler;
|
QPointer<FakeVimHandler::Private> currentHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<BufferData> BufferDataPtr;
|
using BufferDataPtr = QSharedPointer<BufferData>;
|
||||||
void pullOrCreateBufferData();
|
void pullOrCreateBufferData();
|
||||||
BufferDataPtr m_buffer;
|
BufferDataPtr m_buffer;
|
||||||
|
|
||||||
@@ -5899,7 +5899,7 @@ bool FakeVimHandler::Private::handleExMoveCommand(const ExCommand &cmd)
|
|||||||
setMark('>', lastPosition);
|
setMark('>', lastPosition);
|
||||||
|
|
||||||
if (lines > 2)
|
if (lines > 2)
|
||||||
showMessage(MessageInfo, Tr::tr("%n lines moved.", 0, lines));
|
showMessage(MessageInfo, Tr::tr("%n lines moved.", nullptr, lines));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -6044,7 +6044,7 @@ bool FakeVimHandler::Private::handleExBangCommand(const ExCommand &cmd) // :!
|
|||||||
endEditBlock();
|
endEditBlock();
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
//qDebug() << "FILTER: " << command;
|
//qDebug() << "FILTER: " << command;
|
||||||
showMessage(MessageInfo, Tr::tr("%n lines filtered.", 0,
|
showMessage(MessageInfo, Tr::tr("%n lines filtered.", nullptr,
|
||||||
input.count('\n')));
|
input.count('\n')));
|
||||||
} else if (!result.isEmpty()) {
|
} else if (!result.isEmpty()) {
|
||||||
q->extraInformationChanged(result);
|
q->extraInformationChanged(result);
|
||||||
@@ -6489,7 +6489,7 @@ void FakeVimHandler::Private::indentSelectedText(QChar typedChar)
|
|||||||
|
|
||||||
const int lines = endLine - beginLine + 1;
|
const int lines = endLine - beginLine + 1;
|
||||||
if (lines > 2)
|
if (lines > 2)
|
||||||
showMessage(MessageInfo, Tr::tr("%n lines indented.", 0, lines));
|
showMessage(MessageInfo, Tr::tr("%n lines indented.", nullptr, lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::indentText(const Range &range, QChar typedChar)
|
void FakeVimHandler::Private::indentText(const Range &range, QChar typedChar)
|
||||||
@@ -6545,7 +6545,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
|
|||||||
const int lines = endLine - beginLine + 1;
|
const int lines = endLine - beginLine + 1;
|
||||||
if (lines > 2) {
|
if (lines > 2) {
|
||||||
showMessage(MessageInfo,
|
showMessage(MessageInfo,
|
||||||
Tr::tr("%n lines %1ed %2 time.", 0, lines)
|
Tr::tr("%n lines %1ed %2 time.", nullptr, lines)
|
||||||
.arg(repeat > 0 ? '>' : '<').arg(qAbs(repeat)));
|
.arg(repeat > 0 ? '>' : '<').arg(qAbs(repeat)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7083,7 +7083,7 @@ void FakeVimHandler::Private::yankText(const Range &range, int reg)
|
|||||||
const int lines = blockAt(range.endPos).blockNumber()
|
const int lines = blockAt(range.endPos).blockNumber()
|
||||||
- blockAt(range.beginPos).blockNumber() + 1;
|
- blockAt(range.beginPos).blockNumber() + 1;
|
||||||
if (lines > 2)
|
if (lines > 2)
|
||||||
showMessage(MessageInfo, Tr::tr("%n lines yanked.", 0, lines));
|
showMessage(MessageInfo, Tr::tr("%n lines yanked.", nullptr, lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::transformText(
|
void FakeVimHandler::Private::transformText(
|
||||||
@@ -8610,7 +8610,7 @@ void FakeVimHandler::Private::getRegisterType(int *reg, bool *isClipboard, bool
|
|||||||
|
|
||||||
// If register is uppercase, append content to lower case register on yank/delete.
|
// If register is uppercase, append content to lower case register on yank/delete.
|
||||||
const QChar c(*reg);
|
const QChar c(*reg);
|
||||||
if (append != 0)
|
if (append != nullptr)
|
||||||
*append = c.isUpper();
|
*append = c.isUpper();
|
||||||
if (c.isUpper())
|
if (c.isUpper())
|
||||||
*reg = c.toLower().unicode();
|
*reg = c.toLower().unicode();
|
||||||
@@ -8631,9 +8631,9 @@ void FakeVimHandler::Private::getRegisterType(int *reg, bool *isClipboard, bool
|
|||||||
selection = false;
|
selection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isClipboard != 0)
|
if (isClipboard != nullptr)
|
||||||
*isClipboard = clipboard;
|
*isClipboard = clipboard;
|
||||||
if (isSelection != 0)
|
if (isSelection != nullptr)
|
||||||
*isSelection = selection;
|
*isSelection = selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8655,8 +8655,8 @@ FakeVimHandler::~FakeVimHandler()
|
|||||||
// gracefully handle that the parent editor is deleted
|
// gracefully handle that the parent editor is deleted
|
||||||
void FakeVimHandler::disconnectFromEditor()
|
void FakeVimHandler::disconnectFromEditor()
|
||||||
{
|
{
|
||||||
d->m_textedit = 0;
|
d->m_textedit = nullptr;
|
||||||
d->m_plaintextedit = 0;
|
d->m_plaintextedit = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName)
|
void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName)
|
||||||
@@ -8683,7 +8683,7 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
|||||||
if (ev->type() == QEvent::KeyPress &&
|
if (ev->type() == QEvent::KeyPress &&
|
||||||
(ob == d->editor()
|
(ob == d->editor()
|
||||||
|| (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) {
|
|| (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) {
|
||||||
QKeyEvent *kev = static_cast<QKeyEvent *>(ev);
|
auto kev = static_cast<QKeyEvent *>(ev);
|
||||||
KEY_DEBUG("KEYPRESS" << kev->key() << kev->text() << QChar(kev->key()));
|
KEY_DEBUG("KEYPRESS" << kev->key() << kev->text() << QChar(kev->key()));
|
||||||
EventResult res = d->handleEvent(kev);
|
EventResult res = d->handleEvent(kev);
|
||||||
//if (Private::g.mode == InsertMode)
|
//if (Private::g.mode == InsertMode)
|
||||||
@@ -8697,7 +8697,7 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
|||||||
|
|
||||||
if (ev->type() == QEvent::ShortcutOverride && (ob == d->editor()
|
if (ev->type() == QEvent::ShortcutOverride && (ob == d->editor()
|
||||||
|| (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) {
|
|| (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) {
|
||||||
QKeyEvent *kev = static_cast<QKeyEvent *>(ev);
|
auto kev = static_cast<QKeyEvent *>(ev);
|
||||||
if (d->wantsOverride(kev)) {
|
if (d->wantsOverride(kev)) {
|
||||||
KEY_DEBUG("OVERRIDING SHORTCUT" << kev->key());
|
KEY_DEBUG("OVERRIDING SHORTCUT" << kev->key());
|
||||||
ev->accept(); // accepting means "don't run the shortcuts"
|
ev->accept(); // accepting means "don't run the shortcuts"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ enum RangeMode
|
|||||||
|
|
||||||
struct Range
|
struct Range
|
||||||
{
|
{
|
||||||
Range() {}
|
Range() = default;
|
||||||
Range(int b, int e, RangeMode m = RangeCharMode);
|
Range(int b, int e, RangeMode m = RangeCharMode);
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
@@ -59,7 +59,7 @@ struct Range
|
|||||||
|
|
||||||
struct ExCommand
|
struct ExCommand
|
||||||
{
|
{
|
||||||
ExCommand() {}
|
ExCommand() = default;
|
||||||
ExCommand(const QString &cmd, const QString &args = QString(),
|
ExCommand(const QString &cmd, const QString &args = QString(),
|
||||||
const Range &range = Range());
|
const Range &range = Range());
|
||||||
|
|
||||||
@@ -107,8 +107,8 @@ class FakeVimHandler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FakeVimHandler(QWidget *widget, QObject *parent = 0);
|
explicit FakeVimHandler(QWidget *widget, QObject *parent = nullptr);
|
||||||
~FakeVimHandler();
|
~FakeVimHandler() override;
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
bool jumpToLocalMark(QChar mark, bool backTickMode);
|
bool jumpToLocalMark(QChar mark, bool backTickMode);
|
||||||
|
|
||||||
bool eventFilter(QObject *ob, QEvent *ev);
|
bool eventFilter(QObject *ob, QEvent *ev) override;
|
||||||
|
|
||||||
Signal<void(const QString &msg, int cursorPos, int anchorPos, int messageLevel)> commandBufferChanged;
|
Signal<void(const QString &msg, int cursorPos, int anchorPos, int messageLevel)> commandBufferChanged;
|
||||||
Signal<void(const QString &msg)> statusDataChanged;
|
Signal<void(const QString &msg)> statusDataChanged;
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
m_lastMessageLevel = messageLevel;
|
m_lastMessageLevel = messageLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize sizeHint() const
|
QSize sizeHint() const override
|
||||||
{
|
{
|
||||||
QSize size = QWidget::sizeHint();
|
QSize size = QWidget::sizeHint();
|
||||||
// reserve maximal width for line edit widget
|
// reserve maximal width for line edit widget
|
||||||
@@ -259,7 +259,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event)
|
void paintEvent(QPaintEvent *event) override
|
||||||
{
|
{
|
||||||
QTextCursor firstVisibleCursor = m_editor->cursorForPosition(QPoint(0, 0));
|
QTextCursor firstVisibleCursor = m_editor->cursorForPosition(QPoint(0, 0));
|
||||||
QTextBlock firstVisibleBlock = firstVisibleCursor.block();
|
QTextBlock firstVisibleBlock = firstVisibleCursor.block();
|
||||||
@@ -310,7 +310,7 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eventFilter(QObject *, QEvent *event)
|
bool eventFilter(QObject *, QEvent *event) override
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::Resize || event->type() == QEvent::Move)
|
if (event->type() == QEvent::Resize || event->type() == QEvent::Move)
|
||||||
m_timerUpdate.start();
|
m_timerUpdate.start();
|
||||||
@@ -352,8 +352,8 @@ private:
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
typedef QMap<QString, QRegExp> ExCommandMap;
|
using ExCommandMap = QMap<QString, QRegExp>;
|
||||||
typedef QMap<int, QString> UserCommandMap;
|
using UserCommandMap = QMap<int, QString>;
|
||||||
|
|
||||||
class FakeVimOptionPage : public IOptionsPage
|
class FakeVimOptionPage : public IOptionsPage
|
||||||
{
|
{
|
||||||
@@ -368,9 +368,9 @@ public:
|
|||||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish();
|
void finish() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copyTextEditorSettings();
|
void copyTextEditorSettings();
|
||||||
@@ -556,7 +556,7 @@ public:
|
|||||||
|
|
||||||
void setActionChecked(Id id, bool check);
|
void setActionChecked(Id id, bool check);
|
||||||
|
|
||||||
typedef int (*DistFunction)(const QRect &cursor, const QRect &other);
|
using DistFunction = int (*)(const QRect &, const QRect &);
|
||||||
void moveSomewhere(FakeVimHandler *handler, DistFunction f, int count);
|
void moveSomewhere(FakeVimHandler *handler, DistFunction f, int count);
|
||||||
|
|
||||||
void keepOnlyWindow(); // :only
|
void keepOnlyWindow(); // :only
|
||||||
@@ -676,7 +676,7 @@ void FakeVimExCommandsPage::apply()
|
|||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginWriteArray(exCommandMapGroup);
|
settings->beginWriteArray(exCommandMapGroup);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
typedef ExCommandMap::const_iterator Iterator;
|
using Iterator = ExCommandMap::const_iterator;
|
||||||
const Iterator end = newMapping.constEnd();
|
const Iterator end = newMapping.constEnd();
|
||||||
for (Iterator it = newMapping.constBegin(); it != end; ++it) {
|
for (Iterator it = newMapping.constBegin(); it != end; ++it) {
|
||||||
const QString id = it.key();
|
const QString id = it.key();
|
||||||
@@ -807,12 +807,12 @@ public:
|
|||||||
FakeVimUserCommandsModel() { m_commandMap = dd->m_userCommandMap; }
|
FakeVimUserCommandsModel() { m_commandMap = dd->m_userCommandMap; }
|
||||||
|
|
||||||
UserCommandMap commandMap() const { return m_commandMap; }
|
UserCommandMap commandMap() const { return m_commandMap; }
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int columnCount(const QModelIndex &parent) const;
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &data, int role);
|
bool setData(const QModelIndex &index, const QVariant &data, int role) override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UserCommandMap m_commandMap;
|
UserCommandMap m_commandMap;
|
||||||
@@ -856,7 +856,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
||||||
const QModelIndex &) const
|
const QModelIndex &) const override
|
||||||
{
|
{
|
||||||
auto lineEdit = new QLineEdit(parent);
|
auto lineEdit = new QLineEdit(parent);
|
||||||
lineEdit->setFrame(false);
|
lineEdit->setFrame(false);
|
||||||
@@ -864,9 +864,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const override
|
||||||
{
|
{
|
||||||
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
|
auto lineEdit = qobject_cast<QLineEdit *>(editor);
|
||||||
QTC_ASSERT(lineEdit, return);
|
QTC_ASSERT(lineEdit, return);
|
||||||
model->setData(index, lineEdit->text(), Qt::EditRole);
|
model->setData(index, lineEdit->text(), Qt::EditRole);
|
||||||
}
|
}
|
||||||
@@ -891,7 +891,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
FakeVimUserCommandsModel *m_model;
|
FakeVimUserCommandsModel *m_model = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
QWidget *FakeVimUserCommandsPage::widget()
|
QWidget *FakeVimUserCommandsPage::widget()
|
||||||
@@ -928,7 +928,7 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginWriteArray(userCommandMapGroup);
|
settings->beginWriteArray(userCommandMapGroup);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
typedef UserCommandMap::const_iterator Iterator;
|
using Iterator = UserCommandMap::const_iterator;
|
||||||
const Iterator end = current.constEnd();
|
const Iterator end = current.constEnd();
|
||||||
for (Iterator it = current.constBegin(); it != end; ++it) {
|
for (Iterator it = current.constBegin(); it != end; ++it) {
|
||||||
const int key = it.key();
|
const int key = it.key();
|
||||||
@@ -960,7 +960,7 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
class FakeVimCompletionAssistProvider : public CompletionAssistProvider
|
class FakeVimCompletionAssistProvider : public CompletionAssistProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IAssistProcessor *createProcessor() const;
|
IAssistProcessor *createProcessor() const override;
|
||||||
|
|
||||||
void setActive(const QString &needle, bool forward, FakeVimHandler *handler)
|
void setActive(const QString &needle, bool forward, FakeVimHandler *handler)
|
||||||
{
|
{
|
||||||
@@ -969,7 +969,7 @@ public:
|
|||||||
if (!m_handler)
|
if (!m_handler)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TextEditorWidget *editor = qobject_cast<TextEditorWidget *>(handler->widget());
|
auto editor = qobject_cast<TextEditorWidget *>(handler->widget());
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1258,7 +1258,7 @@ void FakeVimPluginPrivate::userActionTriggered(int key)
|
|||||||
|
|
||||||
void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor)
|
void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor)
|
||||||
{
|
{
|
||||||
if (TextEditorWidget *textEditor = qobject_cast<TextEditorWidget *>(editor->widget())) {
|
if (auto textEditor = qobject_cast<TextEditorWidget *>(editor->widget())) {
|
||||||
auto relativeNumbers = new RelativeNumbersColumn(textEditor);
|
auto relativeNumbers = new RelativeNumbersColumn(textEditor);
|
||||||
connect(theFakeVimSetting(ConfigRelativeNumber), &SavedAction::valueChanged,
|
connect(theFakeVimSetting(ConfigRelativeNumber), &SavedAction::valueChanged,
|
||||||
relativeNumbers, &QObject::deleteLater);
|
relativeNumbers, &QObject::deleteLater);
|
||||||
@@ -1386,13 +1386,13 @@ void FakeVimPluginPrivate::moveSomewhere(FakeVimHandler *handler, DistFunction f
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(handler, return);
|
QTC_ASSERT(handler, return);
|
||||||
QWidget *w = handler->widget();
|
QWidget *w = handler->widget();
|
||||||
QPlainTextEdit *pe = qobject_cast<QPlainTextEdit *>(w);
|
auto pe = qobject_cast<QPlainTextEdit *>(w);
|
||||||
QTC_ASSERT(pe, return);
|
QTC_ASSERT(pe, return);
|
||||||
QRect rc = pe->cursorRect();
|
QRect rc = pe->cursorRect();
|
||||||
QRect cursorRect(w->mapToGlobal(rc.topLeft()), w->mapToGlobal(rc.bottomRight()));
|
QRect cursorRect(w->mapToGlobal(rc.topLeft()), w->mapToGlobal(rc.bottomRight()));
|
||||||
//qDebug() << "\nCURSOR: " << cursorRect;
|
//qDebug() << "\nCURSOR: " << cursorRect;
|
||||||
|
|
||||||
IEditor *bestEditor = 0;
|
IEditor *bestEditor = nullptr;
|
||||||
int repeat = count;
|
int repeat = count;
|
||||||
|
|
||||||
IEditor *currentEditor = EditorManager::currentEditor();
|
IEditor *currentEditor = EditorManager::currentEditor();
|
||||||
@@ -1503,12 +1503,12 @@ public:
|
|||||||
: QObject(parent), m_handler(handler)
|
: QObject(parent), m_handler(handler)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~DeferredDeleter()
|
~DeferredDeleter() override
|
||||||
{
|
{
|
||||||
if (m_handler) {
|
if (m_handler) {
|
||||||
m_handler->disconnectFromEditor();
|
m_handler->disconnectFromEditor();
|
||||||
m_handler->deleteLater();
|
m_handler->deleteLater();
|
||||||
m_handler = 0;
|
m_handler = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1526,12 +1526,12 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
|||||||
if (!qobject_cast<QTextEdit *>(widget) && !qobject_cast<QPlainTextEdit *>(widget))
|
if (!qobject_cast<QTextEdit *>(widget) && !qobject_cast<QPlainTextEdit *>(widget))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TextEditorWidget *tew = qobject_cast<TextEditorWidget *>(widget);
|
auto tew = qobject_cast<TextEditorWidget *>(widget);
|
||||||
|
|
||||||
//qDebug() << "OPENING: " << editor << editor->widget()
|
//qDebug() << "OPENING: " << editor << editor->widget()
|
||||||
// << "MODE: " << theFakeVimSetting(ConfigUseFakeVim)->value();
|
// << "MODE: " << theFakeVimSetting(ConfigUseFakeVim)->value();
|
||||||
|
|
||||||
auto handler = new FakeVimHandler(widget, 0);
|
auto handler = new FakeVimHandler(widget, nullptr);
|
||||||
// the handler might have triggered the deletion of the editor:
|
// the handler might have triggered the deletion of the editor:
|
||||||
// make sure that it can return before being deleted itself
|
// make sure that it can return before being deleted itself
|
||||||
new DeferredDeleter(widget, handler);
|
new DeferredDeleter(widget, handler);
|
||||||
@@ -1560,8 +1560,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
|||||||
handler->highlightMatches.connect([](const QString &needle) {
|
handler->highlightMatches.connect([](const QString &needle) {
|
||||||
for (IEditor *editor : EditorManager::visibleEditors()) {
|
for (IEditor *editor : EditorManager::visibleEditors()) {
|
||||||
QWidget *w = editor->widget();
|
QWidget *w = editor->widget();
|
||||||
IFindSupport *find = Aggregation::query<IFindSupport>(w);
|
if (auto find = Aggregation::query<IFindSupport>(w))
|
||||||
if (find != 0)
|
|
||||||
find->highlightAll(needle, FindRegularExpression | FindCaseSensitively);
|
find->highlightAll(needle, FindRegularExpression | FindCaseSensitively);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1707,7 +1706,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
|||||||
handler->foldAll.connect([handler](bool fold) {
|
handler->foldAll.connect([handler](bool fold) {
|
||||||
QTextDocument *document = handler->textCursor().document();
|
QTextDocument *document = handler->textCursor().document();
|
||||||
auto documentLayout = qobject_cast<TextDocumentLayout*>(document->documentLayout());
|
auto documentLayout = qobject_cast<TextDocumentLayout*>(document->documentLayout());
|
||||||
QTC_ASSERT(documentLayout != 0, return);
|
QTC_ASSERT(documentLayout, return);
|
||||||
|
|
||||||
QTextBlock block = document->firstBlock();
|
QTextBlock block = document->firstBlock();
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
@@ -1871,7 +1870,7 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
|||||||
// Context(FAKEVIM_CONTEXT));
|
// Context(FAKEVIM_CONTEXT));
|
||||||
resetCommandBuffer();
|
resetCommandBuffer();
|
||||||
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
||||||
if (TextDocument *textDocument = qobject_cast<TextDocument *>(editor->document()))
|
if (auto textDocument = qobject_cast<const TextDocument *>(editor->document()))
|
||||||
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1928,7 +1927,7 @@ void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handle
|
|||||||
if (failed.isEmpty())
|
if (failed.isEmpty())
|
||||||
handler->showMessage(MessageInfo, Tr::tr("Saving succeeded"));
|
handler->showMessage(MessageInfo, Tr::tr("Saving succeeded"));
|
||||||
else
|
else
|
||||||
handler->showMessage(MessageError, Tr::tr("%n files not saved", 0, failed.size()));
|
handler->showMessage(MessageError, Tr::tr("%n files not saved", nullptr, failed.size()));
|
||||||
if (cmd.matches("wqa", "wqall"))
|
if (cmd.matches("wqa", "wqall"))
|
||||||
emit delayedQuitAllRequested(cmd.hasBang);
|
emit delayedQuitAllRequested(cmd.hasBang);
|
||||||
} else if (cmd.matches("q", "quit")) {
|
} else if (cmd.matches("q", "quit")) {
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ class FakeVimPlugin : public ExtensionSystem::IPlugin
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimPlugin();
|
FakeVimPlugin();
|
||||||
~FakeVimPlugin();
|
~FakeVimPlugin() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// implementation of ExtensionSystem::IPlugin
|
// implementation of ExtensionSystem::IPlugin
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown() override;
|
||||||
void extensionsInitialized();
|
void extensionsInitialized() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class FakeVimPluginPrivate;
|
friend class FakeVimPluginPrivate;
|
||||||
|
|||||||
Reference in New Issue
Block a user