branchitem.cpp
changeset 775 6e4b586aa88a
parent 773 340bc29da9a0
child 776 25e634a7e1dc
     1.1 --- a/branchitem.cpp	Tue May 26 11:24:51 2009 +0000
     1.2 +++ b/branchitem.cpp	Wed Jun 03 20:37:17 2009 +0000
     1.3 @@ -61,22 +61,24 @@
     1.4  	else
     1.5  		scrolledAttr="";
     1.6  
     1.7 -	/* 
     1.8 -	// save area, if not scrolled	// FIXME-3 not needed if HTML is rewritten...
     1.9 +	// save area, if not scrolled	// FIXME-5 not needed if HTML is rewritten...
    1.10  									// also we should check if _any_ of parents is scrolled
    1.11  	QString areaAttr;
    1.12 -	if (!((BranchObj*)(parObj))->isScrolled() )
    1.13 +	if (lmo && parentItem->isBranchLikeType() && !((BranchItem*)parentItem)->isScrolled() )
    1.14  	{
    1.15 +		qreal x=lmo->getAbsPos().x();
    1.16 +		qreal y=lmo->getAbsPos().y();
    1.17  		areaAttr=
    1.18 -			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
    1.19 -			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
    1.20 -			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
    1.21 -			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
    1.22 +			attribut("x1",QString().setNum(x-offset.x())) +
    1.23 +			attribut("y1",QString().setNum(y-offset.y())) +
    1.24 +			attribut("x2",QString().setNum(x+lmo->width()-offset.x())) +
    1.25 +			attribut("y2",QString().setNum(y+lmo->height()-offset.y()));
    1.26  
    1.27  	} else
    1.28  		areaAttr="";
    1.29  	
    1.30 -	// Providing an ID for a branch makes export to XHTML easier
    1.31 +	/*	
    1.32 +	// FIXME-3 Providing an ID for a branch makes export to XHTML easier
    1.33  	QString idAttr;
    1.34  	if (countXLinks()>0)
    1.35  		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
    1.36 @@ -104,8 +106,8 @@
    1.37      s+=valueElement("heading", getHeading(),
    1.38  		attribut ("textColor",QColor( bo->getColor()).name()));
    1.39  
    1.40 -/*
    1.41 -	// Save frame
    1.42 +/*	
    1.43 +	// Save frame  //FIXME-2
    1.44  	if (frame->getFrameType()!=FrameObj::NoFrame) 
    1.45  		s+=frame->saveToDir ();
    1.46  */		
    1.47 @@ -255,7 +257,7 @@
    1.48  	if (this !=start && scrolled) return true;
    1.49  
    1.50  	BranchItem* bi=(BranchItem*)parentItem;
    1.51 -	if (bi) 
    1.52 +	if (bi && bi->isBranchLikeType() ) 
    1.53  		return bi->hasScrolledParent(start);
    1.54  	else
    1.55  		return false;
    1.56 @@ -264,30 +266,32 @@
    1.57  void BranchItem::tmpUnscroll()
    1.58  {
    1.59  	// Unscroll parent (recursivly)
    1.60 -	BranchItem * bi=(BranchItem*)parentItem;
    1.61 -	if (bi) bi->tmpUnscroll();
    1.62 +	BranchItem * pi=(BranchItem*)parentItem;
    1.63 +	if (pi && pi->isBranchLikeType() ) pi->tmpUnscroll();
    1.64  		
    1.65  	// Unscroll myself
    1.66  	if (scrolled)
    1.67  	{
    1.68  		tmpUnscrolled=true;
    1.69 -		// FIXME-1 systemFlags->activate("tmpUnscrolledright");
    1.70 +		systemFlags.activate("system-tmpUnscrolledRight");
    1.71  		toggleScroll();
    1.72 +		model->emitDataHasChanged (this);
    1.73  	}	
    1.74  }
    1.75  
    1.76  void BranchItem::resetTmpUnscroll()
    1.77  {
    1.78  	// Unscroll parent (recursivly)
    1.79 -	BranchItem * bi=(BranchItem*)parentItem;
    1.80 -	if (bi) bi->resetTmpUnscroll();
    1.81 +	BranchItem * pi=(BranchItem*)parentItem;
    1.82 +	if (pi && pi->isBranchLikeType() ) pi->resetTmpUnscroll();
    1.83  		
    1.84  	// Unscroll myself
    1.85  	if (tmpUnscrolled)
    1.86  	{
    1.87  		tmpUnscrolled=false;
    1.88 -		// FIXME-1 systemFlags->deactivate("tmpUnscrolledright");
    1.89 +		systemFlags.deactivate("system-tmpUnscrolledRight");
    1.90  		toggleScroll();
    1.91 +		model->emitDataHasChanged (this);
    1.92  	}	
    1.93  }
    1.94  
    1.95 @@ -361,51 +365,29 @@
    1.96  BranchObj* BranchItem::createMapObj(QGraphicsScene *scene)	
    1.97  {
    1.98  	BranchObj *newbo;
    1.99 -	cout << "BI::createMO  "<<getHeadingStd()<<"  pI="<<parentItem<<"  rI="<<rootItem<<endl;
   1.100 +	newbo=new BranchObj(scene);
   1.101 +	newbo->setTreeItem (this);
   1.102 +	lmo=newbo;
   1.103 +
   1.104  	if (parentItem==rootItem)
   1.105  	{
   1.106 -		// Initialize MapCenterObj, order of things is important...
   1.107 -		cout << "BI::createMO  (MCO) "<<getHeadingStd()<<endl;
   1.108 -		MapCenterObj* mco=new MapCenterObj(scene);
   1.109 -		newbo=mco;
   1.110 -		lmo=mco;
   1.111  		newbo->setParObj(NULL);
   1.112 -		newbo->setTreeItem (this);
   1.113 -		newbo->setDefAttr(BranchObj::NewBranch);
   1.114 +		newbo->setFrameType (FrameObj::Rectangle);
   1.115  	} else
   1.116  	{
   1.117 -	// Initialize BranchObj, order of things is important...
   1.118 -		cout << "BI::createMO  (BO) "<<getHeadingStd()<<endl;
   1.119 -		newbo=new BranchObj(scene);
   1.120 -		lmo=newbo;
   1.121 -		BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
   1.122 -		newbo->setParObj(parbo);
   1.123 -		newbo->setTreeItem (this);
   1.124 -		newbo->setDefAttr(BranchObj::NewBranch);
   1.125 -
   1.126 -		if (parentItem->isBranchLikeType())
   1.127 -		{
   1.128 -			// Set visibility depending on parents
   1.129 -			if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
   1.130 -			{
   1.131 -				if (parentItem && parentItem->isBranchLikeType())
   1.132 -					cout <<"  scrolled="<<((BranchItem*)parentItem)->scrolled<<endl;
   1.133 -				if (parbo)
   1.134 -					cout <<"  par->vis="<<parbo->isVisibleObj()<<endl;
   1.135 -				newbo->setVisibility (false);
   1.136 -			}	
   1.137 -		} else
   1.138 -			cout <<"   pI=no branch!\n";
   1.139 -
   1.140 +		newbo->setParObj(parentItem->getLMO() );
   1.141 +		// Set visibility depending on parents
   1.142 +		if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() )
   1.143 +			newbo->setVisibility (false);
   1.144  	}
   1.145 +	newbo->setDefAttr(BranchObj::NewBranch);
   1.146  	initLMO();
   1.147  
   1.148  	if (!getHeading().isEmpty() ) 
   1.149  	{
   1.150 -		((BranchObj*)lmo)->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
   1.151 -		((BranchObj*)lmo)->setColor (headingColor);
   1.152 +		newbo->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
   1.153 +		newbo->setColor (headingColor);
   1.154  	}	
   1.155 -
   1.156  		
   1.157  	//newbo->updateLink();	//FIXME-3
   1.158