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