Dax89 / QHexView

A versatile Hexadecimal widget for Qt5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hex display width and comments

audetto opened this issue · comments

I was thinking about the width of the hex view, which is currently hardcoded to 16 in QHexCursor.h.

I was thinking how hard it would be to change it to something (semi) dynamic.
With the huge screen existing today, 16 bytes wide is very small.

Questions I had are:

  • where should it be stored?
  • QHexMetadata would need some adjustments because of

QHash<int, QHexLineMetadata> m_metadata;

In my code I have already written something that takes a "start and end" and converts it to multiple calls to metadata, so I was thinking that QHexMetadata could do the same.
Store in absolute values and convert to lines each time the width changes?

Or alternatively that the width can only be set once so there lines never change meaning?

What do you think?

It shouldn't be too hard: this information can be stored as class member in QHexDocument or QHexRenderer with the default value of 16, but it can be changed dynamically too.

QHexLineMetadata must be redesigned a bit in order to support dynamic column changes, maybe using a simple offset + length pairs, which is indepentent to the view

I am not too sure where to store it.

It is currently used in QHexPosition, QHexCursor and QHexRenderer.

Unless one decides to store all the "positions" as absolute and convert when needed (maybe in the renderer only), I am afraid I would add a lot of setLineLenght() synchronisation function which would just make a mess of it.

Or the linelength could be passed as argument every time, but QHexPosition stores lines and columns...

It does not see to do anything

    QHexDocument * auxDocument = QHexDocument::fromMemory<QMemoryBuffer>(auxBase, 0x10000, this);
    QHexCursor * auxCursor = mainDocument->cursor();
    auxCursor->setLineWidth(32);

Do I need more than that?

And how is this handled by the Metadata?

@audetto you need set line width on document not on cursor

Got it.
And I can see that the metadata is not linked to the line width.

QHexLineMetadata must be redesigned a bit in order to support dynamic column changes, maybe using a simple offset + length pairs, which is indepentent to the view

I think this would simplify a lot the usage of the line comments and it could be converted to the current format when the line size changes.

I will provide a PR for this.