# HG changeset patch
# User insilmaril
# Date 1166115704 0
# Node ID 910ba9fab728956865c10b2e9c9aadf08d3009ca
# Parent  ceb4532eae3440bf846ccbe0a8c886d665d9144e
1.8.61 various fixes, see changelog

diff -r ceb4532eae34 -r 910ba9fab728 branchobj.cpp
--- a/branchobj.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/branchobj.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -8,19 +8,6 @@
 extern FlagRowObj *standardFlagsDefault;
 
 
-/* FIXME not needed any longer in QT4
-int BranchObjPointrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
-{
-	// Make sure PtrList::find works
-	if (i==j) return 0;
-
-	if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
-		return 1;
-	else
-		return -1;
-}
-*/
-
 /////////////////////////////////////////////////////////////////
 // BranchObj
 /////////////////////////////////////////////////////////////////
@@ -138,6 +125,14 @@
 		delete branch.takeFirst();
 }
 
+bool isAbove (BranchObj* a, BranchObj *b)
+{
+	if (a->angle < b->angle)
+		return true;
+	else	
+		return false;
+}
+
 int BranchObj::getNum()
 {
 	if (parObj)
@@ -962,11 +957,10 @@
 void BranchObj::removeFloatImage (FloatImageObj *fio)
 {
 	int i=floatimage.indexOf (fio);
-	if (i!=-1) floatimage.takeAt (i);
+	if (i>-1) delete (floatimage.takeAt (i));
 	calcBBoxSize();
 	positionBBox();
 	requestReposition();
-	// FIMXE undo needed
 }
 
 void BranchObj::savePosInAngle ()
@@ -1047,7 +1041,7 @@
 	// Add new bo and resort branches
 	BranchObj *newbo=addBranch ();
 	newbo->angle=pos-0.5;
-	//FIXME   branch.sort();
+	qSort (branch.begin(),branch.end(), isAbove);
 	return newbo;
 }
 
@@ -1057,7 +1051,7 @@
 	// Add new bo and resort branches
 	bo->angle=pos-0.5;
 	BranchObj *newbo=addBranch (bo);
-	//FIXME   branch.sort();
+	qSort (branch.begin(),branch.end(), isAbove);
 	return newbo;
 }
 
@@ -1072,7 +1066,7 @@
 	bo->setDefAttr (MovedBranch);
 	if (scrolled) tmpUnscroll();
 	setLastSelectedBranch (bo);
-	//FIXME branch.sort();
+	qSort (branch.begin(),branch.end(), isAbove);
 	return bo;
 }
 
@@ -1176,7 +1170,7 @@
 	{	// -1 if bo1 not found 
 		branch.at(i)->angle--;
 		branch.at(i-1)->angle++;
-		//FIXME branch.sort();
+		qSort (branch.begin(),branch.end(), isAbove);
 		return branch.at(i);
 	} else
 		return NULL;
@@ -1202,7 +1196,7 @@
 		j = i+1;
 		branch.at(i)->angle++;
 		branch.at(j)->angle--;
-		//FIXME branch.sort();
+		qSort (branch.begin(),branch.end(), isAbove);
 		return branch.at(i);
 	} else
 		return NULL;
