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