X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Fdecoder_output%2FQHexView.hpp;h=fca3c7efa798a4e95f8f9c388464516a0bcd142a;hb=cbf428c209788f1c0860cc7a1247a279379db303;hp=fd4b86f1859ca40b622b48f3eaf5ede7b575f2b9;hpb=c7b76823dac770da072667877622428591ac26a1;p=pulseview.git diff --git a/pv/views/decoder_output/QHexView.hpp b/pv/views/decoder_output/QHexView.hpp index fd4b86f1..fca3c7ef 100644 --- a/pv/views/decoder_output/QHexView.hpp +++ b/pv/views/decoder_output/QHexView.hpp @@ -31,64 +31,63 @@ #define PULSEVIEW_PV_VIEWS_DECODEROUTPUT_QHEXVIEW_H #include -#include -#include -using std::size_t; +#include +using std::size_t; +using pv::data::DecodeBinaryClass; +using pv::data::DecodeBinaryDataChunk; -class DataStorage +class QHexView: public QAbstractScrollArea { -public: - virtual ~DataStorage() {}; - virtual QByteArray getData(size_t position, size_t length) = 0; - virtual size_t size() = 0; -}; + Q_OBJECT - -class DataStorageArray: public DataStorage -{ public: - DataStorageArray(const QByteArray &arr); - virtual QByteArray getData(size_t position, size_t length); - virtual size_t size(); - -private: - QByteArray data_; -}; - + enum Mode { + ChunkedDataMode, ///< Displays all data chunks in succession + MemoryEmulationMode ///< Reconstructs memory contents from data chunks + }; -class QHexView: public QAbstractScrollArea -{ +public: QHexView(QWidget *parent = 0); - ~QHexView(); -public Q_SLOTS: - void setData(DataStorage *pData); + void setMode(Mode m); + void setData(const DecodeBinaryClass* data); + void clear(); void showFromOffset(size_t offset); protected: + void initialize_byte_iterator(size_t offset); + uint8_t get_next_byte(bool* is_next_chunk = nullptr); + void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); private: - QSize fullSize() const; + QSize getFullSize() const; void resetSelection(); void resetSelection(int pos); void setSelection(int pos); void ensureVisible(); void setCursorPos(int pos); - size_t cursorPos(const QPoint &position); + size_t cursorPosFromMousePos(const QPoint &position); private: - DataStorage *pdata_; + Mode mode_; + const DecodeBinaryClass* data_; + size_t data_size_; size_t posAddr_, posHex_, posAscii_; size_t charWidth_, charHeight_; size_t selectBegin_, selectEnd_, selectInit_, cursorPos_; + + size_t current_chunk_id_, current_chunk_offset_, current_offset_; + const DecodeBinaryDataChunk* current_chunk_; + + vector chunk_colors_; }; #endif /* PULSEVIEW_PV_VIEWS_DECODEROUTPUT_QHEXVIEW_H */