forked from qt-creator/qt-creator
BinEditor: Clean up Widget setup phase
Change-Id: I91ef2968416a8629046992664e8bea7d79c109ca Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -76,8 +76,6 @@ namespace BinEditor::Internal {
|
|||||||
|
|
||||||
const int SearchStride = 1024 * 1024;
|
const int SearchStride = 1024 * 1024;
|
||||||
|
|
||||||
class BinEditorWidget;
|
|
||||||
|
|
||||||
class BinEditorDocument : public IDocument
|
class BinEditorDocument : public IDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -207,10 +205,7 @@ class BinEditorWidget final : public QAbstractScrollArea
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinEditorWidget(QWidget *parent = nullptr) : QAbstractScrollArea(parent) {}
|
explicit BinEditorWidget(BinEditorDocument *doc);
|
||||||
~BinEditorWidget() final = default;
|
|
||||||
|
|
||||||
void setup(BinEditorDocument *doc);
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
quint64 baseAddress() const { return m_doc->m_baseAddr; }
|
quint64 baseAddress() const { return m_doc->m_baseAddr; }
|
||||||
@@ -364,7 +359,7 @@ static QByteArray calculateHexPattern(const QByteArray &pattern)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinEditorWidget::setup(BinEditorDocument *doc)
|
BinEditorWidget::BinEditorWidget(BinEditorDocument *doc)
|
||||||
{
|
{
|
||||||
m_doc = doc;
|
m_doc = doc;
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::WheelFocus);
|
||||||
@@ -403,6 +398,8 @@ void BinEditorWidget::setup(BinEditorDocument *doc)
|
|||||||
});
|
});
|
||||||
|
|
||||||
updateCursorPosition(cursorPosition());
|
updateCursorPosition(cursorPosition());
|
||||||
|
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinEditorWidget::init()
|
void BinEditorWidget::init()
|
||||||
@@ -2316,10 +2313,8 @@ public:
|
|||||||
{
|
{
|
||||||
if (!wantsEditor) {
|
if (!wantsEditor) {
|
||||||
auto document = new BinEditorDocument;
|
auto document = new BinEditorDocument;
|
||||||
auto widget = new BinEditorWidget;
|
auto widget = new BinEditorWidget(document);
|
||||||
widget->setup(document);
|
|
||||||
widget->setWindowTitle(title0);
|
widget->setWindowTitle(title0);
|
||||||
widget->init();
|
|
||||||
|
|
||||||
auto service = new BinEditorService;
|
auto service = new BinEditorService;
|
||||||
service->m_widget = widget;
|
service->m_widget = widget;
|
||||||
@@ -2374,9 +2369,7 @@ public:
|
|||||||
|
|
||||||
setEditorCreator([this] {
|
setEditorCreator([this] {
|
||||||
auto doc = new BinEditorDocument;
|
auto doc = new BinEditorDocument;
|
||||||
auto widget = new BinEditorWidget;
|
auto widget = new BinEditorWidget(doc);
|
||||||
widget->setup(doc);
|
|
||||||
widget->init();
|
|
||||||
auto editor = new BinEditorImpl(widget, doc);
|
auto editor = new BinEditorImpl(widget, doc);
|
||||||
|
|
||||||
connect(m_undoAction, &QAction::triggered, doc, &BinEditorDocument::undo);
|
connect(m_undoAction, &QAction::triggered, doc, &BinEditorDocument::undo);
|
||||||
|
Reference in New Issue
Block a user