This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
Minimap for hexedit #266
Open
adamiwaniuk
wants to merge
8
commits into
master
Choose a base branch
from
wip/adami/hexedit-minimap
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Minimap for hexedit #266
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -44,6 +44,8 @@ | |
namespace veles { | ||
namespace ui { | ||
|
||
const float k_minimap_selection_factor = 10; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consts should be in uppercase There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. convention from this component, see trigram.cc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll refactor this old convention in few days (after fixing Jenkins), so insert new code in Google C++ Style |
||
|
||
/*****************************************************************************/ | ||
/* Public methods */ | ||
/*****************************************************************************/ | ||
|
@@ -54,7 +56,9 @@ NodeWidget::NodeWidget(MainWindowWithDetachableDockWidgets *main_window, | |
: View("Hex editor", ":/images/show_hex_edit.png"), | ||
main_window_(main_window), minimap_(nullptr), | ||
minimap_dock_(nullptr), data_model_(data_model), | ||
selection_model_(selection_model), sampler_(nullptr) { | ||
selection_model_(selection_model), sampler_(nullptr), | ||
update_minimap_start_(0), update_minimap_size_(0), | ||
ignore_update_minimap_(false) { | ||
hex_edit_widget_ = new HexEditWidget( | ||
main_window, data_model, selection_model); | ||
addAction(hex_edit_widget_->uploadAction()); | ||
|
@@ -79,49 +83,80 @@ NodeWidget::NodeWidget(MainWindowWithDetachableDockWidgets *main_window, | |
setDockNestingEnabled(true); | ||
addDockWidget(Qt::LeftDockWidgetArea, node_tree_dock_); | ||
|
||
#if 0 // We do not use minimap for NodeWidget yet, | ||
minimap_dock_ = new QDockWidget; | ||
new DockWidgetVisibilityGuard(minimap_dock_); | ||
minimap_dock_->setWindowTitle("Minimap"); | ||
minimap_ = new visualization::MinimapPanel(this); | ||
|
||
if(data_model_->binData().size() > 0) { | ||
loadBinDataToMinimap(); | ||
} else { | ||
sampler_data_ = QByteArray(""); | ||
sampler_ = new util::UniformSampler(sampler_data_); | ||
sampler_->setSampleSize(4096 * 1024); | ||
minimap_->setSampler(sampler_); | ||
} | ||
|
||
minimap_dock_->setWidget(minimap_); | ||
minimap_dock_->setContextMenuPolicy(Qt::PreventContextMenu); | ||
minimap_dock_->setAllowedAreas( | ||
Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); | ||
addDockWidget(Qt::LeftDockWidgetArea, minimap_dock_); | ||
MainWindowWithDetachableDockWidgets::splitDockWidget2(this, node_tree_dock_, | ||
minimap_dock_, Qt::Horizontal); | ||
#endif | ||
|
||
connect(hex_edit_widget_, &HexEditWidget::showNodeTree, | ||
node_tree_dock_, &QDockWidget::setVisible); | ||
connect(node_tree_dock_, &QDockWidget::visibilityChanged, | ||
hex_edit_widget_, &HexEditWidget::nodeTreeVisibilityChanged); | ||
|
||
#if 0 // We do not use minimap for NodeWidget yet, | ||
connect(hex_edit_widget_, &HexEditWidget::showMinimap, | ||
minimap_dock_, &QDockWidget::setVisible); | ||
connect(data_model_.data(), &FileBlobModel::newBinData, | ||
this, &NodeWidget::loadBinDataToMinimap); | ||
connect(minimap_dock_, &QDockWidget::visibilityChanged, | ||
hex_edit_widget_, &HexEditWidget::minimapVisibilityChanged); | ||
#endif | ||
connect(hex_edit_widget_, &HexEditWidget::showMinimap, this, &NodeWidget::showMinimap); | ||
connect(hex_edit_widget_, &HexEditWidget::updateMinimap, [this](qint64 start, qint64 size) { | ||
if (!ignore_update_minimap_) { | ||
update_minimap_start_ = start; | ||
update_minimap_size_ = size; | ||
update_minimap_timer_.start(400); | ||
} | ||
}); | ||
|
||
update_minimap_timer_.setSingleShot(true); | ||
connect(&update_minimap_timer_, &QTimer::timeout, this, &NodeWidget::updateMinimap); | ||
} | ||
|
||
NodeWidget::~NodeWidget() { | ||
delete sampler_; | ||
} | ||
|
||
void NodeWidget::showMinimap(bool show) { | ||
if (minimap_dock_ == nullptr) { | ||
if (!show) { | ||
return; | ||
} | ||
minimap_dock_ = new QDockWidget; | ||
new DockWidgetVisibilityGuard(minimap_dock_); | ||
minimap_dock_->setWindowTitle("Minimap"); | ||
minimap_ = new visualization::MinimapPanel(/*size_control=*/false, this); | ||
|
||
if (data_model_->binData().size() > 0) { | ||
loadBinDataToMinimap(); | ||
} else { | ||
sampler_data_ = QByteArray(""); | ||
sampler_ = new util::UniformSampler(sampler_data_); | ||
sampler_->setSampleSize(4096 * 1024); | ||
minimap_->setSampler(sampler_); | ||
} | ||
|
||
minimap_dock_->setWidget(minimap_); | ||
minimap_dock_->setContextMenuPolicy(Qt::PreventContextMenu); | ||
minimap_dock_->setAllowedAreas( | ||
Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); | ||
addDockWidget(Qt::LeftDockWidgetArea, minimap_dock_); | ||
MainWindowWithDetachableDockWidgets::splitDockWidget2(this, node_tree_dock_, | ||
minimap_dock_, Qt::Horizontal); | ||
|
||
connect(data_model_.data(), &FileBlobModel::newBinData, | ||
this, &NodeWidget::loadBinDataToMinimap); | ||
connect(minimap_dock_, &QDockWidget::visibilityChanged, | ||
hex_edit_widget_, &HexEditWidget::minimapVisibilityChanged); | ||
connect(minimap_, &visualization::MinimapPanel::selectionChanged, [this](size_t start, size_t end) { | ||
if (!ignore_update_minimap_) { | ||
ignore_update_minimap_ = true; | ||
hex_edit_widget_->minimapSelectionChanged(start, end); | ||
ignore_update_minimap_ = false; | ||
} | ||
}); | ||
} | ||
minimap_dock_->setVisible(show); | ||
|
||
} | ||
|
||
void NodeWidget::updateMinimap() { | ||
if (minimap_dock_ == nullptr || sampler_->empty()) { | ||
return; | ||
} | ||
ignore_update_minimap_ = true; | ||
minimap_->adjustMinimaps(update_minimap_size_, k_minimap_selection_factor, update_minimap_start_); | ||
ignore_update_minimap_ = false; | ||
} | ||
|
||
void NodeWidget::loadBinDataToMinimap() { | ||
delete sampler_; | ||
|
||
|
@@ -130,6 +165,7 @@ void NodeWidget::loadBinDataToMinimap() { | |
sampler_ = new util::UniformSampler(sampler_data_); | ||
sampler_->setSampleSize(4096 * 1024); | ||
minimap_->setSampler(sampler_); | ||
updateMinimap(); | ||
} | ||
|
||
} // namespace ui | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent
should be the first argument (same as you did in MinimapPanel ctor)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it is wrong in MinimapPanel , all qt things have it as last argmunet