branchitem.cpp
author insilmaril
Thu, 01 Oct 2009 13:23:20 +0000
changeset 800 959bd133cd1a
parent 798 d251c7b2de54
child 804 14f2b1b15242
permissions -rw-r--r--
preparing sortFilter
insilmaril@747
     1
#include "branchitem.h"
insilmaril@747
     2
#include "branchobj.h"
insilmaril@753
     3
#include "vymmodel.h"
insilmaril@790
     4
#include "xlinkitem.h"
insilmaril@747
     5
insilmaril@747
     6
#include <iostream>
insilmaril@753
     7
#include <QDir>
insilmaril@753
     8
insilmaril@747
     9
using namespace std;
insilmaril@747
    10
insilmaril@779
    11
BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
insilmaril@747
    12
{
insilmaril@749
    13
	//cout << "Constr. BranchItem\n";
insilmaril@749
    14
insilmaril@791
    15
	// Set type if parent is known yet 
insilmaril@791
    16
	// if not, type is set in insertBranch or TreeItem::appendChild
insilmaril@788
    17
	if (parent==rootItem)
insilmaril@788
    18
		setType (MapCenter);
insilmaril@788
    19
	else
insilmaril@788
    20
		setType (Branch);
insilmaril@788
    21
insilmaril@749
    22
	scrolled=false;
insilmaril@749
    23
	tmpUnscrolled=false;
insilmaril@785
    24
insilmaril@785
    25
	includeImagesVer=false;
insilmaril@785
    26
	includeImagesHor=false;
insilmaril@787
    27
	 
insilmaril@787
    28
	lastSelectedBranchNum=-1;
insilmaril@787
    29
	lastSelectedBranchNumAlt=-1;
insilmaril@747
    30
}
insilmaril@747
    31
insilmaril@747
    32
BranchItem::~BranchItem()
insilmaril@747
    33
{
insilmaril@788
    34
	//cout << "Destr. BranchItem "<<getHeadingStd()<<endl;
insilmaril@756
    35
	if (lmo) 
insilmaril@756
    36
	{
insilmaril@756
    37
		delete lmo;
insilmaril@756
    38
		lmo=NULL;
insilmaril@756
    39
	}
insilmaril@747
    40
}
insilmaril@747
    41
insilmaril@749
    42
void BranchItem::copy (BranchItem *other)
insilmaril@749
    43
{
insilmaril@749
    44
	scrolled=other->scrolled;
insilmaril@749
    45
	tmpUnscrolled=other->tmpUnscrolled;
insilmaril@749
    46
}
insilmaril@749
    47
insilmaril@795
    48
BranchItem* BranchItem::parentBranch ()
insilmaril@795
    49
{
insilmaril@795
    50
	return (BranchItem*) parentItem;
insilmaril@795
    51
}
insilmaril@795
    52
insilmaril@756
    53
void BranchItem::insertBranch (int pos, BranchItem *branch)
insilmaril@756
    54
{
insilmaril@756
    55
	if (pos<0) pos=0;
insilmaril@756
    56
	if (pos>branchCounter) pos=branchCounter;
insilmaril@756
    57
    childItems.insert(pos+branchOffset,branch);
insilmaril@756
    58
	branch->parentItem=this;
insilmaril@791
    59
	branch->rootItem=rootItem;
insilmaril@756
    60
	branch->setModel (model);
insilmaril@791
    61
	if (parentItem==rootItem)
insilmaril@791
    62
		setType (MapCenter);
insilmaril@791
    63
	else
insilmaril@791
    64
		setType (Branch);
insilmaril@791
    65
insilmaril@756
    66
insilmaril@756
    67
	if (branchCounter==0)
insilmaril@756
    68
		branchOffset=childItems.count()-1;
insilmaril@756
    69
	branchCounter++;
insilmaril@756
    70
}
insilmaril@756
    71
insilmaril@771
    72
QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-3 Check if everything is saved...
insilmaril@747
    73
{
insilmaril@747
    74
	// Cloudy stuff can be hidden during exports
insilmaril@748
    75
	if (hidden) return QString();
insilmaril@747
    76
insilmaril@747
    77
    QString s,a;
insilmaril@747
    78
	BranchObj *bo=(BranchObj*)lmo;
insilmaril@747
    79
insilmaril@747
    80
	// Update of note is usually done while unselecting a branch
insilmaril@747
    81
	
insilmaril@747
    82
	QString scrolledAttr;
insilmaril@747
    83
	if (scrolled) 
insilmaril@747
    84
		scrolledAttr=attribut ("scrolled","yes");
insilmaril@747
    85
	else
insilmaril@747
    86
		scrolledAttr="";
insilmaril@747
    87
insilmaril@775
    88
	// save area, if not scrolled	// FIXME-5 not needed if HTML is rewritten...
insilmaril@768
    89
									// also we should check if _any_ of parents is scrolled
insilmaril@747
    90
	QString areaAttr;
insilmaril@775
    91
	if (lmo && parentItem->isBranchLikeType() && !((BranchItem*)parentItem)->isScrolled() )
insilmaril@747
    92
	{
insilmaril@775
    93
		qreal x=lmo->getAbsPos().x();
insilmaril@775
    94
		qreal y=lmo->getAbsPos().y();
insilmaril@747
    95
		areaAttr=
insilmaril@775
    96
			attribut("x1",QString().setNum(x-offset.x())) +
insilmaril@775
    97
			attribut("y1",QString().setNum(y-offset.y())) +
insilmaril@775
    98
			attribut("x2",QString().setNum(x+lmo->width()-offset.x())) +
insilmaril@775
    99
			attribut("y2",QString().setNum(y+lmo->height()-offset.y()));
insilmaril@747
   100
insilmaril@747
   101
	} else
insilmaril@747
   102
		areaAttr="";
insilmaril@747
   103
	
insilmaril@790
   104
	// Provide an ID for a branch makes export to XHTML easier
insilmaril@747
   105
	QString idAttr;
insilmaril@790
   106
	if (xlinkCount()>0)
insilmaril@790
   107
		idAttr=attribut ("id",model->getSelectString(this)); 
insilmaril@747
   108
	else
insilmaril@747
   109
		idAttr="";
insilmaril@747
   110
insilmaril@773
   111
	QString elementName;
insilmaril@773
   112
	if (parentItem==rootItem)
insilmaril@773
   113
		elementName="mapcenter";
insilmaril@773
   114
	else	
insilmaril@773
   115
		elementName="branch";
insilmaril@773
   116
insilmaril@773
   117
    s=beginElement (elementName
insilmaril@779
   118
		+getMapAttr()
insilmaril@779
   119
		+getGeneralAttr()
insilmaril@768
   120
		+scrolledAttr 
insilmaril@790
   121
	//	+areaAttr	// FIXME-2
insilmaril@790
   122
		+idAttr 
insilmaril@785
   123
		+getIncludeImageAttr() 
insilmaril@747
   124
		);
insilmaril@747
   125
    incIndent();
insilmaril@747
   126
insilmaril@747
   127
	// save heading
insilmaril@747
   128
    s+=valueElement("heading", getHeading(),
insilmaril@747
   129
		attribut ("textColor",QColor( bo->getColor()).name()));
insilmaril@747
   130
insilmaril@777
   131
	// Save frame  //FIXME-4 not saved if there is no LMO
insilmaril@777
   132
	if (lmo && ((OrnamentedObj*)lmo)->getFrame()->getFrameType()!=FrameObj::NoFrame) 
insilmaril@777
   133
		s+=((OrnamentedObj*)lmo)->getFrame()->saveToDir ();
insilmaril@747
   134
insilmaril@747
   135
	// save names of flags set
insilmaril@768
   136
	s+=standardFlags.saveToDir(tmpdir,prefix,0);
insilmaril@747
   137
	
insilmaril@776
   138
	// Save Images
insilmaril@776
   139
	for (int i=0; i<imageCount(); ++i)
insilmaril@776
   140
		s+=getImageNum(i)->saveToDir (tmpdir,prefix);
insilmaril@747
   141
insilmaril@747
   142
	// save note
insilmaril@747
   143
	if (!note.isEmpty() )
insilmaril@747
   144
		s+=note.saveToDir();
insilmaril@747
   145
	
insilmaril@747
   146
	// Save branches
insilmaril@760
   147
	int i=0;
insilmaril@760
   148
	TreeItem *ti=getBranchNum(i);
insilmaril@760
   149
	while (ti)
insilmaril@760
   150
	{
insilmaril@760
   151
		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
insilmaril@760
   152
		i++;
insilmaril@760
   153
		ti=getBranchNum(i);
insilmaril@760
   154
	}	
insilmaril@747
   155
insilmaril@790
   156
	// Save XLinks 
insilmaril@747
   157
	QString ol;	// old link
insilmaril@747
   158
	QString cl;	// current link
insilmaril@790
   159
	for (int i=0; i<xlinkCount(); ++i)
insilmaril@747
   160
	{
insilmaril@790
   161
		cl=getXLinkNum(i)->saveToDir();
insilmaril@747
   162
		if (cl!=ol)
insilmaril@747
   163
		{
insilmaril@747
   164
			s+=cl;
insilmaril@747
   165
			ol=cl;
insilmaril@747
   166
		} else
insilmaril@747
   167
		{
insilmaril@747
   168
			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
insilmaril@747
   169
		}
insilmaril@747
   170
	}	
insilmaril@747
   171
insilmaril@747
   172
    decIndent();
insilmaril@773
   173
    s+=endElement   (elementName);
insilmaril@747
   174
    return s;
insilmaril@747
   175
}
insilmaril@747
   176
