Check QModelIndex/column before processing double click event (#450)

This commit is contained in:
Paul I 2018-04-23 10:54:06 +03:00 committed by xarkes
parent 09bfc9f3d0
commit 0ae021f9a1
17 changed files with 61 additions and 7 deletions

View File

@ -267,6 +267,9 @@ void ClassesWidget::refreshClasses()
void ClassesWidget::on_classesTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
RVA offset = index.data(ClassesModel::OffsetRole).value<RVA>();
Core()->seek(offset);
}

View File

@ -35,15 +35,21 @@ CommentsWidget::CommentsWidget(MainWindow *main, QAction *action) :
CommentsWidget::~CommentsWidget() {}
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int)
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
if (column < 0)
return;
// Get offset and name of item double clicked
CommentDescription comment = item->data(0, Qt::UserRole).value<CommentDescription>();
Core()->seek(comment.offset);
}
void CommentsWidget::on_nestedCmtsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int)
void CommentsWidget::on_nestedCmtsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
if (column < 0)
return;
// don't react on top-level items
if (item->parent() == nullptr) {
return;

View File

@ -45,8 +45,11 @@ void EntrypointWidget::setScrollMode()
}
void EntrypointWidget::on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
int /* column */)
int column)
{
if (column < 0)
return;
EntrypointDescription ep = item->data(0, Qt::UserRole).value<EntrypointDescription>();
Core()->seek(ep.vaddr);
}

View File

@ -174,6 +174,9 @@ void ExportsWidget::setScrollMode()
void ExportsWidget::on_exportsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
ExportDescription exp = index.data(ExportsModel::ExportDescriptionRole).value<ExportDescription>();
Core()->seek(exp.vaddr);
}

View File

@ -149,6 +149,9 @@ FlagsWidget::~FlagsWidget() {}
void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();
Core()->seek(flag.offset);
}

View File

@ -451,6 +451,9 @@ void FunctionsWidget::refreshTree()
void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
FunctionDescription function = index.data(
FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
Core()->seek(function.offset);

View File

@ -190,5 +190,8 @@ void ImportsWidget::setScrollMode()
void ImportsWidget::on_importsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
Core()->seek(index.data(ImportsModel::AddressRole).toLongLong());
}

View File

@ -88,6 +88,9 @@ RelocsWidget::~RelocsWidget() {}
void RelocsWidget::on_relocsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
Core()->seek(index.data(RelocsModel::AddressRole).toLongLong());
}

View File

@ -113,6 +113,9 @@ void ResourcesWidget::refreshResources()
void ResourcesWidget::onDoubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
ResourcesDescription res = index.data(Qt::UserRole).value<ResourcesDescription>();
Core()->seek(res.vaddr);
}

View File

@ -57,6 +57,9 @@ void SdbDock::reload(QString _path)
void SdbDock::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
if (column < 0)
return;
QString newpath;
if (column == 0) {

View File

@ -154,6 +154,9 @@ SearchWidget::~SearchWidget() {}
void SearchWidget::on_searchTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
SearchDescription search = index.data(
SearchModel::SearchDescriptionRole).value<SearchDescription>();
Core()->seek(search.offset);

View File

@ -95,6 +95,9 @@ void SectionsWidget::fillSections(int row, const SectionDescription &section)
void SectionsWidget::onSectionsDoubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
QTreeWidgetItem *section = tree->topLevelItem(index.row());
auto addr = section->text(2);
Core()->seek(addr);

View File

@ -56,14 +56,20 @@ void SidebarWidget::refresh(RVA addr)
fillRegistersInfo();
}
void SidebarWidget::on_xrefFromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
void SidebarWidget::on_xrefFromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
if (column < 0)
return;
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
Core()->seek(xref.to);
}
void SidebarWidget::on_xrefToTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
void SidebarWidget::on_xrefToTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
if (column < 0)
return;
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
Core()->seek(xref.from);
}

View File

@ -164,6 +164,9 @@ StringsWidget::~StringsWidget() {}
void StringsWidget::on_stringsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
StringDescription str = index.data(StringsModel::StringDescriptionRole).value<StringDescription>();
Core()->seek(str.vaddr);
}

View File

@ -25,7 +25,8 @@ SymbolsWidget::~SymbolsWidget() {}
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
if (column < 0)
return;
// Get offset and name of item double clicked
SymbolDescription symbol = item->data(0, Qt::UserRole).value<SymbolDescription>();

View File

@ -142,7 +142,9 @@ void TypesWidget::setScrollMode()
void TypesWidget::on_typesTreeView_doubleClicked(const QModelIndex &index)
{
Q_UNUSED(index);
if (!index.isValid())
return;
// TypeDescription exp = index.data(TypesModel::TypeDescriptionRole).value<TypeDescription>();
// Core()->seek(exp.vaddr);
}

View File

@ -182,6 +182,9 @@ void VTablesWidget::refreshVTables()
void VTablesWidget::on_vTableTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
QModelIndex parent = index.parent();
if (parent.isValid())
Core()->seek(index.data(