1.9.4 New base class for XML based file parsing (vym & Freemind)
authorinsilmaril
Mon, 30 Jul 2007 09:47:07 +0000
changeset 568b44cc0d3ed4a
parent 567 70b500879182
child 569 df32d920b04e
1.9.4 New base class for XML based file parsing (vym & Freemind)
file.h
headingobj.cpp
     1.1 --- a/file.h	Mon Jul 30 09:47:05 2007 +0000
     1.2 +++ b/file.h	Mon Jul 30 09:47:07 2007 +0000
     1.3 @@ -5,6 +5,7 @@
     1.4  
     1.5  enum LoadMode {NewMap,ImportAdd,ImportReplace};
     1.6  enum SaveMode {PartOfMap,CompleteMap,UndoCommand};
     1.7 +enum FileType {VymMap, FreemindMap};
     1.8  enum ErrorCode {success,aborted,nozip};
     1.9  
    1.10  
     2.1 --- a/headingobj.cpp	Mon Jul 30 09:47:05 2007 +0000
     2.2 +++ b/headingobj.cpp	Mon Jul 30 09:47:07 2007 +0000
     2.3 @@ -80,7 +80,7 @@
     2.4  	// then no selection would be visible, thus we prevent it in ::setText()
     2.5  	if (!textline.isEmpty() )
     2.6  	{
     2.7 -		for (int i=0; i<textline.size(); ++i)
     2.8 +		for (int i=0; i<textline.size(); i++)
     2.9  		{
    2.10  			h+=textline.at(i)->boundingRect().height();
    2.11  			if (w<textline.at(i)->boundingRect().width() )
    2.12 @@ -90,13 +90,17 @@
    2.13      bbox.setSize (QSizeF(w,h));
    2.14  }
    2.15  
    2.16 -QGraphicsSimpleTextItem* HeadingObj::newLine(QString s)
    2.17 +//QGraphicsSimpleTextItem* HeadingObj::newLine(QString s)
    2.18 +QGraphicsTextItem* HeadingObj::newLine(QString s)
    2.19  {
    2.20 -    QGraphicsSimpleTextItem *t=new QGraphicsSimpleTextItem (s,0,scene);
    2.21 +    //QGraphicsSimpleTextItem *t=new QGraphicsSimpleTextItem (s,0,scene);
    2.22 +    QGraphicsTextItem *t=new QGraphicsTextItem (s,0,scene);
    2.23      t->setFont (font);
    2.24      t->setZValue(Z_TEXT);
    2.25 -    //t->setDefaultTextColor(color);
    2.26 -    t->setBrush(color);
    2.27 +	// TextItem
    2.28 +    t->setDefaultTextColor(color);
    2.29 +	// SimpleTextItem
    2.30 +    //t->setBrush(color);
    2.31      return t;
    2.32  }
    2.33  
    2.34 @@ -108,6 +112,21 @@
    2.35  	while (!textline.isEmpty())
    2.36  		delete textline.takeFirst();
    2.37  
    2.38 +	if (s.startsWith("<html>"))
    2.39 +	{
    2.40 +		QGraphicsTextItem *t=new QGraphicsTextItem ();
    2.41 +		t->setFont (font);
    2.42 +		t->setZValue(Z_TEXT);
    2.43 +		t->setHtml (s);
    2.44 +		t->setDefaultTextColor(color);
    2.45 +		scene->addItem (t);
    2.46 +		textline.append (t);
    2.47 +		setVisibility (visible);
    2.48 +		move (absPos.x(),absPos.y());
    2.49 +		calcBBoxSize();
    2.50 +		return;
    2.51 +	}
    2.52 +
    2.53  	// prevent empty textline, so at least a small selection stays
    2.54  	// visible for this heading
    2.55  	if (s.length()==0) s="  ";
    2.56 @@ -218,8 +237,10 @@
    2.57      {
    2.58  		color=c;
    2.59  		for (int i=0; i<textline.size(); ++i)
    2.60 -			//textline.at(i)->setDefaultTextColor(c);
    2.61 -			textline.at(i)->setBrush(c);
    2.62 +			// TextItem
    2.63 +			textline.at(i)->setDefaultTextColor(c);
    2.64 +			// SimpleTextItem
    2.65 +			//textline.at(i)->setBrush(c);
    2.66      }	    
    2.67  }
    2.68