mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Use single QTreeView in FunctionsWidget
This commit is contained in:
parent
9bd57776f6
commit
8cf623c1ab
@ -220,6 +220,14 @@ void FunctionModel::endReloadFunctions()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FunctionModel::setNested(bool nested)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
this->nested = nested;
|
||||||
|
updateCurrentIndex();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
void FunctionModel::seekChanged(RVA)
|
void FunctionModel::seekChanged(RVA)
|
||||||
{
|
{
|
||||||
if (updateCurrentIndex())
|
if (updateCurrentIndex())
|
||||||
@ -361,33 +369,16 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
|
|||||||
ui->functionsTreeView->setModel(function_proxy_model);
|
ui->functionsTreeView->setModel(function_proxy_model);
|
||||||
ui->functionsTreeView->sortByColumn(FunctionModel::NameColumn, Qt::AscendingOrder);
|
ui->functionsTreeView->sortByColumn(FunctionModel::NameColumn, Qt::AscendingOrder);
|
||||||
|
|
||||||
nested_function_model = new FunctionModel(&functions, &import_addresses, true, default_font, highlight_font, this);
|
|
||||||
nested_function_proxy_model = new FunctionSortFilterProxyModel(nested_function_model, this);
|
|
||||||
ui->nestedFunctionsTreeView->setModel(nested_function_proxy_model);
|
|
||||||
ui->nestedFunctionsTreeView->sortByColumn(0, Qt::AscendingOrder);
|
|
||||||
|
|
||||||
connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), function_proxy_model, SLOT(setFilterWildcard(const QString &)));
|
connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), function_proxy_model, SLOT(setFilterWildcard(const QString &)));
|
||||||
connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), nested_function_proxy_model, SLOT(setFilterWildcard(const QString &)));
|
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->functionsTreeView, SLOT(setFocus()));
|
||||||
connect(ui->quickFilterView, &QuickFilterView::filterClosed, this, [this]()
|
|
||||||
{
|
|
||||||
getCurrentTreeView()->setFocus();
|
|
||||||
});
|
|
||||||
|
|
||||||
setScrollMode();
|
setScrollMode();
|
||||||
|
|
||||||
// Set Functions context menu
|
// Set Functions context menu
|
||||||
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->nestedFunctionsTreeView, SIGNAL(customContextMenuRequested(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(functionsTreeView_doubleClicked(const QModelIndex &)));
|
||||||
connect(ui->nestedFunctionsTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(functionsTreeView_doubleClicked(const QModelIndex &)));
|
|
||||||
|
|
||||||
// Hide the tabs
|
|
||||||
QTabBar *tabs = ui->tabWidget->tabBar();
|
|
||||||
tabs->setVisible(false);
|
|
||||||
|
|
||||||
// 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();
|
||||||
@ -405,7 +396,6 @@ FunctionsWidget::~FunctionsWidget() {}
|
|||||||
void FunctionsWidget::refreshTree()
|
void FunctionsWidget::refreshTree()
|
||||||
{
|
{
|
||||||
function_model->beginReloadFunctions();
|
function_model->beginReloadFunctions();
|
||||||
nested_function_model->beginReloadFunctions();
|
|
||||||
|
|
||||||
functions = CutterCore::getInstance()->getAllFunctions();
|
functions = CutterCore::getInstance()->getAllFunctions();
|
||||||
|
|
||||||
@ -414,7 +404,6 @@ void FunctionsWidget::refreshTree()
|
|||||||
import_addresses.insert(import.plt);
|
import_addresses.insert(import.plt);
|
||||||
|
|
||||||
function_model->endReloadFunctions();
|
function_model->endReloadFunctions();
|
||||||
nested_function_model->endReloadFunctions();
|
|
||||||
|
|
||||||
// resize offset and size columns
|
// resize offset and size columns
|
||||||
ui->functionsTreeView->resizeColumnToContents(0);
|
ui->functionsTreeView->resizeColumnToContents(0);
|
||||||
@ -422,14 +411,6 @@ void FunctionsWidget::refreshTree()
|
|||||||
ui->functionsTreeView->resizeColumnToContents(2);
|
ui->functionsTreeView->resizeColumnToContents(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeView *FunctionsWidget::getCurrentTreeView()
|
|
||||||
{
|
|
||||||
if (ui->tabWidget->currentIndex() == 0)
|
|
||||||
return ui->functionsTreeView;
|
|
||||||
else
|
|
||||||
return ui->nestedFunctionsTreeView;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FunctionsWidget::functionsTreeView_doubleClicked(const QModelIndex &index)
|
void FunctionsWidget::functionsTreeView_doubleClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
FunctionDescription function = index.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
FunctionDescription function = index.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
@ -438,8 +419,6 @@ void FunctionsWidget::functionsTreeView_doubleClicked(const QModelIndex &index)
|
|||||||
|
|
||||||
void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
||||||
{
|
{
|
||||||
QTreeView *treeView = getCurrentTreeView();
|
|
||||||
|
|
||||||
// Set functions popup menu
|
// Set functions popup menu
|
||||||
QMenu *menu = new QMenu(ui->functionsTreeView);
|
QMenu *menu = new QMenu(ui->functionsTreeView);
|
||||||
menu->clear();
|
menu->clear();
|
||||||
@ -449,7 +428,7 @@ void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(ui->action_References);
|
menu->addAction(ui->action_References);
|
||||||
|
|
||||||
menu->exec(treeView->mapToGlobal(pt));
|
menu->exec(ui->functionsTreeView->mapToGlobal(pt));
|
||||||
|
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
@ -457,8 +436,7 @@ void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
|||||||
void FunctionsWidget::on_actionDisasAdd_comment_triggered()
|
void FunctionsWidget::on_actionDisasAdd_comment_triggered()
|
||||||
{
|
{
|
||||||
// Get selected item in functions tree view
|
// Get selected item in functions tree view
|
||||||
QTreeView *treeView = getCurrentTreeView();
|
FunctionDescription function = ui->functionsTreeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
FunctionDescription function = treeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
|
||||||
|
|
||||||
// Create dialog
|
// Create dialog
|
||||||
CommentsDialog *c = new CommentsDialog(this);
|
CommentsDialog *c = new CommentsDialog(this);
|
||||||
@ -478,8 +456,7 @@ void FunctionsWidget::on_actionDisasAdd_comment_triggered()
|
|||||||
void FunctionsWidget::on_actionFunctionsRename_triggered()
|
void FunctionsWidget::on_actionFunctionsRename_triggered()
|
||||||
{
|
{
|
||||||
// Get selected item in functions tree view
|
// Get selected item in functions tree view
|
||||||
QTreeView *treeView = getCurrentTreeView();
|
FunctionDescription function = ui->functionsTreeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
FunctionDescription function = treeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
|
||||||
|
|
||||||
// Create dialog
|
// Create dialog
|
||||||
RenameDialog *r = new RenameDialog(this);
|
RenameDialog *r = new RenameDialog(this);
|
||||||
@ -509,16 +486,14 @@ void FunctionsWidget::on_actionFunctionsRename_triggered()
|
|||||||
|
|
||||||
void FunctionsWidget::on_actionFunctionsUndefine_triggered()
|
void FunctionsWidget::on_actionFunctionsUndefine_triggered()
|
||||||
{
|
{
|
||||||
QTreeView *treeView = getCurrentTreeView();
|
FunctionDescription function = ui->functionsTreeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
FunctionDescription function = treeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
|
||||||
Core()->delFunction(function.offset);
|
Core()->delFunction(function.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionsWidget::on_action_References_triggered()
|
void FunctionsWidget::on_action_References_triggered()
|
||||||
{
|
{
|
||||||
// Get selected item in functions tree view
|
// Get selected item in functions tree view
|
||||||
QTreeView *treeView = getCurrentTreeView();
|
FunctionDescription function = ui->functionsTreeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
FunctionDescription function = treeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
|
||||||
XrefsDialog *x = new XrefsDialog(this);
|
XrefsDialog *x = new XrefsDialog(this);
|
||||||
x->fillRefsForAddress(function.offset, function.name, true);
|
x->fillRefsForAddress(function.offset, function.name, true);
|
||||||
x->exec();
|
x->exec();
|
||||||
@ -532,7 +507,7 @@ void FunctionsWidget::showTitleContextMenu(const QPoint &pt)
|
|||||||
menu->addAction(ui->actionHorizontal);
|
menu->addAction(ui->actionHorizontal);
|
||||||
menu->addAction(ui->actionVertical);
|
menu->addAction(ui->actionVertical);
|
||||||
|
|
||||||
if (ui->tabWidget->currentIndex() == 0)
|
if (!function_model->isNested())
|
||||||
{
|
{
|
||||||
ui->actionHorizontal->setChecked(true);
|
ui->actionHorizontal->setChecked(true);
|
||||||
ui->actionVertical->setChecked(false);
|
ui->actionVertical->setChecked(false);
|
||||||
@ -551,12 +526,14 @@ void FunctionsWidget::showTitleContextMenu(const QPoint &pt)
|
|||||||
|
|
||||||
void FunctionsWidget::on_actionHorizontal_triggered()
|
void FunctionsWidget::on_actionHorizontal_triggered()
|
||||||
{
|
{
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
function_model->setNested(false);
|
||||||
|
ui->functionsTreeView->setIndentation(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionsWidget::on_actionVertical_triggered()
|
void FunctionsWidget::on_actionVertical_triggered()
|
||||||
{
|
{
|
||||||
ui->tabWidget->setCurrentIndex(1);
|
function_model->setNested(true);
|
||||||
|
ui->functionsTreeView->setIndentation(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionsWidget::resizeEvent(QResizeEvent *event)
|
void FunctionsWidget::resizeEvent(QResizeEvent *event)
|
||||||
|
@ -60,6 +60,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool updateCurrentIndex();
|
bool updateCurrentIndex();
|
||||||
|
|
||||||
|
void setNested(bool nested);
|
||||||
bool isNested() { return nested; }
|
bool isNested() { return nested; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -110,8 +111,6 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTreeView *getCurrentTreeView();
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::FunctionsWidget> ui;
|
std::unique_ptr<Ui::FunctionsWidget> ui;
|
||||||
MainWindow *main;
|
MainWindow *main;
|
||||||
|
|
||||||
@ -121,9 +120,6 @@ private:
|
|||||||
FunctionModel *function_model;
|
FunctionModel *function_model;
|
||||||
FunctionSortFilterProxyModel *function_proxy_model;
|
FunctionSortFilterProxyModel *function_proxy_model;
|
||||||
|
|
||||||
FunctionModel *nested_function_model;
|
|
||||||
FunctionSortFilterProxyModel *nested_function_proxy_model;
|
|
||||||
|
|
||||||
void setScrollMode();
|
void setScrollMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,51 +30,6 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QTabWidget::pane { /* The tab widget frame */
|
|
||||||
border-top: 0px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="tabPosition">
|
|
||||||
<enum>QTabWidget::West</enum>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="tab">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<attribute name="title">
|
|
||||||
<string>List</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -133,69 +88,6 @@ QToolTip
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tab_2">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Tree</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="nestedFunctionsTreeView">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">
|
|
||||||
QToolTip {
|
|
||||||
background-color: #444;
|
|
||||||
border: 3px solid #444;
|
|
||||||
color: rgb(232, 232, 232);
|
|
||||||
font: 11pt "Monaco";
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sortingEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="expandsOnDoubleClick">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QuickFilterView" name="quickFilterView" native="true"/>
|
<widget class="QuickFilterView" name="quickFilterView" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user