Skip to content
Permalink
Browse files

convert from tab to space.

  • Loading branch information...
haraki committed Jun 6, 2019
1 parent 918e899 commit e8b5dd25b36370bd9c724a39515926b1747b7fb9
Showing with 306 additions and 307 deletions.
  1. +73 −74 include/QHexView.h
  2. +233 −233 src/QHexView.cpp
@@ -6,81 +6,80 @@
#include <QFile>

class QHexView: public QAbstractScrollArea

{
public:
class DataStorage
{
public:
virtual ~DataStorage() = default;
virtual QByteArray getData(std::size_t position, std::size_t length) = 0;
virtual std::size_t size() = 0;
};


class DataStorageArray: public DataStorage
{
public:
DataStorageArray(const QByteArray &arr);
virtual QByteArray getData(std::size_t position, std::size_t length);
virtual std::size_t size();
private:
QByteArray m_data;
};

class DataStorageFile: public DataStorage
{
public:
DataStorageFile(const QString &fileName);
virtual QByteArray getData(std::size_t position, std::size_t length);
virtual std::size_t size();
private:
QFile m_file;
};



QHexView(QWidget *parent = Q_NULLPTR);
~QHexView();

void setFont(const QFont& font);

const QPalette& getAddressAreaPalette() const;
void setAddressAreaPalette(const QPalette &pal);

public slots:
void setData(DataStorage *pData);
void clear();
void showFromOffset(std::size_t offset);

protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
DataStorage *m_pdata;
std::size_t m_posAddr;
std::size_t m_posHex;
std::size_t m_posAscii;
std::size_t m_charWidth;
std::size_t m_charHeight;


std::size_t m_selectBegin;
std::size_t m_selectEnd;
std::size_t m_selectInit;
std::size_t m_cursorPos;

QPalette m_addressAreaPalette;

QSize fullSize() const;
void resetSelection();
void resetSelection(int pos);
void setSelection(int pos);
void ensureVisible();
void setCursorPos(int pos);
std::size_t cursorPos(const QPoint &position);
public:
class DataStorage
{
public:
virtual ~DataStorage() = default;
virtual QByteArray getData(std::size_t position, std::size_t length) = 0;
virtual std::size_t size() = 0;
};


class DataStorageArray: public DataStorage
{
public:
DataStorageArray(const QByteArray &arr);
virtual QByteArray getData(std::size_t position, std::size_t length);
virtual std::size_t size();
private:
QByteArray m_data;
};

class DataStorageFile: public DataStorage
{
public:
DataStorageFile(const QString &fileName);
virtual QByteArray getData(std::size_t position, std::size_t length);
virtual std::size_t size();
private:
QFile m_file;
};



QHexView(QWidget *parent = Q_NULLPTR);
~QHexView();

void setFont(const QFont& font);

const QPalette& getAddressAreaPalette() const;
void setAddressAreaPalette(const QPalette &pal);

public Q_SLOTS:
void setData(DataStorage *pData);
void clear();
void showFromOffset(std::size_t offset);

protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
DataStorage *m_pdata;
std::size_t m_posAddr;
std::size_t m_posHex;
std::size_t m_posAscii;
std::size_t m_charWidth;
std::size_t m_charHeight;


std::size_t m_selectBegin;
std::size_t m_selectEnd;
std::size_t m_selectInit;
std::size_t m_cursorPos;

QPalette m_addressAreaPalette;

QSize fullSize() const;
void resetSelection();
void resetSelection(int pos);
void setSelection(int pos);
void ensureVisible();
void setCursorPos(int pos);
std::size_t cursorPos(const QPoint &position);
};

#endif

0 comments on commit e8b5dd2

Please sign in to comment.
You can’t perform that action at this time.