insilmaril@781
   177
void BranchItem::updateVisibility()	
insilmaril@753
   178
{
insilmaril@781
   179
	// Needed to hide relinked branch, if parent is scrolled
insilmaril@781
   180
	if (lmo)
insilmaril@781
   181
		lmo->setVisibility(!((BranchItem*)parentItem)->isScrolled());
insilmaril@753
   182
}
insilmaril@753
   183
insilmaril@758
   184
void BranchItem::setHeadingColor (QColor color)
insilmaril@758
   185
{
insilmaril@758
   186
	TreeItem::setHeadingColor (color);
insilmaril@758
   187
	if (lmo) ((BranchObj*)lmo)->setColor (color);
insilmaril@758
   188
}
insilmaril@758
   189
insilmaril@749
   190
void BranchItem::unScroll()
insilmaril@749
   191
{
insilmaril@749
   192
	if (tmpUnscrolled) resetTmpUnscroll();
insilmaril@749
   193
	if (scrolled) toggleScroll();
insilmaril@749
   194
}
insilmaril@747
   195
insilmaril@767
   196
bool BranchItem::toggleScroll()	
insilmaril@749
   197
{
insilmaril@763
   198
	BranchObj *bo=NULL;
insilmaril@749
   199
	if (scrolled)
insilmaril@749
   200
	{
insilmaril@749
   201
		scrolled=false;
insilmaril@767
   202
		systemFlags.deactivate("system-scrolledright");
insilmaril@767
   203
		if (branchCounter>0)
insilmaril@763
   204
		{
insilmaril@767
   205
			for (int i=0;i<branchCounter;++i)
insilmaril@767
   206
			{
insilmaril@767
   207
				bo=(BranchObj*)(getBranchNum(i)->getLMO());
insilmaril@767
   208
				if (bo) bo->setVisibility(true);
insilmaril@767
   209
			}
insilmaril@763
   210
		}
insilmaril@749
   211
	} else
insilmaril@749
   212
	{
insilmaril@749
   213
		scrolled=true;
insilmaril@767
   214
		systemFlags.activate("system-scrolledright");
insilmaril@767
   215
		if (branchCounter>0)
insilmaril@763
   216
		{
insilmaril@767
   217
			for (int i=0;i<branchCounter;++i)
insilmaril@767
   218
			{
insilmaril@767
   219
				bo=(BranchObj*)(getBranchNum(i)->getLMO());
insilmaril@767
   220
				if (bo) bo->setVisibility(false);
insilmaril@767
   221
			}
insilmaril@763
   222
		}
insilmaril@749
   223
	}
insilmaril@795
   224
	//model->reposition();	// FIXME-3 we don't really want to update view from here...
insilmaril@767
   225
	return true;
insilmaril@749
   226
}
insilmaril@749
   227
insilmaril@749
   228
bool BranchItem::isScrolled()
insilmaril@749
   229
{
insilmaril@749
   230
	return scrolled;
insilmaril@749
   231
}
insilmaril@749
   232
insilmaril@749
   233
bool BranchItem::hasScrolledParent(BranchItem *start)
insilmaril@749
   234
{
insilmaril@749
   235
	// Calls parents recursivly to
insilmaril@749
   236
	// find out, if we are scrolled at all.
insilmaril@749
   237
	// But ignore myself, just look at parents.
insilmaril@749
   238
insilmaril@749
   239
	if (this !=start && scrolled) return true;
insilmaril@749
   240
insilmaril@749
   241
	BranchItem* bi=(BranchItem*)parentItem;
insilmaril@796
   242
	if (bi && bi!=rootItem ) 
insilmaril@749
   243
		return bi->hasScrolledParent(start);
insilmaril@749
   244
	else
insilmaril@749
   245
		return false;
insilmaril@749
   246
}
insilmaril@749
   247
