HAL
hal::ModuleItem Class Reference

An item in the ModuleModel. More...

#include <module_item.h>

Inheritance diagram for hal::ModuleItem:
Inheritance graph
Collaboration diagram for hal::ModuleItem:
Collaboration graph

Public Types

enum class  TreeItemType { Module , Gate , Net }
 

Public Member Functions

void setData (QList< QVariant > data) override
 
void setDataAtIndex (int index, QVariant &data) override
 
void appendData (QVariant data) override
 
int getColumnCount () const override
 
 ModuleItem (const u32 id, const TreeItemType type, ModuleModel *model)
 
virtual ~ModuleItem ()
 
void appendExistingChildIfAny (const QMap< u32, ModuleItem * > &moduleMap)
 
QVariant getData (int column) const override
 
QString name () const
 
u32 id () const
 
bool highlighted () const
 
bool isToplevelItem () const
 
TreeItemType getType () const
 
void setName (const QString &name)
 
void setModuleType (const QString &moduleType)
 
void setHighlighted (const bool highlighted)
 
- Public Member Functions inherited from hal::BaseTreeItem
 BaseTreeItem ()
 
 BaseTreeItem (QList< QVariant > columnData)
 
virtual ~BaseTreeItem ()
 
virtual BaseTreeItemgetParent () const
 
virtual void setParent (BaseTreeItem *parent)
 
virtual BaseTreeItemgetChild (int row) const
 
virtual QList< BaseTreeItem * > getChildren () const
 
virtual void appendChild (BaseTreeItem *child)
 
virtual void insertChild (int index, BaseTreeItem *child)
 
virtual BaseTreeItemremoveChildAtPos (int row)
 
virtual bool removeChild (BaseTreeItem *child)
 
virtual int getChildCount () const
 
virtual int getRowForChild (const BaseTreeItem *child) const
 
virtual int getOwnRow ()
 

Additional Inherited Members

- Protected Attributes inherited from hal::BaseTreeItem
BaseTreeItemmParent
 
QList< BaseTreeItem * > mChildren
 

Detailed Description

An item in the ModuleModel.

The ModuleItem is one item in the ModuleModel item model. It represents either a module, a gate or a net of the netlist.

Definition at line 47 of file module_item.h.

Member Enumeration Documentation

◆ TreeItemType

The possible types that a ModuleItem in the ModuleModel can have.

Enumerator
Module 
Gate 
Net 

Definition at line 53 of file module_item.h.

Constructor & Destructor Documentation

◆ ModuleItem()

hal::ModuleItem::ModuleItem ( const u32  id,
const TreeItemType  type,
ModuleModel model 
)

Constructor.

Parameters
id- The id of the netlist item this ModuleItem represents
type- The type of the netlist item
model- The parent model where this item is added to.

Definition at line 12 of file module_item.cpp.

References QString::fromStdString(), test_plugin::g, Gate, hal::Netlist::get_gate_by_id(), hal::Netlist::get_module_by_id(), hal::Module::get_name(), hal::Netlist::get_net_by_id(), hal::Module::get_type(), hal::gNetlist, Module, test::n, Net, and type.

◆ ~ModuleItem()

hal::ModuleItem::~ModuleItem ( )
virtual

Destructor.

Must remove item from ModuleModel map as well.

Definition at line 48 of file module_item.cpp.

Member Function Documentation

◆ appendData()

void hal::ModuleItem::appendData ( QVariant  data)
overridevirtual

Unused dummy function overwritten from parent class.

Implements hal::BaseTreeItem.

Definition at line 163 of file module_item.cpp.

References hal::data.

◆ appendExistingChildIfAny()

void hal::ModuleItem::appendExistingChildIfAny ( const QMap< u32, ModuleItem * > &  moduleMap)

Given a set of ModuleItems (in a map [id]->[ModuleItem]) this function adds each ModuleItem of this set as a new children if its underlying module is a submodule (child) of the underlying module of this ModuleItem.

