X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Fdecoder_output%2FQHexView.hpp;h=71b06cdd71ff3a84d8b6f72e485b152fe9d9a839;hb=b6d0bcb839f63ca1aeb78f9f86aeb6cac84ad193;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..71b06cdd 100644 --- a/pv/views/decoder_output/QHexView.hpp +++ b/pv/views/decoder_output/QHexView.hpp @@ -31,64 +31,71 @@ #define PULSEVIEW_PV_VIEWS_DECODEROUTPUT_QHEXVIEW_H #include -#include -#include -using std::size_t; +#include +using std::pair; +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 set_mode(Mode m); + void set_data(const DecodeBinaryClass* data); + unsigned int get_bytes_per_line() const; + void clear(); void showFromOffset(size_t offset); + virtual QSizePolicy sizePolicy() const; + + pair get_selection() const; + + size_t create_hex_line(size_t start, size_t end, QString* dest, + bool with_offset=false, bool with_ascii=false); 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_; + DecodeBinaryDataChunk current_chunk_; // Cache locally so that we're not messed up when the vector is re-allocating its data + + vector chunk_colors_; }; #endif /* PULSEVIEW_PV_VIEWS_DECODEROUTPUT_QHEXVIEW_H */