insilmaril@796
   248
bool BranchItem::tmpUnscroll()
insilmaril@749
   249
{
insilmaril@796
   250
	bool result=false;
insilmaril@796
   251
insilmaril@749
   252
	// Unscroll parent (recursivly)
insilmaril@775
   253
	BranchItem * pi=(BranchItem*)parentItem;
insilmaril@796
   254
	if (pi && pi->isBranchLikeType() ) result=pi->tmpUnscroll();
insilmaril@749
   255
		
insilmaril@749
   256
	// Unscroll myself
insilmaril@749
   257
	if (scrolled)
insilmaril@749
   258
	{
insilmaril@749
   259
		tmpUnscrolled=true;
insilmaril@775
   260
		systemFlags.activate("system-tmpUnscrolledRight");
insilmaril@749
   261
		toggleScroll();
insilmaril@775
   262
		model->emitDataHasChanged (this);
insilmaril@796
   263
		result=true;
insilmaril@749
   264
	}	
insilmaril@796
   265
	return result;
insilmaril@749
   266
}
insilmaril@749
   267
insilmaril@796
   268
bool BranchItem::resetTmpUnscroll()
insilmaril@749
   269
{
insilmaril@796
   270
	bool result=false;
insilmaril@796
   271
insilmaril@749
   272
	// Unscroll parent (recursivly)
insilmaril@775
   273
	BranchItem * pi=(BranchItem*)parentItem;
insilmaril@796
   274
	if (pi && pi->isBranchLikeType() ) result=pi->resetTmpUnscroll();
insilmaril@749
   275
		
insilmaril@749
   276
	// Unscroll myself
insilmaril@749
   277
	if (tmpUnscrolled)
insilmaril@749
   278
	{
insilmaril@749
   279
		tmpUnscrolled=false;
insilmaril@775
   280
		systemFlags.deactivate("system-tmpUnscrolledRight");
insilmaril@749
   281
		toggleScroll();
insilmaril@775
   282
		model->emitDataHasChanged (this);
insilmaril@796
   283
		result=true;
insilmaril@749
   284
	}	
insilmaril@796
   285
	return result;
insilmaril@749
   286
}
insilmaril@749
   287
insilmaril@795
   288
void BranchItem::sortChildren()
insilmaril@795
   289
{
insilmaril@795
   290
	int childCount=branchCounter; 
insilmaril@795
   291
	int curChildIndex;
insilmaril@795
   292
	bool madeChanges=false;
insilmaril@795
   293
	do
insilmaril@795
   294
	{
insilmaril@795
   295
		madeChanges=false;
insilmaril@795
   296
		for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
insilmaril@795
   297
			BranchItem* curChild =getBranchNum(curChildIndex);
insilmaril@795
   298
			BranchItem* prevChild=getBranchNum(curChildIndex-1);
insilmaril@795
   299
			if(prevChild->getHeading().compare(curChild->getHeading())>0)
insilmaril@795
   300
			{
insilmaril@795
   301
				model->moveUp(curChild);
insilmaril@795
   302
				madeChanges=true;
insilmaril@795
   303
			}
insilmaril@795
   304
		}
insilmaril@795
   305
	}while(madeChanges);
insilmaril@795
   306
}
insilmaril@795
   307
insilmaril@785
   308
void BranchItem::setIncludeImagesVer(bool b)
insilmaril@785
   309
{
insilmaril@785
   310
	includeImagesVer=b;
insilmaril@795
   311
	/* calcBBoxSize(); FIXME-3
insilmaril@785
   312
	positionBBox();
insilmaril@785
   313
	requestReposition();
insilmaril@785
   314
	*/
insilmaril@785
   315
}
insilmaril@785
   316
insilmaril@785
   317
bool BranchItem::getIncludeImagesVer()
insilmaril@785
   318
{
insilmaril@785
   319
	return includeImagesVer;
insilmaril@785
   320
}
insilmaril@785
   321
insilmaril@785
   322
