branchitem.cpp
author insilmaril
Thu, 26 Mar 2009 07:50:32 +0000
changeset 747 008e72977ab8
child 748 edb78a44240b
permissions -rw-r--r--
Notes work again (to some degree)
insilmaril@747
     1
#include "branchitem.h"
insilmaril@747
     2
#include "branchobj.h"
insilmaril@747
     3
insilmaril@747
     4
#include <iostream>
insilmaril@747
     5
using namespace std;
insilmaril@747
     6
insilmaril@747
     7
BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
insilmaril@747
     8
{
insilmaril@747
     9
	cout << "Constr. BranchItem\n";
insilmaril@747
    10
}
insilmaril@747
    11
insilmaril@747
    12
BranchItem::~BranchItem()
insilmaril@747
    13
{
insilmaril@747
    14
	cout << "Destr. BranchItem\n";
insilmaril@747
    15
    qDeleteAll(childItems);
insilmaril@747
    16
}
insilmaril@747
    17
insilmaril@747
    18
QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
insilmaril@747
    19
{
insilmaril@747
    20
	// Cloudy stuff can be hidden during exports
insilmaril@747
    21
	if (hidden) return "";
insilmaril@747
    22
insilmaril@747
    23
    QString s,a;
insilmaril@747
    24
	BranchObj *bo=(BranchObj*)lmo;
insilmaril@747
    25
insilmaril@747
    26
	/* FIXME-1
insilmaril@747
    27
	// Update of note is usually done while unselecting a branch
insilmaril@747
    28
	if (isNoteInEditor) getNoteFromTextEditor();
insilmaril@747
    29
	
insilmaril@747
    30
	QString scrolledAttr;
insilmaril@747
    31
	if (scrolled) 
insilmaril@747
    32
		scrolledAttr=attribut ("scrolled","yes");
insilmaril@747
    33
	else
insilmaril@747
    34
		scrolledAttr="";
insilmaril@747
    35
insilmaril@747
    36
	// save area, if not scrolled
insilmaril@747
    37
	QString areaAttr;
insilmaril@747
    38
	if (!((BranchObj*)(parObj))->isScrolled() )
insilmaril@747
    39
	{
insilmaril@747
    40
		areaAttr=
insilmaril@747
    41
			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
insilmaril@747
    42
			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
insilmaril@747
    43
			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
insilmaril@747
    44
			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
insilmaril@747
    45
insilmaril@747
    46
	} else
insilmaril@747
    47
		areaAttr="";
insilmaril@747
    48
	
insilmaril@747
    49
	// Providing an ID for a branch makes export to XHTML easier
insilmaril@747
    50
	QString idAttr;
insilmaril@747
    51
	if (countXLinks()>0)
insilmaril@747
    52
		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
insilmaril@747
    53
	else
insilmaril@747
    54
		idAttr="";
insilmaril@747
    55
insilmaril@747
    56
	*/
insilmaril@747
    57
    s=beginElement ("branch" 
insilmaril@747
    58
	//	+getOrnXMLAttr() 
insilmaril@747
    59
	//	+scrolledAttr 
insilmaril@747
    60
	//	+areaAttr 
insilmaril@747
    61
	//	+idAttr 
insilmaril@747
    62
	//	+getIncludeImageAttr() 
insilmaril@747
    63
		);
insilmaril@747
    64
    incIndent();
insilmaril@747
    65
insilmaril@747
    66
	// save heading
insilmaril@747
    67
    s+=valueElement("heading", getHeading(),
insilmaril@747
    68
		attribut ("textColor",QColor( bo->getColor()).name()));
insilmaril@747
    69
insilmaril@747
    70
/*
insilmaril@747
    71
	// Save frame
insilmaril@747
    72
	if (frame->getFrameType()!=FrameObj::NoFrame) 
insilmaril@747
    73
		s+=frame->saveToDir ();
insilmaril@747
    74
insilmaril@747
    75
	// save names of flags set
insilmaril@747
    76
	s+=standardFlags->saveToDir(tmpdir,prefix,0);
insilmaril@747
    77
	
insilmaril@747
    78
	// Save FloatImages
insilmaril@747
    79
	for (int i=0; i<floatimage.size(); ++i)
insilmaril@747
    80
		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
insilmaril@747
    81
*/
insilmaril@747
    82
insilmaril@747
    83
	// save note
insilmaril@747
    84
	if (!note.isEmpty() )
insilmaril@747
    85
		s+=note.saveToDir();
insilmaril@747
    86
	
insilmaril@747
    87
	// Save branches
insilmaril@747
    88
	TreeItem *ti=getFirstBranch();
insilmaril@747
    89
	TreeItem *last=getLastBranch();
insilmaril@747
    90
	while (ti && ti!=last) 
insilmaril@747
    91
		s+=ti->saveToDir(tmpdir,prefix,offset);
insilmaril@747
    92
insilmaril@747
    93
	/*
insilmaril@747
    94
	// Save XLinks
insilmaril@747
    95
	QString ol;	// old link
insilmaril@747
    96
	QString cl;	// current link
insilmaril@747
    97
	for (int i=0; i<xlink.size(); ++i)
insilmaril@747
    98
	{
insilmaril@747
    99
		cl=xlink.at(i)->saveToDir();
insilmaril@747
   100
		if (cl!=ol)
insilmaril@747
   101
		{
insilmaril@747
   102
			s+=cl;
insilmaril@747
   103
			ol=cl;
insilmaril@747
   104
		} else
insilmaril@747
   105
		{
insilmaril@747
   106
			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
insilmaril@747
   107
		}
insilmaril@747
   108
	}	
insilmaril@747
   109
	*/
insilmaril@747
   110
insilmaril@747
   111
    decIndent();
insilmaril@747
   112
    s+=endElement   ("branch");
insilmaril@747
   113
    return s;
insilmaril@747
   114
}
insilmaril@747
   115
insilmaril@747
   116