mapcenteritem.cpp
author insilmaril
Mon, 18 May 2009 11:22:41 +0000
changeset 771 01f2f6d6789d
parent 770 57ce1ba6d1cb
child 772 e3f722759c7e
permissions -rw-r--r--
Fixed addBranchBefore
     1 #include "mapcenteritem.h"
     2 #include "mapcenterobj.h"
     3 
     4 #include <iostream>
     5 using namespace std;
     6 
     7 MapCenterItem::MapCenterItem(const QList<QVariant> &data, TreeItem *parent):BranchItem (data,parent)
     8 {
     9 	//cout << "Constr. MapCenterItem\n";
    10 	type=MapCenter;
    11 }
    12 
    13 MapCenterItem::~MapCenterItem()
    14 {
    15 	cout << "Destr. MapCenterItem\n";
    16     qDeleteAll(childItems);
    17 }
    18 
    19 QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)	//FIXME-3 Check if everything is saved...
    20 {
    21 	// Cloudy stuff can be hidden during exports
    22 	if (hidden) return QString();
    23 
    24     QString s,a;
    25 	BranchObj *bo=(BranchObj*)lmo;
    26 
    27 	QString scrolledAttr;
    28 	if (scrolled) 
    29 		scrolledAttr=attribut ("scrolled","yes");
    30 	else
    31 		scrolledAttr="";
    32 
    33 	/* 
    34 	// save area, if not scrolled
    35 	QString areaAttr;
    36 	if (!((BranchObj*)(parObj))->isScrolled() )
    37 	{
    38 		areaAttr=
    39 			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
    40 			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
    41 			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
    42 			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
    43 
    44 	} else
    45 		areaAttr="";
    46 	
    47 	// Providing an ID for a branch makes export to XHTML easier
    48 	QString idAttr;
    49 	if (countXLinks()>0)
    50 		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
    51 	else
    52 		idAttr="";
    53 
    54 	*/
    55     s=beginElement ("mapcenter" 
    56 		+getAttr()
    57 	//	+getOrnXMLAttr() 
    58 		+scrolledAttr 
    59 	//	+areaAttr 
    60 	//	+idAttr 
    61 	//	+getIncludeImageAttr() 
    62 		);
    63     incIndent();
    64 
    65 	// save heading
    66     s+=valueElement("heading", getHeading(),
    67 		attribut ("textColor",QColor( bo->getColor()).name()));
    68 
    69 /*
    70 	// Save frame
    71 	if (frame->getFrameType()!=FrameObj::NoFrame) 
    72 		s+=frame->saveToDir ();
    73 
    74 	// save names of flags set
    75 	s+=standardFlags->saveToDir(tmpdir,prefix,0);
    76 	
    77 	// Save FloatImages
    78 	for (int i=0; i<floatimage.size(); ++i)
    79 		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
    80 */
    81 
    82 	// save note
    83 	if (!note.isEmpty() )
    84 		s+=note.saveToDir();
    85 	
    86 	// Save branches
    87 	int i=0;
    88 	TreeItem *ti=getBranchNum(i);
    89 	while (ti)
    90 	{
    91 		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
    92 		i++;
    93 		ti=getBranchNum(i);
    94 	}	
    95 
    96 
    97 	/*
    98 	// Save XLinks
    99 	QString ol;	// old link
   100 	QString cl;	// current link
   101 	for (int i=0; i<xlink.size(); ++i)
   102 	{
   103 		cl=xlink.at(i)->saveToDir();
   104 		if (cl!=ol)
   105 		{
   106 			s+=cl;
   107 			ol=cl;
   108 		} else
   109 		{
   110 			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
   111 		}
   112 	}	
   113 	*/
   114 
   115     decIndent();
   116     s+=endElement   ("mapcenter");
   117     return s;
   118 }
   119 
   120 BranchObj* MapCenterItem::createMapObj(QGraphicsScene *scene)	
   121 {
   122 	// Initialize MapCenterObj, order of things is important...
   123     MapCenterObj* mco=new MapCenterObj(scene);
   124 	lmo=mco;
   125     mco->setParObj(NULL);
   126 	mco->setModel (model);
   127 	mco->setTreeItem (this);
   128 	mco->setDefAttr(BranchObj::NewBranch);
   129 
   130 	initLMO();
   131 
   132 	if (!getHeading().isEmpty() ) 
   133 	{
   134 		mco->updateData();	//FIXME-3 better call model->emitDataHasChanged(treeItem);
   135 		mco->setColor (headingColor);
   136 	}	
   137 		
   138 	//mco->updateLink();	//FIXME-3
   139 
   140 	return mco;
   141 }
   142 
   143