25 #include <QHeaderView>
27 #include <qabstractitemview.h>
31 #include <qhashfunctions.h>
32 #include <qheaderview.h>
35 #include <qnamespace.h>
36 #include <qobjectdefs.h>
51 QStringList columns{
"Source",
"Target"};
52 setColumnCount(columns.size());
53 setHorizontalHeaderLabels(columns);
54 horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
55 horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
56 horizontalHeader()->setVisible(
true);
58 setEditTriggers(QAbstractItemView::NoEditTriggers);
59 setSortingEnabled(
true);
61 setAlternatingRowColors(
true);
67 setContextMenuPolicy(Qt::CustomContextMenu);
75 QTableWidgetItem* result =
nullptr;
77 setSortingEnabled(
false);
82 setItem(row, 0,
new QTableWidgetItem{QString::fromStdString(sourceAttrib.
getName())});
83 setItem(row, 1,
new QTableWidgetItem{QString::fromStdString(targetAttrib.
getName())});
85 result = item(row, 0);
87 setSortingEnabled(
true);
97 font.setBold(edge.attrib().highlighted);
99 setSortingEnabled(
false);
101 int row = this->row(edge.attrib().tableWidgetItem);
102 for (
int col = 0; col < 2; ++col)
104 auto* item = this->item(row, col);
107 item->setData(Qt::BackgroundRole, bgColor);
111 setSortingEnabled(
true);
117 if (currentItem() == edge.attrib().tableWidgetItem)
119 setCurrentItem(
nullptr);
122 removeRow(row(edge.attrib().tableWidgetItem));
123 edge.attrib().tableWidgetItem =
nullptr;
126 QList<QTableWidgetItem*>
138 if (items.size() == 0)
140 QAction* action = menu.addAction(
"No edges selected");
141 action->setEnabled(
false);
146 if (items.size() == 1)
149 item(row(items[0]), 1)->text() +
"'";
153 desc = QString::number(items.size()) +
" edges";
156 menu.addSection(
"Selected " + desc);
157 connect(menu.addAction(
"Remove " + desc),
159 [
this, &items]() { emit edgeRemovalRequested(items); });
162 menu.exec(mapToGlobal(pos));