Beispiel #1
0
covise::WSLink::WSLink(covise::WSPort *from, covise::WSPort *to)
    : QObject(0)
    , fromPort(from)
    , toPort(to)
{
    this->id = makeID(from, to);
    connect(from, SIGNAL(destroyed()), this, SLOT(portDeleted()));
    connect(to, SIGNAL(destroyed()), this, SLOT(portDeleted()));
}
Beispiel #2
0
void RouterItem::changeNumberPorts(int newSize){
	if(numberPorts != newSize){

		numberPorts = newSize;
		int oldSize = childItems().count();

		if(oldSize < numberPorts){
			for(int i=oldSize; i<numberPorts; ++i){
				PortItem *port = new PortItem(this);
				port->setData(5, "Port");
			}
		}

		if(oldSize > numberPorts){
			QList<QGraphicsItem *> list = childItems();
			while(list.size() != numberPorts){

				//удаляем все связи
				PortItem* port = qgraphicsitem_cast<PortItem*>(list.last());
				emit portDeleted(port);

				this->scene()->removeItem(list.last());
				delete list.last();
				list.removeLast();
			}
		}
		setPortsPosition();
	}
}