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