mirror of
https://github.com/rizinorg/cutter.git
synced 2024-11-23 04:49:49 +00:00
Use the addressable item list functionality for global varible widget.
This commit is contained in:
parent
3e50e5f2ad
commit
8251f7ec68
@ -146,20 +146,6 @@ void GlobalsWidget::deleteGlobal()
|
||||
Core()->delGlobalVariable(globalVariableAddress);
|
||||
}
|
||||
|
||||
void GlobalsWidget::showGlobalsContextMenu(const QPoint &pt)
|
||||
{
|
||||
QModelIndex index = ui->treeView->indexAt(pt);
|
||||
|
||||
QMenu menu(ui->treeView);
|
||||
|
||||
if (index.isValid()) {
|
||||
menu.addAction(actionEditGlobal);
|
||||
menu.addAction(actionDeleteGlobal);
|
||||
}
|
||||
|
||||
menu.exec(ui->treeView->mapToGlobal(pt));
|
||||
}
|
||||
|
||||
GlobalsWidget::GlobalsWidget(MainWindow *main)
|
||||
: CutterDockWidget(main), ui(new Ui::GlobalsWidget), tree(new CutterTreeWidget(this))
|
||||
{
|
||||
@ -175,6 +161,8 @@ GlobalsWidget::GlobalsWidget(MainWindow *main)
|
||||
// Set single select mode
|
||||
ui->treeView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
ui->treeView->setMainWindow(mainWindow);
|
||||
|
||||
// Setup up the model and the proxy model
|
||||
globalsModel = new GlobalsModel(&globals, this);
|
||||
globalsProxyModel = new GlobalsProxyModel(globalsModel, this);
|
||||
@ -182,9 +170,6 @@ GlobalsWidget::GlobalsWidget(MainWindow *main)
|
||||
ui->treeView->sortByColumn(GlobalsModel::AddressColumn, Qt::AscendingOrder);
|
||||
|
||||
// Setup custom context menu
|
||||
connect(ui->treeView, &QWidget::customContextMenuRequested, this,
|
||||
&GlobalsWidget::showGlobalsContextMenu);
|
||||
|
||||
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(ui->quickFilterView, &ComboQuickFilterView::filterTextChanged, globalsProxyModel,
|
||||
@ -206,8 +191,12 @@ GlobalsWidget::GlobalsWidget(MainWindow *main)
|
||||
actionEditGlobal = new QAction(tr("Edit Global Variable"), this);
|
||||
actionDeleteGlobal = new QAction(tr("Delete Global Variable"), this);
|
||||
|
||||
connect(actionEditGlobal, &QAction::triggered, [this]() { editGlobal(); });
|
||||
connect(actionDeleteGlobal, &QAction::triggered, [this]() { deleteGlobal(); });
|
||||
auto menu = ui->treeView->getItemContextMenu();
|
||||
menu->addAction(actionEditGlobal);
|
||||
menu->addAction(actionDeleteGlobal);
|
||||
|
||||
connect(actionEditGlobal, &QAction::triggered, this, [this]() { editGlobal(); });
|
||||
connect(actionDeleteGlobal, &QAction::triggered, this, [this]() { deleteGlobal(); });
|
||||
|
||||
connect(Core(), &CutterCore::globalVarsChanged, this, &GlobalsWidget::refreshGlobals);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &GlobalsWidget::refreshGlobals);
|
||||
|
@ -69,8 +69,6 @@ public:
|
||||
private slots:
|
||||
void refreshGlobals();
|
||||
|
||||
void showGlobalsContextMenu(const QPoint &pt);
|
||||
|
||||
void editGlobal();
|
||||
void deleteGlobal();
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CutterTreeView" name="treeView">
|
||||
<widget class="AddressableItemList<>" name="treeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@ -46,7 +46,7 @@
|
||||
}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
@ -73,7 +73,7 @@
|
||||
</widget>
|
||||
<action name="actionEditGlobal">
|
||||
<property name="text">
|
||||
<string>Edit Global Variable</string>
|
||||
<string>Edit Global Variable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit Global Variable</string>
|
||||
@ -89,18 +89,18 @@
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CutterTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>widgets/CutterTreeView.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ComboQuickFilterView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/ComboQuickFilterView.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AddressableItemList<></class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>widgets/AddressableItemList.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user