File: xlinkitem.cpp

package info (click to toggle)
vym 2.6.11-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 12,628 kB
  • sloc: cpp: 34,052; ruby: 846; xml: 278; sh: 187; makefile: 28
file content (92 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download | duplicates (4)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <QGraphicsScene>
#include "xlinkitem.h"

#include "branchitem.h"
#include "linkablemapobj.h"
#include "vymmodel.h"
#include "xlinkobj.h"

/////////////////////////////////////////////////////////////////
// XLinkItem
/////////////////////////////////////////////////////////////////

XLinkItem::XLinkItem (const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)

{
    //qDebug() << "Const XLinkItem () "<<this;
    init();
}

XLinkItem::~XLinkItem ()
{
 //   qDebug() << "Destr XLinkItem begin "<<this<<"  pI="<<parentItem<<"  link="<<link;
    if (link)
    {
	XLinkItem *xli=link->getOtherEnd (this);
	if (xli) model->deleteLater (xli->getID());
	model->deleteLink (link);
    }	
//    qDebug() << "Destr XLinkItem end";
}


void XLinkItem::init () 
{
    setType (XLink);
    link=NULL;
}

void XLinkItem::clear() 
{
}

void XLinkItem::setLink (Link *l)
{
    link=l;
}

Link* XLinkItem::getLink ()
{
    return link;
}

void XLinkItem::updateXLink()
{
    if (link)
	link->updateLink();
}

MapObj* XLinkItem::getMO()
{
    if (link)
	return link->getMO();
    return NULL;	
}

void XLinkItem::setSelection()
{
    if (link)
    {
	XLinkObj* xlo=(XLinkObj*)getMO();
	if (xlo) 
	{
	    if (parentItem==link->getBeginBranch() )
		xlo->setSelection(XLinkObj::C0);
	    else if (parentItem==link->getEndBranch() )
		xlo->setSelection(XLinkObj::C1);
	}
    }
}

BranchItem* XLinkItem::getPartnerBranch()
{
    if (link && link->getBeginBranch() && link->getEndBranch())
    {
	if (parentItem==link->getBeginBranch())
	    return link->getEndBranch();
	else	
	    return link->getBeginBranch();
    }
    return NULL;
}