Parameters
moduleMap- A map [id]->[ModuleItem] of children candidates

Definition at line 60 of file module_item.cpp.

References hal::BaseTreeItem::appendChild(), QMap::constEnd(), QMap::find(), hal::Netlist::get_module_by_id(), hal::Module::get_submodules(), hal::gNetlist, Module, and hal::BaseTreeItem::setParent().

◆ getColumnCount()

int hal::ModuleItem::getColumnCount ( ) const
overridevirtual

Get the number of currently stored column data.

Returns
3

Implements hal::BaseTreeItem.

Definition at line 158 of file module_item.cpp.

◆ getData()

QVariant hal::ModuleItem::getData ( int  column) const
overridevirtual

Gets the data of this item model item i.e. the name of this ModuleItem if column=1.

Parameters
column- The column to get the data for
Returns
the data in the specified column of this ModuleItem

Implements hal::BaseTreeItem.

Definition at line 88 of file module_item.cpp.

Referenced by hal::ModuleModel::data().

◆ getType()

◆ highlighted()

bool hal::ModuleItem::highlighted ( ) const

Checks if this ModuleItem is currently highlighted.

Returns
true if this ModuleItem is currently highlighted.

Definition at line 133 of file module_item.cpp.

Referenced by hal::ModuleModel::data(), and setHighlighted().

◆ id()

◆ isToplevelItem()

bool hal::ModuleItem::isToplevelItem ( ) const

Checks if this ModuleItem is direct child to mRootItem

Returns

Definition at line 138 of file module_item.cpp.

References hal::BaseTreeItem::mParent.

Referenced by hal::ModuleModel::moduleAssignGate(), and hal::ModuleModel::updateModuleParent().

◆ name()

QString hal::ModuleItem::name ( ) const

Gets the name of the netlist item this ModuleItem represents.

Returns
the netlist items name

Definition at line 123 of file module_item.cpp.

Referenced by setName().

◆ setData()

void hal::ModuleItem::setData ( QList< QVariant data)
overridevirtual

Sets the data for the columns name and type. Column 2 (type) can be only set, if this item is a module.

Parameters
data- Each entry in the list represents one column. The second column (id) is ignored.

Implements hal::BaseTreeItem.

Definition at line 102 of file module_item.cpp.

References hal::data, Module, setModuleType(), and setName().

◆ setDataAtIndex()

void hal::ModuleItem::setDataAtIndex ( int  index,
QVariant data 
)
overridevirtual

Sets the data for a specified column. Column 2 (type) can only be set, if this item is a module.

Parameters
index- The column to set the new data. Either 0 (name) or 2(type). Other columns will be ignored.
data- The new column data.

Implements hal::BaseTreeItem.

Definition at line 109 of file module_item.cpp.

References hal::data, setModuleType(), and setName().

◆ setHighlighted()

void hal::ModuleItem::setHighlighted ( const bool  highlighted)

Marks/Unmarks this ModuleItem as highlighted.

Parameters
highlighted- true if the ModuleItem should be marked as highlighted. false if the ModuleItem should be marked as NOT highlighted.

Definition at line 153 of file module_item.cpp.

References highlighted().

◆ setModuleType()

void hal::ModuleItem::setModuleType ( const QString moduleType)

Set the module type name (gate types are immutable)

Parameters
moduleType

Definition at line 79 of file module_item.cpp.

References hal::Netlist::get_module_by_id(), hal::gNetlist, Module, hal::ShortestPath::module(), hal::Module::set_type(), and QString::toStdString().

Referenced by setData(), and setDataAtIndex().

◆ setName()

void hal::ModuleItem::setName ( const QString name)

Sets the name of this ModuleItem (not the underlying module).

Parameters
name- The new name

Definition at line 148 of file module_item.cpp.

References name().

Referenced by setData(), setDataAtIndex(), hal::ModuleModel::updateGateName(), hal::ModuleModel::updateModuleName(), and hal::ModuleModel::updateNetName().


The documentation for this class was generated from the following files: