aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-15 15:12:31 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-15 15:12:31 +0200
commit3eb34bf38b8e2da66b3852bf35927a0b540a3cff (patch)
tree53339d77fe1bbfba64d5c573f01e8b141b9491b5 /gui
parentbf0b1d2db3e071f5606e117d5fc5f2213b948997 (diff)
downloadnextpnr-3eb34bf38b8e2da66b3852bf35927a0b540a3cff.tar.gz
nextpnr-3eb34bf38b8e2da66b3852bf35927a0b540a3cff.tar.bz2
nextpnr-3eb34bf38b8e2da66b3852bf35927a0b540a3cff.zip
make linked items clickable
Diffstat (limited to 'gui')
-rw-r--r--gui/designwidget.cc58
-rw-r--r--gui/designwidget.h4
-rw-r--r--gui/ice40/mainwindow.cc20
3 files changed, 57 insertions, 25 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index cfcdc9fc..2b0c43c0 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -155,6 +155,9 @@ DesignWidget::~DesignWidget() {}
void DesignWidget::newContext(Context *ctx)
{
treeWidget->clear();
+ for (int i = 0; i < 6; i++)
+ nameToItem[i].clear();
+
this->ctx = ctx;
// Add bels to tree
@@ -174,7 +177,7 @@ void DesignWidget::newContext(Context *ctx)
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));
+ nameToItem[0].insert(name, new IdStringTreeItem(id, ElementType::BEL, items.at(i), parent));
else
bel_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
@@ -185,6 +188,9 @@ void DesignWidget::newContext(Context *ctx)
for (auto bel : bel_items.toStdMap()) {
bel_root->addChild(bel.second);
}
+ for (auto bel : nameToItem[0].toStdMap()) {
+ bel_root->addChild(bel.second);
+ }
// Add wires to tree
QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget);
@@ -203,7 +209,7 @@ void DesignWidget::newContext(Context *ctx)
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));
+ nameToItem[1].insert(name, new IdStringTreeItem(id, ElementType::WIRE, items.at(i), parent));
else
wire_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
@@ -214,7 +220,9 @@ void DesignWidget::newContext(Context *ctx)
for (auto wire : wire_items.toStdMap()) {
wire_root->addChild(wire.second);
}
-
+ for (auto wire : nameToItem[1].toStdMap()) {
+ wire_root->addChild(wire.second);
+ }
// Add pips to tree
QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> pip_items;
@@ -232,7 +240,7 @@ void DesignWidget::newContext(Context *ctx)
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));
+ nameToItem[2].insert(name, new IdStringTreeItem(id, ElementType::PIP, items.at(i), parent));
else
pip_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
}
@@ -243,6 +251,9 @@ void DesignWidget::newContext(Context *ctx)
for (auto pip : pip_items.toStdMap()) {
pip_root->addChild(pip.second);
}
+ for (auto pip : nameToItem[2].toStdMap()) {
+ pip_root->addChild(pip.second);
+ }
// Add nets to tree
nets_root = new QTreeWidgetItem(treeWidget);
@@ -260,36 +271,38 @@ void DesignWidget::updateTree()
clearProperties();
delete nets_root;
delete cells_root;
+ nameToItem[3].clear();
+ nameToItem[4].clear();
// Add nets to tree
nets_root = new QTreeWidgetItem(treeWidget);
- QMap<QString, QTreeWidgetItem *> nets_items;
nets_root->setText(0, "Nets");
treeWidget->insertTopLevelItem(0, nets_root);
if (ctx) {
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));
+ IdStringTreeItem *newItem = new IdStringTreeItem(id, ElementType::NET, name, nullptr);
+ nameToItem[3].insert(name, newItem);
}
}
- for (auto item : nets_items.toStdMap()) {
+ for (auto item : nameToItem[3].toStdMap()) {
nets_root->addChild(item.second);
}
// Add cells to tree
cells_root = new QTreeWidgetItem(treeWidget);
- QMap<QString, QTreeWidgetItem *> cells_items;
cells_root->setText(0, "Cells");
treeWidget->insertTopLevelItem(0, cells_root);
if (ctx) {
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));
+ IdStringTreeItem *newItem = new IdStringTreeItem(id, ElementType::CELL, name, nullptr);
+ nameToItem[4].insert(name, newItem);
}
}
- for (auto item : cells_items.toStdMap()) {
+ for (auto item : nameToItem[4].toStdMap()) {
cells_root->addChild(item.second);
}
}
@@ -368,6 +381,20 @@ QString DesignWidget::getElementTypeName(ElementType type)
return "CELL";
return "";
}
+int DesignWidget::getElementIndex(ElementType type)
+{
+ if (type == ElementType::BEL)
+ return 0;
+ if (type == ElementType::WIRE)
+ return 1;
+ if (type == ElementType::PIP)
+ return 2;
+ if (type == ElementType::NET)
+ return 3;
+ if (type == ElementType::CELL)
+ return 4;
+ return -1;
+}
ElementType DesignWidget::getElementTypeByName(QString type)
{
@@ -615,7 +642,6 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos)
QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
- // if (((ElementTreeItem*)itemContextMenu)->getType() == ElementType::NONE) return;
QMenu menu(this);
QAction *selectAction = new QAction("&Select", this);
connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); });
@@ -629,13 +655,15 @@ void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column)
{
QtProperty *selectedProperty = propertyEditor->itemToBrowserItem(item)->property();
ElementType type = getElementTypeByName(selectedProperty->propertyId());
- IdString value = ctx->id(selectedProperty->valueText().toStdString());
+ QString value = selectedProperty->valueText();
+ int index = getElementIndex(type);
switch (type) {
case ElementType::NONE:
return;
- default:
- Q_EMIT info("double clicked " + std::string(value.c_str(ctx)) + "\n");
- break;
+ default: {
+ if (nameToItem[index].contains(value))
+ treeWidget->setCurrentItem(nameToItem[index].value(value));
+ } break;
}
}
diff --git a/gui/designwidget.h b/gui/designwidget.h
index 50f00bbe..8f2fa375 100644
--- a/gui/designwidget.h
+++ b/gui/designwidget.h
@@ -56,6 +56,7 @@ class DesignWidget : public QWidget
const ElementType &type = ElementType::NONE);
QString getElementTypeName(ElementType type);
ElementType getElementTypeByName(QString type);
+ int getElementIndex(ElementType type);
Q_SIGNALS:
void info(std::string text);
void selected(std::vector<DecalXY> decal);
@@ -83,6 +84,9 @@ class DesignWidget : public QWidget
QMap<QtProperty *, QString> propertyToId;
QMap<QString, QtProperty *> idToProperty;
+
+ QMap<QString, QTreeWidgetItem *> nameToItem[6];
+
QTreeWidgetItem *nets_root;
QTreeWidgetItem *cells_root;
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 772ca6ac..28792ed3 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -71,43 +71,43 @@ void MainWindow::createMenu()
QMenu *menu_Design = new QMenu("&Design", menuBar);
menuBar->addAction(menu_Design->menuAction());
- actionLoadJSON = new QAction("Open JSON", this);
+ actionLoadJSON = new QAction("Open JSON", this);
actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
actionLoadJSON->setStatusTip("Open an existing JSON file");
actionLoadJSON->setEnabled(true);
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
- actionLoadPCF = new QAction("Open PCF", this);
+ actionLoadPCF = new QAction("Open PCF", this);
actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
actionLoadPCF->setStatusTip("Open PCF file");
actionLoadPCF->setEnabled(false);
connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
- actionPack = new QAction("Pack", this);
+ actionPack = new QAction("Pack", this);
actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
actionPack->setStatusTip("Pack current design");
actionPack->setEnabled(false);
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
- actionAssignBudget = new QAction("Assign Budget", this);
+ actionAssignBudget = new QAction("Assign Budget", this);
actionAssignBudget->setIcon(QIcon(":/icons/resources/time_add.png"));
actionAssignBudget->setStatusTip("Assign time budget for current design");
actionAssignBudget->setEnabled(false);
connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
- actionPlace = new QAction("Place", this);
+ actionPlace = new QAction("Place", this);
actionPlace->setIcon(QIcon(":/icons/resources/place.png"));
actionPlace->setStatusTip("Place current design");
actionPlace->setEnabled(false);
connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
- actionRoute = new QAction("Route", this);
+ actionRoute = new QAction("Route", this);
actionRoute->setIcon(QIcon(":/icons/resources/route.png"));
actionRoute->setStatusTip("Route current design");
actionRoute->setEnabled(false);
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
- actionSaveAsc = new QAction("Save ASC", this);
+ actionSaveAsc = new QAction("Save ASC", this);
actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
actionSaveAsc->setStatusTip("Save ASC file");
actionSaveAsc->setEnabled(false);
@@ -132,19 +132,19 @@ void MainWindow::createMenu()
menu_Design->addAction(actionRoute);
menu_Design->addAction(actionSaveAsc);
- actionPlay = new QAction("Play", this);
+ actionPlay = new QAction("Play", this);
actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
actionPlay->setStatusTip("Continue running task");
actionPlay->setEnabled(false);
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
- actionPause = new QAction("Pause", this);
+ actionPause = new QAction("Pause", this);
actionPause->setIcon(QIcon(":/icons/resources/control_pause.png"));
actionPause->setStatusTip("Pause running task");
actionPause->setEnabled(false);
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
- actionStop = new QAction("Stop", this);
+ actionStop = new QAction("Stop", this);
actionStop->setIcon(QIcon(":/icons/resources/control_stop.png"));
actionStop->setStatusTip("Stop running task");
actionStop->setEnabled(false);