-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9aebcb
commit 63ba753
Showing
19 changed files
with
430 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "datahighlighter.h" | ||
|
||
#include <QSyntaxHighlighter> | ||
#include <QFont> | ||
#include <QStringList> | ||
#include <QString> | ||
|
||
#define BOUNDARY(s) ("\\b" s "\\b") | ||
|
||
DataHighlighter::DataHighlighter(QTextDocument *parent) : | ||
QSyntaxHighlighter (parent) | ||
{ | ||
|
||
QTextCharFormat string_format, ident_format, integer_format; | ||
|
||
string_format.setForeground(Qt::darkBlue); | ||
|
||
highlighting_rules.append({ | ||
QRegExp("\".*\";"), | ||
string_format | ||
}); | ||
|
||
ident_format.setForeground(Qt::blue); | ||
ident_format.setFontItalic(true); | ||
|
||
highlighting_rules.append({ | ||
QRegExp(".+(?=:)"), | ||
ident_format | ||
}); | ||
|
||
integer_format.setForeground(Qt::black); | ||
integer_format.setFontWeight(QFont::Bold); | ||
highlighting_rules.append({ | ||
QRegExp("\\d+"), | ||
integer_format | ||
}); | ||
|
||
} | ||
|
||
void DataHighlighter::highlightBlock(const QString &text) | ||
{ | ||
foreach (const HighlightingRule &rule, highlighting_rules) { | ||
QRegExp expression(rule.pattern); | ||
int index = expression.indexIn(text); | ||
while (index >= 0) { | ||
int length = expression.matchedLength(); | ||
setFormat(index, length, rule.format); | ||
index = expression.indexIn(text, index + length); | ||
} | ||
} | ||
|
||
setCurrentBlockState(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef DATAHIGHLIGHTER_H | ||
#define DATAHIGHLIGHTER_H | ||
|
||
#include <QSyntaxHighlighter> | ||
#include <QVector> | ||
#include <QRegExp> | ||
#include <QTextCharFormat> | ||
#include <QString> | ||
#include <QTextDocument> | ||
|
||
|
||
class DataHighlighter : public QSyntaxHighlighter | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
DataHighlighter(QTextDocument *parent=0); | ||
|
||
protected: | ||
void highlightBlock(const QString &text) Q_DECL_OVERRIDE; | ||
|
||
private: | ||
struct HighlightingRule | ||
{ | ||
QRegExp pattern; | ||
QTextCharFormat format; | ||
}; | ||
|
||
QVector<HighlightingRule> highlighting_rules; | ||
}; | ||
|
||
#endif // DATAHIGHLIGHTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "datavisualizer.h" | ||
#include "ui_datavisualizer.h" | ||
|
||
DataVisualizer::DataVisualizer(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::DataVisualizer) | ||
{ | ||
ui->setupUi(this); | ||
ui->status_panel->setPlainText("test"); | ||
highlighter = new DataHighlighter(ui->text_display->document()); | ||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(close())); | ||
} | ||
|
||
DataVisualizer::~DataVisualizer() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void DataVisualizer::visualize(Struct *s) | ||
{ | ||
if (current_data != nullptr) | ||
delete current_data; | ||
current_data = s; | ||
ui->text_display->setText(s->to_string()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef DATAVISUALIZER_H | ||
#define DATAVISUALIZER_H | ||
|
||
#include <QDialog> | ||
#include "structtypes.h" | ||
#include "datahighlighter.h" | ||
|
||
namespace Ui { | ||
class DataVisualizer; | ||
} | ||
|
||
class DataVisualizer : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DataVisualizer(QWidget *parent = 0); | ||
~DataVisualizer(); | ||
void visualize(Struct *s); | ||
|
||
private: | ||
Ui::DataVisualizer *ui; | ||
Struct *current_data = nullptr; | ||
DataHighlighter *highlighter; | ||
}; | ||
|
||
#endif // DATAVISUALIZER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>DataVisualizer</class> | ||
<widget class="QDialog" name="DataVisualizer"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>584</width> | ||
<height>372</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>BinGrok :: Data Visualizer</string> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QTextEdit" name="text_display"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>3</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QWidget" name="right_panel" native="true"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
<horstretch>1</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item alignment="Qt::AlignRight"> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPlainTextEdit" name="status_panel"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>1</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>0</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="focusPolicy"> | ||
<enum>Qt::NoFocus</enum> | ||
</property> | ||
<property name="contextMenuPolicy"> | ||
<enum>Qt::NoContextMenu</enum> | ||
</property> | ||
<property name="acceptDrops"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="autoFillBackground"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="textInteractionFlags"> | ||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.