From d0f9d0c136a1bc443f6db502551eb0f3d940bec4 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh <orgad.shaneh@audiocodes.com> Date: Thu, 20 Dec 2012 23:07:40 +0200 Subject: [PATCH] BinEditor: Fix Ctrl+Home/End for files Doesn't seem to affect memory editor Change-Id: I9cc21744d0dcc5fe8cf2685c61f8e71f87af3961 Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/bineditor/bineditor.cpp | 30 ++++++++++++----------- src/plugins/bineditor/bineditor.h | 2 -- src/plugins/bineditor/bineditorplugin.cpp | 12 --------- src/plugins/debugger/memoryagent.cpp | 23 ----------------- src/plugins/debugger/memoryagent.h | 2 -- 5 files changed, 16 insertions(+), 53 deletions(-) diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index 2695bf0c903..69396c7cc18 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -1302,20 +1302,22 @@ void BinEditor::keyPressEvent(QKeyEvent *e) setCursorPosition((verticalScrollBar()->value() + line) * m_bytesPerLine + m_cursorPosition % m_bytesPerLine, moveMode); } break; - case Qt::Key_Home: - if (e->modifiers() & Qt::ControlModifier) { - emit startOfFileRequested(editor()); - } else { - setCursorPosition(m_cursorPosition/m_bytesPerLine * m_bytesPerLine, moveMode); - } - break; - case Qt::Key_End: - if (e->modifiers() & Qt::ControlModifier) { - emit endOfFileRequested(editor()); - } else { - setCursorPosition(m_cursorPosition/m_bytesPerLine * m_bytesPerLine + 15, moveMode); - } - break; + case Qt::Key_Home: { + int pos; + if (e->modifiers() & Qt::ControlModifier) + pos = 0; + else + pos = m_cursorPosition/m_bytesPerLine * m_bytesPerLine; + setCursorPosition(pos, moveMode); + } break; + case Qt::Key_End: { + int pos; + if (e->modifiers() & Qt::ControlModifier) + pos = m_size; + else + pos = m_cursorPosition/m_bytesPerLine * m_bytesPerLine + 15; + setCursorPosition(pos, moveMode); + } break; default: if (m_readOnly) break; diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h index 5e3416114a1..671f85e72c6 100644 --- a/src/plugins/bineditor/bineditor.h +++ b/src/plugins/bineditor/bineditor.h @@ -142,8 +142,6 @@ Q_SIGNALS: void newWindowRequested(quint64 address); void newRangeRequested(Core::IEditor *, quint64 address); void addWatchpointRequested(quint64 address, uint size); - void startOfFileRequested(Core::IEditor *); - void endOfFileRequested(Core::IEditor *); void dataChanged(Core::IEditor *, quint64 address, const QByteArray &data); protected: diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 8bc09c73bf7..0eaebaa2766 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -187,10 +187,6 @@ public: this, SLOT(provideData(Core::IEditor*,quint64))); connect(m_editor, SIGNAL(newRangeRequested(Core::IEditor*,quint64)), this, SLOT(provideNewRange(Core::IEditor*,quint64))); - connect(m_editor, SIGNAL(startOfFileRequested(Core::IEditor*)), this, - SLOT(handleStartOfFileRequested(Core::IEditor*))); - connect(m_editor, SIGNAL(endOfFileRequested(Core::IEditor*)), this, - SLOT(handleEndOfFileRequested(Core::IEditor*))); } ~BinEditorDocument() {} @@ -273,14 +269,6 @@ private slots: open(0, m_fileName, offset); } - void handleStartOfFileRequested(Core::IEditor *) { - open(0, m_fileName, 0); - } - - void handleEndOfFileRequested(Core::IEditor *) { - open(0, m_fileName, QFileInfo(m_fileName).size() - 1); - } - public: void setFilename(const QString &filename) { diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp index 82625f35899..678b0a4bc10 100644 --- a/src/plugins/debugger/memoryagent.cpp +++ b/src/plugins/debugger/memoryagent.cpp @@ -140,12 +140,6 @@ void MemoryAgent::connectBinEditorWidget(QWidget *w) connect(w, SIGNAL(newRangeRequested(Core::IEditor*,quint64)), SLOT(provideNewRange(Core::IEditor*,quint64))); - connect(w, - SIGNAL(startOfFileRequested(Core::IEditor*)), - SLOT(handleStartOfFileRequested(Core::IEditor*))); - connect(w, - SIGNAL(endOfFileRequested(Core::IEditor*)), - SLOT(handleEndOfFileRequested(Core::IEditor*))); connect(w, SIGNAL(dataChanged(Core::IEditor*,quint64,QByteArray)), SLOT(handleDataChanged(Core::IEditor*,quint64,QByteArray))); @@ -250,23 +244,6 @@ void MemoryAgent::provideNewRange(IEditor *, quint64 address) MemoryView::setBinEditorRange(w, address, DataRange, BinBlockSize); } -// Since we are not dealing with files, we take these signals to mean -// "move to start/end of range". This seems to make more sense than -// jumping to the start or end of the address space, respectively. -void MemoryAgent::handleStartOfFileRequested(IEditor *) -{ - QWidget *w = qobject_cast<QWidget *>(sender()); - QTC_ASSERT(w, return); - MemoryView::binEditorSetCursorPosition(w, 0); -} - -void MemoryAgent::handleEndOfFileRequested(IEditor *) -{ - QWidget *w = qobject_cast<QWidget *>(sender()); - QTC_ASSERT(w, return); - MemoryView::binEditorSetCursorPosition(w, DataRange - 1); -} - void MemoryAgent::handleDataChanged(IEditor *, quint64 addr, const QByteArray &data) { diff --git a/src/plugins/debugger/memoryagent.h b/src/plugins/debugger/memoryagent.h index 217f31ec354..6ecad1968a0 100644 --- a/src/plugins/debugger/memoryagent.h +++ b/src/plugins/debugger/memoryagent.h @@ -99,8 +99,6 @@ public slots: private slots: void fetchLazyData(Core::IEditor *, quint64 block); void provideNewRange(Core::IEditor *editor, quint64 address); - void handleStartOfFileRequested(Core::IEditor *editor); - void handleEndOfFileRequested(Core::IEditor *editor); void handleDataChanged(Core::IEditor *editor, quint64 address, const QByteArray &data); void handleWatchpointRequest(quint64 address, uint size); -- GitLab