@@ -1345,7 +1339,7 @@
 
 	    alignRelativeTo ( QPointF (absPos.x(),
 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
-		//FIXME branch.sort();	
+		qSort (branch.begin(),branch.end(), isAbove);
 		positionBBox();	// Reposition bbox and contents
 	} else
 	{
diff -r ceb4532eae34 -r 910ba9fab728 branchobj.h
--- a/branchobj.h	Fri Dec 08 20:18:58 2006 +0000
+++ b/branchobj.h	Thu Dec 14 17:01:44 2006 +0000
@@ -10,6 +10,8 @@
 enum BranchModification {NewBranch, MovedBranch};
 enum HideTmpMode {HideNone, HideExport};
 
+bool isAbove(BranchObj*,BranchObj*);
+
 /////////////////////////////////////////////////////////////////////////////
 class BranchObj:public OrnamentedObj {
 public:
diff -r ceb4532eae34 -r 910ba9fab728 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r ceb4532eae34 -r 910ba9fab728 flagrowobj.cpp
--- a/flagrowobj.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/flagrowobj.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -228,9 +228,9 @@
 			for (int i=0; i<flag.size(); ++i)
 				if (g==flag.at(i)->getGroup() && keepfo!=flag.at(i)) 
 				{
-					flag.remove(flag.at(i));
-					//FIXME also delete flags
-					//and better only delete flags that are really set
+					FlagObj *fo=flag.at(i);
+					flag.remove (fo);
+					delete (fo);
 				}	
 		}		
 	}	
diff -r ceb4532eae34 -r 910ba9fab728 floatimageobj.cpp
--- a/floatimageobj.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/floatimageobj.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -35,7 +35,7 @@
 
 FloatImageObj::~FloatImageObj ()
 {
-//	cout << "Destr FloatImageObj "<<this<<"\n";
+	cout << "Destr FloatImageObj "<<this<<"\n";
 	delete(icon);
 }
 
@@ -219,13 +219,13 @@
 
 QRectF FloatImageObj::getBBoxSizeWithChilds()
 {
-	//FIXME  abstract in linkablemapobj.h, not calculated
+	//TODO abstract in linkablemapobj.h, not calculated
 	return bboxTotal;
 }
 
 void FloatImageObj::calcBBoxSizeWithChilds()
 {
-	//FIXME  abstract in linkablemapobj.h
+	//TODO abstract in linkablemapobj.h
 }
 
 QString FloatImageObj::getSelectString()
diff -r ceb4532eae34 -r 910ba9fab728 linkablemapobj.cpp
--- a/linkablemapobj.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/linkablemapobj.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -72,7 +72,7 @@
 	linkpos=LinkBottom;
     arcsegs=13;
     
-// FIXME instead of linkcolor pen.color() could be used	
+// FIXME instead of linkcolor pen.color() could be used	all around
 	pen.setWidth (1);
 	pen.setColor (linkcolor);
 	pen.setCapStyle ( Qt::RoundCap );
@@ -639,36 +639,8 @@
                     (int)( + 150*sin (a)));
 }
 
-/*
-void LinkableMapObj::alignRelativeTo (QPointF ref)
-{
-	// Overloaded, only called for BO, FIO, ...
-	// FIXME not needed?
-}
-*/
-
 void LinkableMapObj::reposition()
 {
-	cout << "LMO::reposition\n";
-	// FIXME LMO::reposition not needed? Is overloaded in BranchObj...
-	/*
-	if (depth==0)
-	{
-		// only calculate the sizes once. If the deepest LMO changes its height,
-		// all upper LMOs have to change, too.
-		calcBBoxSizeWithChilds();
-
-	    alignRelativeTo ( QPointF (absPos.x(),
-							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
-	} else
-	{
-		// This is only important for moving branches:
-		// For editing a branch it isn't called...
-		cout << "  reposition to abs "<<absPos<<endl;
-	    alignRelativeTo ( QPointF (absPos.x(),
-							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
-	}
-	*/
 }
 
 void LinkableMapObj::requestReposition()
@@ -718,7 +690,6 @@
 	setSelBox();
     selected=true;
     selbox->show();
-// FIXME not needed?	
 	setVisibility (visible);
 }
 
diff -r ceb4532eae34 -r 910ba9fab728 mapcenterobj.cpp
--- a/mapcenterobj.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/mapcenterobj.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -33,7 +33,7 @@
 	BranchObj::init();
     orientation=OrientUndef;
 
-	// FIXME this should be done in TextObj later...
+	// TODO this should be done in TextObj later...
 	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
 	//heading->setFont(font);
 	depth=0;
diff -r ceb4532eae34 -r 910ba9fab728 mapeditor.cpp
--- a/mapeditor.cpp	Fri Dec 08 20:18:58 2006 +0000
+++ b/mapeditor.cpp	Thu Dec 14 17:01:44 2006 +0000
@@ -72,7 +72,7 @@
 
     setScene (mapScene);
 	
-    /* FIXME not needed in QT4? 
+    /* FIXME scrollview handles not needed in QT4? 
 	// Maybe check QAbstractScrollArea...
 	// Always show scroll bars (automatic would flicker sometimes)
 	setVScrollBarMode ( QScrollView::AlwaysOn );
@@ -173,7 +173,7 @@
 void MapEditor::adjustCanvasSize()
 {
 
-/* FIXME QT4 probably not needed any longer!
+/* FIXME QT4 adjustcanvassize probably not needed any longer!
 
 	// To adjust the scene to map, viewport size and position, we have to
 	// do some coordinate magic...
@@ -335,11 +335,6 @@
 		else if ( typeid(*saveSel) == typeid(FloatImageObj) )
 			// Save image
 			s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
-			
-		else if (selection && typeid(*selection)==typeid(BranchObj))
-			// Save selected branch is saved from mainwindow		//FIXME maybe use "subtree" above?
-			// FIXME is this possible at all? BO is already above...
-			s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
 	}
 
 	// Save local settings
@@ -1226,10 +1221,9 @@
 		double   mapAspect = (double)totalBBox.width() / (double)totalBBox.height();
 
 		QRectF mapRect=totalBBox;
-/* FIXME todo for QT4
-		Q3CanvasRectangle *frame=NULL;
-		Q3CanvasText *footerFN=NULL;
-		Q3CanvasText *footerDate=NULL;
+		QGraphicsRectItem *frame=NULL;
+		QGraphicsTextItem *footerFN=NULL;
+		QGraphicsTextItem *footerDate=NULL;
 		if (printFrame || printFooter)
 		{
 			
@@ -1238,10 +1232,8 @@
 				// Print frame around map
 				mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, 
 					totalBBox.width()+20, totalBBox.height()+20);
-				frame=new Q3CanvasRectangle (mapRect,mapScene);
-				frame->setBrush (QColor(Qt::white));
-				frame->setPen (QColor(Qt::black));
-				frame->setZ(0);
+				frame=mapScene->addRect (mapRect, QPen(Qt::black),QBrush(Qt::red));
+				frame->setZValue(0);
 				frame->show();    
 			}		
 			// TODO remove after testing 
@@ -1256,26 +1248,23 @@
 				// Print footer below map
 				QFont font;		
 				font.setPointSize(10);
-				footerFN=new Q3CanvasText (mapScene);
-				footerFN->setText ("VYM - " + fileName);
-				footerFN->setFont(font);
-				footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() );
-				footerFN->setZ(Z_TEXT);
+				footerFN=mapScene->addText ("VYM - " + fileName,font);
+				footerFN->setPos (mapRect.x(), mapRect.y() + mapRect.height() );
+				footerFN->setZValue (Z_TEXT);
 				footerFN->show();    
-				footerDate=new Q3CanvasText (mapScene);
-				footerDate->setText (QDate::currentDate().toString(Qt::TextDate));
-				footerDate->setFont(font);
-				footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
-				footerDate->setZ(Z_TEXT);
+				footerDate=mapScene->addText (QDate::currentDate().toString(Qt::TextDate),font);
+				footerDate->setPos(mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
+				footerDate->setZValue(Z_TEXT);
 				footerDate->show();    
 			}
-			pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
+			//pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
 		}	else	
 		{
-			pp.setWindow (mapRect);
+			//pp.setWindow (mapRect);
+			//pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
 		}	
-*/
-
+
+/*
 		if (mapAspect>=paperAspect)
 		{
 			// Fit horizontally to paper width
@@ -1285,8 +1274,11 @@
 			// Fit vertically to paper height
 			pp.setViewport(0,0,(int)(metrics.height()*mapAspect),metrics.height());	
 		}	
-
-		mapScene->render(&pp);	// draw scene to printer
+*/
+		QRect viewport=rect();
+		render (&pp, QRect(),QRect());
+
+		//mapScene->render(&pp);	// draw scene to printer
 
 /*
 		// Delete Frame and footer
@@ -1295,8 +1287,8 @@
 			delete (footerFN);
 			delete (footerDate);
 		}	
-		if (frame)  delete (frame);
 */		
+//		if (frame)  delete (frame);
 
 		// Restore selection
 		if (oldselection) 