void BranchItem::setIncludeImagesHor(bool b)
insilmaril@785
   323
{
insilmaril@785
   324
	includeImagesHor=b;
insilmaril@795
   325
	/* calcBBoxSize(); FIXME-3
insilmaril@785
   326
	positionBBox();
insilmaril@785
   327
	requestReposition();
insilmaril@785
   328
	*/
insilmaril@785
   329
}
insilmaril@785
   330
insilmaril@785
   331
bool BranchItem::getIncludeImagesHor()
insilmaril@785
   332
{
insilmaril@785
   333
	return includeImagesHor;
insilmaril@785
   334
}
insilmaril@785
   335
insilmaril@785
   336
QString BranchItem::getIncludeImageAttr()
insilmaril@785
   337
{
insilmaril@785
   338
	QString a;
insilmaril@785
   339
	if (includeImagesVer)
insilmaril@785
   340
		a=attribut ("incImgV","true");
insilmaril@785
   341
	if (includeImagesHor)
insilmaril@785
   342
		a+=attribut ("incImgH","true");
insilmaril@785
   343
	return a;	
insilmaril@785
   344
}
insilmaril@785
   345
insilmaril@787
   346
void BranchItem::setLastSelectedBranch()
insilmaril@787
   347
{
insilmaril@787
   348
	int d=depth();
insilmaril@787
   349
	if (d>=0)
insilmaril@787
   350
	{
insilmaril@787
   351
		if (d==1)
insilmaril@787
   352
			// Hack to save an additional lastSelected for mapcenters in MapEditor
insilmaril@787
   353
			// depending on orientation
insilmaril@787
   354
			// this allows to go both left and right from there
insilmaril@787
   355
			if (lmo && lmo->getOrientation()==LinkableMapObj::LeftOfCenter)
insilmaril@787
   356
			{
insilmaril@787
   357
				((BranchItem*)parentItem)->lastSelectedBranchNumAlt=parentItem->num(this);
insilmaril@787
   358
				return;
insilmaril@787
   359
			}
insilmaril@787
   360
		((BranchItem*)parentItem)->lastSelectedBranchNum=parentItem->num(this);
insilmaril@787
   361
	}
insilmaril@787
   362
}
insilmaril@787
   363
insilmaril@787
   364
void BranchItem::setLastSelectedBranch(int i)
insilmaril@787
   365
{
insilmaril@787
   366
		lastSelectedBranchNum=i;
insilmaril@787
   367
}
insilmaril@787
   368
insilmaril@787
   369
BranchItem* BranchItem::getLastSelectedBranch()
insilmaril@787
   370
{
insilmaril@787
   371
	return getBranchNum (lastSelectedBranchNum);
insilmaril@787
   372
}
insilmaril@787
   373
insilmaril@787
   374
BranchItem* BranchItem::getLastSelectedBranchAlt()
insilmaril@787
   375
{
insilmaril@787
   376
	return getBranchNum (lastSelectedBranchNumAlt);
insilmaril@787
   377
}
insilmaril@787
   378
insilmaril@787
   379
insilmaril@787
   380
insilmaril@785
   381
insilmaril@785
   382
insilmaril@758
   383
TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI)
insilmaril@754
   384
{
insilmaril@754
   385
	// Search branches
insilmaril@754
   386
	TreeItem *ti;
insilmaril@754
   387
	for (int i=0; i<branchCount(); ++i)
insilmaril@754
   388
    {	
insilmaril@758
   389
		ti=getBranchNum(i)->findMapItem(p, excludeTI);
insilmaril@754
   390
		if (ti != NULL) return ti;
insilmaril@754
   391
    }
insilmaril@754
   392
	
insilmaril@754
   393
insilmaril@754
   394
	// Search myself
insilmaril@758
   395
    if (getBranchObj()->isInClickBox (p) && (this != excludeTI) && getBranchObj()->isVisibleObj() ) 
insilmaril@754
   396
		return this;
insilmaril@754
   397
insilmaril@776
   398
	// Search images
insilmaril@776
   399
	ImageItem *ii;
insilmaril@776
   400
    for (int i=0; i<imageCount(); ++i )
insilmaril@776
   401
	{
insilmaril@776
   402
		ii=getImageNum (i);
insilmaril@776
   403
		LinkableMapObj *mo=ii->getLMO();
insilmaril@776
   404
		if (mo && mo->isInClickBox(p) && 
insilmaril@776
   405
			(ii != excludeTI) && 
insilmaril@776
   406
			this!= excludeTI &&
insilmaril@776
   407
			mo->isVisibleObj() 
insilmaril@776
   408
		) return ii;
insilmaril@776
   409
	}
insilmaril@776
   410
	return NULL;
insilmaril@754
   411
}
insilmaril@795
   412
