Elaztek Developer Hub
Blamite Game Engine - Keystone  00390.07.02.23.1947.blamite
A library that enables the use of Qt in Blamite's editing tools.
qhexmetadata.h
Go to the documentation of this file.
1 #ifndef QHEXMETADATA_H
2 #define QHEXMETADATA_H
3 
4 #include <QtGlobal>
5 #include <QObject>
6 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
7 #include <QLinkedList>
8 #else
9 #include <list>
10 #endif
11 #include <QColor>
12 #include <QHash>
13 #include <QVector>
14 
16 {
17  qint64 begin;
18  qint64 end;
20  QString comment;
21 };
22 
24 {
25  quint64 line;
26  int start, length;
28  QString comment;
29 };
30 
31 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
32 typedef QLinkedList<QHexMetadataItem> QHexLineMetadata;
33 #else
34 typedef std::list<QHexMetadataItem> QHexLineMetadata;
35 #endif
36 
37 class QHexMetadata : public QObject
38 {
39  Q_OBJECT
40 
41  public:
42  explicit QHexMetadata(QObject *parent = nullptr);
43  const QHexLineMetadata& get(quint64 line) const;
44  QString comments(quint64 line, int column) const;
45  bool hasMetadata(quint64 line) const;
46 
47  void clear(quint64 line); // this is transient till next call to setLineWidth()
48 
49  void clear();
50  void setLineWidth(quint8 width);
51 
52  public:
53  // new interface with begin, end
54  void metadata(qint64 begin, qint64 end, const QColor &fgcolor, const QColor &bgcolor, const QString &comment);
55 
56  // old interface with line, start, length
57  void metadata(quint64 line, int start, int length, const QColor& fgcolor, const QColor& bgcolor, const QString& comment);
58  void color(quint64 line, int start, int length, const QColor& fgcolor, const QColor& bgcolor);
59  void foreground(quint64 line, int start, int length, const QColor& fgcolor);
60  void background(quint64 line, int start, int length, const QColor& bgcolor);
61  void comment(quint64 line, int start, int length, const QString &comment);
62 
63  private:
64  void setMetadata(const QHexMetadataItem& mi);
65  void setAbsoluteMetadata(const QHexMetadataAbsoluteItem& mi);
66 
67  signals:
68  void metadataChanged(quint64 line);
69  void metadataCleared();
70 
71  private:
72  quint8 m_lineWidth;
73  QHash<quint64, QHexLineMetadata> m_metadata;
74  QVector<QHexMetadataAbsoluteItem> m_absoluteMetadata;
75 };
76 
77 #endif // QHEXMETADATA_H
QHexMetadata::setLineWidth
void setLineWidth(quint8 width)
Definition: qhexmetadata.cpp:94
QHexMetadataAbsoluteItem
Definition: qhexmetadata.h:15
QHexMetadata::hasMetadata
bool hasMetadata(quint64 line) const
Definition: qhexmetadata.cpp:36
QHexMetadata::metadata
void metadata(qint64 begin, qint64 end, const QColor &fgcolor, const QColor &bgcolor, const QString &comment)
Definition: qhexmetadata.cpp:56
QHexMetadataItem::comment
QString comment
Definition: qhexmetadata.h:28
QHexMetadataItem
Definition: qhexmetadata.h:23
QHexMetadata::metadataCleared
void metadataCleared()
QHexMetadataAbsoluteItem::end
qint64 end
Definition: qhexmetadata.h:18
QHexMetadataAbsoluteItem::foreground
QColor foreground
Definition: qhexmetadata.h:19
QHexMetadataItem::background
QColor background
Definition: qhexmetadata.h:27
QHexMetadata::get
const QHexLineMetadata & get(quint64 line) const
Definition: qhexmetadata.cpp:5
QHexMetadata::comment
void comment(quint64 line, int start, int length, const QString &comment)
Definition: qhexmetadata.cpp:132
QHexMetadataAbsoluteItem::comment
QString comment
Definition: qhexmetadata.h:20
QHexMetadataAbsoluteItem::background
QColor background
Definition: qhexmetadata.h:19
QHexMetadataItem::start
int start
Definition: qhexmetadata.h:26
qhexmetadata.h
QHexMetadataAbsoluteItem::begin
qint64 begin
Definition: qhexmetadata.h:17
QHexMetadata::metadataChanged
void metadataChanged(quint64 line)
QHexMetadata::color
void color(quint64 line, int start, int length, const QColor &fgcolor, const QColor &bgcolor)
Definition: qhexmetadata.cpp:117
QHexMetadata::clear
void clear()
Definition: qhexmetadata.cpp:49
QHexMetadata::background
void background(quint64 line, int start, int length, const QColor &bgcolor)
Definition: qhexmetadata.cpp:127
QHexMetadataItem::line
quint64 line
Definition: qhexmetadata.h:25
QHexLineMetadata
std::list< QHexMetadataItem > QHexLineMetadata
Definition: qhexmetadata.h:34
QHexMetadata::foreground
void foreground(quint64 line, int start, int length, const QColor &fgcolor)
Definition: qhexmetadata.cpp:122
QHexMetadataItem::length
int length
Definition: qhexmetadata.h:26
QHexMetadataItem::foreground
QColor foreground
Definition: qhexmetadata.h:27
QHexMetadata::QHexMetadata
QHexMetadata(QObject *parent=nullptr)
Definition: qhexmetadata.cpp:3
QHexMetadata
Definition: qhexmetadata.h:37
QHexMetadata::comments
QString comments(quint64 line, int column) const
Definition: qhexmetadata.cpp:11