OSDN Git Service

bineditor: add a facility to invalidate the cache from the outside
authorhjk <qtc-committer@nokia.com>
Wed, 8 Dec 2010 06:57:20 +0000 (07:57 +0100)
committerhjk <qtc-committer@nokia.com>
Wed, 8 Dec 2010 06:58:23 +0000 (07:58 +0100)
This is necessary to handle "live updates". Originally done by ck.

src/plugins/bineditor/bineditor.cpp
src/plugins/bineditor/bineditor.h

index 23b5d04..ae3945d 100644 (file)
@@ -1264,7 +1264,10 @@ void BinEditor::changeData(int position, uchar character, bool highNibble)
     cmd.character = (uchar) dataAt(position);
     cmd.highNibble = highNibble;
 
-    if (!highNibble && !m_undoStack.isEmpty() && m_undoStack.top().position == position && m_undoStack.top().highNibble) {
+    if (!highNibble
+            && !m_undoStack.isEmpty()
+            && m_undoStack.top().position == position
+            && m_undoStack.top().highNibble) {
         // compress
         cmd.character = m_undoStack.top().character;
         m_undoStack.pop();
@@ -1400,6 +1403,11 @@ void BinEditor::setNewWindowRequestAllowed()
     m_canRequestNewWindow = true;
 }
 
+void BinEditor::updateContents()
+{
+    setLazyData(baseAddress() + cursorPosition(), dataSize(), m_blockSize);
+}
+
 QPoint BinEditor::offsetToPos(int offset)
 {
     const int x = m_labelWidth + (offset % 16) * m_columnWidth;
index 70241a7..aca4a71 100644 (file)
@@ -73,6 +73,7 @@ public:
     inline int lazyDataBlockSize() const { return m_blockSize; }
     Q_INVOKABLE void addLazyData(quint64 block, const QByteArray &data);
     Q_INVOKABLE void setNewWindowRequestAllowed();
+    Q_INVOKABLE void updateContents();
     bool save(const QString &oldFileName, const QString &newFileName);
 
     void zoomIn(int range = 1);