25 #include <QHeaderView>
36 QStringList columns{
"Source",
"Target"};
37 setColumnCount(columns.size());
38 setHorizontalHeaderLabels(columns);
39 horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
40 horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
41 horizontalHeader()->setVisible(
true);
43 setEditTriggers(QAbstractItemView::NoEditTriggers);
44 setSortingEnabled(
true);
46 setAlternatingRowColors(
true);
52 setContextMenuPolicy(Qt::CustomContextMenu);
61 QTableWidgetItem* result =
nullptr;
63 setSortingEnabled(
false);
68 setItem(row, 0,
new QTableWidgetItem{QString::fromStdString(sourceAttrib.
getName())});
69 setItem(row, 1,
new QTableWidgetItem{QString::fromStdString(targetAttrib.
getName())});
71 result = item(row, 0);
73 setSortingEnabled(
true);
84 font.setBold(edge.attrib().highlighted);
86 setSortingEnabled(
false);
88 int row = this->row(edge.attrib().tableWidgetItem);
89 for (
int col = 0; col < 2; ++col)
91 auto* item = this->item(row, col);
94 item->setData(Qt::BackgroundRole, bgColor);
98 setSortingEnabled(
true);
105 if (currentItem() == edge.attrib().tableWidgetItem)
107 setCurrentItem(
nullptr);
110 removeRow(row(edge.attrib().tableWidgetItem));
111 edge.attrib().tableWidgetItem =
nullptr;
115 QList<QTableWidgetItem*>
128 if (items.size() == 0)
130 QAction* action = menu.addAction(
"No edges selected");
131 action->setEnabled(
false);
136 if (items.size() == 1)
139 item(row(items[0]), 1)->text() +
"'";
143 desc = QString::number(items.size()) +
" edges";
146 menu.addSection(
"Selected " + desc);
147 connect(menu.addAction(
"Remove " + desc),
149 [
this, &items]() { emit edgeRemovalRequested(items); });
152 menu.exec(mapToGlobal(pos));