xlinkitem.cpp
author convert-repo
Fri, 23 Jul 2010 16:43:49 +0000
changeset 849 988f1908a7c4
parent 847 43268373032d
permissions -rw-r--r--
update tags
     1 #include <QGraphicsScene>
     2 #include "xlinkitem.h"
     3 
     4 #include "branchitem.h"
     5 #include "linkablemapobj.h"
     6 #include "vymmodel.h"
     7 #include "xlinkobj.h"
     8 
     9 /////////////////////////////////////////////////////////////////
    10 // XLinkItem
    11 /////////////////////////////////////////////////////////////////
    12 
    13 XLinkItem::XLinkItem (const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
    14 
    15 {
    16 	//qDebug() << "Const XLinkItem () "<<this;
    17 	init();
    18 }
    19 
    20 XLinkItem::~XLinkItem ()
    21 {
    22 	//qDebug() << "Destr XLinkItem begin "<<this<<"  pI="<<parentItem<<"  link="<<link;
    23 	if (link)
    24 	{
    25 		// tell the model to remove the link later
    26 		// (and then remove partner link in VymModel::cleanupLinks)
    27 		model->deleteLink (link);
    28 		link->removeXLinkItem (this);
    29 		link->deactivate();
    30 	}	
    31 	//qDebug() << "Destr XLinkItem end"<<this;
    32 }
    33 
    34 
    35 void XLinkItem::init () 
    36 {
    37 	setType (XLink);
    38 	link=NULL;
    39 }
    40 
    41 void XLinkItem::setLink (Link *l)
    42 {
    43 	link=l;
    44 }
    45 
    46 Link* XLinkItem::getLink ()
    47 {
    48 	return link;
    49 }
    50 
    51 void XLinkItem::updateXLink()
    52 {
    53 	qDebug()<<"XLI::updateXLink";
    54 	if (link)
    55 		link->updateLink();
    56 }
    57 
    58 BranchItem* XLinkItem::getPartnerBranch()
    59 {
    60 	if (link && link->getBeginBranch() && link->getEndBranch())
    61 	{
    62 		if (parentItem==link->getBeginBranch())
    63 			return link->getEndBranch();
    64 		else	
    65 			return link->getBeginBranch();
    66 	}
    67 	return NULL;
    68 }
    69