vymmodel.cpp
changeset 784 9db215a4ad53
parent 781 6cbf3c9cbd21
child 785 5987f9f15bac
     1.1 --- a/vymmodel.cpp	Mon Jul 27 12:53:17 2009 +0000
     1.2 +++ b/vymmodel.cpp	Mon Jul 27 12:53:17 2009 +0000
     1.3 @@ -49,7 +49,7 @@
     1.4  
     1.5  int VymModel::mapNum=0;	// make instance
     1.6  
     1.7 -VymModel::VymModel() 
     1.8 +VymModel::VymModel()
     1.9  {
    1.10  //    cout << "Const VymModel\n";
    1.11  	init();
    1.12 @@ -151,11 +151,11 @@
    1.13  	//  addMapCenter();  FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene
    1.14  
    1.15  	//Initialize DBUS
    1.16 -	//new CarAdaptor(car);
    1.17 +	adaptorModel=new AdaptorModel(this);	// Created and not deleted as documented in Qt
    1.18 +	//adaptor->setModel (this);
    1.19      //connection.registerObject("/Car", car);
    1.20 -    dbusConnection.registerService("org.insilmaril.vym");
    1.21 -
    1.22 -
    1.23 +    dbusConnection.registerService("org.insilmaril.VymModel");
    1.24 +    dbusConnection.sessionBus().registerObject ("/Object1",this);
    1.25  }
    1.26  
    1.27  void VymModel::makeTmpDirectories()
    1.28 @@ -168,7 +168,7 @@
    1.29  }
    1.30  
    1.31  
    1.32 -MapEditor* VymModel::getMapEditor()	// FIXME-2 VM better return favourite editor here
    1.33 +MapEditor* VymModel::getMapEditor()	// FIXME-3 VM better return favourite editor here
    1.34  {
    1.35  	return mapEditor;
    1.36  }
    1.37 @@ -1503,6 +1503,15 @@
    1.38  	}
    1.39  }
    1.40  
    1.41 +QString VymModel::getHeading()
    1.42 +{
    1.43 +	TreeItem *selti=getSelectedItem();
    1.44 +	if (selti)
    1.45 +		return selti->getHeading();
    1.46 +	else	
    1.47 +		return QString();
    1.48 +}
    1.49 +
    1.50  BranchItem* VymModel::findText (QString s, bool cs)   
    1.51  {
    1.52  	QTextDocument::FindFlags flags=0;
    1.53 @@ -3717,6 +3726,7 @@
    1.54  
    1.55  void VymModel::exportImage(QString fname, bool askName, QString format)
    1.56  {
    1.57 +/* FIXME-2 export as image, but directly from mapEditor?!
    1.58  	if (fname=="")
    1.59  	{
    1.60  		fname=getMapName()+".png";
    1.61 @@ -3740,9 +3750,10 @@
    1.62  	}
    1.63  
    1.64  	setExportMode (true);
    1.65 -	QPixmap pix (getPixmap());
    1.66 +	QPixmap pix (mapEditor->getPixmap());
    1.67  	pix.save(fname, format);
    1.68  	setExportMode (false);
    1.69 +*/	
    1.70  }
    1.71  
    1.72  
    1.73 @@ -3761,8 +3772,8 @@
    1.74  	// Create subdirectories
    1.75  	makeSubDirs (dir);
    1.76  
    1.77 -	// write to directory
    1.78 -	QString saveFile=saveToDir (dir,mapName+"-",true,getTotalBBox().topLeft() ,NULL);
    1.79 +	// write to directory	//FIXME-4 check totalBBox here...
    1.80 +	QString saveFile=saveToDir (dir,mapName+"-",true,mapEditor->getTotalBBox().topLeft() ,NULL); 
    1.81  	QFile file;
    1.82  
    1.83  	file.setName ( dir + "/"+mapName+".xml");
    1.84 @@ -4008,27 +4019,6 @@
    1.85  }
    1.86  */
    1.87  
    1.88 -QPixmap VymModel::getPixmap()
    1.89 -{
    1.90 -	QRectF mapRect=getTotalBBox();
    1.91 -	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1);
    1.92 -	QPainter pp (&pix);
    1.93 -	
    1.94 -	pp.setRenderHints(mapEditor->renderHints());
    1.95 -
    1.96 -	// Don't print the visualisation of selection
    1.97 -	unselect();
    1.98 -
    1.99 -	mapScene->render (	&pp, 
   1.100 -		QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
   1.101 -		QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
   1.102 -
   1.103 -	// Restore selection
   1.104 -	reselect();
   1.105 -	
   1.106 -	return pix;
   1.107 -}
   1.108 -
   1.109  
   1.110  void VymModel::setMapLinkStyle (const QString & s)
   1.111  {
   1.112 @@ -4483,8 +4473,16 @@
   1.113      }
   1.114  }
   1.115  
   1.116 -
   1.117 -
   1.118 +/* FIXME-3
   1.119 +QDBusVariant VymModel::query (const QString &query)
   1.120 +{
   1.121 +	TreeItem *selti=getSelectedItem();
   1.122 +	if (selti)
   1.123 +		return QDBusVariant (selti->getHeading());
   1.124 +	else
   1.125 +		return QDBusVariant ("Nothing selected.");
   1.126 +}
   1.127 +*/
   1.128  
   1.129  void VymModel::selectMapSelectionColor()
   1.130  {
   1.131 @@ -4559,17 +4557,6 @@
   1.132  	// FIXME-3 needed? scene()->update();
   1.133  }
   1.134  
   1.135 -
   1.136 -QRectF VymModel::getTotalBBox()	//FIXME-2
   1.137 -{
   1.138 -	QRectF r;
   1.139 -/*
   1.140 -	for (int i=0;i<rootItem->branchCount(); i++)
   1.141 -		r=addBBox (rootItem->getBranchNum(i)->getTotalBBox(), r);
   1.142 -*/ 
   1.143 -	return r;	
   1.144 -}
   1.145 -
   1.146  //////////////////////////////////////////////
   1.147  // Selection related
   1.148  //////////////////////////////////////////////