1.1 --- a/branchobj.cpp Mon Nov 20 12:12:00 2006 +0000
1.2 +++ b/branchobj.cpp Mon Nov 20 12:12:02 2006 +0000
1.3 @@ -86,7 +86,6 @@
1.4 void BranchObj::init ()
1.5 {
1.6 branch.setAutoDelete (false);
1.7 - floatimage.setAutoDelete (true);
1.8 xlink.setAutoDelete (false);
1.9
1.10 if (parObj)
1.11 @@ -118,10 +117,8 @@
1.12 // Those will get a deep copy, too
1.13 addBranch(b);
1.14
1.15 - FloatImageObj *fi;
1.16 - for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
1.17 - addFloatImage (fi);
1.18 -
1.19 + for (int i=0; i<other->floatimage.size(); ++i)
1.20 + addFloatImage (other->floatimage.at(i));
1.21 scrolled=other->scrolled;
1.22 tmpUnscrolled=other->tmpUnscrolled;
1.23 setVisibility (other->visible);
1.24 @@ -133,7 +130,9 @@
1.25
1.26 void BranchObj::clear()
1.27 {
1.28 - floatimage.clear();
1.29 + while (!floatimage.isEmpty())
1.30 + delete floatimage.takeFirst();
1.31 +
1.32 while (!xlink.isEmpty())
1.33 deleteXLink (xlink.first() );
1.34
1.35 @@ -166,7 +165,7 @@
1.36
1.37 int BranchObj::getFloatImageNum(FloatImageObj *fio)
1.38 {
1.39 - return floatimage.findRef (fio);
1.40 + return floatimage.indexOf(fio);
1.41 }
1.42
1.43 int BranchObj::countBranches()
1.44 @@ -366,9 +365,8 @@
1.45 BranchObj* b;
1.46 for (b=branch.first(); b;b=branch.next() )
1.47 b->setVisibility (v,toDepth);
1.48 - FloatImageObj *fio;
1.49 - for (fio=floatimage.first(); fio; fio=floatimage.next())
1.50 - fio->setVisibility (v);
1.51 + for (int i=0; i<floatimage.size(); ++i)
1.52 + floatimage.at(i)->setVisibility (v);
1.53 XLinkObj* xlo;
1.54 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
1.55 xlo->setVisibility ();
1.56 @@ -535,18 +533,16 @@
1.57
1.58 void BranchObj::positionContents()
1.59 {
1.60 - FloatImageObj *fio;
1.61 - for (fio=floatimage.first(); fio; fio=floatimage.next() )
1.62 - fio->reposition();
1.63 + for (int i=0; i<floatimage.size(); ++i )
1.64 + floatimage.at(i)->reposition();
1.65 OrnamentedObj::positionContents();
1.66 }
1.67
1.68 void BranchObj::move (double x, double y)
1.69 {
1.70 OrnamentedObj::move (x,y);
1.71 - FloatImageObj *fio;
1.72 - for (fio=floatimage.first(); fio; fio=floatimage.next() )
1.73 - fio->reposition();
1.74 + for (int i=0; i<floatimage.size(); ++i )
1.75 + floatimage.at(i)->reposition();
1.76 positionBBox();
1.77 }
1.78
1.79 @@ -614,22 +610,21 @@
1.80
1.81 // Floatimages
1.82 QPoint rp;
1.83 - FloatImageObj *foi;
1.84
1.85 topPad=botPad=leftPad=rightPad=0;
1.86 if (includeImagesVer || includeImagesHor)
1.87 {
1.88 if (countFloatImages()>0)
1.89 {
1.90 - for (foi=floatimage.first(); foi; foi=floatimage.next() )
1.91 + for (int i=0; i<floatimage.size(); ++i )
1.92 {
1.93 - rp=foi->getRelPos();
1.94 + rp=floatimage.at(i)->getRelPos();
1.95 if (includeImagesVer)
1.96 {
1.97 if (rp.y() < 0)
1.98 topPad=max (topPad,-rp.y()-h);
1.99 - if (rp.y()+foi->height() > 0)
1.100 - botPad=max (botPad,rp.y()+foi->height());
1.101 + if (rp.y()+floatimage.at(i)->height() > 0)
1.102 + botPad=max (botPad,rp.y()+floatimage.at(i)->height());
1.103 }
1.104 if (includeImagesHor)
1.105 {
1.106 @@ -637,14 +632,14 @@
1.107 {
1.108 if (-rp.x()-w > 0)
1.109 leftPad=max (leftPad,-rp.x()-w);
1.110 - if (rp.x()+foi->width() > 0)
1.111 - rightPad=max (rightPad,rp.x()+foi->width());
1.112 + if (rp.x()+floatimage.at(i)->width() > 0)
1.113 + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
1.114 } else
1.115 {
1.116 if (rp.x()< 0)
1.117 leftPad=max (leftPad,-rp.x());
1.118 - if (rp.x()+foi->width() > w)
1.119 - rightPad=max (rightPad,rp.x()+foi->width()-w);
1.120 + if (rp.x()+floatimage.at(i)->width() > w)
1.121 + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
1.122 }
1.123 }
1.124 }
1.125 @@ -691,13 +686,12 @@
1.126 return this;
1.127
1.128 // Search float images
1.129 - FloatImageObj *foi;
1.130 - for (foi=floatimage.first(); foi; foi=floatimage.next() )
1.131 - if (foi->inBox(p) &&
1.132 - (foi != excludeLMO) &&
1.133 - foi->getParObj()!= excludeLMO &&
1.134 - foi->isVisibleObj()
1.135 - ) return foi;
1.136 + for (int i=0; i<floatimage.size(); ++i )
1.137 + if (floatimage.at(i)->inBox(p) &&
1.138 + (floatimage.at(i) != excludeLMO) &&
1.139 + floatimage.at(i)->getParObj()!= excludeLMO &&
1.140 + floatimage.at(i)->isVisibleObj()
1.141 + ) return floatimage.at(i);
1.142
1.143 return NULL;
1.144 }
1.145 @@ -803,9 +797,8 @@
1.146 s+=standardFlags->saveToDir(tmpdir,prefix,0);
1.147
1.148 // Save FloatImages
1.149 - FloatImageObj *fio;
1.150 - for (fio=floatimage.first(); fio; fio=floatimage.next() )
1.151 - s+=fio->saveToDir (tmpdir,prefix);
1.152 + for (int i=0; i<floatimage.size(); ++i)
1.153 + s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
1.154
1.155 // save note
1.156 if (!note.isEmpty() )
1.157 @@ -971,7 +964,8 @@
1.158
1.159 void BranchObj::removeFloatImage (FloatImageObj *fio)
1.160 {
1.161 - floatimage.remove (fio);
1.162 + int i=floatimage.indexOf (fio);
1.163 + if (i!=-1) floatimage.takeAt (i);
1.164 calcBBoxSize();
1.165 positionBBox();
1.166 requestReposition();
1.167 @@ -1379,10 +1373,9 @@
1.168 if (!b->isHidden())
1.169 r=addBBox(b->getTotalBBox(),r);
1.170
1.171 - FloatImageObj* fio;
1.172 - for (fio=floatimage.first();fio ;fio=floatimage.next() )
1.173 - if (!fio->isHidden())
1.174 - r=addBBox(fio->getTotalBBox(),r);
1.175 + for (int i=0; i<floatimage.size(); ++i)
1.176 + if (!floatimage.at(i)->isHidden())
1.177 + r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1.178
1.179 return r;
1.180 }