/*
insilmaril@790
   413
TreeItem* BranchItem::findID (QString sid)	//FIXME-3 move to TreeItem	//FIXME-4 search images
insilmaril@754
   414
{
insilmaril@754
   415
	// Search branches
insilmaril@754
   416
    TreeItem *ti;
insilmaril@754
   417
	for (int i=0; i<branchCount(); ++i)
insilmaril@754
   418
    {	
insilmaril@754
   419
		ti=getBranchNum(i)->findID (sid);
insilmaril@754
   420
		if (ti != NULL) return ti;
insilmaril@754
   421
    }
insilmaril@754
   422
	
insilmaril@754
   423
	// Search myself
insilmaril@754
   424
	if (sid==objID) return this;
insilmaril@754
   425
insilmaril@754
   426
insilmaril@790
   427
	// Search float images 
insilmaril@754
   428
    for (int i=0; i<floatimage.size(); ++i )
insilmaril@754
   429
		if (floatimage.at(i)->inBox(p) && 
insilmaril@754
   430
			(floatimage.at(i) != excludeLMO) && 
insilmaril@754
   431
			floatimage.at(i)->getParObj()!= excludeLMO &&
insilmaril@754
   432
			floatimage.at(i)->isVisibleObj() 
insilmaril@754
   433
		) return floatimage.at(i);
insilmaril@754
   434
    return NULL;
insilmaril@754
   435
}
insilmaril@795
   436
*/
insilmaril@773
   437
void BranchItem::updateStyles()
insilmaril@773
   438
{
insilmaril@773
   439
	// FIXME-5 compare also MapItem::initLMO...
insilmaril@773
   440
insilmaril@798
   441
	if (lmo)
insilmaril@798
   442
	{ 
insilmaril@798
   443
		if ( parentItem != rootItem)
insilmaril@798
   444
			lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
insilmaril@798
   445
		else
insilmaril@798
   446
			lmo->setParObj (NULL);
insilmaril@798
   447
		((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch);
insilmaril@773
   448
	}
insilmaril@773
   449
}
insilmaril@754
   450
insilmaril@750
   451
BranchObj* BranchItem::getBranchObj()	// FIXME-3 only for transition BO->BI
insilmaril@750
   452
{
insilmaril@750
   453
	return (BranchObj*)lmo;
insilmaril@750
   454
}
insilmaril@749
   455
insilmaril@786
   456
BranchObj* BranchItem::createMapObj(QGraphicsScene *scene)	// FIXME-4 maybe move this into MapEditor to get rid of scene in VymModel?
insilmaril@755
   457
{
insilmaril@773
   458
	BranchObj *newbo;
insilmaril@790
   459
	newbo=new BranchObj(scene,this);
insilmaril@775
   460
	lmo=newbo;
insilmaril@775
   461
insilmaril@773
   462
	if (parentItem==rootItem)
insilmaril@773
   463
	{
insilmaril@773
   464
		newbo->setParObj(NULL);
insilmaril@798
   465
		//newbo->setFrameType (FrameObj::Rectangle);	//FIXME-4 maybe call updateStyles?
insilmaril@773
   466
	} else
insilmaril@773
   467
	{
insilmaril@779
   468
		newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
insilmaril@775
   469
		// Set visibility depending on parents
insilmaril@791
   470
		if (parentItem!=rootItem && 
insilmaril@791
   471
			( ((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() ) )
insilmaril@775
   472
			newbo->setVisibility (false);
insilmaril@773
   473
	}
insilmaril@775
   474
	newbo->setDefAttr(BranchObj::NewBranch);
insilmaril@760
   475
	initLMO();
insilmaril@758
   476
insilmaril@758
   477
	if (!getHeading().isEmpty() ) 
insilmaril@758
   478
	{
insilmaril@775
   479
		newbo->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
insilmaril@775
   480
		newbo->setColor (headingColor);
insilmaril@758
   481
	}	
insilmaril@758
   482
		
insilmaril@779
   483
	//newbo->updateLinkGeometry();	//FIXME-3
insilmaril@755
   484
insilmaril@755
   485
	return newbo;
insilmaril@755
   486
}
insilmaril@755
   487