From 7a8d034530f1c9dfebdbe9550aea2bd68100b9bd Mon Sep 17 00:00:00 2001 From: Julia Date: Sat, 21 Oct 2023 16:36:42 +0200 Subject: [PATCH] change ModuleItem to inherit from BaseTreeItem and ModuleModel to inherit from BaseTreeModel --- plugins/gui/src/module_model/module_item.cpp | 68 +++++++++++++------ .../gate_details_widget/pin_tree_model.cpp | 5 +- .../netlist_elements_tree_model.cpp | 5 +- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/plugins/gui/src/module_model/module_item.cpp b/plugins/gui/src/module_model/module_item.cpp index a0159b99676..3719efad404 100644 --- a/plugins/gui/src/module_model/module_item.cpp +++ b/plugins/gui/src/module_model/module_item.cpp @@ -7,25 +7,6 @@ namespace hal { -void ModuleItem::setData(QList data) -{ - -} - -void ModuleItem::setDataAtIndex(int index, QVariant &data) -{ - -} - -void ModuleItem::appendData(QVariant data) -{ - -} - -int ModuleItem::getColumnCount() const -{ - -} ModuleItem::ModuleItem(const u32 id, const TreeItemType type) : mParent(nullptr), @@ -148,6 +129,48 @@ ModuleItem::ModuleItem(const u32 id, const TreeItemType type) : return QVariant(); } + void ModuleItem::setData(QList data) + { + setName(data[0].toString()); + switch(mType) + { + case TreeItemType::Module: + { + Module* module = gNetlist->get_module_by_id(mId); + if(!module) + return; + module->set_type(data[3].toString().toStdString()); + } + case TreeItemType::Gate: + return; + } + } + + void ModuleItem::setDataAtIndex(int index, QVariant &data) + { + if(index == 0) { + setName(data.toString()); + return; + } + else if (index == 1) + return; + else if(index == 2) + { + switch(mType) + { + case TreeItemType::Module: + { + Module* module = gNetlist->get_module_by_id(mId); + if(!module) + return; + module->set_type(data.toString().toStdString()); + } + case TreeItemType::Gate: + return; + } + } + } + QString ModuleItem::name() const { return mName; @@ -181,4 +204,11 @@ ModuleItem::ModuleItem(const u32 id, const TreeItemType type) : { mHighlighted = highlighted; } + + int ModuleItem::getColumnCount() const + { + return 3; + } + + void ModuleItem::appendData(QVariant data) {} } diff --git a/plugins/gui/src/selection_details_widget/gate_details_widget/pin_tree_model.cpp b/plugins/gui/src/selection_details_widget/gate_details_widget/pin_tree_model.cpp index f9b7ea9703f..3b2a9e9138b 100644 --- a/plugins/gui/src/selection_details_widget/gate_details_widget/pin_tree_model.cpp +++ b/plugins/gui/src/selection_details_widget/gate_details_widget/pin_tree_model.cpp @@ -71,10 +71,7 @@ namespace hal } - void PinTreeItem::appendData(QVariant data) - { - - } + void PinTreeItem::appendData(QVariant data) {} int PinTreeItem::getColumnCount() const { diff --git a/plugins/gui/src/selection_details_widget/module_details_widget/netlist_elements_tree_model.cpp b/plugins/gui/src/selection_details_widget/module_details_widget/netlist_elements_tree_model.cpp index 536d24d6103..0073b6e8a0c 100644 --- a/plugins/gui/src/selection_details_widget/module_details_widget/netlist_elements_tree_model.cpp +++ b/plugins/gui/src/selection_details_widget/module_details_widget/netlist_elements_tree_model.cpp @@ -59,10 +59,7 @@ namespace hal } } - void NetlistElementsTreeitem::appendData(QVariant data) - { - - } + void NetlistElementsTreeitem::appendData(QVariant data) {} int NetlistElementsTreeitem::getColumnCount() const {