forked from qt-creator/qt-creator
BinEditor: Modernize
modernize-use-nullptr modernize-use-override modernize-use-equals-default modernize-use-using Change-Id: I1d1381962b3ffd87cbf761f50d8f073068f9a06f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -148,7 +148,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
result = NotFound;
|
result = NotFound;
|
||||||
m_contPos = -1;
|
m_contPos = -1;
|
||||||
m_widget->highlightSearchResults(QByteArray(), 0);
|
m_widget->highlightSearchResults(QByteArray(), nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -313,7 +313,7 @@ public:
|
|||||||
void provideNewRange(quint64 offset)
|
void provideNewRange(quint64 offset)
|
||||||
{
|
{
|
||||||
if (filePath().exists())
|
if (filePath().exists())
|
||||||
openImpl(0, filePath().toString(), offset);
|
openImpl(nullptr, filePath().toString(), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -404,13 +404,13 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jumpToAddress() {
|
void jumpToAddress() {
|
||||||
editorWidget()->jumpToAddress(m_addressEdit->text().toULongLong(0, 16));
|
editorWidget()->jumpToAddress(m_addressEdit->text().toULongLong(nullptr, 16));
|
||||||
updateCursorPosition(editorWidget()->cursorPosition());
|
updateCursorPosition(editorWidget()->cursorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
BinEditorWidget *editorWidget() const
|
BinEditorWidget *editorWidget() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(qobject_cast<BinEditorWidget *>(m_widget.data()), return 0);
|
QTC_ASSERT(qobject_cast<BinEditorWidget *>(m_widget.data()), return nullptr);
|
||||||
return static_cast<BinEditorWidget *>(m_widget.data());
|
return static_cast<BinEditorWidget *>(m_widget.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ class BinEditorPluginPrivate : public QObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BinEditorPluginPrivate();
|
BinEditorPluginPrivate();
|
||||||
~BinEditorPluginPrivate();
|
~BinEditorPluginPrivate() override;
|
||||||
|
|
||||||
QAction *m_undoAction = nullptr;
|
QAction *m_undoAction = nullptr;
|
||||||
QAction *m_redoAction = nullptr;
|
QAction *m_redoAction = nullptr;
|
||||||
@@ -511,7 +511,7 @@ EditorService *FactoryServiceImpl::createEditorService(const QString &title0, bo
|
|||||||
IEditor *editor = EditorManager::openEditorWithContents(
|
IEditor *editor = EditorManager::openEditorWithContents(
|
||||||
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
|
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return 0;
|
return nullptr;
|
||||||
widget = qobject_cast<BinEditorWidget *>(editor->widget());
|
widget = qobject_cast<BinEditorWidget *>(editor->widget());
|
||||||
widget->setEditor(editor);
|
widget->setEditor(editor);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class BinEditorPlugin : public ExtensionSystem::IPlugin
|
|||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BinEditor.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BinEditor.json")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinEditorPlugin() {}
|
BinEditorPlugin() = default;
|
||||||
~BinEditorPlugin();
|
~BinEditorPlugin() override;
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||||
void extensionsInitialized() final {}
|
void extensionsInitialized() final {}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace BinEditor {
|
|||||||
class EditorService
|
class EditorService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~EditorService() {}
|
virtual ~EditorService() = default;
|
||||||
|
|
||||||
virtual QWidget *widget() = 0;
|
virtual QWidget *widget() = 0;
|
||||||
virtual Core::IEditor *editor() = 0;
|
virtual Core::IEditor *editor() = 0;
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
class FactoryService
|
class FactoryService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~FactoryService() {}
|
virtual ~FactoryService() = default;
|
||||||
|
|
||||||
// Create a BinEditor widget. Embed into a Core::IEditor iff wantsEditor == true.
|
// Create a BinEditor widget. Embed into a Core::IEditor iff wantsEditor == true.
|
||||||
virtual EditorService *createEditorService(const QString &title, bool wantsEditor) = 0;
|
virtual EditorService *createEditorService(const QString &title, bool wantsEditor) = 0;
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ class BinEditorWidget : public QAbstractScrollArea
|
|||||||
Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false)
|
Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinEditorWidget(QWidget *parent = 0);
|
BinEditorWidget(QWidget *parent = nullptr);
|
||||||
~BinEditorWidget();
|
~BinEditorWidget() override;
|
||||||
|
|
||||||
EditorService *editorService() const;
|
EditorService *editorService() const;
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
|
|
||||||
int find(const QByteArray &pattern, qint64 from = 0,
|
int find(const QByteArray &pattern, qint64 from = 0,
|
||||||
QTextDocument::FindFlags findFlags = 0);
|
QTextDocument::FindFlags findFlags = nullptr);
|
||||||
|
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void clear();
|
void clear();
|
||||||
@@ -112,7 +112,7 @@ public:
|
|||||||
int selectionStart() const { return qMin(m_anchorPosition, m_cursorPosition); }
|
int selectionStart() const { return qMin(m_anchorPosition, m_cursorPosition); }
|
||||||
int selectionEnd() const { return qMax(m_anchorPosition, m_cursorPosition); }
|
int selectionEnd() const { return qMax(m_anchorPosition, m_cursorPosition); }
|
||||||
|
|
||||||
bool event(QEvent*);
|
bool event(QEvent*) override;
|
||||||
|
|
||||||
bool isUndoAvailable() const { return m_undoStack.size(); }
|
bool isUndoAvailable() const { return m_undoStack.size(); }
|
||||||
bool isRedoAvailable() const { return m_redoStack.size(); }
|
bool isRedoAvailable() const { return m_redoStack.size(); }
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
|
|
||||||
void setFontSettings(const TextEditor::FontSettings &fs);
|
void setFontSettings(const TextEditor::FontSettings &fs);
|
||||||
void highlightSearchResults(const QByteArray &pattern,
|
void highlightSearchResults(const QByteArray &pattern,
|
||||||
QTextDocument::FindFlags findFlags = 0);
|
QTextDocument::FindFlags findFlags = nullptr);
|
||||||
void copy(bool raw = false);
|
void copy(bool raw = false);
|
||||||
void setMarkup(const QList<Markup> &markup);
|
void setMarkup(const QList<Markup> &markup);
|
||||||
void setNewWindowRequestAllowed(bool c);
|
void setNewWindowRequestAllowed(bool c);
|
||||||
@@ -137,24 +137,24 @@ signals:
|
|||||||
void cursorPositionChanged(int position);
|
void cursorPositionChanged(int position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scrollContentsBy(int dx, int dy);
|
void scrollContentsBy(int dx, int dy) override;
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *) override;
|
||||||
void changeEvent(QEvent *);
|
void changeEvent(QEvent *) override;
|
||||||
void wheelEvent(QWheelEvent *e);
|
void wheelEvent(QWheelEvent *e) override;
|
||||||
void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
void focusInEvent(QFocusEvent *);
|
void focusInEvent(QFocusEvent *) override;
|
||||||
void focusOutEvent(QFocusEvent *);
|
void focusOutEvent(QFocusEvent *) override;
|
||||||
void timerEvent(QTimerEvent *);
|
void timerEvent(QTimerEvent *) override;
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
|
||||||
friend class BinEditorWidgetPrivate;
|
friend class BinEditorWidgetPrivate;
|
||||||
BinEditorWidgetPrivate *d;
|
BinEditorWidgetPrivate *d;
|
||||||
|
|
||||||
typedef QMap<qint64, QByteArray> BlockMap;
|
using BlockMap = QMap<qint64, QByteArray>;
|
||||||
BlockMap m_data;
|
BlockMap m_data;
|
||||||
BlockMap m_oldData;
|
BlockMap m_oldData;
|
||||||
int m_blockSize;
|
int m_blockSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user