Page MenuHomePhabricator

No OneTemporary

Size
11 KB
Referenced Files
None
Subscribers
None
diff --git a/trunk/hexeditwidget.cpp b/trunk/hexeditwidget.cpp
index bcedcaf..d5c7603 100644
--- a/trunk/hexeditwidget.cpp
+++ b/trunk/hexeditwidget.cpp
@@ -1,125 +1,143 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include <QFont>
#include <QSizePolicy>
#include "hexeditwidget.h"
-HexEditWidget::HexEditWidget(QWidget *p_parent) : QWidget(p_parent) {
+HexEditWidget::HexEditWidget(QWidget *p_parent,
+ bool with_data_interpreter,
+ bool is_read_only) : QWidget(p_parent)
+{
// Init private vars
+ this->has_data_interpreter=with_data_interpreter;
+ this->read_only=is_read_only;
this->data=QByteArray();
- this->read_only=true;
// Set widget layout. Setting it's parent to "this" will also call
// this->SetLayout.
this->p_widget_layout=new QVBoxLayout(this);
// Create sub-widgets
- this->p_widget_splitter=new QSplitter(this);
- this->p_hex_edit_layout_widget=new QWidget(this->p_widget_splitter);
- this->p_hex_edit_layout=new QVBoxLayout(this->p_hex_edit_layout_widget);
- this->p_hex_edit=new QHexEdit(this->p_hex_edit_layout_widget);
- this->p_hex_edit_status_bar=new QLabel();
- this->p_data_interpreter_widget=
- new DataInterpreterWidget(this);
-
- // Add hex edit and hex edit status bar to their layout
- this->p_hex_edit_layout->addWidget(this->p_hex_edit);
- this->p_hex_edit_layout->addWidget(this->p_hex_edit_status_bar);
-
- // Add sub-widgets to splitter and splitter to our layout
- this->p_widget_splitter->addWidget(this->p_hex_edit_layout_widget);
- this->p_widget_splitter->addWidget(this->p_data_interpreter_widget);
- this->p_widget_layout->addWidget(this->p_widget_splitter);
+ if(this->has_data_interpreter) {
+ // Widget should include a data interpreter
+ this->p_widget_splitter=new QSplitter(this);
+ this->p_hex_edit_layout_widget=new QWidget(this->p_widget_splitter);
+ this->p_hex_edit_layout=new QVBoxLayout(this->p_hex_edit_layout_widget);
+ this->p_hex_edit=new QHexEdit(this->p_hex_edit_layout_widget);
+ this->p_hex_edit_status_bar=new QLabel(this);
+ this->p_data_interpreter_widget=new DataInterpreterWidget(this);
+
+ // Add hex edit and hex edit status bar to their layout
+ this->p_hex_edit_layout->addWidget(this->p_hex_edit);
+ this->p_hex_edit_layout->addWidget(this->p_hex_edit_status_bar);
+
+ // Add sub-widgets to splitter and splitter to our layout
+ this->p_widget_splitter->addWidget(this->p_hex_edit_layout_widget);
+ this->p_widget_splitter->addWidget(this->p_data_interpreter_widget);
+ this->p_widget_layout->addWidget(this->p_widget_splitter);
+
+ // Configure sub-widgets
+ this->p_widget_splitter->setOrientation(Qt::Horizontal);
+ this->p_hex_edit_layout_widget->setContentsMargins(0,0,0,0);
+ this->p_hex_edit_layout->setContentsMargins(0,0,0,0);
+
+ // Set size policies of sub-widgets
+ QSizePolicy hex_edit_layout_widget_policy=
+ this->p_hex_edit_layout_widget->sizePolicy();
+ hex_edit_layout_widget_policy.setVerticalStretch(2);
+ hex_edit_layout_widget_policy.setHorizontalStretch(200);
+ this->p_hex_edit_layout_widget->setSizePolicy(hex_edit_layout_widget_policy);
+
+ QSizePolicy data_interpreter_widget_policy=
+ this->p_data_interpreter_widget->sizePolicy();
+ data_interpreter_widget_policy.setVerticalStretch(2);
+ data_interpreter_widget_policy.setHorizontalStretch(0);
+ this->p_data_interpreter_widget->
+ setSizePolicy(data_interpreter_widget_policy);
+ } else {
+ // Widget shouldn't include a data interpreter
+ this->p_hex_edit=new QHexEdit(this);
+ this->p_hex_edit_status_bar=new QLabel(this);
+ this->p_widget_layout->addWidget(this->p_hex_edit);
+ this->p_widget_layout->addWidget(this->p_hex_edit_status_bar);
+ }
// Configure widget and sub-widgets
this->setContentsMargins(0,0,0,0);
this->p_widget_layout->setContentsMargins(0,0,0,0);
- this->p_widget_splitter->setOrientation(Qt::Horizontal);
- this->p_hex_edit_layout_widget->setContentsMargins(0,0,0,0);
- this->p_hex_edit_layout->setContentsMargins(0,0,0,0);
this->p_hex_edit->setContentsMargins(0,0,0,0);
// 5 pixel bottom margin makes hex edit and data interpreter lignup correctly
this->p_hex_edit_status_bar->setContentsMargins(0,0,0,5);
this->p_hex_edit->setReadOnly(this->read_only);
- this->setEnabled(false);
+ //this->setEnabled(false);
// Make sure hex edit font is monospaced.
QFont mono_font("Monospace");
mono_font.setStyleHint(QFont::TypeWriter);
this->p_hex_edit->setFont(mono_font);
- // Set size policies of sub-widgets
- QSizePolicy hex_edit_layout_widget_policy=
- this->p_hex_edit_layout_widget->sizePolicy();
- hex_edit_layout_widget_policy.setVerticalStretch(2);
- hex_edit_layout_widget_policy.setHorizontalStretch(200);
- this->p_hex_edit_layout_widget->setSizePolicy(hex_edit_layout_widget_policy);
-
- QSizePolicy data_interpreter_widget_policy=
- this->p_data_interpreter_widget->sizePolicy();
- data_interpreter_widget_policy.setVerticalStretch(2);
- data_interpreter_widget_policy.setHorizontalStretch(0);
- this->p_data_interpreter_widget->
- setSizePolicy(data_interpreter_widget_policy);
-
// Connect signals
this->connect(this->p_hex_edit,
SIGNAL(currentAddressChanged(int)),
this,
SLOT(SlotHexEditOffsetChanged(int)));
}
HexEditWidget::~HexEditWidget() {
- delete this->p_data_interpreter_widget;
delete this->p_hex_edit_status_bar;
delete this->p_hex_edit;
- delete this->p_hex_edit_layout;
- delete this->p_hex_edit_layout_widget;
- delete this->p_widget_splitter;
+ if(this->has_data_interpreter) {
+ delete this->p_data_interpreter_widget;
+ delete this->p_hex_edit_layout;
+ delete this->p_hex_edit_layout_widget;
+ delete this->p_widget_splitter;
+ }
delete this->p_widget_layout;
}
void HexEditWidget::SetData(QByteArray const &new_data) {
this->data=new_data;
this->p_hex_edit->setData(this->data);
if(data.size()!=0) {
// Data set, update status bar and init data interpreter
this->SlotHexEditOffsetChanged(0);
} else {
// No data set, clear status bar and data interpreter
this->p_hex_edit_status_bar->setText("");
this->p_data_interpreter_widget->SetData(QByteArray());
}
}
void HexEditWidget::SlotHexEditOffsetChanged(int offset) {
// Update hex edit status bar
this->p_hex_edit_status_bar->setText(tr("Byte offset: 0x%1 (%2)")
.arg((quint16)offset,
4,
16,
QChar('0'))
.arg(offset));
// Update data interpreter
- this->p_data_interpreter_widget->SetData(this->data.mid(offset,8));
+ if(this->has_data_interpreter) {
+ this->p_data_interpreter_widget->SetData(this->data.mid(offset,8));
+ }
}
diff --git a/trunk/hexeditwidget.h b/trunk/hexeditwidget.h
index db8d58d..8c83ba6 100644
--- a/trunk/hexeditwidget.h
+++ b/trunk/hexeditwidget.h
@@ -1,64 +1,67 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#ifndef HEXEDITWIDGET_H
#define HEXEDITWIDGET_H
#include <QWidget>
#include <QSplitter>
#include <QVBoxLayout>
#include <QLabel>
#include <QByteArray>
#include "qhexedit/qhexedit.h"
#include "datainterpreterwidget.h"
class HexEditWidget : public QWidget {
Q_OBJECT
public:
- explicit HexEditWidget(QWidget *p_parent=0);
+ explicit HexEditWidget(QWidget *p_parent=0,
+ bool with_data_interpreter=true,
+ bool is_read_only=true);
~HexEditWidget();
void SetData(QByteArray const &data);
signals:
public slots:
private:
// Widget layout
QVBoxLayout *p_widget_layout;
QSplitter *p_widget_splitter;
// Sub-widgets
QWidget *p_hex_edit_layout_widget;
QVBoxLayout *p_hex_edit_layout;
QHexEdit *p_hex_edit;
QLabel *p_hex_edit_status_bar;
DataInterpreterWidget *p_data_interpreter_widget;
// Vars
- QByteArray data;
+ bool has_data_interpreter;
bool read_only;
+ QByteArray data;
private slots:
void SlotHexEditOffsetChanged(int offset);
};
#endif // HEXEDITWIDGET_H

File Metadata

Mime Type
text/x-diff
Expires
Wed, Dec 25, 4:07 AM (44 m, 43 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1176939
Default Alt Text
(11 KB)

Event Timeline