Skip to content

Commit

Permalink
Migrated SelectionTreeModel to ModuleModel and refactored references.…
Browse files Browse the repository at this point in the history
… Removed SelectionTreeItem.
  • Loading branch information
Skaleee committed Mar 7, 2024
1 parent 1cf5f60 commit f7afb42
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 1,162 deletions.
4 changes: 2 additions & 2 deletions plugins/gui/include/gui/graph_widget/graphics_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "gui/graph_widget/items/utility_items/node_drag_shadow.h"
#include "gui/graph_widget/shaders/graph_shader.h"
#include "gui/gui_globals.h"
#include "gui/selection_details_widget/tree_navigation/selection_tree_item.h"
#include "gui/module_model/module_item.h"
#include "gui/graph_widget/graphics_qss_adapter.h"
#include "hal_core/defines.h"
#include "hal_core/netlist/gate.h"
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace hal
*
* @param highlightItems - The selection tree items to highlight
*/
void handleHighlight(const QVector<const SelectionTreeItem*>& highlightItems);
void handleHighlight(const QVector<const ModuleItem*>& highlightItems);

/**
* Q_SLOT to call whenever a module was assigned to or removed from a grouping. It is used to update the
Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/include/gui/module_model/module_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace hal
* @param id - The id of the netlist item this ModuleItem represents
* @param type - The type of the netlist item
*/
ModuleItem(const u32 id, const TreeItemType type = TreeItemType::Module);
ModuleItem(const u32 id, const TreeItemType type);

/**
* Given a set of ModuleItems (in a map [id]->[ModuleItem]) this function adds each ModuleItem of this set as
Expand Down
72 changes: 44 additions & 28 deletions plugins/gui/include/gui/module_model/module_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,23 @@ namespace hal
ModuleItem* getItem(const QModelIndex& index) const;

/**
* Returns the ModuleItem for a specified id and type.
* Returns the first ModuleItem for a specified id and type.
*
* @param module_id - The id of the ModuleItem
* @param type - The type of the ModuleItem
* @returns the ModuleItem with the specified id and type.
*/
ModuleItem* getItem(const u32 id, ModuleItem::TreeItemType type = ModuleItem::TreeItemType::Module) const;

/**
* Returns all ModuleItems for a specified id and type.
*
* @param module_id - The id of the ModuleItems
* @param type - The type of the ModuleItems
* @returns QList of ModuleItems with the specified id and type.
*/
QList<ModuleItem*> getItems(const u32 id, ModuleItem::TreeItemType type = ModuleItem::TreeItemType::Module) const;

/**
* Initializes the item model using the global netlist object gNetlist.
*/
Expand All @@ -133,23 +142,23 @@ namespace hal
void clear() override;

/**
* Add a module to the item model. For the specified module a new ModuleItem is created and stored.
* Add a module to the item model. For the specified module new ModuleItems are created and stored.
*
* @param id - The id of the module to add.
* @param parent_module - The id of the parent module of the module to add.
*/
void addModule(const u32 id, const u32 parentId);

/**
* Add a gate to the item model. For the specified gate a new ModuleItem is created and stored.
* Add a gate to the item model. For the specified gate new ModuleItems are created and stored.
*
* @param id - The id of the gate to add.
* @param parent_module - The id of the parent module of the gate to add.
*/
void addGate(const u32 id, const u32 parentId);

/**
* Add a net to the item model. For the specified net a new ModuleItem is created and stored.
* Add a net to the item model. For the specified net new ModuleItems are created and stored.
*
* @param id - The id of the net to add.
* @param parent_module - The id of the parent module of the net to add.
Expand All @@ -158,7 +167,7 @@ namespace hal

/**
* Recursively adds the given module with all of its submodules (and their submodules and so on...)
* and the gates those modules to the item model.
* and the gates of those modules to the item model.
*
* @param module - The module which should be added to the item model together with all its
* submodules, gates and nets.
Expand Down Expand Up @@ -209,29 +218,29 @@ namespace hal
void updateNetParent(const Net* net, const QHash<const Net*,ModuleItem*>* parentAssignment = nullptr);

/**
* Reattaches the ModuleItem corresponding to the specified module to a new parent item.
* Reattaches the ModuleItems corresponding to the specified module to new parent items.
* The new parent must already be set in the Module object.
*
* @param module - The module whose ModuleItem will be reattached to a new parent in the item model.
* @param module - The module whose ModuleItems will be reattached to new parents in the item model.
*/
void updateModuleParent(const Module* module);

/**
* Updates the ModuleItem for the specified module. The specified module MUST be contained in the item model.
* Updates the ModuleItems for the specified module. The specified module MUST be contained in the item model.
*
* @param id - The id of the module to update
*/
void updateModuleName(const u32 id);

