Skip to content

Commit

Permalink
FIx loading colors into ModuleModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaleee committed Oct 15, 2023
1 parent 9b2395b commit 8569a3a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
15 changes: 0 additions & 15 deletions plugins/gui/include/gui/module_model/module_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@ namespace hal
*/
u32 id() const;

/**
* Gets the color of the netlist item this ModuleItem represents.
*
* @returns the module color
*/
QColor color() const;

/**
* Checks if this ModuleItem is currently highlighted.
*
Expand Down Expand Up @@ -195,13 +188,6 @@ namespace hal
*/
void setName(const QString& name);

/**
* Sets the color of the module this ModuleItem represents.
*
* @param color - The new color
*/
void setColor(const QColor& color);

/**
* Marks/Unmarks this ModuleItem as highlighted.
*
Expand All @@ -218,7 +204,6 @@ namespace hal
TreeItemType mType;
QString mName;

QColor mColor;
bool mHighlighted;
};
}
4 changes: 3 additions & 1 deletion plugins/gui/src/grouping/grouping_color_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ namespace hal {
QModelIndex inx = mm->index(irow,0,parent);
const ModuleItem* mItem = mm->getItem(inx);
if (!mItem) continue;
if(mItem->getType() != ModuleItem::TreeItemType::Module) continue;

QJsonObject mcEntry;
mcEntry["id"] = (int) mItem->id();
mcEntry["color"] = mItem->color().name(QColor::HexArgb);
mcEntry["color"] = mm->moduleColor(mItem->id()).name(QColor::HexArgb);
mcArr.append(mcEntry);
serializeColorRecursion(mcArr,mm,inx);
}
Expand Down
11 changes: 0 additions & 11 deletions plugins/gui/src/module_model/module_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace hal
{
case TreeItemType::Module:
mName = QString::fromStdString(gNetlist->get_module_by_id(id)->get_name());
mColor = gNetlistRelay->getModuleColor(id);
break;
case TreeItemType::Gate:
mName = QString::fromStdString(gNetlist->get_gate_by_id(id)->get_name());
Expand Down Expand Up @@ -139,11 +138,6 @@ namespace hal
return mId;
}

QColor ModuleItem::color() const
{
return mColor;
}

bool ModuleItem::highlighted() const
{
return mHighlighted;
Expand All @@ -163,11 +157,6 @@ namespace hal
mName = name;
}

void ModuleItem::setColor(const QColor& color)
{
mColor = color;
}

void ModuleItem::setHighlighted(const bool highlighted)
{
mHighlighted = highlighted;
Expand Down
5 changes: 2 additions & 3 deletions plugins/gui/src/module_model/module_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "gui/gui_globals.h"
#include "gui/gui_utils/graphics.h"
//#include "gui/ModuleModel/ModuleItem.h"

#include "gui/selection_details_widget/selection_details_icon_provider.h"

#include "hal_core/netlist/gate.h"
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace hal
{
switch(item->getType()){
case ModuleItem::TreeItemType::Module:
return QIcon(*SelectionDetailsIconProvider::instance()->getIcon(SelectionDetailsIconProvider::ModuleIcon, item->id()));
return QIcon(gui_utility::getStyledSvgIcon("all->" + mModuleColors[item->id()].name(QColor::HexRgb), ":/icons/ne_module"));
case ModuleItem::TreeItemType::Gate:
return QIcon(*SelectionDetailsIconProvider::instance()->getIcon(SelectionDetailsIconProvider::GateIcon, item->id()));
case ModuleItem::TreeItemType::Net:
Expand Down Expand Up @@ -444,7 +444,6 @@ namespace hal
assert(item);

item->setName(QString::fromStdString(gNetlist->get_module_by_id(id)->get_name())); // REMOVE & ADD AGAIN
item->setColor(gNetlistRelay->getModuleColor(id));

QModelIndex index = getIndex(item);
Q_EMIT dataChanged(index, index);
Expand Down

0 comments on commit 8569a3a

Please sign in to comment.