-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistview.cpp
More file actions
44 lines (36 loc) · 1.13 KB
/
listview.cpp
File metadata and controls
44 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "listview.h"
ListView::ListView(QWidget *parent) : QWidget(parent)
{
myLayout=new QVBoxLayout(this);
this->setLayout(myLayout);
}
void ListView::update(QObject * sender){
Q_UNUSED (sender);
source=Engine::getInstance()->getGraph();
QLayoutItem *wItem;
while (true){
wItem=this->myLayout->takeAt(0);
if(!wItem){
break;
}
delete wItem->widget();
delete wItem;
}
delete myLayout;
myLayout=new QVBoxLayout(this);
this->setLayout(myLayout);
std::vector<std::vector<int> > list=source->getAdjacencyList();
for(unsigned i=0;i<list.size();i++){
if(list[i].size()>0){
ListViewItem * item=new ListViewItem(this,i,list[i],source->getVerticesNumber());
connect(item,SIGNAL(remove(int,int)),this,SLOT(removeRequest(int,int)));
item->setContentsMargins(0,-12,0,-12);
item->setMaximumHeight(20);
myLayout->addWidget(item,Qt::AlignTop);
}
}
}
void ListView::removeRequest(int firstID, int secondID){
source->disconnectVertices(firstID,secondID);
emit changed(this);
}