make linked items clickable
This commit is contained in:
parent
bf0b1d2db3
commit
3eb34bf38b
@ -155,6 +155,9 @@ DesignWidget::~DesignWidget() {}
|
|||||||
void DesignWidget::newContext(Context *ctx)
|
void DesignWidget::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
treeWidget->clear();
|
treeWidget->clear();
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
nameToItem[i].clear();
|
||||||
|
|
||||||
this->ctx = ctx;
|
this->ctx = ctx;
|
||||||
|
|
||||||
// Add bels to tree
|
// Add bels to tree
|
||||||
@ -174,7 +177,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!bel_items.contains(name)) {
|
if (!bel_items.contains(name)) {
|
||||||
if (i == items.size() - 1)
|
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
|
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));
|
||||||
}
|
}
|
||||||
@ -185,6 +188,9 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
for (auto bel : bel_items.toStdMap()) {
|
for (auto bel : bel_items.toStdMap()) {
|
||||||
bel_root->addChild(bel.second);
|
bel_root->addChild(bel.second);
|
||||||
}
|
}
|
||||||
|
for (auto bel : nameToItem[0].toStdMap()) {
|
||||||
|
bel_root->addChild(bel.second);
|
||||||
|
}
|
||||||
|
|
||||||
// Add wires to tree
|
// Add wires to tree
|
||||||
QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget);
|
QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget);
|
||||||
@ -203,7 +209,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!wire_items.contains(name)) {
|
if (!wire_items.contains(name)) {
|
||||||
if (i == items.size() - 1)
|
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
|
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));
|
||||||
}
|
}
|
||||||
@ -214,7 +220,9 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
for (auto wire : wire_items.toStdMap()) {
|
for (auto wire : wire_items.toStdMap()) {
|
||||||
wire_root->addChild(wire.second);
|
wire_root->addChild(wire.second);
|
||||||
}
|
}
|
||||||
|
for (auto wire : nameToItem[1].toStdMap()) {
|
||||||
|
wire_root->addChild(wire.second);
|
||||||
|
}
|
||||||
// Add pips to tree
|
// Add pips to tree
|
||||||
QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget);
|
QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget);
|
||||||
QMap<QString, QTreeWidgetItem *> pip_items;
|
QMap<QString, QTreeWidgetItem *> pip_items;
|
||||||
@ -232,7 +240,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!pip_items.contains(name)) {
|
if (!pip_items.contains(name)) {
|
||||||
if (i == items.size() - 1)
|
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
|
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));
|
||||||
}
|
}
|
||||||
@ -243,6 +251,9 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
for (auto pip : pip_items.toStdMap()) {
|
for (auto pip : pip_items.toStdMap()) {
|
||||||
pip_root->addChild(pip.second);
|
pip_root->addChild(pip.second);
|
||||||
}
|
}
|
||||||
|
for (auto pip : nameToItem[2].toStdMap()) {
|
||||||
|
pip_root->addChild(pip.second);
|
||||||
|
}
|
||||||
|
|
||||||
// Add nets to tree
|
// Add nets to tree
|
||||||
nets_root = new QTreeWidgetItem(treeWidget);
|
nets_root = new QTreeWidgetItem(treeWidget);
|
||||||
@ -260,36 +271,38 @@ void DesignWidget::updateTree()
|
|||||||
clearProperties();
|
clearProperties();
|
||||||
delete nets_root;
|
delete nets_root;
|
||||||
delete cells_root;
|
delete cells_root;
|
||||||
|
nameToItem[3].clear();
|
||||||
|
nameToItem[4].clear();
|
||||||
|
|
||||||
// Add nets to tree
|
// Add nets to tree
|
||||||
nets_root = new QTreeWidgetItem(treeWidget);
|
nets_root = new QTreeWidgetItem(treeWidget);
|
||||||
QMap<QString, QTreeWidgetItem *> nets_items;
|
|
||||||
nets_root->setText(0, "Nets");
|
nets_root->setText(0, "Nets");
|
||||||
treeWidget->insertTopLevelItem(0, nets_root);
|
treeWidget->insertTopLevelItem(0, nets_root);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
for (auto &item : ctx->nets) {
|
for (auto &item : ctx->nets) {
|
||||||
auto id = item.first;
|
auto id = item.first;
|
||||||
QString name = QString(id.c_str(ctx));
|
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);
|
nets_root->addChild(item.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add cells to tree
|
// Add cells to tree
|
||||||
cells_root = new QTreeWidgetItem(treeWidget);
|
cells_root = new QTreeWidgetItem(treeWidget);
|
||||||
QMap<QString, QTreeWidgetItem *> cells_items;
|
|
||||||
cells_root->setText(0, "Cells");
|
cells_root->setText(0, "Cells");
|
||||||
treeWidget->insertTopLevelItem(0, cells_root);
|
treeWidget->insertTopLevelItem(0, cells_root);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
for (auto &item : ctx->cells) {
|
for (auto &item : ctx->cells) {
|
||||||
auto id = item.first;
|
auto id = item.first;
|
||||||
QString name = QString(id.c_str(ctx));
|
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);
|
cells_root->addChild(item.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,6 +381,20 @@ QString DesignWidget::getElementTypeName(ElementType type)
|
|||||||
return "CELL";
|
return "CELL";
|
||||||
return "";
|
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)
|
ElementType DesignWidget::getElementTypeByName(QString type)
|
||||||
{
|
{
|
||||||
@ -615,7 +642,6 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos)
|
|||||||
|
|
||||||
QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
|
QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
|
||||||
|
|
||||||
// if (((ElementTreeItem*)itemContextMenu)->getType() == ElementType::NONE) return;
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *selectAction = new QAction("&Select", this);
|
QAction *selectAction = new QAction("&Select", this);
|
||||||
connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); });
|
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();
|
QtProperty *selectedProperty = propertyEditor->itemToBrowserItem(item)->property();
|
||||||
ElementType type = getElementTypeByName(selectedProperty->propertyId());
|
ElementType type = getElementTypeByName(selectedProperty->propertyId());
|
||||||
IdString value = ctx->id(selectedProperty->valueText().toStdString());
|
QString value = selectedProperty->valueText();
|
||||||
|
int index = getElementIndex(type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ElementType::NONE:
|
case ElementType::NONE:
|
||||||
return;
|
return;
|
||||||
default:
|
default: {
|
||||||
Q_EMIT info("double clicked " + std::string(value.c_str(ctx)) + "\n");
|
if (nameToItem[index].contains(value))
|
||||||
break;
|
treeWidget->setCurrentItem(nameToItem[index].value(value));
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ class DesignWidget : public QWidget
|
|||||||
const ElementType &type = ElementType::NONE);
|
const ElementType &type = ElementType::NONE);
|
||||||
QString getElementTypeName(ElementType type);
|
QString getElementTypeName(ElementType type);
|
||||||
ElementType getElementTypeByName(QString type);
|
ElementType getElementTypeByName(QString type);
|
||||||
|
int getElementIndex(ElementType type);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void info(std::string text);
|
void info(std::string text);
|
||||||
void selected(std::vector<DecalXY> decal);
|
void selected(std::vector<DecalXY> decal);
|
||||||
@ -83,6 +84,9 @@ class DesignWidget : public QWidget
|
|||||||
|
|
||||||
QMap<QtProperty *, QString> propertyToId;
|
QMap<QtProperty *, QString> propertyToId;
|
||||||
QMap<QString, QtProperty *> idToProperty;
|
QMap<QString, QtProperty *> idToProperty;
|
||||||
|
|
||||||
|
QMap<QString, QTreeWidgetItem *> nameToItem[6];
|
||||||
|
|
||||||
QTreeWidgetItem *nets_root;
|
QTreeWidgetItem *nets_root;
|
||||||
QTreeWidgetItem *cells_root;
|
QTreeWidgetItem *cells_root;
|
||||||
|
|
||||||
|
@ -71,43 +71,43 @@ void MainWindow::createMenu()
|
|||||||
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
||||||
menuBar->addAction(menu_Design->menuAction());
|
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->setIcon(QIcon(":/icons/resources/open_json.png"));
|
||||||
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
|
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->setIcon(QIcon(":/icons/resources/open_pcf.png"));
|
||||||
actionLoadPCF->setStatusTip("Open PCF file");
|
actionLoadPCF->setStatusTip("Open PCF file");
|
||||||
actionLoadPCF->setEnabled(false);
|
actionLoadPCF->setEnabled(false);
|
||||||
connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
|
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->setIcon(QIcon(":/icons/resources/pack.png"));
|
||||||
actionPack->setStatusTip("Pack current design");
|
actionPack->setStatusTip("Pack current design");
|
||||||
actionPack->setEnabled(false);
|
actionPack->setEnabled(false);
|
||||||
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
|
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->setIcon(QIcon(":/icons/resources/time_add.png"));
|
||||||
actionAssignBudget->setStatusTip("Assign time budget for current design");
|
actionAssignBudget->setStatusTip("Assign time budget for current design");
|
||||||
actionAssignBudget->setEnabled(false);
|
actionAssignBudget->setEnabled(false);
|
||||||
connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
|
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->setIcon(QIcon(":/icons/resources/place.png"));
|
||||||
actionPlace->setStatusTip("Place current design");
|
actionPlace->setStatusTip("Place current design");
|
||||||
actionPlace->setEnabled(false);
|
actionPlace->setEnabled(false);
|
||||||
connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
|
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->setIcon(QIcon(":/icons/resources/route.png"));
|
||||||
actionRoute->setStatusTip("Route current design");
|
actionRoute->setStatusTip("Route current design");
|
||||||
actionRoute->setEnabled(false);
|
actionRoute->setEnabled(false);
|
||||||
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
|
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->setIcon(QIcon(":/icons/resources/save_asc.png"));
|
||||||
actionSaveAsc->setStatusTip("Save ASC file");
|
actionSaveAsc->setStatusTip("Save ASC file");
|
||||||
actionSaveAsc->setEnabled(false);
|
actionSaveAsc->setEnabled(false);
|
||||||
@ -132,19 +132,19 @@ void MainWindow::createMenu()
|
|||||||
menu_Design->addAction(actionRoute);
|
menu_Design->addAction(actionRoute);
|
||||||
menu_Design->addAction(actionSaveAsc);
|
menu_Design->addAction(actionSaveAsc);
|
||||||
|
|
||||||
actionPlay = new QAction("Play", this);
|
actionPlay = new QAction("Play", this);
|
||||||
actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
|
actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
|
||||||
actionPlay->setStatusTip("Continue running task");
|
actionPlay->setStatusTip("Continue running task");
|
||||||
actionPlay->setEnabled(false);
|
actionPlay->setEnabled(false);
|
||||||
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
|
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->setIcon(QIcon(":/icons/resources/control_pause.png"));
|
||||||
actionPause->setStatusTip("Pause running task");
|
actionPause->setStatusTip("Pause running task");
|
||||||
actionPause->setEnabled(false);
|
actionPause->setEnabled(false);
|
||||||
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
|
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->setIcon(QIcon(":/icons/resources/control_stop.png"));
|
||||||
actionStop->setStatusTip("Stop running task");
|
actionStop->setStatusTip("Stop running task");
|
||||||
actionStop->setEnabled(false);
|
actionStop->setEnabled(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user