-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddconnection.cpp
More file actions
35 lines (31 loc) · 1.06 KB
/
addconnection.cpp
File metadata and controls
35 lines (31 loc) · 1.06 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
#include "addconnection.h"
#include "ui_addconnection.h"
AddConnection::AddConnection(QWidget *parent) :
QWidget(parent),
ui(new Ui::AddConnection)
{
ui->setupUi(this);
connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(onApplyClicked()));
}
AddConnection::~AddConnection()
{
delete ui;
}
void AddConnection::update(QObject * sender){
if(sender!=this){
this->source=Engine::getInstance()->getGraph();
ui->first->clear();
ui->second->clear();
for(int i=0;i<source->getVerticesNumber();i++){
ui->first->addItem(QString::number(i+1));
ui->second->addItem(QString::number(i+1));
}
}
}
void AddConnection::onApplyClicked(){
if((ui->first->currentText().toInt()-1) !=(ui->second->currentText().toInt()-1)){
source->_adjacencyMatrix[ui->first->currentText().toInt()-1][ui->second->currentText().toInt()-1]=true;
source->_weightMatrix[ui->first->currentText().toInt()-1][ui->second->currentText().toInt()-1]=ui->connectionWeight->value();
emit changed(this);
}
}