summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/bineditor/bineditor.cpp136
-rw-r--r--src/plugins/bineditor/bineditor.h6
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp122
-rw-r--r--src/plugins/bineditor/bineditorplugin.h6
4 files changed, 136 insertions, 134 deletions
diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp
index 2037b4542d..4fa6c608eb 100644
--- a/src/plugins/bineditor/bineditor.cpp
+++ b/src/plugins/bineditor/bineditor.cpp
@@ -85,7 +85,7 @@ static QByteArray calculateHexPattern(const QByteArray &pattern)
namespace BINEditor {
-BinEditor::BinEditor(QWidget *parent)
+BinEditorWidget::BinEditorWidget(QWidget *parent)
: QAbstractScrollArea(parent)
{
m_bytesPerLine = 16;
@@ -108,11 +108,11 @@ BinEditor::BinEditor(QWidget *parent)
setFrameStyle(QFrame::Plain);
}
-BinEditor::~BinEditor()
+BinEditorWidget::~BinEditorWidget()
{
}
-void BinEditor::init()
+void BinEditorWidget::init()
{
const int addressStringWidth =
2*m_addressBytes + (m_addressBytes - 1) / 2;
@@ -162,7 +162,7 @@ void BinEditor::init()
}
-void BinEditor::addData(quint64 block, const QByteArray &data)
+void BinEditorWidget::addData(quint64 block, const QByteArray &data)
{
QTC_ASSERT(data.size() == m_blockSize, return);
const quint64 addr = block * m_blockSize;
@@ -176,7 +176,7 @@ void BinEditor::addData(quint64 block, const QByteArray &data)
}
}
-bool BinEditor::requestDataAt(int pos) const
+bool BinEditorWidget::requestDataAt(int pos) const
{
int block = pos / m_blockSize;
BlockMap::const_iterator it = m_modifiedData.find(block);
@@ -187,27 +187,27 @@ bool BinEditor::requestDataAt(int pos) const
return true;
if (!m_requests.contains(block)) {
m_requests.insert(block);
- emit const_cast<BinEditor*>(this)->
+ emit const_cast<BinEditorWidget*>(this)->
dataRequested(editor(), m_baseAddr / m_blockSize + block);
return true;
}
return false;
}
-bool BinEditor::requestOldDataAt(int pos) const
+bool BinEditorWidget::requestOldDataAt(int pos) const
{
int block = pos / m_blockSize;
BlockMap::const_iterator it = m_oldData.find(block);
return it != m_oldData.end();
}
-char BinEditor::dataAt(int pos, bool old) const
+char BinEditorWidget::dataAt(int pos, bool old) const
{
int block = pos / m_blockSize;
return blockData(block, old).at(pos - block*m_blockSize);
}
-void BinEditor::changeDataAt(int pos, char c)
+void BinEditorWidget::changeDataAt(int pos, char c)
{
int block = pos / m_blockSize;
BlockMap::iterator it = m_modifiedData.find(block);
@@ -225,7 +225,7 @@ void BinEditor::changeDataAt(int pos, char c)
emit dataChanged(editor(), m_baseAddr + pos, QByteArray(1, c));
}
-QByteArray BinEditor::dataMid(int from, int length, bool old) const
+QByteArray BinEditorWidget::dataMid(int from, int length, bool old) const
{
int end = from + length;
int block = from / m_blockSize;
@@ -239,7 +239,7 @@ QByteArray BinEditor::dataMid(int from, int length, bool old) const
return data.mid(from - ((from / m_blockSize) * m_blockSize), length);
}
-QByteArray BinEditor::blockData(int block, bool old) const
+QByteArray BinEditorWidget::blockData(int block, bool old) const
{
if (old) {
BlockMap::const_iterator it = m_modifiedData.find(block);
@@ -251,12 +251,12 @@ QByteArray BinEditor::blockData(int block, bool old) const
? it.value() : m_data.value(block, m_emptyBlock);
}
-void BinEditor::setFontSettings(const TextEditor::FontSettings &fs)
+void BinEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
setFont(fs.toTextCharFormat(TextEditor::C_TEXT).font());
}
-void BinEditor::setBlinkingCursorEnabled(bool enable)
+void BinEditorWidget::setBlinkingCursorEnabled(bool enable)
{
if (enable && QApplication::cursorFlashTime() > 0)
m_cursorBlinkTimer.start(QApplication::cursorFlashTime() / 2, this);
@@ -266,17 +266,17 @@ void BinEditor::setBlinkingCursorEnabled(bool enable)
updateLines();
}
-void BinEditor::focusInEvent(QFocusEvent *)
+void BinEditorWidget::focusInEvent(QFocusEvent *)
{
setBlinkingCursorEnabled(true);
}
-void BinEditor::focusOutEvent(QFocusEvent *)
+void BinEditorWidget::focusOutEvent(QFocusEvent *)
{
setBlinkingCursorEnabled(false);
}
-void BinEditor::timerEvent(QTimerEvent *e)
+void BinEditorWidget::timerEvent(QTimerEvent *e)
{
if (e->timerId() == m_autoScrollTimer.timerId()) {
QRect visible = viewport()->rect();
@@ -314,7 +314,7 @@ void BinEditor::timerEvent(QTimerEvent *e)
}
-void BinEditor::setModified(bool modified)
+void BinEditorWidget::setModified(bool modified)
{
int unmodifiedState = modified ? -1 : m_undoStack.size();
if (unmodifiedState == m_unmodifiedState)
@@ -323,22 +323,22 @@ void BinEditor::setModified(bool modified)
emit modificationChanged(m_undoStack.size() != m_unmodifiedState);
}
-bool BinEditor::isModified() const
+bool BinEditorWidget::isModified() const
{
return (m_undoStack.size() != m_unmodifiedState);
}
-void BinEditor::setReadOnly(bool readOnly)
+void BinEditorWidget::setReadOnly(bool readOnly)
{
m_readOnly = readOnly;
}
-bool BinEditor::isReadOnly() const
+bool BinEditorWidget::isReadOnly() const
{
return m_readOnly;
}
-bool BinEditor::save(QString *errorString, const QString &oldFileName, const QString &newFileName)
+bool BinEditorWidget::save(QString *errorString, const QString &oldFileName, const QString &newFileName)
{
if (oldFileName != newFileName) {
QString tmpName;
@@ -381,7 +381,7 @@ bool BinEditor::save(QString *errorString, const QString &oldFileName, const QSt
return true;
}
-void BinEditor::setSizes(quint64 startAddr, int range, int blockSize)
+void BinEditorWidget::setSizes(quint64 startAddr, int range, int blockSize)
{
int newBlockSize = blockSize;
QTC_ASSERT((blockSize/m_bytesPerLine) * m_bytesPerLine == blockSize,
@@ -423,12 +423,12 @@ void BinEditor::setSizes(quint64 startAddr, int range, int blockSize)
viewport()->update();
}
-void BinEditor::resizeEvent(QResizeEvent *)
+void BinEditorWidget::resizeEvent(QResizeEvent *)
{
init();
}
-void BinEditor::scrollContentsBy(int dx, int dy)
+void BinEditorWidget::scrollContentsBy(int dx, int dy)
{
viewport()->scroll(isRightToLeft() ? -dx : dx, dy * m_lineHeight);
const QScrollBar * const scrollBar = verticalScrollBar();
@@ -439,7 +439,7 @@ void BinEditor::scrollContentsBy(int dx, int dy)
emit newRangeRequested(editor(), baseAddress());
}
-void BinEditor::changeEvent(QEvent *e)
+void BinEditorWidget::changeEvent(QEvent *e)
{
QAbstractScrollArea::changeEvent(e);
if (e->type() == QEvent::ActivationChange) {
@@ -451,7 +451,7 @@ void BinEditor::changeEvent(QEvent *e)
}
-void BinEditor::wheelEvent(QWheelEvent *e)
+void BinEditorWidget::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() & Qt::ControlModifier) {
const int delta = e->delta();
@@ -466,7 +466,7 @@ void BinEditor::wheelEvent(QWheelEvent *e)
-QRect BinEditor::cursorRect() const
+QRect BinEditorWidget::cursorRect() const
{
int topLine = verticalScrollBar()->value();
int line = m_cursorPosition / m_bytesPerLine;
@@ -481,7 +481,7 @@ QRect BinEditor::cursorRect() const
return QRect(x, y, w, m_lineHeight);
}
-int BinEditor::posAt(const QPoint &pos) const
+int BinEditorWidget::posAt(const QPoint &pos) const
{
int xoffset = horizontalScrollBar()->value();
int x = xoffset + pos.x() - m_margin - m_labelWidth;
@@ -508,19 +508,19 @@ int BinEditor::posAt(const QPoint &pos) const
return qMin(m_size, qMin(m_numLines, topLine + line) * m_bytesPerLine) + column;
}
-bool BinEditor::inTextArea(const QPoint &pos) const
+bool BinEditorWidget::inTextArea(const QPoint &pos) const
{
int xoffset = horizontalScrollBar()->value();
int x = xoffset + pos.x() - m_margin - m_labelWidth;
return (x > m_bytesPerLine * m_columnWidth + m_charWidth/2);
}
-void BinEditor::updateLines()
+void BinEditorWidget::updateLines()
{
updateLines(m_cursorPosition, m_cursorPosition);
}
-void BinEditor::updateLines(int fromPosition, int toPosition)
+void BinEditorWidget::updateLines(int fromPosition, int toPosition)
{
int topLine = verticalScrollBar()->value();
int firstLine = qMin(fromPosition, toPosition) / m_bytesPerLine;
@@ -531,7 +531,7 @@ void BinEditor::updateLines(int fromPosition, int toPosition)
viewport()->update(0, y, viewport()->width(), h);
}
-int BinEditor::dataIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const
+int BinEditorWidget::dataIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const
{
int trailing = pattern.size();
if (trailing > m_blockSize)
@@ -564,7 +564,7 @@ int BinEditor::dataIndexOf(const QByteArray &pattern, int from, bool caseSensiti
return end == m_size ? -1 : -2;
}
-int BinEditor::dataLastIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const
+int BinEditorWidget::dataLastIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const
{
int trailing = pattern.size();
if (trailing > m_blockSize)
@@ -596,7 +596,7 @@ int BinEditor::dataLastIndexOf(const QByteArray &pattern, int from, bool caseSen
}
-int BinEditor::find(const QByteArray &pattern_arg, int from,
+int BinEditorWidget::find(const QByteArray &pattern_arg, int from,
QTextDocument::FindFlags findFlags)
{
if (pattern_arg.isEmpty())
@@ -633,7 +633,7 @@ int BinEditor::find(const QByteArray &pattern_arg, int from,
return pos;
}
-int BinEditor::findPattern(const QByteArray &data, const QByteArray &dataHex,
+int BinEditorWidget::findPattern(const QByteArray &data, const QByteArray &dataHex,
int from, int offset, int *match)
{
if (m_searchPattern.isEmpty())
@@ -658,7 +658,7 @@ int BinEditor::findPattern(const QByteArray &data, const QByteArray &dataHex,
}
-void BinEditor::drawItems(QPainter *painter, int x, int y, const QString &itemString)
+void BinEditorWidget::drawItems(QPainter *painter, int x, int y, const QString &itemString)
{
if (m_isMonospacedFont) {
painter->drawText(x, y, itemString);
@@ -668,7 +668,7 @@ void BinEditor::drawItems(QPainter *painter, int x, int y, const QString &itemSt
}
}
-void BinEditor::drawChanges(QPainter *painter, int x, int y, const char *changes)
+void BinEditorWidget::drawChanges(QPainter *painter, int x, int y, const char *changes)
{
const QBrush red(QColor(250, 150, 150));
for (int i = 0; i < m_bytesPerLine; ++i) {
@@ -679,7 +679,7 @@ void BinEditor::drawChanges(QPainter *painter, int x, int y, const char *changes
}
}
-QString BinEditor::addressString(quint64 address)
+QString BinEditorWidget::addressString(quint64 address)
{
QChar *addressStringData = m_addressString.data();
const char *hex = "0123456789abcdef";
@@ -698,7 +698,7 @@ QString BinEditor::addressString(quint64 address)
return m_addressString;
}
-void BinEditor::paintEvent(QPaintEvent *e)
+void BinEditorWidget::paintEvent(QPaintEvent *e)
{
QPainter painter(viewport());
const int topLine = verticalScrollBar()->value();
@@ -930,12 +930,12 @@ void BinEditor::paintEvent(QPaintEvent *e)
}
-int BinEditor::cursorPosition() const
+int BinEditorWidget::cursorPosition() const
{
return m_cursorPosition;
}
-void BinEditor::setCursorPosition(int pos, MoveMode moveMode)
+void BinEditorWidget::setCursorPosition(int pos, MoveMode moveMode)
{
pos = qMin(m_size-1, qMax(0, pos));
int oldCursorPosition = m_cursorPosition;
@@ -957,7 +957,7 @@ void BinEditor::setCursorPosition(int pos, MoveMode moveMode)
}
-void BinEditor::ensureCursorVisible()
+void BinEditorWidget::ensureCursorVisible()
{
QRect cr = cursorRect();
QRect vr = viewport()->rect();
@@ -969,7 +969,7 @@ void BinEditor::ensureCursorVisible()
}
}
-void BinEditor::mousePressEvent(QMouseEvent *e)
+void BinEditorWidget::mousePressEvent(QMouseEvent *e)
{
if (e->button() != Qt::LeftButton)
return;
@@ -982,7 +982,7 @@ void BinEditor::mousePressEvent(QMouseEvent *e)
}
}
-void BinEditor::mouseMoveEvent(QMouseEvent *e)
+void BinEditorWidget::mouseMoveEvent(QMouseEvent *e)
{
if (!(e->buttons() & Qt::LeftButton))
return;
@@ -998,7 +998,7 @@ void BinEditor::mouseMoveEvent(QMouseEvent *e)
m_autoScrollTimer.start(100, this);
}
-void BinEditor::mouseReleaseEvent(QMouseEvent *)
+void BinEditorWidget::mouseReleaseEvent(QMouseEvent *)
{
if (m_autoScrollTimer.isActive()) {
m_autoScrollTimer.stop();
@@ -1006,13 +1006,13 @@ void BinEditor::mouseReleaseEvent(QMouseEvent *)
}
}
-void BinEditor::selectAll()
+void BinEditorWidget::selectAll()
{
setCursorPosition(0);
setCursorPosition(m_size-1, KeepAnchor);
}
-void BinEditor::clear()
+void BinEditorWidget::clear()
{
m_baseAddr = 0;
m_data.clear();
@@ -1034,7 +1034,7 @@ void BinEditor::clear()
viewport()->update();
}
-bool BinEditor::event(QEvent *e)
+bool BinEditorWidget::event(QEvent *e)
{
switch (e->type()) {
case QEvent::KeyPress:
@@ -1075,7 +1075,7 @@ bool BinEditor::event(QEvent *e)
return QAbstractScrollArea::event(e);
}
-QString BinEditor::toolTip(const QHelpEvent *helpEvent) const
+QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
{
// Selection if mouse is in, else 1 byte at cursor
int selStart = selectionStart();
@@ -1257,7 +1257,7 @@ QString BinEditor::toolTip(const QHelpEvent *helpEvent) const
return msg;
}
-void BinEditor::keyPressEvent(QKeyEvent *e)
+void BinEditorWidget::keyPressEvent(QKeyEvent *e)
{
if (e == QKeySequence::SelectAll) {
@@ -1356,7 +1356,7 @@ void BinEditor::keyPressEvent(QKeyEvent *e)
e->accept();
}
-void BinEditor::zoomIn(int range)
+void BinEditorWidget::zoomIn(int range)
{
QFont f = font();
const int newSize = f.pointSize() + range;
@@ -1366,12 +1366,12 @@ void BinEditor::zoomIn(int range)
setFont(f);
}
-void BinEditor::zoomOut(int range)
+void BinEditorWidget::zoomOut(int range)
{
zoomIn(-range);
}
-void BinEditor::copy(bool raw)
+void BinEditorWidget::copy(bool raw)
{
int selStart = selectionStart();
int selEnd = selectionEnd();
@@ -1400,7 +1400,7 @@ void BinEditor::copy(bool raw)
QApplication::clipboard()->setText(hexString);
}
-void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags findFlags)
+void BinEditorWidget::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags findFlags)
{
if (m_searchPattern == pattern)
return;
@@ -1412,7 +1412,7 @@ void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument:
viewport()->update();
}
-void BinEditor::changeData(int position, uchar character, bool highNibble)
+void BinEditorWidget::changeData(int position, uchar character, bool highNibble)
{
if (!requestDataAt(position))
return;
@@ -1444,7 +1444,7 @@ void BinEditor::changeData(int position, uchar character, bool highNibble)
}
-void BinEditor::undo()
+void BinEditorWidget::undo()
{
if (m_undoStack.isEmpty())
return;
@@ -1464,7 +1464,7 @@ void BinEditor::undo()
emit redoAvailable(true);
}
-void BinEditor::redo()
+void BinEditorWidget::redo()
{
if (m_redoStack.isEmpty())
return;
@@ -1483,7 +1483,7 @@ void BinEditor::redo()
emit redoAvailable(false);
}
-void BinEditor::contextMenuEvent(QContextMenuEvent *event)
+void BinEditorWidget::contextMenuEvent(QContextMenuEvent *event)
{
const int selStart = selectionStart();
const int byteCount = selectionEnd() - selStart + 1;
@@ -1545,7 +1545,7 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event)
delete contextMenu;
}
-void BinEditor::setupJumpToMenuAction(QMenu *menu, QAction *actionHere,
+void BinEditorWidget::setupJumpToMenuAction(QMenu *menu, QAction *actionHere,
QAction *actionNew, quint64 addr)
{
actionHere->setText(tr("Jump to Address 0x%1 in This Window")
@@ -1558,7 +1558,7 @@ void BinEditor::setupJumpToMenuAction(QMenu *menu, QAction *actionHere,
actionNew->setEnabled(false);
}
-void BinEditor::jumpToAddress(quint64 address)
+void BinEditorWidget::jumpToAddress(quint64 address)
{
if (address >= m_baseAddr && address < m_baseAddr + m_size)
setCursorPosition(address - m_baseAddr);
@@ -1566,26 +1566,26 @@ void BinEditor::jumpToAddress(quint64 address)
emit newRangeRequested(editor(), address);
}
-void BinEditor::setNewWindowRequestAllowed(bool c)
+void BinEditorWidget::setNewWindowRequestAllowed(bool c)
{
m_canRequestNewWindow = c;
}
-void BinEditor::updateContents()
+void BinEditorWidget::updateContents()
{
m_oldData = m_data;
m_data.clear();
setSizes(baseAddress() + cursorPosition(), m_size, m_blockSize);
}
-QPoint BinEditor::offsetToPos(int offset) const
+QPoint BinEditorWidget::offsetToPos(int offset) const
{
const int x = m_labelWidth + (offset % m_bytesPerLine) * m_columnWidth;
const int y = (offset / m_bytesPerLine - verticalScrollBar()->value()) * m_lineHeight;
return QPoint(x, y);
}
-void BinEditor::asFloat(int offset, float &value, bool old) const
+void BinEditorWidget::asFloat(int offset, float &value, bool old) const
{
value = 0;
const QByteArray data = dataMid(offset, sizeof(float), old);
@@ -1594,7 +1594,7 @@ void BinEditor::asFloat(int offset, float &value, bool old) const
value = *f;
}
-void BinEditor::asDouble(int offset, double &value, bool old) const
+void BinEditorWidget::asDouble(int offset, double &value, bool old) const
{
value = 0;
const QByteArray data = dataMid(offset, sizeof(double), old);
@@ -1603,7 +1603,7 @@ void BinEditor::asDouble(int offset, double &value, bool old) const
value = *f;
}
-void BinEditor::asIntegers(int offset, int count, quint64 &bigEndianValue,
+void BinEditorWidget::asIntegers(int offset, int count, quint64 &bigEndianValue,
quint64 &littleEndianValue, bool old) const
{
bigEndianValue = littleEndianValue = 0;
@@ -1615,12 +1615,12 @@ void BinEditor::asIntegers(int offset, int count, quint64 &bigEndianValue,
}
}
-bool BinEditor::isMemoryView() const
+bool BinEditorWidget::isMemoryView() const
{
return editor()->property("MemoryView").toBool();
}
-void BinEditor::setMarkup(const QList<Markup> &markup)
+void BinEditorWidget::setMarkup(const QList<Markup> &markup)
{
m_markup = markup;
viewport()->update();
diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h
index 9242a5b00f..83ef6a346c 100644
--- a/src/plugins/bineditor/bineditor.h
+++ b/src/plugins/bineditor/bineditor.h
@@ -55,7 +55,7 @@ class FontSettings;
namespace BINEditor {
-class BinEditor : public QAbstractScrollArea
+class BinEditorWidget : public QAbstractScrollArea
{
Q_OBJECT
Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
@@ -63,8 +63,8 @@ class BinEditor : public QAbstractScrollArea
Q_PROPERTY(QList<BINEditor::Markup> markup READ markup WRITE setMarkup DESIGNABLE false)
Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false)
public:
- BinEditor(QWidget *parent = 0);
- ~BinEditor();
+ BinEditorWidget(QWidget *parent = 0);
+ ~BinEditorWidget();
quint64 baseAddress() const { return m_baseAddr; }
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index f6e401dae7..a805e66f6c 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -70,15 +70,17 @@ using namespace BINEditor::Internal;
class BinEditorFind : public Find::IFindSupport
{
Q_OBJECT
+
public:
- BinEditorFind(BinEditor *editor)
+ BinEditorFind(BinEditorWidget *widget)
{
- m_editor = editor;
+ m_widget = widget;
m_incrementalStartPos = m_contPos = -1;
}
~BinEditorFind() {}
bool supportsReplace() const { return false; }
+
Find::FindFlags supportedFindFlags() const
{
return Find::FindBackward | Find::FindCaseSensitively;
@@ -91,21 +93,21 @@ public:
virtual void highlightAll(const QString &txt, Find::FindFlags findFlags)
{
- m_editor->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
}
- void clearResults() { m_editor->highlightSearchResults(QByteArray()); }
+ void clearResults() { m_widget->highlightSearchResults(QByteArray()); }
QString currentFindString() const { return QString(); }
QString completedFindString() const { return QString(); }
int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags) {
if (pattern.isEmpty()) {
- m_editor->setCursorPosition(pos);
+ m_widget->setCursorPosition(pos);
return pos;
}
- return m_editor->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
+ return m_widget->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
}
Result findIncremental(const QString &txt, Find::FindFlags findFlags) {
@@ -114,25 +116,25 @@ public:
resetIncrementalSearch(); // Because we don't search for nibbles.
m_lastPattern = pattern;
if (m_incrementalStartPos < 0)
- m_incrementalStartPos = m_editor->selectionStart();
+ m_incrementalStartPos = m_widget->selectionStart();
if (m_contPos == -1)
m_contPos = m_incrementalStartPos;
int found = find(pattern, m_contPos, findFlags);
Result result;
if (found >= 0) {
result = Found;
- m_editor->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
m_contPos = -1;
} else {
if (found == -2) {
result = NotYetFound;
m_contPos +=
findFlags & Find::FindBackward
- ? -BinEditor::SearchStride : BinEditor::SearchStride;
+ ? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
m_contPos = -1;
- m_editor->highlightSearchResults(QByteArray(), 0);
+ m_widget->highlightSearchResults(QByteArray(), 0);
}
}
return result;
@@ -142,9 +144,9 @@ public:
QByteArray pattern = txt.toLatin1();
bool wasReset = (m_incrementalStartPos < 0);
if (m_contPos == -1) {
- m_contPos = m_editor->cursorPosition();
+ m_contPos = m_widget->cursorPosition();
if (findFlags & Find::FindBackward)
- m_contPos = m_editor->selectionStart()-1;
+ m_contPos = m_widget->selectionStart()-1;
}
int found = find(pattern, m_contPos, findFlags);
Result result;
@@ -153,11 +155,11 @@ public:
m_incrementalStartPos = found;
m_contPos = -1;
if (wasReset)
- m_editor->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
} else if (found == -2) {
result = NotYetFound;
m_contPos += findFlags & Find::FindBackward
- ? -BinEditor::SearchStride : BinEditor::SearchStride;
+ ? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
m_contPos = -1;
@@ -167,7 +169,7 @@ public:
}
private:
- BinEditor *m_editor;
+ BinEditorWidget *m_widget;
int m_incrementalStartPos;
int m_contPos; // Only valid if last result was NotYetFound.
QByteArray m_lastPattern;
@@ -178,13 +180,13 @@ class BinEditorDocument : public Core::IDocument
{
Q_OBJECT
public:
- BinEditorDocument(BinEditor *parent) :
+ BinEditorDocument(BinEditorWidget *parent) :
Core::IDocument(parent)
{
- m_editor = parent;
- connect(m_editor, SIGNAL(dataRequested(Core::IEditor*,quint64)),
+ m_widget = parent;
+ connect(m_widget, SIGNAL(dataRequested(Core::IEditor*,quint64)),
this, SLOT(provideData(Core::IEditor*,quint64)));
- connect(m_editor, SIGNAL(newRangeRequested(Core::IEditor*,quint64)),
+ connect(m_widget, SIGNAL(newRangeRequested(Core::IEditor*,quint64)),
this, SLOT(provideNewRange(Core::IEditor*,quint64)));
}
~BinEditorDocument() {}
@@ -198,9 +200,9 @@ public:
QTC_ASSERT(!autoSave, return true); // bineditor does not support autosave - it would be a bit expensive
const QString fileNameToUse
= fileName.isEmpty() ? m_fileName : fileName;
- if (m_editor->save(errorString, m_fileName, fileNameToUse)) {
+ if (m_widget->save(errorString, m_fileName, fileNameToUse)) {
m_fileName = fileNameToUse;
- m_editor->editor()->setDisplayName(QFileInfo(fileNameToUse).fileName());
+ m_widget->editor()->setDisplayName(QFileInfo(fileNameToUse).fileName());
emit changed();
return true;
} else {
@@ -210,7 +212,7 @@ public:
void rename(const QString &newName) {
m_fileName = newName;
- m_editor->editor()->setDisplayName(QFileInfo(fileName()).fileName());
+ m_widget->editor()->setDisplayName(QFileInfo(fileName()).fileName());
emit changed();
}
@@ -230,8 +232,8 @@ public:
if (file.open(QIODevice::ReadOnly)) {
file.close();
m_fileName = fileName;
- m_editor->setSizes(offset, file.size());
- m_editor->editor()->setDisplayName(QFileInfo(fileName).fileName());
+ m_widget->setSizes(offset, file.size());
+ m_widget->editor()->setDisplayName(QFileInfo(fileName).fileName());
return true;
}
QString errStr = tr("Cannot open %1: %2").arg(
@@ -249,14 +251,14 @@ private slots:
return;
QFile file(m_fileName);
if (file.open(QIODevice::ReadOnly)) {
- int blockSize = m_editor->dataBlockSize();
+ int blockSize = m_widget->dataBlockSize();
file.seek(block * blockSize);
QByteArray data = file.read(blockSize);
file.close();
const int dataSize = data.size();
if (dataSize != blockSize)
data += QByteArray(blockSize - dataSize, 0);
- m_editor->addData(block, data);
+ m_widget->addData(block, data);
} else {
QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"),
tr("Cannot open %1: %2").arg(
@@ -280,10 +282,10 @@ public:
QString suggestedFileName() const { return QString(); }
- bool isModified() const { return m_editor->isMemoryView() ? false : m_editor->isModified(); }
+ bool isModified() const { return m_widget->isMemoryView() ? false : m_widget->isModified(); }
bool isFileReadOnly() const {
- if (m_editor->isMemoryView() || m_fileName.isEmpty())
+ if (m_widget->isMemoryView() || m_fileName.isEmpty())
return false;
const QFileInfo fi(m_fileName);
return !fi.isWritable();
@@ -306,19 +308,19 @@ public:
}
private:
- BinEditor *m_editor;
+ BinEditorWidget *m_widget;
QString m_fileName;
};
-class BinEditorInterface : public Core::IEditor
+class BinEditor : public Core::IEditor
{
Q_OBJECT
public:
- BinEditorInterface(BinEditor *editor)
+ BinEditor(BinEditorWidget *widget)
{
- setWidget(editor);
- m_editor = editor;
- m_file = new BinEditorDocument(m_editor);
+ setWidget(widget);
+ m_widget = widget;
+ m_file = new BinEditorDocument(m_widget);
m_context.add(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
m_context.add(Constants::C_BINEDITOR);
m_addressEdit = new QLineEdit;
@@ -339,19 +341,19 @@ public:
m_toolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_toolBar->addWidget(w);
- connect(m_editor, SIGNAL(cursorPositionChanged(int)), this,
+ connect(m_widget, SIGNAL(cursorPositionChanged(int)), this,
SLOT(updateCursorPosition(int)));
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
connect(m_addressEdit, SIGNAL(editingFinished()), this,
SLOT(jumpToAddress()));
- updateCursorPosition(m_editor->cursorPosition());
+ updateCursorPosition(m_widget->cursorPosition());
}
- ~BinEditorInterface() {
- delete m_editor;
+ ~BinEditor() {
+ delete m_widget;
}
bool createNew(const QString & /* contents */ = QString()) {
- m_editor->clear();
+ m_widget->clear();
m_file->setFilename(QString());
return true;
}
@@ -366,20 +368,20 @@ public:
QWidget *toolBar() { return m_toolBar; }
- bool isTemporary() const { return m_editor->isMemoryView(); }
+ bool isTemporary() const { return m_widget->isMemoryView(); }
private slots:
void updateCursorPosition(int position) {
- m_addressEdit->setText(QString::number(m_editor->baseAddress() + position, 16));
+ m_addressEdit->setText(QString::number(m_widget->baseAddress() + position, 16));
}
void jumpToAddress() {
- m_editor->jumpToAddress(m_addressEdit->text().toULongLong(0, 16));
- updateCursorPosition(m_editor->cursorPosition());
+ m_widget->jumpToAddress(m_addressEdit->text().toULongLong(0, 16));
+ updateCursorPosition(m_widget->cursorPosition());
}
private:
- BinEditor *m_editor;
+ BinEditorWidget *m_widget;
QString m_displayName;
BinEditorDocument *m_file;
QToolBar *m_toolBar;
@@ -408,9 +410,9 @@ QString BinEditorFactory::displayName() const
Core::IEditor *BinEditorFactory::createEditor(QWidget *parent)
{
- BinEditor *editor = new BinEditor(parent);
- m_owner->initializeEditor(editor);
- return editor->editor();
+ BinEditorWidget *widget = new BinEditorWidget(parent);
+ m_owner->initializeEditor(widget);
+ return widget->editor();
}
QStringList BinEditorFactory::mimeTypes() const
@@ -433,7 +435,7 @@ BinEditorWidgetFactory::BinEditorWidgetFactory(QObject *parent) :
QWidget *BinEditorWidgetFactory::createWidget(QWidget *parent)
{
- return new BinEditor(parent);
+ return new BinEditorWidget(parent);
}
///////////////////////////////// BinEditorPlugin //////////////////////////////////
@@ -467,11 +469,11 @@ QAction *BinEditorPlugin::registerNewAction(Core::Id id,
return rc;
}
-void BinEditorPlugin::initializeEditor(BinEditor *editor)
+void BinEditorPlugin::initializeEditor(BinEditorWidget *widget)
{
- BinEditorInterface *editorInterface = new BinEditorInterface(editor);
- QObject::connect(editor, SIGNAL(modificationChanged(bool)), editorInterface, SIGNAL(changed()));
- editor->setEditor(editorInterface);
+ BinEditor *editor = new BinEditor(widget);
+ QObject::connect(widget, SIGNAL(modificationChanged(bool)), editor, SIGNAL(changed()));
+ widget->setEditor(editor);
m_context.add(Constants::C_BINEDITOR);
if (!m_undoAction) {
@@ -483,17 +485,17 @@ void BinEditorPlugin::initializeEditor(BinEditor *editor)
// Font settings
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
- editor->setFontSettings(settings->fontSettings());
+ widget->setFontSettings(settings->fontSettings());
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
- editor, SLOT(setFontSettings(TextEditor::FontSettings)));
+ widget, SLOT(setFontSettings(TextEditor::FontSettings)));
- QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateActions()));
- QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateActions()));
+ QObject::connect(widget, SIGNAL(undoAvailable(bool)), this, SLOT(updateActions()));
+ QObject::connect(widget, SIGNAL(redoAvailable(bool)), this, SLOT(updateActions()));
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
- BinEditorFind *binEditorFind = new BinEditorFind(editor);
+ BinEditorFind *binEditorFind = new BinEditorFind(widget);
aggregate->add(binEditorFind);
- aggregate->add(editor);
+ aggregate->add(widget);
}
bool BinEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
@@ -515,9 +517,9 @@ void BinEditorPlugin::extensionsInitialized()
void BinEditorPlugin::updateCurrentEditor(Core::IEditor *editor)
{
- BinEditor *binEditor = 0;
+ BinEditorWidget *binEditor = 0;
if (editor)
- binEditor = qobject_cast<BinEditor *>(editor->widget());
+ binEditor = qobject_cast<BinEditorWidget *>(editor->widget());
if (m_currentEditor == binEditor)
return;
m_currentEditor = binEditor;
diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h
index 7c383d2ff7..0adf0f62b4 100644
--- a/src/plugins/bineditor/bineditorplugin.h
+++ b/src/plugins/bineditor/bineditorplugin.h
@@ -40,7 +40,7 @@
#include <QAction>
namespace BINEditor {
-class BinEditor;
+class BinEditorWidget;
class BinEditorWidgetFactory : public QObject
{
@@ -67,7 +67,7 @@ public:
void extensionsInitialized();
// Connect editor to settings changed signals.
- void initializeEditor(BinEditor *editor);
+ void initializeEditor(BinEditorWidget *editor);
private slots:
void undoAction();
@@ -92,7 +92,7 @@ private:
Core::IEditor *createEditor(QWidget *parent);
BinEditorFactory *m_factory;
- QPointer<BinEditor> m_currentEditor;
+ QPointer<BinEditorWidget> m_currentEditor;
};
class BinEditorFactory : public Core::IEditorFactory