clang format and some cleanup

This commit is contained in:
Miodrag Milanovic 2018-07-06 19:19:18 +02:00
parent cc901d67f5
commit 7a741b66a1
4 changed files with 85 additions and 96 deletions

View File

@ -40,7 +40,10 @@ enum class ElementType
class ElementTreeItem : public QTreeWidgetItem
{
public:
ElementTreeItem(ElementType t, QString str, QTreeWidgetItem *parent) : QTreeWidgetItem(parent, QStringList(str)), type(t) {}
ElementTreeItem(ElementType t, QString str, QTreeWidgetItem *parent)
: QTreeWidgetItem(parent, QStringList(str)), type(t)
{
}
virtual ~ElementTreeItem(){};
ElementType getType() { return type; };
@ -52,7 +55,10 @@ class ElementTreeItem : public QTreeWidgetItem
class IdStringTreeItem : public ElementTreeItem
{
public:
IdStringTreeItem(IdString d, ElementType t, QString str, QTreeWidgetItem *parent) : ElementTreeItem(t, str, parent) { this->data = d; }
IdStringTreeItem(IdString d, ElementType t, QString str, QTreeWidgetItem *parent) : ElementTreeItem(t, str, parent)
{
this->data = d;
}
virtual ~IdStringTreeItem(){};
IdString getData() { return this->data; };
@ -61,7 +67,6 @@ class IdStringTreeItem : public ElementTreeItem
IdString data;
};
DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), nets_root(nullptr), cells_root(nullptr)
{
@ -99,9 +104,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(onItemClicked(QTreeWidgetItem *, int)));
}
DesignWidget::~DesignWidget()
{
}
DesignWidget::~DesignWidget() {}
void DesignWidget::newContext(Context *ctx)
{
@ -119,15 +122,15 @@ void DesignWidget::newContext(Context *ctx)
QStringList items = QString(id.c_str(ctx)).split("/");
QString name;
QTreeWidgetItem *parent = nullptr;
for(int i=0;i<items.size();i++)
{
if (!name.isEmpty()) name += "/";
for (int i = 0; i < items.size(); i++) {
if (!name.isEmpty())
name += "/";
name += items.at(i);
if (!bel_items.contains(name)) {
if (i==items.size()-1)
bel_items.insert(name,new IdStringTreeItem(id, ElementType::BEL, items.at(i),parent));
if (i == items.size() - 1)
bel_items.insert(name, new IdStringTreeItem(id, ElementType::BEL, items.at(i), parent));
else
bel_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
bel_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
parent = bel_items[name];
}
@ -148,15 +151,15 @@ void DesignWidget::newContext(Context *ctx)
QStringList items = QString(id.c_str(ctx)).split("/");
QString name;
QTreeWidgetItem *parent = nullptr;
for(int i=0;i<items.size();i++)
{
if (!name.isEmpty()) name += "/";
for (int i = 0; i < items.size(); i++) {
if (!name.isEmpty())
name += "/";
name += items.at(i);
if (!wire_items.contains(name)) {
if (i==items.size()-1)
wire_items.insert(name,new IdStringTreeItem(id, ElementType::WIRE, items.at(i),parent));
if (i == items.size() - 1)
wire_items.insert(name, new IdStringTreeItem(id, ElementType::WIRE, items.at(i), parent));
else
wire_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
wire_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
parent = wire_items[name];
}
@ -177,15 +180,15 @@ void DesignWidget::newContext(Context *ctx)
QStringList items = QString(id.c_str(ctx)).split("/");
QString name;
QTreeWidgetItem *parent = nullptr;
for(int i=0;i<items.size();i++)
{
if (!name.isEmpty()) name += "/";
for (int i = 0; i < items.size(); i++) {
if (!name.isEmpty())
name += "/";
name += items.at(i);
if (!pip_items.contains(name)) {
if (i==items.size()-1)
pip_items.insert(name,new IdStringTreeItem(id, ElementType::PIP, items.at(i),parent));
if (i == items.size() - 1)
pip_items.insert(name, new IdStringTreeItem(id, ElementType::PIP, items.at(i), parent));
else
pip_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
pip_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
parent = pip_items[name];
}
@ -204,7 +207,6 @@ void DesignWidget::newContext(Context *ctx)
cells_root = new QTreeWidgetItem(treeWidget);
cells_root->setText(0, "Cells");
treeWidget->insertTopLevelItem(0, cells_root);
}
void DesignWidget::updateTree()
@ -219,7 +221,7 @@ void DesignWidget::updateTree()
nets_root->setText(0, "Nets");
treeWidget->insertTopLevelItem(0, nets_root);
if (ctx) {
for (auto& item : ctx->nets) {
for (auto &item : ctx->nets) {
auto id = item.first;
QString name = QString(id.c_str(ctx));
nets_items.insert(name, new IdStringTreeItem(id, ElementType::NET, name, nullptr));
@ -235,16 +237,15 @@ void DesignWidget::updateTree()
cells_root->setText(0, "Cells");
treeWidget->insertTopLevelItem(0, cells_root);
if (ctx) {
for (auto& item : ctx->cells) {
for (auto &item : ctx->cells) {
auto id = item.first;
QString name = QString(id.c_str(ctx));
cells_items.insert(name,new IdStringTreeItem(id, ElementType::CELL,name, nullptr));
cells_items.insert(name, new IdStringTreeItem(id, ElementType::CELL, name, nullptr));
}
}
for (auto item : cells_items.toStdMap()) {
cells_root->addChild(item.second);
}
}
void DesignWidget::addProperty(QtProperty *property, const QString &id)
@ -270,7 +271,6 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
if (!item->parent())
return;
ElementType type = static_cast<ElementTreeItem *>(item)->getType();
if (type == ElementType::NONE) {
return;
@ -334,17 +334,16 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
budgetItem->setValue(net->driver.budget);
driverItem->addSubProperty(budgetItem);
if (net->driver.cell) {
CellInfo *cell = net->driver.cell;
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell");
if (net->driver.cell)
cellNameItem->setValue(net->driver.cell->name.c_str(ctx));
else
cellNameItem->setValue("");
driverItem->addSubProperty(cellNameItem);
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell");
cellNameItem->setValue(cell->name.c_str(ctx));
driverItem->addSubProperty(cellNameItem);
}
QtProperty *usersItem = groupManager->addProperty("Users");
topItem->addSubProperty(usersItem);
for(auto &item : net->users)
{
for (auto &item : net->users) {
QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx));
usersItem->addSubProperty(portItem);
@ -366,8 +365,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtProperty *attrsItem = groupManager->addProperty("Attributes");
topItem->addSubProperty(attrsItem);
for(auto &item : net->attrs)
{
for (auto &item : net->attrs) {
QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
attrItem->setValue(item.second.c_str());
attrsItem->addSubProperty(attrItem);
@ -375,8 +373,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtProperty *wiresItem = groupManager->addProperty("Wires");
topItem->addSubProperty(wiresItem);
for(auto &item : net->wires)
{
for (auto &item : net->wires) {
auto name = ctx->getWireName(item.first).c_str(ctx);
QtProperty *wireItem = groupManager->addProperty(name);
@ -387,7 +384,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, "Pip");
if (item.second.pip!=PipId())
if (item.second.pip != PipId())
pipItem->setValue(ctx->getPipName(item.second.pip).c_str(ctx));
else
pipItem->setValue("");
@ -416,7 +413,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
topItem->addSubProperty(cellTypeItem);
QtVariantProperty *cellBelItem = readOnlyManager->addProperty(QVariant::String, "Bel");
if (cell->bel!=BelId())
if (cell->bel != BelId())
cellBelItem->setValue(ctx->getBelName(cell->bel).c_str(ctx));
else
cellBelItem->setValue("");
@ -428,8 +425,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtProperty *cellPortsItem = groupManager->addProperty("Ports");
topItem->addSubProperty(cellPortsItem);
for(auto &item : cell->ports)
{
for (auto &item : cell->ports) {
PortInfo p = item.second;
QtProperty *portInfoItem = groupManager->addProperty(p.name.c_str(ctx));
@ -454,8 +450,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtProperty *cellAttrItem = groupManager->addProperty("Attributes");
topItem->addSubProperty(cellAttrItem);
for(auto &item : cell->attrs)
{
for (auto &item : cell->attrs) {
QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
attrItem->setValue(item.second.c_str());
cellAttrItem->addSubProperty(attrItem);
@ -463,18 +458,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
QtProperty *cellParamsItem = groupManager->addProperty("Parameters");
topItem->addSubProperty(cellParamsItem);
for(auto &item : cell->params)
{
for (auto &item : cell->params) {
QtVariantProperty *paramItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
paramItem->setValue(item.second.c_str());
cellParamsItem->addSubProperty(paramItem);
}
QtProperty *cellPinsItem = groupManager->addProperty("Pins");
topItem->addSubProperty(cellPinsItem);
for(auto &item : cell->pins)
{
for (auto &item : cell->pins) {
std::string cell_port = item.first.c_str(ctx);
std::string bel_pin = item.second.c_str(ctx);
@ -490,7 +482,6 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
cellPinsItem->addSubProperty(pinGroupItem);
}
}
}

View File

@ -22,10 +22,10 @@
#include <QTreeWidget>
#include "nextpnr.h"
#include "qtgroupboxpropertybrowser.h"
#include "qtpropertymanager.h"
#include "qttreepropertybrowser.h"
#include "qtvariantproperty.h"
#include "qtgroupboxpropertybrowser.h"
NEXTPNR_NAMESPACE_BEGIN

View File

@ -249,7 +249,7 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
setFormat(fmt);
fmt = format();
//printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), fmt.minorVersion());
// printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), fmt.minorVersion());
if (fmt.majorVersion() < 3) {
printf("Could not get OpenGL 3.0 context. Aborting.\n");
log_abort();

View File

@ -34,8 +34,7 @@ NEXTPNR_NAMESPACE_BEGIN
// Vertex2DPOD is a structure of X, Y coordinates that can be passed to OpenGL
// directly.
NPNR_PACKED_STRUCT(struct Vertex2DPOD
{
NPNR_PACKED_STRUCT(struct Vertex2DPOD {
GLfloat x;
GLfloat y;
@ -44,8 +43,7 @@ NPNR_PACKED_STRUCT(struct Vertex2DPOD
// Vertex2DPOD is a structure of R, G, B, A values that can be passed to OpenGL
// directly.
NPNR_PACKED_STRUCT(struct ColorPOD
{
NPNR_PACKED_STRUCT(struct ColorPOD {
GLfloat r;
GLfloat g;
GLfloat b;