1.1 --- a/headingobj.cpp Sun Jan 30 12:58:47 2005 +0000
1.2 +++ b/headingobj.cpp Thu Jul 27 14:07:11 2006 +0000
1.3 @@ -1,4 +1,5 @@
1.4 #include "headingobj.h"
1.5 +#include <qregexp.h>
1.6
1.7 /////////////////////////////////////////////////////////////////
1.8 // HeadingObj
1.9 @@ -9,7 +10,7 @@
1.10 init ();
1.11 }
1.12
1.13 -HeadingObj::HeadingObj(QCanvas* c) :MapObj(c)
1.14 +HeadingObj::HeadingObj(Q3Canvas* c) :MapObj(c)
1.15 {
1.16 // cout << "Const HeadingObj\n";
1.17 init ();
1.18 @@ -26,6 +27,7 @@
1.19 textwidth=40;
1.20 color=QColor ("black");
1.21 font=QFont();
1.22 + heading="";
1.23 }
1.24
1.25 void HeadingObj::copy(HeadingObj *other)
1.26 @@ -40,13 +42,15 @@
1.27 void HeadingObj::move(double x, double y)
1.28 {
1.29 MapObj::move(x,y);
1.30 +
1.31 int h; // height of a textline
1.32 int ho; // offset of height while drawing all lines
1.33 +
1.34 if (textline.first() )
1.35 h=textline.first()->boundingRect().height();
1.36 else
1.37 h=2;
1.38 - QCanvasText *t;
1.39 + Q3CanvasText *t;
1.40 ho=0;
1.41 for (t=textline.first(); t; t=textline.next() )
1.42 {
1.43 @@ -76,7 +80,7 @@
1.44 // then no selection would be visible, thus we prevent it in ::setText()
1.45 if (!textline.isEmpty() )
1.46 {
1.47 - QCanvasText *t;
1.48 + Q3CanvasText *t;
1.49 for (t=textline.first(); t; t=textline.next() )
1.50 {
1.51 h+=t->boundingRect().height();
1.52 @@ -87,14 +91,15 @@
1.53 bbox.setSize (QSize(w,h));
1.54 }
1.55
1.56 -QCanvasText* HeadingObj::newLine(QString s)
1.57 +Q3CanvasText* HeadingObj::newLine(QString s)
1.58 {
1.59 - QCanvasText *t;
1.60 - t = new QCanvasText(canvas);
1.61 + Q3CanvasText *t;
1.62 + t = new Q3CanvasText(canvas);
1.63 t->setFont (font);
1.64 t->setColor (color);
1.65 t->setZ(Z_TEXT);
1.66 t->setText(s);
1.67 + t->setTextFlags(Qt::AlignLeft);
1.68 t->show();
1.69 return t;
1.70 }
1.71 @@ -114,15 +119,17 @@
1.72 int j=0; // index of last ws
1.73 int k=0; // index of "<br>" or similar linebreak
1.74 int br=0; // width of found break, e.g. for <br> it is 4
1.75 + QRegExp re("<br.*/>");
1.76 + re.setMinimal (true);
1.77
1.78 // set the text and wrap lines
1.79 while (s.length()>0)
1.80 {
1.81 // ok, some people wanted manual linebreaks, here we go
1.82 - k=s.find ("<br>",i,false);
1.83 + k=re.search (s,i);
1.84 if (k>=0)
1.85 {
1.86 - br=4;
1.87 + br=re.cap(0).length();
1.88 i=k;
1.89 } else
1.90 i=s.find (" ",i,false);
1.91 @@ -184,6 +191,7 @@
1.92 }
1.93 }
1.94 setVisibility (visible);
1.95 + move (absPos.x(),absPos.y());
1.96 calcBBoxSize();
1.97 }
1.98
1.99 @@ -212,7 +220,7 @@
1.100 if (color!=c)
1.101 {
1.102 color=c;
1.103 - QCanvasText *t;
1.104 + Q3CanvasText *t;
1.105 for (t=textline.first(); t; t=textline.next() )
1.106 t->setColor(c);
1.107 }
1.108 @@ -226,7 +234,7 @@
1.109 void HeadingObj::setVisibility (bool v)
1.110 {
1.111 MapObj::setVisibility(v);
1.112 - QCanvasText *t;
1.113 + Q3CanvasText *t;
1.114 for (t=textline.first(); t; t=textline.next() )
1.115 if (v)
1.116 t->show();