@@ -1322,7 +1314,7 @@
 
 QPixmap MapEditor::getPixmap()
 {
-/* FIXME not ported yet to QT4
+/* FIXME getPixmap not ported yet to QT4
 	QRectF mapRect=mapCenter->getTotalBBox();
 	QPixmap pix (mapRect.size());
 	QPainter pp (&pix);
@@ -2216,13 +2208,14 @@
 
 		s=s.left (s.length() -num.length());
 
+		int n=num.toInt()-1;
+		
 		// Go to next lmo
-		num=QString ("%1").arg(num.toUInt()-1);
-
+		num=QString ("%1").arg(n);
 		s=s+num;
 		
 		// Try to select this one
-		if (select (s)) return;
+		if (n>=0 && select (s)) return;
 
 		// We have no direct precessor, 
 		// try to decrease the parental number in order to
@@ -2244,15 +2237,15 @@
 			if (d>1)
 			{
 				// decrease number of parent
-				num=QString ("%1").arg(num.toUInt()-1);
+				num=QString ("%1").arg(num.toInt()-1);
 				s=s.section (",",0,d-2) + ","+ typ+num;
 			} else
 			{
 				// Special case, look at orientation
 				if (selection->getOrientation()==OrientRightOfCenter)
-					num=QString ("%1").arg(num.toUInt()-1);
+					num=QString ("%1").arg(num.toInt()-1);
 				else	
-					num=QString ("%1").arg(num.toUInt()+1);
+					num=QString ("%1").arg(num.toInt()+1);
 				s=typ+num;
 			}	
 
@@ -2627,7 +2620,7 @@
 {
 	// transform to sceneView Coord:
 	QPointF p=matrix().map(movingCenter);
-	//FIXME not ported yet to QT4 (center ist TextStream there)
+	//FIXME setViewCenter not ported yet to QT4 (center ist TextStream there)
 	//center ( p.x(), p.y());
 }
 
@@ -3565,7 +3558,7 @@
 
 void MapEditor::keyPressEvent(QKeyEvent* e)
 {
-	if (e->modifiers() && Qt::ControlModifier)
+	if (e->modifiers() & Qt::ControlModifier)
 	{
 		switch (mainWindow->getModMode())
 		{
@@ -3587,7 +3580,7 @@
 
 void MapEditor::keyReleaseEvent(QKeyEvent* e)
 {
-	if (!(e->modifiers() && Qt::ControlModifier))
+	if (!(e->modifiers() & Qt::ControlModifier))
 		setCursor (Qt::ArrowCursor);
 }
 
@@ -3843,8 +3836,7 @@
 	}	 
 	
     // Move sceneView 
-    //if (!movingObj && !pickingColor &&!drawingLink && e->button() == Qt::LeftButton ) 
-    if (e->buttons() == Qt::LeftButton ) 
+    if (!movingObj && !pickingColor &&!drawingLink && e->buttons() == Qt::LeftButton ) 
 	{
 		QPointF p=e->globalPos();
 		movingVec.setX(-p.x() + movingObj_start.x() );
diff -r ceb4532eae34 -r 910ba9fab728 tex/vym.changelog
--- a/tex/vym.changelog	Fri Dec 08 20:18:58 2006 +0000
+++ b/tex/vym.changelog	Thu Dec 14 17:01:44 2006 +0000
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Mon Dec 11 12:31:46 CET 2006 - uwedr
+
+- Version: 1.8.61
+- Bugfix: move up/down to next subtree is working again
+
 -------------------------------------------------------------------
 Mon Dec  6 22:48:07 CET 2006 - uwe
 
diff -r ceb4532eae34 -r 910ba9fab728 version.h
--- a/version.h	Fri Dec 08 20:18:58 2006 +0000
+++ b/version.h	Thu Dec 14 17:01:44 2006 +0000
@@ -4,8 +4,8 @@
 #include <QString>
 
 #define __VYM_NAME "VYM"
-#define __VYM_VERSION "1.8.61"
-#define __VYM_BUILD_DATE "December 8, 2006"
+#define __VYM_VERSION "1.8.62"
+#define __VYM_BUILD_DATE "December 11, 2006"
 
 
 bool checkVersion(const QString &);