/**
* Updates the ModuleItem for the specified gate. The specified gate MUST be contained in the item model.
* Updates the ModuleItems for the specified gate. The specified gate MUST be contained in the item model.
*
* @param id - The id of the gate to update
*/
void updateGateName(const u32 id);

/**
* Updates the ModuleItem for the specified net. The specified gate MUST be contained in the item model.
* Updates the ModuleItems for the specified net. The specified gate MUST be contained in the item model.
*
* @param id - The id of the net to update
*/
Expand All @@ -254,7 +263,7 @@ namespace hal
void handleModuleCreated(Module* mod);

/**
* Moves the ModuleItem corresponding to the module under it's new parent ModuleItem.
* Moves the ModuleItems corresponding to the module under their new parent ModuleItems.
* The items for all nets, that have at least one source or one destination within the module,
* will be updated afterwards.
*
Expand Down Expand Up @@ -287,6 +296,30 @@ namespace hal
void handleNetRemoved(Net* net);

void handleNetUpdated(Net* net, u32 data);

protected:
/**
* Factory method to append new tree items. Insert signals are sent to view. New items are put into hash table.
* @param id - ID of new tree item
* @param itemType - Whether new tree item is module, gate, or net
* @param parentItem - Parent to new tree item. Will create top-level item if parent is nullptr
* @return Point to new tree item
*/
ModuleItem* createChildItem(u32 id, ModuleItem::TreeItemType itemType, BaseTreeItem* parentItem = nullptr);

/**
* Method to remove and delete tree items. Remove signals are sent to view.
* Hash table will _NOT_ be updated since caller can do it more efficiently.
* @param itemToRemove - Item to be removed from tree
* @param parentItem - Parent item. Must be present.
*/
void removeChildItem(ModuleItem* itemToRemove, BaseTreeItem* parentItem);

/**
* See isModifying()
*/
void setIsModifying(bool pIsModifying);

private:
/**
* Searches for a new parent module, such that it is the deepest module in the hierarchy, that contains all
Expand All @@ -307,23 +340,6 @@ namespace hal
*/
void findNetParentRecursion(BaseTreeItem* parent, QHash<const Net*,ModuleItem*>& parentAssignment, std::unordered_set<Net*>& assignedNets) const;

/**
* Factory method to append new tree items. Insert signals are sent to view. New items are put into hash table.
* @param id - ID of new tree item
* @param itemType - Whether new tree item is module, gate, or net
* @param parentItem - Parent to new tree item. Will create top-level item if parent is nullptr
* @return Point to new tree item
*/
ModuleItem* createChildItem(u32 id, ModuleItem::TreeItemType itemType, BaseTreeItem* parentItem = nullptr);

/**
* Method to remove and delete tree items. Remove signals are sent to view.
* Hash table will _NOT_ be updated since caller can do it more efficiently.
* @param itemToRemove - Item to be removed from tree
* @param parentItem - Parent item. Must be present.
*/
void removeChildItem(ModuleItem* itemToRemove, BaseTreeItem* parentItem);

QMultiMap<u32, ModuleItem*> mModuleMap;
QMultiMap<u32, ModuleItem*> mGateMap;
QMultiMap<u32, ModuleItem*> mNetMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#pragma once

#include "gui/content_widget/content_widget.h"
#include "gui/selection_details_widget/tree_navigation/selection_tree_item.h"
#include "gui/module_model/module_item.h"
#include "gui/selection_details_widget/tree_navigation/selection_tree_proxy.h"
#include "gui/selection_details_widget/tree_navigation/selection_tree_model.h"
#include "hal_core/defines.h"
Expand Down Expand Up @@ -238,7 +238,7 @@ namespace hal
*
* @param highlight - The items to highlight (that were selected in the view).
*/
void triggerHighlight(QVector<const SelectionTreeItem*> highlight);
void triggerHighlight(QVector<const ModuleItem*> highlight);

/**
* Q_SIGNAL that is emitted when a gate-type item in the treeview is double clicked
Expand Down Expand Up @@ -280,7 +280,7 @@ namespace hal
*
* @param sti - The selected item.
*/
void handleTreeSelection(const SelectionTreeItem* sti);
void handleTreeSelection(const ModuleItem* sti);

/**
* Overriden function of the ContentWidget. Sets up all shortcuts and returns them.
Expand Down Expand Up @@ -320,7 +320,7 @@ namespace hal
*
* @param sti - The clicked item in the selection-treeview.
*/
void handleTreeViewItemFocusClicked(const SelectionTreeItem* sti);
void handleTreeViewItemFocusClicked(const ModuleItem* sti);

private:

Expand All @@ -330,7 +330,7 @@ namespace hal
*
* @param sti - The item that is to be displayed.
*/
void singleSelectionInternal(const SelectionTreeItem* sti);
void singleSelectionInternal(const ModuleItem* sti);

/**
* Adds the current selection to a module selected by id (=actionCode if positive).
Expand Down
Loading

0 comments on commit f7afb42

Please sign in to comment.