From 7a741b66a141b786cc86552a43ef256f6fc82f6e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 6 Jul 2018 19:19:18 +0200 Subject: clang format and some cleanup --- gui/designwidget.cc | 171 ++++++++++++++++++++++++-------------------------- gui/designwidget.h | 2 +- gui/fpgaviewwidget.cc | 2 +- gui/fpgaviewwidget.h | 6 +- 4 files changed, 85 insertions(+), 96 deletions(-) diff --git a/gui/designwidget.cc b/gui/designwidget.cc index d8882cf3..c5637cf7 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -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) { @@ -112,28 +115,28 @@ void DesignWidget::newContext(Context *ctx) QTreeWidgetItem *bel_root = new QTreeWidgetItem(treeWidget); QMap bel_items; bel_root->setText(0, "Bels"); - treeWidget->insertTopLevelItem(0, bel_root); + treeWidget->insertTopLevelItem(0, bel_root); if (ctx) { for (auto bel : ctx->getBels()) { auto id = ctx->getBelName(bel); QStringList items = QString(id.c_str(ctx)).split("/"); QString name; QTreeWidgetItem *parent = nullptr; - for(int i=0;iaddChild(bel.second); } @@ -141,28 +144,28 @@ void DesignWidget::newContext(Context *ctx) QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget); QMap wire_items; wire_root->setText(0, "Wires"); - treeWidget->insertTopLevelItem(0, wire_root); + treeWidget->insertTopLevelItem(0, wire_root); if (ctx) { for (auto wire : ctx->getWires()) { auto id = ctx->getWireName(wire); QStringList items = QString(id.c_str(ctx)).split("/"); QString name; QTreeWidgetItem *parent = nullptr; - for(int i=0;iaddChild(wire.second); } @@ -177,34 +180,33 @@ void DesignWidget::newContext(Context *ctx) QStringList items = QString(id.c_str(ctx)).split("/"); QString name; QTreeWidgetItem *parent = nullptr; - for(int i=0;iaddChild(pip.second); } // Add nets to tree nets_root = new QTreeWidgetItem(treeWidget); nets_root->setText(0, "Nets"); - treeWidget->insertTopLevelItem(0, nets_root); + treeWidget->insertTopLevelItem(0, nets_root); // Add cells to tree cells_root = new QTreeWidgetItem(treeWidget); cells_root->setText(0, "Cells"); - treeWidget->insertTopLevelItem(0, cells_root); - + treeWidget->insertTopLevelItem(0, cells_root); } void DesignWidget::updateTree() @@ -217,34 +219,33 @@ void DesignWidget::updateTree() nets_root = new QTreeWidgetItem(treeWidget); QMap nets_items; nets_root->setText(0, "Nets"); - treeWidget->insertTopLevelItem(0, nets_root); + 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)); } } - for (auto item : nets_items.toStdMap()) { + for (auto item : nets_items.toStdMap()) { nets_root->addChild(item.second); - } + } // Add cells to tree cells_root = new QTreeWidgetItem(treeWidget); QMap cells_items; cells_root->setText(0, "Cells"); - treeWidget->insertTopLevelItem(0, cells_root); + 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()) { + for (auto item : cells_items.toStdMap()) { cells_root->addChild(item.second); - } - + } } void DesignWidget::addProperty(QtProperty *property, const QString &id) @@ -270,12 +271,11 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) if (!item->parent()) return; - ElementType type = static_cast(item)->getType(); if (type == ElementType::NONE) { return; } - + clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(item)->getData(); @@ -295,7 +295,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) } else if (type == ElementType::WIRE) { IdString c = static_cast(item)->getData(); - QtProperty *topItem = groupManager->addProperty("Wire"); + QtProperty *topItem = groupManager->addProperty("Wire"); addProperty(topItem, "Wire"); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); @@ -305,7 +305,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) } else if (type == ElementType::PIP) { IdString c = static_cast(item)->getData(); - QtProperty *topItem = groupManager->addProperty("Pip"); + QtProperty *topItem = groupManager->addProperty("Pip"); addProperty(topItem, "Pip"); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); @@ -316,36 +316,35 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) IdString c = static_cast(item)->getData(); NetInfo *net = ctx->nets.at(c).get(); - QtProperty *topItem = groupManager->addProperty("Net"); + QtProperty *topItem = groupManager->addProperty("Net"); addProperty(topItem, "Net"); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); nameItem->setValue(net->name.c_str(ctx)); topItem->addSubProperty(nameItem); - QtProperty *driverItem = groupManager->addProperty("Driver"); + QtProperty *driverItem = groupManager->addProperty("Driver"); topItem->addSubProperty(driverItem); QtVariantProperty *portItem = readOnlyManager->addProperty(QVariant::String, "Port"); portItem->setValue(net->driver.port.c_str(ctx)); driverItem->addSubProperty(portItem); - + QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, "Budget"); budgetItem->setValue(net->driver.budget); driverItem->addSubProperty(budgetItem); - if (net->driver.cell) { - CellInfo *cell = net->driver.cell; - - QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell"); - cellNameItem->setValue(cell->name.c_str(ctx)); - driverItem->addSubProperty(cellNameItem); - } - QtProperty *usersItem = groupManager->addProperty("Users"); + 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); + + QtProperty *usersItem = groupManager->addProperty("Users"); topItem->addSubProperty(usersItem); - for(auto &item : net->users) - { - QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx)); + for (auto &item : net->users) { + QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx)); usersItem->addSubProperty(portItem); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Port"); @@ -364,30 +363,28 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) portItem->addSubProperty(userItem); } - QtProperty *attrsItem = groupManager->addProperty("Attributes"); + 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); } - QtProperty *wiresItem = groupManager->addProperty("Wires"); + 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); + QtProperty *wireItem = groupManager->addProperty(name); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); nameItem->setValue(name); wireItem->addSubProperty(nameItem); - + 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(""); @@ -397,14 +394,14 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) strengthItem->setValue((int)item.second.strength); wireItem->addSubProperty(strengthItem); - wiresItem->addSubProperty(wireItem); + wiresItem->addSubProperty(wireItem); } } else if (type == ElementType::CELL) { IdString c = static_cast(item)->getData(); CellInfo *cell = ctx->cells.at(c).get(); - QtProperty *topItem = groupManager->addProperty("Cell"); + QtProperty *topItem = groupManager->addProperty("Cell"); addProperty(topItem, "Cell"); QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Name"); @@ -414,9 +411,9 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) QtVariantProperty *cellTypeItem = readOnlyManager->addProperty(QVariant::String, "Type"); cellTypeItem->setValue(cell->type.c_str(ctx)); 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,10 +425,9 @@ 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)); QtVariantProperty *portInfoNameItem = readOnlyManager->addProperty(QVariant::String, "Name"); @@ -445,7 +441,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) QtVariantProperty *portInfoNetItem = readOnlyManager->addProperty(QVariant::String, "Net"); if (p.net) portInfoNetItem->setValue(p.net->name.c_str(ctx)); - else + else portInfoNetItem->setValue(""); portInfoItem->addSubProperty(portInfoNetItem); @@ -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); @@ -489,8 +481,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos) pinGroupItem->addSubProperty(belItem); cellPinsItem->addSubProperty(pinGroupItem); - } - + } } } diff --git a/gui/designwidget.h b/gui/designwidget.h index 953a578f..7785513a 100644 --- a/gui/designwidget.h +++ b/gui/designwidget.h @@ -22,10 +22,10 @@ #include #include "nextpnr.h" +#include "qtgroupboxpropertybrowser.h" #include "qtpropertymanager.h" #include "qttreepropertybrowser.h" #include "qtvariantproperty.h" -#include "qtgroupboxpropertybrowser.h" NEXTPNR_NAMESPACE_BEGIN diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 2ea5db74..0c6b1a98 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -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(); diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 0342bb8a..c281fd77 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -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; -- cgit v1.2.3