Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
c2ec9257
Commit
c2ec9257
authored
Jul 02, 2010
by
ck
Browse files
BinEditor: Add "jump to address" functionality.
Task-number: QTCREATORBUG-1607
parent
07c83490
Changes
3
Show whitespace changes
Inline
Side-by-side
src/plugins/bineditor/bineditor.cpp
View file @
c2ec9257
...
...
@@ -439,6 +439,7 @@ void BinEditor::setLazyData(quint64 startAddr, int range, int blockSize)
init
();
setCursorPosition
(
startAddr
-
m_baseAddr
);
viewport
()
->
update
();
}
void
BinEditor
::
resizeEvent
(
QResizeEvent
*
)
...
...
@@ -926,11 +927,6 @@ int BinEditor::cursorPosition() const
void
BinEditor
::
setCursorPosition
(
int
pos
,
MoveMode
moveMode
)
{
pos
=
qMin
(
m_size
-
1
,
qMax
(
0
,
pos
));
if
(
pos
==
m_cursorPosition
&&
(
m_anchorPosition
==
m_cursorPosition
||
moveMode
==
KeepAnchor
)
&&
!
m_lowNibble
)
return
;
int
oldCursorPosition
=
m_cursorPosition
;
bool
hasSelection
=
m_anchorPosition
!=
m_cursorPosition
;
...
...
src/plugins/bineditor/bineditor.h
View file @
c2ec9257
...
...
@@ -85,6 +85,7 @@ public:
int
cursorPosition
()
const
;
void
setCursorPosition
(
int
pos
,
MoveMode
moveMode
=
MoveAnchor
);
void
jumpToAddress
(
quint64
address
);
void
setModified
(
bool
);
bool
isModified
()
const
;
...
...
@@ -212,7 +213,6 @@ private:
void
setupJumpToMenuAction
(
QMenu
*
menu
,
QAction
*
actionHere
,
QAction
*
actionNew
,
quint64
addr
);
void
jumpToAddress
(
quint64
address
);
struct
BinEditorEditCommand
{
int
position
;
...
...
src/plugins/bineditor/bineditorplugin.cpp
View file @
c2ec9257
...
...
@@ -36,10 +36,13 @@
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtCore/QRegExp>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtGui/QMainWindow>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QRegExpValidator>
#include <QtGui/QToolBar>
#include <coreplugin/actionmanager/actionmanager.h>
...
...
@@ -54,7 +57,6 @@
#include <find/ifindsupport.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorsettings.h>
#include <utils/linecolumnlabel.h>
#include <utils/reloadpromptutils.h>
using
namespace
BINEditor
;
...
...
@@ -301,21 +303,29 @@ public:
m_file
=
new
BinEditorFile
(
m_editor
);
m_context
<<
uidm
->
uniqueIdentifier
(
Core
::
Constants
::
K_DEFAULT_BINARY_EDITOR_ID
);
m_context
<<
uidm
->
uniqueIdentifier
(
Constants
::
C_BINEDITOR
);
m_cursorPositionLabel
=
new
Utils
::
LineColumnLabel
;
m_addressEdit
=
new
QLineEdit
;
QRegExpValidator
*
const
addressValidator
=
new
QRegExpValidator
(
QRegExp
(
QLatin1String
(
"[0-9a-fA-F]{1,16}"
)),
m_addressEdit
);
m_addressEdit
->
setValidator
(
addressValidator
);
QHBoxLayout
*
l
=
new
QHBoxLayout
;
QWidget
*
w
=
new
QWidget
;
l
->
setMargin
(
0
);
l
->
setContentsMargins
(
0
,
0
,
5
,
0
);
l
->
addStretch
(
1
);
l
->
addWidget
(
m_
cursorPositionLabel
);
l
->
addWidget
(
m_
addressEdit
);
w
->
setLayout
(
l
);
m_toolBar
=
new
QToolBar
;
m_toolBar
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Minimum
);
m_toolBar
->
addWidget
(
w
);
connect
(
m_editor
,
SIGNAL
(
cursorPositionChanged
(
int
)),
this
,
SLOT
(
updateCursorPosition
(
int
)));
connect
(
m_editor
,
SIGNAL
(
cursorPositionChanged
(
int
)),
this
,
SLOT
(
updateCursorPosition
(
int
)));
connect
(
m_addressEdit
,
SIGNAL
(
editingFinished
()),
this
,
SLOT
(
jumpToAddress
()));
updateCursorPosition
(
m_editor
->
cursorPosition
());
}
~
BinEditorInterface
()
{
delete
m_editor
;
...
...
@@ -348,10 +358,14 @@ public:
bool
isTemporary
()
const
{
return
false
;
}
p
ublic
slots
:
p
rivate
slots
:
void
updateCursorPosition
(
int
position
)
{
m_cursorPositionLabel
->
setText
(
m_editor
->
addressString
(
m_editor
->
baseAddress
()
+
position
),
m_editor
->
addressString
(
m_editor
->
baseAddress
()
+
m_editor
->
data
().
size
()));
m_addressEdit
->
setText
(
QString
::
number
(
m_editor
->
baseAddress
()
+
position
,
16
));
}
void
jumpToAddress
()
{
m_editor
->
jumpToAddress
(
m_addressEdit
->
text
().
toULongLong
(
0
,
16
));
updateCursorPosition
(
m_editor
->
cursorPosition
());
}
private:
...
...
@@ -360,7 +374,7 @@ private:
BinEditorFile
*
m_file
;
QList
<
int
>
m_context
;
QToolBar
*
m_toolBar
;
Utils
::
LineColumnLabel
*
m_cursorPositionLabel
;
QLineEdit
*
m_addressEdit
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment