Patch from Xavier Oswald to compile with older compilers release-1-12-maintained
authorinsilmaril
Tue, 23 Mar 2010 11:54:30 +0000
branchrelease-1-12-maintained
changeset 81876eed30ba3b
parent 80 5c5b4464b24f
Patch from Xavier Oswald to compile with older compilers
exports.cpp
file.cpp
linkablemapobj.cpp
main.cpp
process.cpp
xml-base.cpp
     1.1 --- a/exports.cpp	Fri Mar 05 20:16:46 2010 +0000
     1.2 +++ b/exports.cpp	Tue Mar 23 11:54:30 2010 +0000
     1.3 @@ -5,6 +5,7 @@
     1.4  #include "mainwindow.h"
     1.5  #include "warningdialog.h"
     1.6  #include "xsltproc.h"
     1.7 +#include <cstdlib>
     1.8  
     1.9  extern Main *mainWindow;
    1.10  extern QDir vymBaseDir;
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/file.cpp	Tue Mar 23 11:54:30 2010 +0000
     2.3 @@ -0,0 +1,500 @@
     2.4 +#include <QDir>
     2.5 +#include <QMessageBox>
     2.6 +#include <QPixmap>
     2.7 +#include <QLabel>
     2.8 +#include <QTextStream>
     2.9 +#include <iostream>
    2.10 +#include <cstdlib>
    2.11 +
    2.12 +#include "file.h"
    2.13 +#include "process.h"
    2.14 +
    2.15 +#if defined(Q_OS_WIN32)
    2.16 +#include "mkdtemp.h"
    2.17 +#include <windows.h>
    2.18 +#endif
    2.19 +
    2.20 +QString maskPath(QString p)
    2.21 +{
    2.22 +	// Change " " to "\ " to enable blanks in filenames
    2.23 +	p=p.replace(QChar('&'),"\\&");
    2.24 +	return p.replace(QChar(' '),"\\ ");
    2.25 +}
    2.26 +
    2.27 +QString convertToRel (const QString &src, const QString &dst)
    2.28 +{
    2.29 +	QString s=src;
    2.30 +	QString d=dst;
    2.31 +	int i;
    2.32 +
    2.33 +	if (s==d) 
    2.34 +	{
    2.35 +		// Special case, we just need the name of the file,
    2.36 +		// not the complete path
    2.37 +		i=d.findRev ("/");
    2.38 +		d=d.right (d.length()-i-1);
    2.39 +	} else
    2.40 +	{
    2.41 +		// Find relative path from src to dst
    2.42 +
    2.43 +		// Remove the first "/"
    2.44 +		if (s.section ("/",0,0).isEmpty()) 
    2.45 +		{
    2.46 +			s=s.right (s.length()-1);
    2.47 +			d=d.right (d.length()-1);
    2.48 +		}
    2.49 +		
    2.50 +		// remove identical left parts
    2.51 +		while (s.section("/",0,0) == d.section("/",0,0) ) 
    2.52 +		{
    2.53 +			i=s.find ("/");
    2.54 +			s=s.right (s.length()-i-1);
    2.55 +			d=d.right (d.length()-i-1);
    2.56 +		}
    2.57 +
    2.58 +		// Now take care of paths where we have to go back first
    2.59 +		int srcsep=s.count("/");
    2.60 +		int dstsep=d.count("/");
    2.61 +		if (srcsep <=  dstsep )
    2.62 +		{
    2.63 +			// find path to go up first and then back to dst
    2.64 +			i=1;
    2.65 +			while (i<=srcsep) 
    2.66 +			{
    2.67 +				d="../"+d;
    2.68 +				i++;
    2.69 +			}	
    2.70 +		}
    2.71 +	}	
    2.72 +	return d;
    2.73 +}
    2.74 +
    2.75 +#include <QFileDialog>
    2.76 +extern QString vymName;
    2.77 +extern QDir lastFileDir;
    2.78 +
    2.79 +QString browseDirectory (QWidget *parent,const QString &caption)
    2.80 +{
    2.81 +	QFileDialog fd(parent,caption);
    2.82 +	fd.setMode (QFileDialog::DirectoryOnly);
    2.83 +	fd.setCaption(vymName+ " - "+caption);
    2.84 +	fd.setDir (lastFileDir);
    2.85 +	fd.show();
    2.86 +	
    2.87 +	if ( fd.exec() == QDialog::Accepted )
    2.88 +		return fd.selectedFile();
    2.89 +	else
    2.90 +		return "";
    2.91 +}
    2.92 +
    2.93 +
    2.94 +
    2.95 +bool reallyWriteDirectory(const QString &dir)
    2.96 +{
    2.97 +	QStringList eList = QDir(dir).entryList();
    2.98 +	if (eList.first() ==".")  eList.pop_front();	// remove "."
    2.99 +	if (eList.first() =="..") eList.pop_front();	// remove "."
   2.100 +	if (!eList.isEmpty())
   2.101 +	{
   2.102 +		QMessageBox mb( vymName,
   2.103 +			QObject::tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
   2.104 +		QMessageBox::Warning,
   2.105 +		QMessageBox::Yes ,
   2.106 +		QMessageBox::Cancel | QMessageBox::Default,
   2.107 +		QMessageBox::NoButton );
   2.108 +
   2.109 +		mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
   2.110 +		mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
   2.111 +		switch( mb.exec() ) 
   2.112 +		{
   2.113 +			case QMessageBox::Yes:
   2.114 +				// save 
   2.115 +				return true;
   2.116 +			case QMessageBox::Cancel:
   2.117 +				// do nothing
   2.118 +				return false;
   2.119 +		}
   2.120 +	}
   2.121 +	return true;
   2.122 +}
   2.123 +
   2.124 +QString makeTmpDir (bool &ok, QString prefix)
   2.125 +{
   2.126 +	bool b;
   2.127 +	QString path=makeUniqueDir (b,QDir::tempPath()+"/"+prefix+"-XXXXXX");
   2.128 +	ok=b;
   2.129 +	return path;
   2.130 +}
   2.131 +
   2.132 +bool isInTmpDir(QString fn)
   2.133 +{
   2.134 +	QString temp=QDir::tempPath();
   2.135 +	int l=temp.length();
   2.136 +	return fn.left(l)==temp;
   2.137 +}
   2.138 +
   2.139 +QString makeUniqueDir (bool &ok,QString s)
   2.140 +{
   2.141 +	// Create unique directory e.g. for s="/tmp/vym-XXXXXX"
   2.142 +
   2.143 +	// Convert Separators
   2.144 +	s=QDir::convertSeparators(s);
   2.145 +
   2.146 +	// Convert QString to string 
   2.147 +	ok=true;
   2.148 +	char *p;
   2.149 +	int bytes=s.length();
   2.150 +	p=(char*) malloc (bytes+1);
   2.151 +	int i;
   2.152 +	for (i=0;i<bytes;i++)
   2.153 +		p[i]=s.at(i).latin1();
   2.154 +	p[bytes]=0;	
   2.155 +
   2.156 +	QString r=mkdtemp (p);
   2.157 +	if (r.isEmpty()) ok=false;
   2.158 +	free (p);
   2.159 +	return r;
   2.160 +}
   2.161 +
   2.162 +void removeDir(QDir d)
   2.163 +{
   2.164 +	// This check should_ not be necessary, but proved to be useful ;-)
   2.165 +	if (!isInTmpDir(d.path()))
   2.166 +	{
   2.167 +		qWarning ("file.cpp::removeDir should remove "+d.path()+" - aborted.");
   2.168 +		return;
   2.169 +	}
   2.170 +
   2.171 +	// Traverse directories
   2.172 +	d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
   2.173 +	QFileInfoList list = d.entryInfoList();
   2.174 +	QFileInfo fi;
   2.175 +
   2.176 +	for (int i = 0; i < list.size(); ++i) 
   2.177 +	{
   2.178 +		fi=list.at(i);
   2.179 +		if (fi.fileName() != "." && fi.fileName() != ".." )
   2.180 +		{
   2.181 +			if ( !d.cd(fi.fileName()) ) 
   2.182 +				qWarning ("removeDir() cannot find the directory "+fi.fileName());
   2.183 +			else 
   2.184 +			{
   2.185 +				// Recursively remove subdirs
   2.186 +				removeDir (d);
   2.187 +				d.cdUp();
   2.188 +			}
   2.189 +		}	
   2.190 +	}
   2.191 +
   2.192 +	// Traverse files
   2.193 +	d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
   2.194 +	list = d.entryInfoList();
   2.195 +
   2.196 +	for (int i = 0; i < list.size(); ++i) 
   2.197 +	{
   2.198 +		fi=list.at(i);
   2.199 +		QFile (fi.filePath()).remove(); 
   2.200 +	}	
   2.201 +
   2.202 +	if (!d.rmdir(d.path()))
   2.203 +		qWarning ("removeDir("+d.path()+") failed!");
   2.204 +}		
   2.205 +
   2.206 +void copyDir (QDir src, QDir dst)
   2.207 +{
   2.208 +	system ("cp -r "+src.path()+"/* "+dst.path());
   2.209 +
   2.210 +	/*
   2.211 +	ErrorCode err=success;
   2.212 +
   2.213 +	Process *cpProc=new Process ();
   2.214 +	QStringList args;
   2.215 +	cpProc->setWorkingDirectory (src.path());
   2.216 +	args <<"-r";
   2.217 +	args <<src.path();
   2.218 +	args <<dst.path();
   2.219 +
   2.220 +	cpProc->start ("cp",args);
   2.221 +	if (!cpProc->waitForStarted() )
   2.222 +	{	
   2.223 +		// zip could not be started
   2.224 +		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.225 +					   QObject::tr("Couldn't start zip to compress data."));
   2.226 +		err=aborted;
   2.227 +	} else
   2.228 +	{
   2.229 +		// zip could be started
   2.230 +		cpProc->waitForFinished();
   2.231 +		if (cpProc->exitStatus()!=QProcess::NormalExit )
   2.232 +		{
   2.233 +			QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.234 +						   QObject::tr("cp didn't exit normally")+
   2.235 +						   "\n" + cpProc->getErrout());
   2.236 +			err=aborted;
   2.237 +		} else
   2.238 +		{
   2.239 +			if (cpProc->exitCode()>0)
   2.240 +			{
   2.241 +				QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.242 +						   QString("cp exit code:  %1").arg(cpProc->exitCode() )+
   2.243 +						   "\n" + cpProc->getErrout() );
   2.244 +				err=aborted;
   2.245 +			}
   2.246 +		}
   2.247 +	}	// cp could be started
   2.248 +	*/
   2.249 +}
   2.250 +
   2.251 +void makeSubDirs (const QString &s)
   2.252 +{
   2.253 +	QDir d(s);
   2.254 +	d.mkdir(s);
   2.255 +	d.mkdir ("images");	
   2.256 +	d.mkdir ("flags");	
   2.257 +}
   2.258 +
   2.259 +ErrorCode zipDir (const QDir &zipDir, const QString &zipName)
   2.260 +{
   2.261 +	ErrorCode err=success;
   2.262 +	
   2.263 +	// zip the temporary directory
   2.264 +	QStringList args;
   2.265 +	Process *zipProc=new Process ();
   2.266 +	zipProc->setWorkingDirectory (zipDir.path());
   2.267 +	args <<"-r";
   2.268 +	args <<zipName;
   2.269 +	args <<".";
   2.270 +
   2.271 +	zipProc->start ("zip",args);
   2.272 +	if (!zipProc->waitForStarted() )
   2.273 +	{	
   2.274 +		// zip could not be started
   2.275 +		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.276 +					   QObject::tr("Couldn't start zip to compress data."));
   2.277 +		err=aborted;
   2.278 +	} else
   2.279 +	{
   2.280 +		// zip could be started
   2.281 +		zipProc->waitForFinished();
   2.282 +		if (zipProc->exitStatus()!=QProcess::NormalExit )
   2.283 +		{
   2.284 +			QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.285 +						   QObject::tr("zip didn't exit normally")+
   2.286 +						   "\n" + zipProc->getErrout());
   2.287 +			err=aborted;
   2.288 +		} else
   2.289 +		{
   2.290 +			if (zipProc->exitCode()>0)
   2.291 +			{
   2.292 +				QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.293 +						   QString("zip exit code:  %1").arg(zipProc->exitCode() )+
   2.294 +						   "\n" + zipProc->getErrout() );
   2.295 +				err=aborted;
   2.296 +			}
   2.297 +		}
   2.298 +	}	// zip could be started
   2.299 +	return err;	
   2.300 +}
   2.301 +
   2.302 +ErrorCode unzipDir (const QDir &zipDir, const QString &zipName)
   2.303 +{
   2.304 +	ErrorCode err=success;
   2.305 +
   2.306 +	// Try to unzip file
   2.307 +#if !defined(Q_OS_WIN32)
   2.308 +	QStringList args;
   2.309 +	Process *zipProc=new Process ();
   2.310 +	zipProc->setWorkingDirectory (zipDir.path());
   2.311 +	args << "-o";	// overwrite existing files!
   2.312 +	args << zipName ;
   2.313 +	args << "-d";
   2.314 +	args << zipDir.path();
   2.315 +
   2.316 +	zipProc->start ("unzip",args);
   2.317 +	if (!zipProc->waitForStarted() )
   2.318 +	{
   2.319 +		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.320 +					   QObject::tr("Couldn't start unzip to decompress data."));
   2.321 +		err=aborted;
   2.322 +		
   2.323 +	} else
   2.324 +	{
   2.325 +		zipProc->waitForFinished();
   2.326 +		if (zipProc->exitStatus()!=QProcess::NormalExit )
   2.327 +		{
   2.328 +			QMessageBox::critical( 0,QObject::tr( "Critical Error" ),
   2.329 +						   QObject::tr("unzip didn't exit normally") +
   2.330 +						   zipProc->getErrout() );
   2.331 +			err=aborted;
   2.332 +		} else
   2.333 +		{
   2.334 +			if (zipProc->exitCode()>0)
   2.335 +			{
   2.336 +				if (zipProc->exitCode()==9)
   2.337 +					// no zipped file, but maybe .xml or old version? Try again.
   2.338 +					err=nozip;
   2.339 +				else	
   2.340 +				{
   2.341 +					QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
   2.342 +								   QString("unzip exit code:  %1").arg(zipProc->exitCode() ) +
   2.343 +								   zipProc->getErrout() );
   2.344 +					err=aborted;
   2.345 +				}
   2.346 +			} 
   2.347 +		}
   2.348 +	}
   2.349 +#else
   2.350 +    // Do this process creation using Win32 API.
   2.351 +    //! Create process.
   2.352 +    PROCESS_INFORMATION piProcInfo;
   2.353 +    STARTUPINFO siStartInfo;
   2.354 +
   2.355 +    // Initialize members of the PROCESS_INFORMATION structure.
   2.356 +    ::ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
   2.357 +
   2.358 +    // Set up members of the STARTUPINFO structure.
   2.359 +    ::ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
   2.360 +    siStartInfo.cb = sizeof(STARTUPINFO);
   2.361 +
   2.362 +    // Create command line.
   2.363 +    QString argv("unzip -o ");
   2.364 +    argv.append(QDir::convertSeparators(zipName));
   2.365 +    argv.append(" -d ");
   2.366 +    argv.append(QDir::convertSeparators(zipDir.path()));
   2.367 +
   2.368 +    // Create the child process.
   2.369 +    if( !::CreateProcess(NULL, 
   2.370 +        (LPWSTR)argv.unicode(), // command line
   2.371 +        NULL, // process security attributes
   2.372 +        NULL, // primary thread security attributes
   2.373 +        TRUE, // handles are inherited
   2.374 +        0, // creation flags
   2.375 +        NULL, // use parent's environment
   2.376 +        NULL, // use parent's current directory
   2.377 +        &siStartInfo, // STARTUPINFO pointer
   2.378 +        &piProcInfo) ) // receives PROCESS_INFORMATION
   2.379 +    {
   2.380 +        err = aborted;
   2.381 +    }
   2.382 +    else
   2.383 +    {
   2.384 +        // Wait for it to finish.
   2.385 +        ::WaitForSingleObject( piProcInfo.hProcess, 10000 );
   2.386 +    }
   2.387 +#endif
   2.388 +	return err;	
   2.389 +}
   2.390 +
   2.391 +bool loadStringFromDisk (const QString &fname, QString &s)
   2.392 +{
   2.393 +	s="";
   2.394 +	QFile file ( fname);
   2.395 +	if ( !file.open( QIODevice::ReadOnly ) ) return false;
   2.396 +
   2.397 +	QTextStream ts( &file );
   2.398 +	ts.setEncoding (QTextStream::UnicodeUTF8);
   2.399 +	while ( !ts.atEnd() ) 
   2.400 +		s+=ts.readLine()+"\n"; 
   2.401 +	file.close();
   2.402 +	return true;
   2.403 +}
   2.404 +
   2.405 +bool saveStringToDisk (const QString &fname, const QString &s)
   2.406 +{
   2.407 +	QFile file( fname);
   2.408 +
   2.409 +	file.setName ( fname);
   2.410 +	if ( !file.open( QIODevice::WriteOnly ) ) 
   2.411 +	{
   2.412 +		file.close();
   2.413 +		return false;
   2.414 +	}	
   2.415 +
   2.416 +	// Write it finally, and write in UTF8, no matter what 
   2.417 +	QTextStream ts( &file );
   2.418 +	ts.setEncoding (QTextStream::UnicodeUTF8);
   2.419 +	ts << s;
   2.420 +	file.close();
   2.421 +	return true;
   2.422 +}
   2.423 +
   2.424 +
   2.425 +ImagePreview::ImagePreview (QWidget *par=0): QLabel (par)
   2.426 +{
   2.427 +	fdia=(Q3FileDialog*)par;
   2.428 +}
   2.429 +
   2.430 +void ImagePreview::previewUrl( const Q3Url &u )
   2.431 +{
   2.432 +    QString path = u.path();
   2.433 +    QPixmap pix( path );
   2.434 +    if ( pix.isNull() )
   2.435 +	{
   2.436 +		// Strange: If we have fd->setMode (QFileDialog::ExistingFiles)
   2.437 +		// in the filedialog, then there are 3 calls to previewURL 
   2.438 +		// for each selection. And only the first is the actual selected file
   2.439 +		// while the following 2 point to the directory above the current one.
   2.440 +		// So here's my workaround:
   2.441 +		
   2.442 +		if (fdia && fdia->selectedFiles().count()==0)
   2.443 +			setText( QObject::tr("This is not an image.") );
   2.444 +		if (fdia &&fdia->selectedFiles().count()>1)
   2.445 +			setText( QObject::tr("Sorry, no preview for\nmultiple selected files.") );
   2.446 +	}	
   2.447 +    else
   2.448 +	{
   2.449 +		float max_w=300;
   2.450 +		float max_h=300;
   2.451 +		float r;
   2.452 +		if (pix.width()>max_w)
   2.453 +		{
   2.454 +			r=max_w / pix.width();
   2.455 +			pix.resize(qRound(pix.width()*r), qRound(pix.height()*r));
   2.456 +			// TODO not a resize, but a shrink/enlarge is needed here...
   2.457 +		}
   2.458 +		if (pix.height()>max_h)
   2.459 +		{
   2.460 +			r=max_h / pix.height();
   2.461 +			pix.resize(qRound(pix.width()*r), qRound(pix.height()*r));
   2.462 +			// TODO not a resize, but a shrink/enlarge is needed here...
   2.463 +		}
   2.464 +        setPixmap( pix );
   2.465 +	}	
   2.466 +}
   2.467 +
   2.468 +ImageIO::ImageIO ()
   2.469 +{
   2.470 +	// Create list with supported image types
   2.471 +	// foreach (QByteArray format, QImageWriter::supportedImageFormats()) 
   2.472 +	// imageTypes.append( tr("%1...").arg(QString(format).toUpper()));
   2.473 +	imageFilters.append ("Images (*.png *.jpg *.jpeg *.bmp *.bmp *.ppm *.xpm *.xbm)");
   2.474 +	imageTypes.append ("PNG");
   2.475 +	imageFilters.append ("Portable Network Graphics (*.png)");
   2.476 +	imageTypes.append ("PNG");
   2.477 +	imageFilters.append ("Joint Photographic Experts Group (*.jpg)");
   2.478 +	imageTypes.append ("JPG");
   2.479 +	imageFilters.append ("Joint Photographic Experts Group (*.jpeg)");
   2.480 +	imageTypes.append ("JPG");
   2.481 +	imageFilters.append ("Windows Bitmap (*.bmp)");
   2.482 +	imageTypes.append ("BMP");
   2.483 +	imageFilters.append ("Portable Pixmap (*.ppm)");
   2.484 +	imageTypes.append ("PPM");
   2.485 +	imageFilters.append ("X11 Bitmap (*.xpm)");
   2.486 +	imageTypes.append ("XPM");
   2.487 +	imageFilters.append ("X11 Bitmap (*.xbm)");
   2.488 +	imageTypes.append ("XBM");
   2.489 +}
   2.490 +
   2.491 +QStringList ImageIO::getFilters()
   2.492 +{
   2.493 +	return imageFilters;
   2.494 +}
   2.495 +
   2.496 +QString ImageIO::getType(QString filter)
   2.497 +{
   2.498 +	for (int i=0;i<imageFilters.count()+1;i++)
   2.499 +		if (imageFilters.at(i)==filter) return imageTypes.at(i);
   2.500 +	return QString();	
   2.501 +}
   2.502 +
   2.503 +
     3.1 --- a/linkablemapobj.cpp	Fri Mar 05 20:16:46 2010 +0000
     3.2 +++ b/linkablemapobj.cpp	Tue Mar 23 11:54:30 2010 +0000
     3.3 @@ -1,12 +1,10 @@
     3.4 -//#include <math.h>
     3.5 +#include <math.h>
     3.6 +#include <cstdlib>
     3.7  
     3.8  #include "linkablemapobj.h"
     3.9  #include "branchobj.h"
    3.10  #include "mapeditor.h"
    3.11  
    3.12 -#include "version.h"
    3.13 -
    3.14 -
    3.15  /////////////////////////////////////////////////////////////////
    3.16  // LinkableMapObj
    3.17  /////////////////////////////////////////////////////////////////
    3.18 @@ -17,13 +15,13 @@
    3.19      init ();
    3.20  }
    3.21  
    3.22 -LinkableMapObj::LinkableMapObj(QCanvas* c) :MapObj(c)
    3.23 +LinkableMapObj::LinkableMapObj(QGraphicsScene* s) :MapObj(s)
    3.24  {
    3.25 -//    cout << "Const LinkableMapObj\n";
    3.26 +//    cout << "Const LinkableMapObj (s)\n";
    3.27      init ();
    3.28  }
    3.29  
    3.30 -LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->canvas)
    3.31 +LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->scene)
    3.32  {
    3.33      copy (lmo);
    3.34  }
    3.35 @@ -31,8 +29,6 @@
    3.36  LinkableMapObj::~LinkableMapObj()
    3.37  {
    3.38      delete (bottomline);
    3.39 -    delete (selbox);
    3.40 -	delete (frame);
    3.41  	delLink();
    3.42  }
    3.43  
    3.44 @@ -40,19 +36,17 @@
    3.45  {
    3.46  	switch (style)
    3.47  	{
    3.48 -		case StyleLine:
    3.49 +		case Line:
    3.50  			delete (l);
    3.51  			break;
    3.52 -		case StyleParabel:
    3.53 -			segment.clear();
    3.54 +		case Parabel:
    3.55 +			while (!segment.isEmpty()) delete segment.takeFirst();
    3.56  			break;
    3.57 -		case StylePolyLine:
    3.58 +		case PolyLine:
    3.59  			delete (p);
    3.60 -			delete (l);
    3.61  			break;
    3.62 -		case StylePolyParabel:
    3.63 +		case PolyParabel:
    3.64  			delete (p);
    3.65 -			segment.clear();
    3.66  			break;
    3.67  		default:
    3.68  			break;
    3.69 @@ -62,49 +56,56 @@
    3.70  void LinkableMapObj::init ()
    3.71  {
    3.72      depth=-1;	
    3.73 +	mapEditor=NULL;
    3.74      childObj=NULL;
    3.75      parObj=NULL;
    3.76      parObjTmpBuf=NULL;
    3.77 -    parPos=QPoint(0,0);
    3.78 -    childPos=QPoint(0,0);
    3.79 +    parPos=QPointF(0,0);
    3.80 +    childPos=QPointF(0,0);
    3.81  	link2ParPos=false;
    3.82      l=NULL;
    3.83 -    orientation=OrientUndef;
    3.84 +    orientation=UndefinedOrientation;
    3.85      linkwidth=20;		
    3.86  	thickness_start=8;
    3.87 -    style=StyleUndef;
    3.88 -	linkpos=LinkBottom;
    3.89 -    segment.setAutoDelete (TRUE);
    3.90 +    style=UndefinedStyle;
    3.91 +	linkpos=Bottom;
    3.92      arcsegs=13;
    3.93 -	QPointArray pa(arcsegs*2+2);
    3.94      
    3.95 -    bottomline=new QCanvasLine(canvas);
    3.96 -    bottomline->setPen( QPen(linkcolor, 1) );
    3.97 -    bottomline->setZ(Z_LINK);
    3.98 +// TODO instead of linkcolor pen.color() could be used	all around
    3.99 +	pen.setWidth (1);
   3.100 +	pen.setColor (linkcolor);
   3.101 +	pen.setCapStyle ( Qt::RoundCap );
   3.102 +	bottomline=scene->addLine(QLineF(1,1,1,1),pen);
   3.103 +    bottomline->setZValue(Z_LINK);
   3.104      bottomline->show();
   3.105  
   3.106      // Prepare showing the selection of a MapObj
   3.107 -    selbox = new QCanvasRectangle (canvas);
   3.108 -    selbox->setZ(Z_SELBOX);
   3.109 -    selbox->setBrush( QColor(255,255,0) );
   3.110 -    selbox->setPen( QPen(QColor(255,255,0) ));
   3.111 -    selbox->hide();
   3.112      selected=false;
   3.113  
   3.114 -	// initialize frame
   3.115 -	frame = new FrameObj (canvas);
   3.116 -	
   3.117 +	hideLinkUnselected=false;
   3.118 +
   3.119 +	topPad=botPad=leftPad=rightPad=0;
   3.120 +
   3.121  	repositionRequest=false;
   3.122 +
   3.123 +	// Rel Positions
   3.124 +	relPos=QPointF(0,0);
   3.125 +	useRelPos=false;
   3.126 +	useOrientation=true;
   3.127 +
   3.128 +	// Reset ID
   3.129 +	objID="";
   3.130  }
   3.131  
   3.132  void LinkableMapObj::copy (LinkableMapObj* other)
   3.133  {
   3.134      MapObj::copy(other);
   3.135  	bboxTotal=other->bboxTotal;
   3.136 -//    linkwidth=other->linkwidth;		
   3.137 -
   3.138      setLinkStyle(other->style);
   3.139      setLinkColor (other->linkcolor);
   3.140 +	relPos=other->relPos;
   3.141 +	useOrientation=other->useOrientation;
   3.142 +	objID=other->objID;
   3.143  }
   3.144  
   3.145  void LinkableMapObj::setChildObj(LinkableMapObj* o)
   3.146 @@ -118,7 +119,7 @@
   3.147  	mapEditor=parObj->getMapEditor();
   3.148  }
   3.149  
   3.150 -void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPoint,int)
   3.151 +void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int)
   3.152  {
   3.153  }
   3.154  
   3.155 @@ -126,66 +127,116 @@
   3.156  {
   3.157  }
   3.158  
   3.159 -LinkStyle LinkableMapObj::getDefLinkStyle ()
   3.160 +bool LinkableMapObj::hasParObjTmp()
   3.161  {
   3.162 -	LinkStyle ls=mapEditor->getLinkStyle();
   3.163 +	if (parObjTmpBuf) return true;
   3.164 +	return false;
   3.165 +}
   3.166 +
   3.167 +void LinkableMapObj::setUseRelPos (const bool &b)
   3.168 +{
   3.169 +	useRelPos=b;
   3.170 +}
   3.171 +
   3.172 +void LinkableMapObj::setRelPos()
   3.173 +{
   3.174 +	if (parObj)
   3.175 +	{	
   3.176 +		relPos.setX (absPos.x() - parObj->getChildPos().x() );
   3.177 +		relPos.setY (absPos.y() - parObj->getChildPos().y() );
   3.178 +		parObj->calcBBoxSize();
   3.179 +	}	
   3.180 +}
   3.181 +
   3.182 +void LinkableMapObj::setRelPos(const QPointF &p)
   3.183 +{
   3.184 +	relPos=p;
   3.185 +	if (parObj)
   3.186 +	{		
   3.187 +		parObj->calcBBoxSize();
   3.188 +		requestReposition();
   3.189 +	}
   3.190 +}
   3.191 +
   3.192 +QPointF LinkableMapObj::getRelPos()
   3.193 +{
   3.194 +	if (!parObj) return QPointF();
   3.195 +	return relPos;
   3.196 +}
   3.197 +
   3.198 +qreal LinkableMapObj::getTopPad()
   3.199 +{
   3.200 +	return topPad;
   3.201 +}
   3.202 +
   3.203 +qreal LinkableMapObj::getLeftPad()
   3.204 +{
   3.205 +	return leftPad;
   3.206 +}
   3.207 +
   3.208 +qreal LinkableMapObj::getRightPad()
   3.209 +{
   3.210 +	return rightPad;
   3.211 +}
   3.212 +
   3.213 +LinkableMapObj::Style LinkableMapObj::getDefLinkStyle ()
   3.214 +{
   3.215 +	if (!mapEditor) return UndefinedStyle;
   3.216 +	Style ls=mapEditor->getMapLinkStyle();
   3.217  	switch (ls)
   3.218  	{
   3.219 -		case StyleLine: 
   3.220 +		case Line: 
   3.221  			return ls;
   3.222  			break;
   3.223 -		case StyleParabel:
   3.224 +		case Parabel:
   3.225  			return ls;
   3.226  			break;
   3.227 -		case StylePolyLine:	
   3.228 +		case PolyLine:	
   3.229  			if (depth>1)
   3.230 -				return StyleLine;
   3.231 +				return Line;
   3.232  			else	
   3.233  				return ls;
   3.234  			break;
   3.235 -		case StylePolyParabel:	
   3.236 +		case PolyParabel:	
   3.237  			if (depth>1)
   3.238 -				return StyleParabel;
   3.239 +				return Parabel;
   3.240  			else	
   3.241  				return ls;
   3.242  			break;
   3.243  		default: 
   3.244  			break;	
   3.245  	}	
   3.246 -	return StyleUndef;
   3.247 +	return UndefinedStyle;
   3.248  }
   3.249  
   3.250 -void LinkableMapObj::setLinkStyle(LinkStyle newstyle)
   3.251 +void LinkableMapObj::setLinkStyle(Style newstyle)
   3.252  {
   3.253 +	//if (newstyle=style) return;
   3.254  	delLink();
   3.255  		
   3.256  	style=newstyle;
   3.257  
   3.258      if (childObj!=NULL && parObj != NULL)
   3.259      {
   3.260 -		int i;
   3.261 -		QCanvasLine* cl;
   3.262 +		QGraphicsLineItem *cl;
   3.263  		switch (style)
   3.264  		{
   3.265 -			case StyleUndef:
   3.266 +			case UndefinedStyle:
   3.267  				bottomline->hide();
   3.268  				break;
   3.269 -			case StyleLine: 
   3.270 -				l = new QCanvasLine(canvas);
   3.271 -				l->setPen( QPen(linkcolor, 1) );
   3.272 -				l->setZ(Z_LINK);
   3.273 +			case Line: 
   3.274 +				l = scene->addLine(QLineF(1,1,1,1),pen);
   3.275 +				l->setZValue(Z_LINK);
   3.276  				if (visible)
   3.277  					l->show();
   3.278  				else
   3.279  					l->hide();
   3.280  				break;
   3.281 -			case StyleParabel:
   3.282 -				for (i=0;i<arcsegs;i++)
   3.283 +			case Parabel:
   3.284 +				for (int i=0;i<arcsegs;i++)
   3.285  				{
   3.286 -					cl = new QCanvasLine(canvas);
   3.287 -					cl->setPen( QPen(linkcolor, 1) );
   3.288 -					cl->setPoints( 0,0,i*10,100);
   3.289 -					cl->setZ(Z_LINK);
   3.290 +					cl = scene->addLine(QLineF(i*5,0,i*10,100),pen);
   3.291 +					cl->setZValue(Z_LINK);
   3.292  					if (visible)
   3.293  						cl->show();
   3.294  					else
   3.295 @@ -194,30 +245,18 @@
   3.296  				}
   3.297  				pa0.resize (arcsegs+1);
   3.298  				break;
   3.299 -			case StylePolyLine:	
   3.300 -				p = new QCanvasPolygon(canvas);
   3.301 -				p->setBrush( linkcolor );
   3.302 -				p->setZ(Z_LINK);
   3.303 +			case PolyLine:	
   3.304 +				p =scene->addPolygon(QPolygonF(),pen,linkcolor);
   3.305 +				p->setZValue(Z_LINK);
   3.306  				if (visible)
   3.307  					p->show();
   3.308  				else
   3.309  					p->hide();
   3.310  				pa0.resize (3);
   3.311 -				// TODO
   3.312 -				// a bit awkward: draw the lines additionally to polygon, to avoid
   3.313 -				// missing pixels, when polygon is extremly flat
   3.314 -				l = new QCanvasLine(canvas);
   3.315 -				l->setPen( QPen(linkcolor, 1) );
   3.316 -				l->setZ(Z_LINK);
   3.317 -				if (visible)
   3.318 -					l->show();
   3.319 -				else
   3.320 -					l->hide();
   3.321  				break;
   3.322 -			case StylePolyParabel:	
   3.323 -				p = new QCanvasPolygon(canvas);
   3.324 -				p->setBrush( linkcolor );
   3.325 -				p->setZ(Z_LINK);
   3.326 +			case PolyParabel:	
   3.327 +				p = scene->addPolygon(QPolygonF(),pen,linkcolor);
   3.328 +				p->setZValue(Z_LINK);
   3.329  				if (visible)
   3.330  					p->show();
   3.331  				else
   3.332 @@ -225,83 +264,83 @@
   3.333  				pa0.resize (arcsegs*2+2);
   3.334  				pa1.resize (arcsegs+1);
   3.335  				pa2.resize (arcsegs+1);
   3.336 -
   3.337 -				// TODO
   3.338 -				// a bit awkward: draw the lines additionally 
   3.339 -				// to polygon, to avoid missing pixels, 
   3.340 -				// if polygon is extremly flat
   3.341 -				for (i=0;i<arcsegs;i++)
   3.342 -				{
   3.343 -					cl = new QCanvasLine(canvas);
   3.344 -					cl->setPen( QPen(linkcolor, 1) );
   3.345 -					cl->setPoints( 0,0,i*10,100);
   3.346 -					cl->setZ(Z_LINK);
   3.347 -					if (visible)
   3.348 -						cl->show();
   3.349 -					else
   3.350 -						cl->hide();
   3.351 -					segment.append(cl);
   3.352 -				}
   3.353  				break;
   3.354  			default: 
   3.355  				break;	
   3.356  		}	
   3.357 -	} else
   3.358 -	{
   3.359 -		cout << "Error: ChildObj or parObj == NULL in LinkableMapObj::setLinkStyle\n";
   3.360 -	}
   3.361 +	} 
   3.362  }
   3.363  
   3.364 -LinkStyle LinkableMapObj::getLinkStyle()
   3.365 +LinkableMapObj::Style LinkableMapObj::getLinkStyle()
   3.366  {
   3.367  	return style;
   3.368  }
   3.369  
   3.370 -void LinkableMapObj::setLinkPos(LinkPos lp)
   3.371 +void LinkableMapObj::setHideLinkUnselected(bool b)
   3.372 +{
   3.373 +	hideLinkUnselected=b;
   3.374 +	setVisibility (visible);
   3.375 +	updateLink();
   3.376 +}
   3.377 +
   3.378 +bool LinkableMapObj::getHideLinkUnselected()
   3.379 +{
   3.380 +	return hideLinkUnselected;
   3.381 +}
   3.382 +
   3.383 +void LinkableMapObj::setLinkPos(Position lp)
   3.384  {
   3.385  	linkpos=lp;
   3.386  }
   3.387  
   3.388 -LinkPos LinkableMapObj::getLinkPos()
   3.389 +LinkableMapObj::Position LinkableMapObj::getLinkPos()
   3.390  {
   3.391  	return linkpos;
   3.392  }
   3.393  
   3.394 +void LinkableMapObj::setID (const QString &s)
   3.395 +{
   3.396 +	objID=s;
   3.397 +}
   3.398 +
   3.399 +QString LinkableMapObj::getID()
   3.400 +{
   3.401 +	return objID;
   3.402 +}
   3.403  
   3.404  void LinkableMapObj::setLinkColor()
   3.405  {
   3.406  	// Overloaded in BranchObj and childs
   3.407  	// here only set default color
   3.408 -	setLinkColor (mapEditor->getDefLinkColor());
   3.409 +	if (mapEditor)
   3.410 +		setLinkColor (mapEditor->getMapDefLinkColor());
   3.411  }
   3.412  
   3.413  void LinkableMapObj::setLinkColor(QColor col)
   3.414  {
   3.415  	linkcolor=col;
   3.416 -    bottomline->setPen( QPen(linkcolor, 1) );
   3.417 -	QCanvasLine *cl;
   3.418 +	pen.setColor(col);
   3.419 +    bottomline->setPen( pen );
   3.420  	switch (style)
   3.421  	{
   3.422 -		case StyleLine:
   3.423 -			l->setPen( QPen(col,1));
   3.424 +		case Line:
   3.425 +			l->setPen( pen);
   3.426  			break;	
   3.427 -		case StyleParabel:	
   3.428 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.429 -				cl->setPen( QPen(col,1));
   3.430 +		case Parabel:	
   3.431 +			for (int i=0; i<segment.size(); ++i)
   3.432 +				segment.at(i)->setPen( pen);
   3.433  			break;
   3.434 -		case StylePolyLine:
   3.435 +		case PolyLine:
   3.436  			p->setBrush( QBrush(col));
   3.437 -			l->setPen( QPen(col,1));
   3.438 +			p->setPen( pen);
   3.439  			break;
   3.440 -		case StylePolyParabel:	
   3.441 +		case PolyParabel:	
   3.442  			p->setBrush( QBrush(col));
   3.443 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.444 -				cl->setPen( QPen(col,1));
   3.445 +			p->setPen( pen);
   3.446  			break;
   3.447  		default:
   3.448  			break;
   3.449  	} // switch (style)	
   3.450 -	updateLink();
   3.451  }
   3.452  
   3.453  QColor LinkableMapObj::getLinkColor()
   3.454 @@ -309,58 +348,85 @@
   3.455  	return linkcolor;
   3.456  }
   3.457  
   3.458 -FrameType LinkableMapObj::getFrameType()
   3.459 -{
   3.460 -	return frame->getFrameType();
   3.461 -}
   3.462 -
   3.463 -void LinkableMapObj::setFrameType(const FrameType &t)
   3.464 -{
   3.465 -	frame->setFrameType(t);
   3.466 -	calcBBoxSize();
   3.467 -	positionBBox();
   3.468 -	requestReposition();
   3.469 -}
   3.470 -
   3.471 -void LinkableMapObj::setFrameType(const QString &t)
   3.472 -{
   3.473 -	frame->setFrameType(t);
   3.474 -	calcBBoxSize();
   3.475 -	positionBBox();
   3.476 -	requestReposition();
   3.477 -}
   3.478 -
   3.479  void LinkableMapObj::setVisibility (bool v)
   3.480  {
   3.481  	MapObj::setVisibility (v);
   3.482 -	if (visible) 
   3.483 +	bool visnow=visible;
   3.484 +
   3.485 +	// We can hide the link, while object is not selected
   3.486 +	if (hideLinkUnselected && !selected)
   3.487 +		visnow=false;
   3.488 +
   3.489 +	if (visnow) 
   3.490  	{
   3.491  		bottomline->show();
   3.492 -		// FIXME lines and segments should be done in LMO?
   3.493 -		if (style==StyleLine && l) 
   3.494 +		switch (style)
   3.495  		{
   3.496 -			l->show();
   3.497 -		} else
   3.498 -		{
   3.499 -			QCanvasLine* cl;
   3.500 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.501 -				cl->show();
   3.502 -		} 
   3.503 +			case Line:
   3.504 +				if (l) l->show();
   3.505 +				break;
   3.506 +			case Parabel:	
   3.507 +				for (int i=0; i<segment.size(); ++i)
   3.508 +					segment.at(i)->show();
   3.509 +				break;	
   3.510 +			case PolyLine:
   3.511 +				if (p) p->show();
   3.512 +				break;
   3.513 +			case PolyParabel:	
   3.514 +				if (p) p->show();
   3.515 +				break;
   3.516 +			default:
   3.517 +				break;
   3.518 +		}
   3.519  	} else 
   3.520  	{
   3.521  		bottomline->hide();
   3.522 -		if (style==StyleLine && l) 
   3.523 +		switch (style)
   3.524  		{
   3.525 -			l->hide();
   3.526 -		} else
   3.527 -		{
   3.528 -			QCanvasLine* cl;
   3.529 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.530 -				cl->hide();
   3.531 -		} 
   3.532 +			case Line:
   3.533 +				if (l) l->hide();
   3.534 +				break;
   3.535 +			case Parabel:	
   3.536 +				for (int i=0; i<segment.size(); ++i)
   3.537 +					segment.at(i)->hide();
   3.538 +				break;	
   3.539 +			case PolyLine:
   3.540 +				if (p) p->hide();
   3.541 +				break;
   3.542 +			case PolyParabel:	
   3.543 +				if (p) p->hide();
   3.544 +				break;
   3.545 +			default:
   3.546 +				break;
   3.547 +		}
   3.548  	}	
   3.549  }
   3.550  
   3.551 +void LinkableMapObj::setOrientation()
   3.552 +{
   3.553 +	Orientation orientOld=orientation;
   3.554 +
   3.555 +	if (!parObj) 
   3.556 +	{
   3.557 +		orientation=UndefinedOrientation;
   3.558 +		return;
   3.559 +	}
   3.560 +		
   3.561 +    // Set orientation, first look for orientation of parent
   3.562 +    if (parObj->getOrientation() != UndefinedOrientation ) 
   3.563 +		// use the orientation of the parent:
   3.564 +		orientation=parObj->getOrientation();
   3.565 +    else
   3.566 +    {
   3.567 +		// calc orientation depending on position rel to parent
   3.568 +		if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
   3.569 +			orientation=LeftOfCenter; 
   3.570 +		else
   3.571 +			orientation=RightOfCenter;
   3.572 +    }
   3.573 +	if (orientOld!=orientation) requestReposition();
   3.574 +}
   3.575 +
   3.576  void LinkableMapObj::updateLink()
   3.577  {
   3.578      // needs:
   3.579 @@ -370,84 +436,38 @@
   3.580      // 
   3.581      // sets:
   3.582      //	orientation
   3.583 -    //	childPos
   3.584 -    //	parPos
   3.585 -	//  offset
   3.586 +    //	childPos	(by calling setDockPos())
   3.587 +    //	parPos		(by calling setDockPos())
   3.588 +	//  bottomlineY
   3.589      //	drawing of the link itself
   3.590  
   3.591 -
   3.592  	// updateLink is called from move, but called from constructor we don't
   3.593  	// have parents yet...
   3.594 -	if (style==StyleUndef) return;	
   3.595 +	if (style==UndefinedStyle) return;	
   3.596  
   3.597 -	if (frame->getFrameType() == NoFrame)
   3.598 -		linkpos=LinkBottom;
   3.599 -	else	
   3.600 -		linkpos=LinkMiddle;
   3.601  	switch (linkpos)
   3.602  	{
   3.603 -		case LinkMiddle:
   3.604 -			offset=bbox.height() /2;
   3.605 +		case Middle:
   3.606 +			bottomlineY=bbox.top() + bbox.height()/2;	// draw link to middle (of frame)
   3.607  			break;
   3.608 -		default :
   3.609 -			offset=bbox.height()-1;			// draw link to bottom of bbox
   3.610 +		case Bottom:
   3.611 +			bottomlineY=bbox.bottom()-1;	// draw link to bottom of box
   3.612  			break;
   3.613  	}
   3.614  	
   3.615      double p2x,p2y;								// Set P2 Before setting
   3.616  	if (!link2ParPos)
   3.617  	{
   3.618 -		p2x=QPoint( parObj->getChildPos() ).x();	// P1, we have to look at
   3.619 -		p2y=QPoint( parObj->getChildPos() ).y();	// orientation
   3.620 +		p2x=QPointF( parObj->getChildPos() ).x();	// P1, we have to look at
   3.621 +		p2y=QPointF( parObj->getChildPos() ).y();	// orientation
   3.622  	} else	
   3.623  	{
   3.624 -		p2x=QPoint( parObj->getParPos() ).x();	
   3.625 -		p2y=QPoint( parObj->getParPos() ).y();
   3.626 +		p2x=QPointF( parObj->getParPos() ).x();	
   3.627 +		p2y=QPointF( parObj->getParPos() ).y();
   3.628  	} 
   3.629  
   3.630 -	LinkOrient orientOld=orientation;
   3.631 -
   3.632 -    // Set orientation, first look for orientation of parent
   3.633 -    if (parObj->getOrientation() != OrientUndef ) 
   3.634 -		// use the orientation of the parent:
   3.635 -		orientation=parObj->getOrientation();
   3.636 -    else
   3.637 -    {
   3.638 -		// calc orientation depending on position rel to mapCenter
   3.639 -		if (absPos.x() < QPoint(parObj->getChildPos() ).x() )
   3.640 -			orientation=OrientLeftOfCenter; 
   3.641 -		else
   3.642 -			orientation=OrientRightOfCenter;
   3.643 -    }
   3.644 -
   3.645 -	if ((orientation!=orientOld) && (orientOld!= OrientUndef))
   3.646 -	{
   3.647 -		// Orientation just changed. Reorient this subbranch, because move is called
   3.648 -		// before updateLink => Position is still the old one, which could lead to 
   3.649 -		// linking of subranch to itself => segfault
   3.650 -		//
   3.651 -		// Also possible: called in BranchObj::init(), then orientOld==OrientUndef,
   3.652 -		// no need to reposition now
   3.653 -		reposition();
   3.654 -	}
   3.655 -	
   3.656 -    if (orientation==OrientLeftOfCenter )
   3.657 -    {
   3.658 -		childPos=QPoint (absPos.x(),absPos.y()+offset);
   3.659 -		parPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset );
   3.660 -    } else
   3.661 -    {
   3.662 -		childPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset ); 
   3.663 -		parPos=QPoint (absPos.x(),absPos.y()+offset);
   3.664 -    }
   3.665 -	/* FIXME
   3.666 -		cout << "      LMO::updateLink   absPos="<<absPos<<endl;
   3.667 -		cout << "      LMO::updateLink childPos="<<childPos<<endl;
   3.668 -		cout << "      LMO::updateLink   parPos="<<parPos<<endl;
   3.669 -		cout << "      LMO::updateLink   offset="<<offset<<endl;
   3.670 -		cout << "      LMO::updateLink   bbox.w="<<bbox.width()<<endl;
   3.671 -		cout << "      LMO::updateLink   bbox.h="<<bbox.height()<<endl;
   3.672 -	*/	
   3.673 +	setDockPos(); // Call overloaded method
   3.674 +	setOrientation();
   3.675  
   3.676  	double p1x=parPos.x();	// Link is drawn from P1 to P2
   3.677  	double p1y=parPos.y();
   3.678 @@ -456,10 +476,11 @@
   3.679  	double vy=p2y - p1y;
   3.680  
   3.681  	// Draw the horizontal line below heading (from ChildPos to ParPos)
   3.682 -	bottomline->setPoints (lrint(childPos.x()),
   3.683 -		lrint(childPos.y()),
   3.684 -		lrint(p1x),
   3.685 -		lrint(p1y) );
   3.686 +	//bottomline->prepareGeometryChange();
   3.687 +	bottomline->setLine (QLine (qRound(childPos.x()),
   3.688 +		qRound(childPos.y()),
   3.689 +		qRound(p1x),
   3.690 +		qRound(p1y) ));
   3.691  
   3.692  	double a;	// angle
   3.693  	if (vx > -0.000001 && vx < 0.000001)
   3.694 @@ -467,57 +488,44 @@
   3.695  	else
   3.696  		a=atan( vy / vx );
   3.697  	// "turning point" for drawing polygonal links
   3.698 -	QPoint tp (-lrint(sin (a)*thickness_start), lrint(cos (a)*thickness_start));	
   3.699 +	QPointF tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start));	
   3.700  	
   3.701 -	QCanvasLine *cl;
   3.702 -
   3.703 -	int i;
   3.704 -
   3.705      // Draw the link
   3.706  	switch (style)
   3.707  	{
   3.708 -		case StyleLine:
   3.709 -			l->setPoints( lrint (parPos.x()),
   3.710 -				lrint(parPos.y()),
   3.711 -				lrint(p2x),
   3.712 -				lrint(p2y) );
   3.713 +		case Line:
   3.714 +			//l->prepareGeometryChange();
   3.715 +			l->setLine( QLine(qRound (parPos.x()),
   3.716 +				qRound(parPos.y()),
   3.717 +				qRound(p2x),
   3.718 +				qRound(p2y) ));
   3.719  			break;	
   3.720 -		case StyleParabel:	
   3.721 +		case Parabel:	
   3.722  			parabel (pa0, p1x,p1y,p2x,p2y);
   3.723 -			i=0;
   3.724 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.725 -			{	
   3.726 -				cl->setPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y());
   3.727 -				i++;
   3.728 -			}
   3.729 +			for (int i=0; i<segment.size(); ++i)
   3.730 +			{
   3.731 +				//segment.at(i)->prepareGeometryChange();
   3.732 +				segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y()));
   3.733 +			}	
   3.734  			break;
   3.735 -		case StylePolyLine:
   3.736 -			pa0[0]=QPoint (lrint(p2x+tp.x()), lrint(p2y+tp.y()));
   3.737 -			pa0[1]=QPoint (lrint(p2x-tp.x()), lrint(p2y-tp.y()));
   3.738 -			pa0[2]=QPoint (lrint (parPos.x()), lrint(parPos.y()) );
   3.739 -			p->setPoints (pa0);
   3.740 -			// here too, draw line to avoid missing pixels
   3.741 -			l->setPoints( lrint (parPos.x()),
   3.742 -				lrint(parPos.y()),
   3.743 -				lrint(p2x),
   3.744 -				lrint(p2y) );
   3.745 +		case PolyLine:
   3.746 +			pa0.clear();
   3.747 +			pa0<<QPointF (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
   3.748 +			pa0<<QPointF (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
   3.749 +			pa0<<QPointF (qRound (parPos.x()), qRound(parPos.y()) );
   3.750 +			//p->prepareGeometryChange();
   3.751 +			p->setPolygon(QPolygonF (pa0));
   3.752  			break;
   3.753 -		case StylePolyParabel:	
   3.754 +		case PolyParabel:	
   3.755  			parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y());
   3.756  			parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y());
   3.757 -			for (i=0;i<=arcsegs;i++)
   3.758 -			{
   3.759 -				// Combine the arrays to a single one
   3.760 -				pa0[i]=pa1[i];
   3.761 -				pa0[i+arcsegs+1]=pa2[arcsegs-i];
   3.762 -			}	
   3.763 -			p->setPoints (pa0);
   3.764 -			i=0;
   3.765 -			for (cl=segment.first(); cl; cl=segment.next() )
   3.766 -			{	
   3.767 -				cl->setPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y());
   3.768 -				i++;
   3.769 -			}
   3.770 +			pa0.clear();
   3.771 +			for (int i=0;i<=arcsegs;i++)
   3.772 +				pa0 << QPointF (pa1.at(i));
   3.773 +			for (int i=0;i<=arcsegs;i++)
   3.774 +				pa0 << QPointF (pa2.at(arcsegs-i));
   3.775 +			//p->prepareGeometryChange();
   3.776 +			p->setPolygon(QPolygonF (pa0));
   3.777  			break;
   3.778  		default:
   3.779  			break;
   3.780 @@ -534,26 +542,59 @@
   3.781      return parObj;
   3.782  }
   3.783  
   3.784 -QPoint LinkableMapObj::getChildPos()
   3.785 +LinkableMapObj* LinkableMapObj::findObjBySelect (QString s)
   3.786 +{
   3.787 +	LinkableMapObj *lmo=this;
   3.788 +	QString part;
   3.789 +	QString typ;
   3.790 +	QString num;
   3.791 +	while (!s.isEmpty() )
   3.792 +	{
   3.793 +		part=s.section(",",0,0);
   3.794 +		typ=part.left (3);
   3.795 +		num=part.right(part.length() - 3);
   3.796 +		if (typ=="mc:")
   3.797 +		{
   3.798 +			if (depth>0)
   3.799 +				return false;	// in a subtree there is no center
   3.800 +			else
   3.801 +				break;
   3.802 +		} else
   3.803 +			if (typ=="bo:")
   3.804 +				lmo=((BranchObj*)lmo)->getBranchNum (num.toInt());
   3.805 +			else
   3.806 +				if (typ=="fi:")
   3.807 +					lmo=((BranchObj*)lmo)->getFloatImageNum (num.toUInt());
   3.808 +		if (!lmo) break;
   3.809 +		
   3.810 +		if (s.contains(","))
   3.811 +			s=s.right(s.length() - part.length() -1 );
   3.812 +		else	
   3.813 +			break;
   3.814 +	}
   3.815 +	return lmo;
   3.816 +}
   3.817 +
   3.818 +QPointF LinkableMapObj::getChildPos()
   3.819  {
   3.820      return childPos;
   3.821  }
   3.822  
   3.823 -QPoint LinkableMapObj::getParPos()
   3.824 +QPointF LinkableMapObj::getParPos()
   3.825  {
   3.826      return parPos;
   3.827  }
   3.828  
   3.829 -QPoint LinkableMapObj::getRelPos()
   3.830 -{
   3.831 -	if (!parObj) return QPoint (0,0);
   3.832 -    return QPoint(
   3.833 -		absPos.x() - parObj->x(),
   3.834 -		absPos.y() - parObj->y()
   3.835 -	);
   3.836 +void LinkableMapObj::setUseOrientation (const bool &b)
   3.837 +{	
   3.838 +	if (useOrientation!=b)
   3.839 +	{
   3.840 +		useOrientation=b;
   3.841 +		requestReposition();
   3.842 +	}	
   3.843  }
   3.844  
   3.845 -LinkOrient LinkableMapObj::getOrientation()
   3.846 +LinkableMapObj::Orientation LinkableMapObj::getOrientation()
   3.847  {
   3.848      return orientation;
   3.849  }
   3.850 @@ -573,36 +614,16 @@
   3.851  	return mapEditor;
   3.852  }
   3.853  
   3.854 -QPoint LinkableMapObj::getRandPos()
   3.855 +QPointF LinkableMapObj::getRandPos()
   3.856  {
   3.857  	// Choose a random position with given distance to parent:
   3.858  	double a=rand()%360 * 2 * M_PI / 360;
   3.859 -    return QPoint ( (int)( + 150*cos (a)),
   3.860 +    return QPointF ( (int)( + 150*cos (a)),
   3.861                      (int)( + 150*sin (a)));
   3.862  }
   3.863  
   3.864 -void LinkableMapObj::alignRelativeTo (QPoint ref)
   3.865 -{
   3.866 -}
   3.867 -
   3.868  void LinkableMapObj::reposition()
   3.869  {
   3.870 -cout << "LMO::reposition  ???"<<endl;
   3.871 -	if (depth==0)
   3.872 -	{
   3.873 -		// only calculate the sizes once. If the deepest LMO changes its height,
   3.874 -		// all upper LMOs have to change, too.
   3.875 -		calcBBoxSizeWithChilds();
   3.876 -
   3.877 -	    alignRelativeTo ( QPoint (absPos.x(),
   3.878 -							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
   3.879 -	} else
   3.880 -	{
   3.881 -		// This is only important for moving branches:
   3.882 -		// For editing a branch it isn't called...
   3.883 -	    alignRelativeTo ( QPoint (absPos.x(),
   3.884 -							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
   3.885 -	}
   3.886  }
   3.887  
   3.888  void LinkableMapObj::requestReposition()
   3.889 @@ -626,14 +647,15 @@
   3.890  	// we want to block expensive repositioning, but just do it once at
   3.891  	// the end, thus check first:
   3.892  
   3.893 -	if (mapEditor->blockReposition()) return;
   3.894 +	if (mapEditor->isRepositionBlocked()) return;
   3.895  	
   3.896  	// Pass on the request to parental objects, if this hasn't been done yet
   3.897  	
   3.898  	if (parObj) 
   3.899  		parObj->forceReposition(); 
   3.900  	else 
   3.901 -		reposition(); }
   3.902 +		reposition(); 
   3.903 +}
   3.904  
   3.905  bool LinkableMapObj::repositionRequested()
   3.906  {
   3.907 @@ -641,28 +663,23 @@
   3.908  }
   3.909  
   3.910  
   3.911 -void LinkableMapObj::setSelBox()
   3.912 -{
   3.913 -    selbox->setX (bbox.x() );
   3.914 -    selbox->setY (bbox.y() );
   3.915 -    selbox->setSize (bbox.width(), bbox.height() );
   3.916 -}
   3.917 -
   3.918  void LinkableMapObj::select()
   3.919  {
   3.920 -	setSelBox();
   3.921 +	// select and unselect are still needed to
   3.922 +	// handle hiding of links
   3.923      selected=true;
   3.924 -    selbox->show();
   3.925 +	setVisibility (visible);
   3.926  }
   3.927  
   3.928  
   3.929  void LinkableMapObj::unselect()
   3.930  {
   3.931      selected=false;
   3.932 -    selbox->hide();
   3.933 +	// Maybe we have to hide the link:
   3.934 +	setVisibility (visible);
   3.935  }
   3.936  
   3.937 -void LinkableMapObj::parabel (QPointArray &ya, double p1x, double p1y, double p2x, double p2y)
   3.938 +void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y)
   3.939  
   3.940  {
   3.941  	double vx=p2x - p1x;	// V=P2-P1
   3.942 @@ -679,15 +696,24 @@
   3.943  	else	
   3.944  		m=(vy / (vx*vx));
   3.945  	dx=vx/(arcsegs);
   3.946 -	int i;
   3.947 -	ya.setPoint (0,QPoint (lrint(p1x),lrint(p1y)));
   3.948 -	for (i=1;i<=arcsegs;i++)
   3.949 +	ya.clear();
   3.950 +	ya<<QPointF (p1x,p1y);
   3.951 +	for (int i=1;i<=arcsegs;i++)
   3.952  	{	
   3.953  		pnx=p1x+dx;
   3.954  		pny=m*(pnx-parPos.x())*(pnx-parPos.x())+parPos.y();
   3.955 -		ya.setPoint (i,QPoint (lrint(pnx),lrint(pny)));
   3.956 +		ya<<QPointF (pnx,pny);
   3.957  		p1x=pnx;
   3.958  		p1y=pny;
   3.959  	}	
   3.960  }
   3.961  
   3.962 +QString LinkableMapObj::getLinkAttr ()
   3.963 +{
   3.964 +	if (hideLinkUnselected)
   3.965 +		return attribut ("hideLink","true");
   3.966 +	else
   3.967 +		return attribut ("hideLink","false");
   3.968 +	
   3.969 +}
   3.970 +
     4.1 --- a/main.cpp	Fri Mar 05 20:16:46 2010 +0000
     4.2 +++ b/main.cpp	Tue Mar 23 11:54:30 2010 +0000
     4.3 @@ -1,4 +1,5 @@
     4.4  #include <QApplication>
     4.5 +#include <cstdlib>
     4.6  
     4.7  #include "flagrowobj.h"
     4.8  #include "mainwindow.h"
     5.1 --- a/process.cpp	Fri Mar 05 20:16:46 2010 +0000
     5.2 +++ b/process.cpp	Tue Mar 23 11:54:30 2010 +0000
     5.3 @@ -1,13 +1,14 @@
     5.4  #include "process.h"
     5.5 +#include <cstdlib>
     5.6  
     5.7  /////////////////////////////////////////////////////////////////
     5.8  // Process
     5.9  /////////////////////////////////////////////////////////////////
    5.10  Process::Process()
    5.11  {
    5.12 -	connect( this, SIGNAL(readyReadStderr()),
    5.13 +	connect( this, SIGNAL(readyReadStandardError()),
    5.14  			 this, SLOT(readProcErrout()) );
    5.15 -	connect( this, SIGNAL(readyReadStdout()),
    5.16 +	connect( this, SIGNAL(readyReadStandardOutput()),
    5.17  			 this, SLOT(readProcStdout()) );
    5.18  	clear();		 
    5.19  }
    5.20 @@ -22,22 +23,14 @@
    5.21  	stdOut="";
    5.22  }
    5.23  
    5.24 -void Process::waitFinished()
    5.25 -{
    5.26 -	while (isRunning())
    5.27 -	{
    5.28 -	// FIXME use some kind of sleep here...
    5.29 -	}
    5.30 -}
    5.31 -
    5.32  void Process::readProcErrout()
    5.33  {
    5.34 -	errOut+=readStderr();
    5.35 +	errOut+=readAllStandardError();
    5.36  }
    5.37  
    5.38  void Process::readProcStdout()
    5.39  {
    5.40 -	stdOut+=readStdout();
    5.41 +	stdOut+=readAllStandardOutput();
    5.42  }
    5.43  
    5.44  QString Process::getErrout()
     6.1 --- a/xml-base.cpp	Fri Mar 05 20:16:46 2010 +0000
     6.2 +++ b/xml-base.cpp	Tue Mar 23 11:54:30 2010 +0000
     6.3 @@ -4,6 +4,7 @@
     6.4  #include <QColor>
     6.5  #include <QTextStream>
     6.6  #include <iostream>
     6.7 +#include <cstdlib>
     6.8  
     6.9  #include "misc.h"
    6.10  #include "settings.h"