Added double click handling on SectionsWidget

fix #303
This commit is contained in:
xarkes 2018-02-02 16:56:39 +01:00
parent 085b858bb6
commit ba3f655a9f
5 changed files with 20 additions and 5 deletions

View File

@ -363,7 +363,11 @@ void CutterCore::seek(ut64 offset)
void CutterCore::seek(QString offset) void CutterCore::seek(QString offset)
{ {
seek(offset.toULongLong()); bool converted;
auto s = offset.toULongLong(&converted, 16);
if (!converted)
s = offset.toULongLong();
seek(s);
} }
void CutterCore::seekPrev() void CutterCore::seekPrev()

View File

@ -378,7 +378,7 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
connect(ui->functionsTreeView, SIGNAL(customContextMenuRequested(const QPoint &)), connect(ui->functionsTreeView, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showFunctionsContextMenu(const QPoint &))); this, SLOT(showFunctionsContextMenu(const QPoint &)));
connect(ui->functionsTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(functionsTreeView_doubleClicked(const QModelIndex &))); connect(ui->functionsTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(onFunctionsDoubleClicked(const QModelIndex &)));
// Use a custom context menu on the dock title bar // Use a custom context menu on the dock title bar
//this->title_bar = this->titleBarWidget(); //this->title_bar = this->titleBarWidget();
@ -411,10 +411,10 @@ void FunctionsWidget::refreshTree()
ui->functionsTreeView->resizeColumnToContents(2); ui->functionsTreeView->resizeColumnToContents(2);
} }
void FunctionsWidget::functionsTreeView_doubleClicked(const QModelIndex &index) void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index)
{ {
FunctionDescription function = index.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>(); FunctionDescription function = index.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
CutterCore::getInstance()->seek(function.offset); Core()->seek(function.offset);
} }
void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt) void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)

View File

@ -92,7 +92,7 @@ public:
~FunctionsWidget(); ~FunctionsWidget();
private slots: private slots:
void functionsTreeView_doubleClicked(const QModelIndex &index); void onFunctionsDoubleClicked(const QModelIndex &index);
void showFunctionsContextMenu(const QPoint &pt); void showFunctionsContextMenu(const QPoint &pt);
void on_actionDisasAdd_comment_triggered(); void on_actionDisasAdd_comment_triggered();

View File

@ -16,6 +16,8 @@ SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
setupViews(); setupViews();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
connect(this->tree, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(onSectionsDoubleClicked(const QModelIndex &)));
tree->sortByColumn(0, Qt::AscendingOrder); tree->sortByColumn(0, Qt::AscendingOrder);
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshSections())); connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshSections()));
@ -92,3 +94,10 @@ void SectionsWidget::fillSections(int row, const SectionDescription &section)
tempItem->setData(0, Qt::DecorationRole, colors[row % colors.size()]); tempItem->setData(0, Qt::DecorationRole, colors[row % colors.size()]);
this->tree->insertTopLevelItem(0, tempItem); this->tree->insertTopLevelItem(0, tempItem);
} }
void SectionsWidget::onSectionsDoubleClicked(const QModelIndex &index)
{
QTreeWidgetItem* section = tree->topLevelItem(index.row());
auto addr = section->text(2);
Core()->seek(addr);
}

View File

@ -26,6 +26,8 @@ public:
private slots: private slots:
void refreshSections(); void refreshSections();
void onSectionsDoubleClicked(const QModelIndex &index);
private: private:
QAbstractItemView *pieChart; QAbstractItemView *pieChart;
QItemSelectionModel *selectionModel; QItemSelectionModel *selectionModel;