mapeditor.cpp
changeset 412 8059b6aa74d7
parent 411 910ba9fab728
child 417 1cc7bbf75f0b
     1.1 --- a/mapeditor.cpp	Thu Dec 14 17:01:44 2006 +0000
     1.2 +++ b/mapeditor.cpp	Fri Dec 29 13:52:17 2006 +0000
     1.3 @@ -3,7 +3,6 @@
     1.4  #include <q3dragobject.h>
     1.5  #include <q3urloperator.h>
     1.6  #include <q3networkprotocol.h>
     1.7 -#include <q3paintdevicemetrics.h>
     1.8  #include <q3filedialog.h>
     1.9  
    1.10  #include <iostream>
    1.11 @@ -72,13 +71,6 @@
    1.12  
    1.13      setScene (mapScene);
    1.14  	
    1.15 -    /* FIXME scrollview handles not needed in QT4? 
    1.16 -	// Maybe check QAbstractScrollArea...
    1.17 -	// Always show scroll bars (automatic would flicker sometimes)
    1.18 -	setVScrollBarMode ( QScrollView::AlwaysOn );
    1.19 -	setHScrollBarMode ( QScrollView::AlwaysOn );
    1.20 -	*/
    1.21 -
    1.22      mapCenter = new MapCenterObj(mapScene);
    1.23      mapCenter->setVisibility (true);
    1.24  	mapCenter->setMapEditor (this);
    1.25 @@ -170,73 +162,6 @@
    1.26      return mapScene;
    1.27  }
    1.28  
    1.29 -void MapEditor::adjustCanvasSize()
    1.30 -{
    1.31 -
    1.32 -/* FIXME QT4 adjustcanvassize probably not needed any longer!
    1.33 -
    1.34 -	// To adjust the scene to map, viewport size and position, we have to
    1.35 -	// do some coordinate magic...
    1.36 -	//
    1.37 -	// Get rectangle of (scroll-)view. 
    1.38 -	// We want to be in scene coords, so
    1.39 -	// we map. Important if view is zoomed...
    1.40 -	QRectF view = inverseWorldMatrix().mapRect( QRectF( contentsX(), contentsY(),
    1.41 -												visibleWidth(), visibleHeight()) );	
    1.42 -												
    1.43 -	// Now we need the bounding box of view AND map to calc the correct scene size.
    1.44 -	// Why? Because if the map itself is moved out of view, the view has to be enlarged
    1.45 -	// to avoid jumping aroung...
    1.46 -	QRectF map=mapCenter->getTotalBBox();
    1.47 -
    1.48 -	// right edge - left edge
    1.49 -	int cw= max(map.x() + map.width(),  view.x() + view.width())  - min(map.x(), view.x());
    1.50 -	int ch= max(map.y() + map.height(), view.y() + view.height()) - min(map.y(), view.y());
    1.51 -
    1.52 -
    1.53 -	if ( (cw!=mapScene->width()) || (ch!=mapScene->height()) ||
    1.54 -		!mapScene->onCanvas (map.topLeft()) || !mapScene->onCanvas (map.bottomRight())
    1.55 -	)	
    1.56 -	{	
    1.57 -		// move the map on scene (in order to not move it on screen) this is neccessary
    1.58 -		// a) if topleft corner of scene is left or above topleft corner of view and also left of
    1.59 -		//    above topleft corner of map. E.g. if map is completly inside view, but it would be possible 
    1.60 -		//    to scroll to an empty area of scene to the left.
    1.61 -		// b) if topleft corner of map left of or above topleft of scene
    1.62 -		int dx=0;
    1.63 -		int dy=0;
    1.64 -
    1.65 -		if (cw > mapScene->width() )
    1.66 -		{
    1.67 -			if (map.x()<0) dx=-map.x();	
    1.68 -		}
    1.69 -		if (cw <  mapScene->width() )
    1.70 -			dx=-min (view.x(),map.x());
    1.71 -		if (ch > mapScene->height() )
    1.72 -		{
    1.73 -			if (map.y()<0) dy=-map.y();	
    1.74 -		}
    1.75 -		if (ch <  mapScene->height() )
    1.76 -		{
    1.77 -			dy=-min (view.y(),map.y());
    1.78 -		}
    1.79 -		// We really have to resize now. Let's go...
    1.80 -		// FIXME old code mapScene->resize (cw,ch);
    1.81 -		mapScene->setSceneRect (QRectFF(0,0,cw,ch));
    1.82 -		if ( (dx!=0) || (dy!=0) ) 
    1.83 -		{
    1.84 -			mapCenter->moveAllBy(dx,dy);
    1.85 -			mapCenter->reposition();
    1.86 -//			mapCenter->positionBBox();	// To move float
    1.87 -
    1.88 -			// scroll the view (in order to not move map on screen)
    1.89 -			scrollBy (dx,dy);
    1.90 -		}	
    1.91 -	}
    1.92 -
    1.93 -	*/
    1.94 -}
    1.95 -
    1.96  bool MapEditor::isRepositionBlocked()
    1.97  {
    1.98  	return blockReposition;
    1.99 @@ -1108,7 +1033,6 @@
   1.100  		if ( ok ) 
   1.101  		{
   1.102  			mapCenter->reposition();
   1.103 -			adjustCanvasSize();
   1.104  			if (lmode==NewMap)
   1.105  			{
   1.106  				mapDefault=false;
   1.107 @@ -1179,6 +1103,8 @@
   1.108  		printer = new QPrinter;
   1.109  		printer->setColorMode (QPrinter::Color);
   1.110  		printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
   1.111 +		printer->setOutputFormat((QPrinter::OutputFormat)settings.value("/mainwindow/printerFormat",printer->outputFormat()).toInt());
   1.112 +		printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString());
   1.113  	}
   1.114  
   1.115  	QRectF totalBBox=mapCenter->getTotalBBox();
   1.116 @@ -1200,6 +1126,9 @@
   1.117  	{
   1.118  		QPainter pp(printer);
   1.119  
   1.120 +		//pp.setRenderHints(renderHints());
   1.121 +		pp.setRenderHint(QPainter::Antialiasing,true);
   1.122 +
   1.123  		// Don't print the visualisation of selection
   1.124  		LinkableMapObj *oldselection=NULL;
   1.125  		if (selection) 
   1.126 @@ -1208,22 +1137,9 @@
   1.127  			selection->unselect();
   1.128  		}
   1.129  
   1.130 -		// Handle sizes of map and paper:
   1.131 -		//
   1.132 -		// setWindow defines which part of the scene will be transformed 
   1.133 -		// setViewport defines area on paper in device coordinates (dpi)
   1.134 -		// e.g. (0,50,700,700) is upper part on A4
   1.135 -		// see also /usr/lib/qt3/doc/html/coordsys.html
   1.136 -
   1.137 -		Q3PaintDeviceMetrics metrics (printer);
   1.138 -
   1.139 -		double paperAspect = (double)metrics.width()   / (double)metrics.height();
   1.140 -		double   mapAspect = (double)totalBBox.width() / (double)totalBBox.height();
   1.141 -
   1.142  		QRectF mapRect=totalBBox;
   1.143  		QGraphicsRectItem *frame=NULL;
   1.144 -		QGraphicsTextItem *footerFN=NULL;
   1.145 -		QGraphicsTextItem *footerDate=NULL;
   1.146 +
   1.147  		if (printFrame || printFooter)
   1.148  		{
   1.149  			
   1.150 @@ -1232,63 +1148,72 @@
   1.151  				// Print frame around map
   1.152  				mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, 
   1.153  					totalBBox.width()+20, totalBBox.height()+20);
   1.154 -				frame=mapScene->addRect (mapRect, QPen(Qt::black),QBrush(Qt::red));
   1.155 +				frame=mapScene->addRect (mapRect, QPen(Qt::black),QBrush(Qt::NoBrush));
   1.156  				frame->setZValue(0);
   1.157  				frame->show();    
   1.158  			}		
   1.159 -			// TODO remove after testing 
   1.160 -			//QCanvasLine *l=new QCanvasLine (mapScene);
   1.161 -			//l->setPoints (0,0,mapRect.width(),mapRect.height());
   1.162 -			//l->setPen (QPen(QColor(black), 1));
   1.163 -			//l->setZ (200);
   1.164 -			//l->show();
   1.165  
   1.166  			if (printFooter) 
   1.167  			{
   1.168  				// Print footer below map
   1.169  				QFont font;		
   1.170  				font.setPointSize(10);
   1.171 -				footerFN=mapScene->addText ("VYM - " + fileName,font);
   1.172 -				footerFN->setPos (mapRect.x(), mapRect.y() + mapRect.height() );
   1.173 -				footerFN->setZValue (Z_TEXT);
   1.174 -				footerFN->show();    
   1.175 -				footerDate=mapScene->addText (QDate::currentDate().toString(Qt::TextDate),font);
   1.176 -				footerDate->setPos(mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
   1.177 -				footerDate->setZValue(Z_TEXT);
   1.178 -				footerDate->show();    
   1.179 +				pp.setFont (font);
   1.180 +				QRectF footerBox(0,printer->height()-15,printer->width(),15);
   1.181 +				pp.drawText ( footerBox,Qt::AlignLeft,"VYM - " +fileName);
   1.182 +				pp.drawText ( footerBox, Qt::AlignRight, QDate::currentDate().toString(Qt::TextDate));
   1.183  			}
   1.184 -			//pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
   1.185 -		}	else	
   1.186 -		{
   1.187 -			//pp.setWindow (mapRect);
   1.188 -			//pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
   1.189 -		}	
   1.190 -
   1.191 -/*
   1.192 +		}
   1.193 +
   1.194 +		/*
   1.195 +		double paperAspect = (double)printer->width()   / (double)printer->height();
   1.196 +		double   mapAspect = (double)mapRect.width() / (double)mapRect.height();
   1.197 +		cout <<"mapAspect="<<mapAspect<<"   paperAspect"<<paperAspect<<endl;
   1.198  		if (mapAspect>=paperAspect)
   1.199  		{
   1.200  			// Fit horizontally to paper width
   1.201 -			pp.setViewport(0,0, metrics.width(),(int)(metrics.width()/mapAspect) );	
   1.202 +			pp.setViewport(0,0, printer->width(),(int)(printer->width()/mapAspect) );	
   1.203 +			qWarning ("Fit hor");
   1.204  		}	else
   1.205  		{
   1.206  			// Fit vertically to paper height
   1.207 -			pp.setViewport(0,0,(int)(metrics.height()*mapAspect),metrics.height());	
   1.208 +			pp.setViewport(0,0,(int)(printer->height()*mapAspect),printer->height());	
   1.209 +			qWarning ("Fit ver");
   1.210  		}	
   1.211 -*/
   1.212 -		QRect viewport=rect();
   1.213 -		render (&pp, QRect(),QRect());
   1.214 -
   1.215 +		*/
   1.216 +		mapScene->render (
   1.217 +			&pp, 
   1.218 +			//pp.viewport(),
   1.219 +			QRectF (0,0,printer->width(),printer->height()-15),
   1.220 +			QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height())
   1.221 +		);
   1.222 +		
   1.223 +		//render (&pp,printer->pageRect(), QRect ((int)mapRect.x(),(int)mapRect.y(),400,400));
   1.224 +
   1.225 +		//pp.setWindow (QRect (mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height()));
   1.226  		//mapScene->render(&pp);	// draw scene to printer
   1.227  
   1.228 -/*
   1.229 -		// Delete Frame and footer
   1.230 -		if (footerFN) 
   1.231 -		{
   1.232 -			delete (footerFN);
   1.233 -			delete (footerDate);
   1.234 -		}	
   1.235 -*/		
   1.236 -//		if (frame)  delete (frame);
   1.237 +		// Viewport has paper dimension
   1.238 +		pp.drawLine (QLine (0,0,printer->width(),printer->height()));
   1.239 +		cout << "sceneRect: "
   1.240 +			<<mapScene->sceneRect().x()<<","
   1.241 +			<<mapScene->sceneRect().y()<<","
   1.242 +			<<mapScene->sceneRect().width()<<","
   1.243 +			<<mapScene->sceneRect().height()<<","<<endl;
   1.244 +		cout << "mapRect: "
   1.245 +			<<mapRect.x()<<","
   1.246 +			<<mapRect.y()<<","
   1.247 +			<<mapRect.width()<<","
   1.248 +			<<mapRect.height()<<","<<endl;
   1.249 +		cout << "pp.viewport: "
   1.250 +			<<pp.viewport().x()<<","
   1.251 +			<<pp.viewport().y()<<","
   1.252 +			<<pp.viewport().width()<<","
   1.253 +			<<pp.viewport().height()<<","<<endl;
   1.254 +		cout << "painter: w,h="<<pp.viewport().width()<<","<<pp.viewport().height()<<endl;
   1.255 +		cout << "printer: w,h="<<printer->width()<<","<<printer->height()<<endl;
   1.256 +
   1.257 +		if (frame)  delete (frame);
   1.258  
   1.259  		// Restore selection
   1.260  		if (oldselection) 
   1.261 @@ -1299,6 +1224,8 @@
   1.262  
   1.263  		// Save settings in vymrc
   1.264  		settings.writeEntry("/mainwindow/printerName",printer->printerName());
   1.265 +		settings.writeEntry("/mainwindow/printerFormat",printer->outputFormat());
   1.266 +		settings.writeEntry("/mainwindow/printerFileName",printer->outputFileName());
   1.267  	}
   1.268  }
   1.269  
   1.270 @@ -1349,7 +1276,6 @@
   1.271  	hidemode=mode;
   1.272  	mapCenter->setHideTmp (hidemode);
   1.273  	mapCenter->reposition();
   1.274 -	adjustCanvasSize();
   1.275  	scene()->update();
   1.276  }
   1.277  
   1.278 @@ -1749,7 +1675,6 @@
   1.279  			QString("Paste to %1").arg( getName(selection))
   1.280  		);
   1.281  		mapCenter->reposition();
   1.282 -		adjustCanvasSize();
   1.283  	}
   1.284  }
   1.285  
   1.286 @@ -1764,7 +1689,6 @@
   1.287  	copy();
   1.288  	cutNoSave();
   1.289  	mapCenter->reposition();
   1.290 -	adjustCanvasSize();
   1.291  }
   1.292  
   1.293  void MapEditor::move(const int &x, const int &y)
   1.294 @@ -1779,7 +1703,6 @@
   1.295  			QString("Move %1 to  %2").arg(getName(selection)).arg(ps));
   1.296  		selection->move(x,y);
   1.297  		mapCenter->reposition();
   1.298 -		adjustCanvasSize();
   1.299  	}
   1.300  
   1.301  }
   1.302 @@ -1798,7 +1721,6 @@
   1.303  			QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
   1.304  		((OrnamentedObj*)selection)->move2RelPos (x,y);
   1.305  		mapCenter->reposition();
   1.306 -		adjustCanvasSize();
   1.307  	}
   1.308  }
   1.309  
   1.310 @@ -1869,7 +1791,6 @@
   1.311  		editingBO->setHeading(s );
   1.312  		editingBO=NULL;
   1.313  		mapCenter->reposition();
   1.314 -		adjustCanvasSize();
   1.315  		ensureSelectionVisible();
   1.316  	}
   1.317  }
   1.318 @@ -1883,7 +1804,6 @@
   1.319  	{
   1.320  		((BranchObj*)selection)->setURL(s);
   1.321  		mapCenter->reposition();
   1.322 -		adjustCanvasSize();
   1.323  		ensureSelectionVisible();
   1.324  	}
   1.325  }
   1.326 @@ -1896,7 +1816,6 @@
   1.327  	{
   1.328  		((BranchObj*)selection)->setHeading(s);
   1.329  		mapCenter->reposition();
   1.330 -		adjustCanvasSize();
   1.331  		ensureSelectionVisible();
   1.332  	}
   1.333  }
   1.334 @@ -1910,7 +1829,6 @@
   1.335  	{
   1.336  		((BranchObj*)selection)->setVymLink(s);
   1.337  		mapCenter->reposition();
   1.338 -		adjustCanvasSize();
   1.339  		ensureSelectionVisible();
   1.340  	}
   1.341  }
   1.342 @@ -1967,14 +1885,13 @@
   1.343  		if (newbo)
   1.344  		{
   1.345  			saveState(
   1.346 -				selection,		// FIXME sholdnt newbo be deleted here???
   1.347 +				selection,		// FIXME addNewBranch (int pos) sholdnt newbo be deleted here???
   1.348  				"delete ()",
   1.349  				selection,
   1.350  				QString ("addBranch (%1)").arg(pos-2),
   1.351  				QString ("Add new branch to %1").arg(getName(bo)));	
   1.352  
   1.353  			mapCenter->reposition();
   1.354 -			adjustCanvasSize();
   1.355  		}
   1.356  	}	
   1.357  	return newbo;
   1.358 @@ -2007,7 +1924,6 @@
   1.359  				QString ("Add branch before %1").arg(getName(bo)));
   1.360  
   1.361  			mapCenter->reposition();
   1.362 -			adjustCanvasSize();
   1.363  		}
   1.364  	}	
   1.365  	return newbo;
   1.366 @@ -2027,7 +1943,6 @@
   1.367  		selection->select();
   1.368  		ensureSelectionVisible();
   1.369  		mapCenter->reposition();
   1.370 -		adjustCanvasSize();
   1.371  	}
   1.372  	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
   1.373  	{
   1.374 @@ -2046,7 +1961,6 @@
   1.375  		selection->select();
   1.376  		ensureSelectionVisible();
   1.377  		mapCenter->reposition();
   1.378 -		adjustCanvasSize();
   1.379  	}
   1.380  }
   1.381  
   1.382 @@ -2085,7 +1999,6 @@
   1.383  		if (selection) unselect();
   1.384  		selection=lmo;
   1.385  		selection->select();
   1.386 -		adjustCanvasSize();
   1.387  		ensureSelectionVisible();
   1.388  		return true;
   1.389  	} 
   1.390 @@ -2106,8 +2019,6 @@
   1.391  		if (selection) selection->unselect();
   1.392  		selection=lmo;
   1.393  		selection->select();
   1.394 -			
   1.395 -		adjustCanvasSize();
   1.396  	}
   1.397  }
   1.398  
   1.399 @@ -2328,7 +2239,6 @@
   1.400  					par->unselect();
   1.401  					selection=bo;
   1.402  					selection->select();
   1.403 -					adjustCanvasSize();
   1.404  					ensureSelectionVisible();
   1.405  				}
   1.406  			}	
   1.407 @@ -2343,7 +2253,6 @@
   1.408  					selection->unselect();
   1.409  					selection=par;
   1.410  					selection->select();
   1.411 -					adjustCanvasSize();
   1.412  					ensureSelectionVisible();
   1.413  				}
   1.414  			} else
   1.415 @@ -2356,7 +2265,6 @@
   1.416  						selection->unselect();
   1.417  						selection=bo;
   1.418  						selection->select();
   1.419 -						adjustCanvasSize();
   1.420  						ensureSelectionVisible();
   1.421  					}
   1.422  				}
   1.423 @@ -2400,7 +2308,6 @@
   1.424  					selection->unselect();
   1.425  					selection=par;
   1.426  					selection->select();
   1.427 -					adjustCanvasSize();
   1.428  					ensureSelectionVisible();
   1.429  				}
   1.430  			} else
   1.431 @@ -2413,7 +2320,6 @@
   1.432  						selection->unselect();
   1.433  						selection=bo;
   1.434  						selection->select();
   1.435 -						adjustCanvasSize();
   1.436  						ensureSelectionVisible();
   1.437  					}
   1.438  				}
   1.439 @@ -2440,7 +2346,6 @@
   1.440  				ensureSelectionVisible();
   1.441  			}
   1.442  		}		
   1.443 -		adjustCanvasSize();
   1.444  	}
   1.445  }
   1.446  
   1.447 @@ -2462,7 +2367,6 @@
   1.448  				ensureSelectionVisible();
   1.449  			}
   1.450  		}		
   1.451 -		adjustCanvasSize();
   1.452  	}
   1.453  }
   1.454  
   1.455 @@ -2481,7 +2385,7 @@
   1.456  
   1.457  	if ( fd->exec() == QDialog::Accepted )
   1.458  	{
   1.459 -		// FIXME in QT4 use:	lastImageDir=fd->directory();
   1.460 +		// TODO selectMapBackgroundImg in QT4 use:	lastImageDir=fd->directory();
   1.461  		lastImageDir=QDir (fd->dirPath());
   1.462  		setMapBackgroundImage (fd->selectedFile());
   1.463  	}
   1.464 @@ -2611,7 +2515,6 @@
   1.465  				QString("%1 (\"%2\")").arg(r).arg(f),
   1.466  				QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
   1.467  			bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
   1.468 -			adjustCanvasSize();
   1.469  		}
   1.470  	}	
   1.471  }
   1.472 @@ -2651,7 +2554,6 @@
   1.473  					if (selection) ((BranchObj*)selection)->unselect();
   1.474  					selection=itFind;
   1.475  					selection->select();
   1.476 -					adjustCanvasSize();
   1.477  					ensureSelectionVisible();
   1.478  				}
   1.479  				if (textEditor->findText(s,flags)) 
   1.480 @@ -2666,7 +2568,6 @@
   1.481  				if (selection) ((BranchObj*)selection)->unselect();
   1.482  				selection=itFind;
   1.483  				selection->select();
   1.484 -				adjustCanvasSize();
   1.485  				ensureSelectionVisible();
   1.486  				searching=false;
   1.487  			}
   1.488 @@ -2679,7 +2580,6 @@
   1.489  	}	
   1.490  	if (!searching)
   1.491  	{
   1.492 -		adjustCanvasSize();
   1.493  		return (BranchObj*)selection;
   1.494  	}	else
   1.495  		return NULL;
   1.496 @@ -2817,7 +2717,6 @@
   1.497  			bo->setVymLink (fd->selectedFile() );
   1.498  			updateActions();
   1.499  			mapCenter->reposition();
   1.500 -			adjustCanvasSize();
   1.501  			scene()->update();
   1.502  		}
   1.503  	}
   1.504 @@ -2839,7 +2738,6 @@
   1.505  		bo->setVymLink ("" );
   1.506  		updateActions();
   1.507  		mapCenter->reposition();
   1.508 -		adjustCanvasSize();
   1.509  		scene()->update();
   1.510  	}
   1.511  }
   1.512 @@ -2863,7 +2761,6 @@
   1.513  		);	
   1.514  		updateActions();
   1.515  		mapCenter->reposition();
   1.516 -		adjustCanvasSize();
   1.517  		scene()->update();
   1.518  	}
   1.519  }
   1.520 @@ -2925,7 +2822,6 @@
   1.521  		select (sel);
   1.522  		((BranchObj*)selection)->move2RelPos (p);
   1.523  		mapCenter->reposition();
   1.524 -		adjustCanvasSize();
   1.525  	}	
   1.526  }
   1.527  
   1.528 @@ -2987,7 +2883,7 @@
   1.529  void MapEditor::updateActions()
   1.530  {
   1.531  	mainWindow->updateActions();
   1.532 -	// FIXME maybe don't update if blockReposition is set
   1.533 +	// TODO maybe don't update if blockReposition is set
   1.534  }
   1.535  
   1.536  void MapEditor::updateNoteFlag()
   1.537 @@ -3166,7 +3062,6 @@
   1.538  			QString ("%1 %2").arg(r).arg(getName(bo))
   1.539  		);
   1.540  		bo->toggleScroll();
   1.541 -		adjustCanvasSize();
   1.542  		scene()->update();
   1.543  	}
   1.544  }
   1.545 @@ -3204,7 +3099,7 @@
   1.546  		QString fn;
   1.547  		if ( fd->exec() == QDialog::Accepted )
   1.548  		{
   1.549 -			// FIXME in QT4 use:	lastImageDir=fd->directory();
   1.550 +			// FIXME loadFIO in QT4 use:	lastImageDir=fd->directory();
   1.551  			lastImageDir=QDir (fd->dirPath());
   1.552  			QStringList flist = fd->selectedFiles();
   1.553  			QStringList::Iterator it = flist.begin();
   1.554 @@ -3215,7 +3110,7 @@
   1.555  				bo->addFloatImage();
   1.556  				fio=bo->getLastFloatImage();
   1.557  				fio->load(*it);
   1.558 -				// FIXME check if load of fio was successful
   1.559 +				// FIXME loadFIO check if load of fio was successful
   1.560  				saveState(
   1.561  					(LinkableMapObj*)fio,
   1.562  					"delete ()",
   1.563 @@ -3228,7 +3123,6 @@
   1.564  			}
   1.565  
   1.566  			mapCenter->reposition();
   1.567 -			adjustCanvasSize();
   1.568  			scene()->update();
   1.569  		}
   1.570  		delete (p);
   1.571 @@ -3392,7 +3286,6 @@
   1.572  			BranchObj *bo=((BranchObj*)selection);
   1.573  			importDirInt (bo,QDir(fd->selectedFile()) );
   1.574  			mapCenter->reposition();
   1.575 -			adjustCanvasSize();
   1.576  			scene()->update();
   1.577  		}
   1.578  	}	
   1.579 @@ -3436,7 +3329,7 @@
   1.580  				}
   1.581  				if (dia.deleteXLink())
   1.582  					((BranchObj*)selection)->deleteXLinkAt(i);
   1.583 -				//saveStateComplete("Edit xLink");	//FIXME undoCommand
   1.584 +				//saveStateComplete("Edit xLink");	//FIXME editXLink undoCommand
   1.585  			}
   1.586  		}	
   1.587  	}
   1.588 @@ -3502,7 +3395,7 @@
   1.589  
   1.590  void MapEditor::updateViewCenter()
   1.591  {
   1.592 -/* FIXME still to port to QT4 inverseworldmatrix
   1.593 +/* FIXME updateViewCenter still to port to QT4 inverseworldmatrix
   1.594  	// Update movingCenter, so that we can zoom comfortably later
   1.595  	QRectF rc = QRectF( contentsX(), contentsY(),
   1.596  				  visibleWidth(), visibleHeight() );
   1.597 @@ -3528,7 +3421,6 @@
   1.598  			if (selection) selection->unselect();
   1.599  			selection=lmo;
   1.600  			selection->select();
   1.601 -			adjustCanvasSize();
   1.602  		}
   1.603  		// Context Menu 
   1.604  		if (selection) 
   1.605 @@ -3705,8 +3597,6 @@
   1.606  		{
   1.607  			movingObj=NULL;	// move Content not Obj
   1.608  			movingObj_start=e->globalPos();
   1.609 -			// FIXME not ported to QT4 yet (move canvasView)
   1.610 -			//movingCont_start=QPointF (contentsX(), contentsY() );
   1.611  			movingCont_start=QPointF (
   1.612  				horizontalScrollBar()->value(),
   1.613  				verticalScrollBar()->value());
   1.614 @@ -3841,9 +3731,6 @@
   1.615  		QPointF p=e->globalPos();
   1.616  		movingVec.setX(-p.x() + movingObj_start.x() );
   1.617  		movingVec.setY(-p.y() + movingObj_start.y() );
   1.618 -		// FIXME not ported to QT4 yet (move canvasView)
   1.619 -		//setContentsPos( movingCont_start.x() + movingVec.x(),
   1.620 -	    //movingCont_start.y() + movingVec.y();
   1.621  		horizontalScrollBar()->setSliderPosition((int)( movingCont_start.x()+movingVec.x() ));
   1.622  		verticalScrollBar()->setSliderPosition((int)( movingCont_start.y()+movingVec.y() ) );
   1.623      }
   1.624 @@ -3913,7 +3800,6 @@
   1.625  				"moveRel "+pnow,
   1.626  				QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
   1.627  
   1.628 -			// FIXME Why calling parObj here?
   1.629  			selection->getParObj()->requestReposition();
   1.630  			mapCenter->reposition();
   1.631  		}	
   1.632 @@ -3927,8 +3813,7 @@
   1.633  			dst=NULL;
   1.634  		
   1.635  		if (typeid(*selection) == typeid(MapCenterObj)  )
   1.636 -		{	// The MapCenter was moved
   1.637 -			cout << "FIXME missing savestate...\n";	
   1.638 +		{	// FIXME The MapCenter was moved, no savestate yet
   1.639  		}
   1.640  		
   1.641  		if (typeid(*selection) == typeid(BranchObj)  )
   1.642 @@ -4002,7 +3887,6 @@
   1.643  			mapCenter->reposition();
   1.644  		}
   1.645  		// Finally resize scene, if needed
   1.646 -		adjustCanvasSize();
   1.647  		scene()->update();
   1.648  		movingObj=NULL;		
   1.649  
   1.650 @@ -4033,68 +3917,25 @@
   1.651  void MapEditor::resizeEvent (QResizeEvent* e)
   1.652  {
   1.653  	QGraphicsView::resizeEvent( e );
   1.654 -	adjustCanvasSize();
   1.655  }
   1.656  
   1.657 -void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) 
   1.658 +void MapEditor::dragEnterEvent(QDragEnterEvent *event)
   1.659  {
   1.660 -	//FIXME not ported to QT4 yet
   1.661 -
   1.662 -//  for (unsigned int i=0;event->format(i);i++) // Debug mime type
   1.663 -//    cerr << event->format(i) << endl;
   1.664 -
   1.665 -  if (selection && 
   1.666 -      (typeid(*selection) == typeid(BranchObj)) || 
   1.667 -      (typeid(*selection) == typeid(MapCenterObj))) {
   1.668 -    
   1.669 -    // If QImageDrag can decode mime type 
   1.670 -    if (Q3ImageDrag::canDecode(event)) {
   1.671 -      event->accept();
   1.672 -      return;
   1.673 -    }
   1.674 -    
   1.675 -    // If image are dragged from firefox 
   1.676 -    if (event->provides("application/x-moz-file-promise-url") && 
   1.677 -	event->provides("application/x-moz-nativeimage")) {
   1.678 -      event->accept(true);
   1.679 -      return;
   1.680 -    }
   1.681 -
   1.682 -    // If QUriDrag can decode mime type 
   1.683 -    if (Q3UriDrag::canDecode(event)) {
   1.684 -      event->accept();
   1.685 -      return;
   1.686 -    }
   1.687 -    
   1.688 -	// If Uri are dragged from firefox 
   1.689 -    if (event->provides("_NETSCAPE_URL")){
   1.690 -      event->accept();
   1.691 -      return;
   1.692 -    }
   1.693 -
   1.694 -    // If QTextDrag can decode mime type
   1.695 -    if (Q3TextDrag::canDecode(event)) {
   1.696 -      event->accept();
   1.697 -      return;
   1.698 -    }
   1.699 -
   1.700 -  }
   1.701 -  event->ignore();
   1.702 +  for (unsigned int i=0;event->format(i);i++) // Debug mime type
   1.703 +    cerr << event->format(i) << endl;
   1.704 +
   1.705 +	if (event->mimeData()->hasFormat("image/png"))
   1.706 +	event->acceptProposedAction();
   1.707  }
   1.708  
   1.709 -bool isUnicode16(const QByteArray &d) 
   1.710 +void MapEditor::dropEvent(QDropEvent *event)
   1.711  {
   1.712 -  // TODO: make more precise check for unicode 16.
   1.713 -  // Guess unicode16 if any of second bytes are zero
   1.714 -  unsigned int length = max(0,d.size()-2)/2;
   1.715 -  for (unsigned int i = 0; i<length ; i++)
   1.716 -    if (d.at(i*2+1)==0) return true;
   1.717 -  return false;
   1.718 +	if (event->mimeData()->hasFormat("image/png"))
   1.719  }
   1.720 -      
   1.721 +
   1.722  void MapEditor::contentsDropEvent(QDropEvent *event) 
   1.723  {
   1.724 -	//FIXME not ported to QT4 yet
   1.725 +	//FIXME dropEvent not ported to QT4 yet
   1.726  	if (selection && 
   1.727        (typeid(*selection) == typeid(BranchObj)) || 
   1.728        (typeid(*selection) == typeid(MapCenterObj))) 
   1.729 @@ -4170,7 +4011,7 @@
   1.730  		}
   1.731  		*/
   1.732  
   1.733 -		/* FIXME not ported yet  QSTRINGLIST has no next... 
   1.734 +		/* not ported yet  QSTRINGLIST has no next... 
   1.735  		if (uris.count()>0)
   1.736  		{
   1.737  			QStringList files;
   1.738 @@ -4209,15 +4050,71 @@
   1.739  		*/
   1.740  		if (update) 
   1.741  		{
   1.742 -			//FIXME saveState has to be called earlier for each of the drops...
   1.743 +			//FIXME dropEvent: saveState has to be called earlier for each of the drops...
   1.744  			//saveStateComplete("Drop Event");	//TODO undo Command
   1.745  			mapCenter->reposition();
   1.746 -			adjustCanvasSize();
   1.747  			scene()->update();
   1.748  		}	
   1.749  	}	
   1.750  }
   1.751  
   1.752 +
   1.753 +void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) 
   1.754 +{
   1.755 +	//FIXME contentsDragEnterEvent not ported to QT4 yet
   1.756 +
   1.757 +//  for (unsigned int i=0;event->format(i);i++) // Debug mime type
   1.758 +//    cerr << event->format(i) << endl;
   1.759 +
   1.760 +  if (selection && 
   1.761 +      (typeid(*selection) == typeid(BranchObj)) || 
   1.762 +      (typeid(*selection) == typeid(MapCenterObj))) {
   1.763 +    
   1.764 +    // If QImageDrag can decode mime type 
   1.765 +    if (Q3ImageDrag::canDecode(event)) {
   1.766 +      event->accept();
   1.767 +      return;
   1.768 +    }
   1.769 +    
   1.770 +    // If image are dragged from firefox 
   1.771 +    if (event->provides("application/x-moz-file-promise-url") && 
   1.772 +	event->provides("application/x-moz-nativeimage")) {
   1.773 +      event->accept(true);
   1.774 +      return;
   1.775 +    }
   1.776 +
   1.777 +    // If QUriDrag can decode mime type 
   1.778 +    if (Q3UriDrag::canDecode(event)) {
   1.779 +      event->accept();
   1.780 +      return;
   1.781 +    }
   1.782 +    
   1.783 +	// If Uri are dragged from firefox 
   1.784 +    if (event->provides("_NETSCAPE_URL")){
   1.785 +      event->accept();
   1.786 +      return;
   1.787 +    }
   1.788 +
   1.789 +    // If QTextDrag can decode mime type
   1.790 +    if (Q3TextDrag::canDecode(event)) {
   1.791 +      event->accept();
   1.792 +      return;
   1.793 +    }
   1.794 +
   1.795 +  }
   1.796 +  event->ignore();
   1.797 +}
   1.798 +
   1.799 +bool isUnicode16(const QByteArray &d) 
   1.800 +{
   1.801 +  // TODO: make more precise check for unicode 16.
   1.802 +  // Guess unicode16 if any of second bytes are zero
   1.803 +  unsigned int length = max(0,d.size()-2)/2;
   1.804 +  for (unsigned int i = 0; i<length ; i++)
   1.805 +    if (d.at(i*2+1)==0) return true;
   1.806 +  return false;
   1.807 +}
   1.808 +      
   1.809  void MapEditor::addFloatImageInt (const QPixmap &img) 
   1.810  {
   1.811    if (selection && 
   1.812 @@ -4232,13 +4129,13 @@
   1.813      fio->load(img);
   1.814      fio->setOriginalFilename("Image added by Drag and Drop");
   1.815      mapCenter->reposition();
   1.816 -    adjustCanvasSize();
   1.817      scene()->update();
   1.818    }
   1.819  }
   1.820  
   1.821 -
   1.822 -void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) 
   1.823 +/*
   1.824 +
   1.825 +void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation * / *nop* /) 
   1.826  {
   1.827    if (!imageBuffer) imageBuffer = new QBuffer();
   1.828    if (!imageBuffer->isOpen()) {
   1.829 @@ -4281,3 +4178,5 @@
   1.830  	  this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *)));
   1.831    urlOperator->get();
   1.832  }
   1.833 +*/
   1.834 +