diff -r 85dec6a8c12c -r 9db215a4ad53 vymmodel.cpp --- a/vymmodel.cpp Mon Jul 27 12:53:17 2009 +0000 +++ b/vymmodel.cpp Mon Jul 27 12:53:17 2009 +0000 @@ -49,7 +49,7 @@ int VymModel::mapNum=0; // make instance -VymModel::VymModel() +VymModel::VymModel() { // cout << "Const VymModel\n"; init(); @@ -151,11 +151,11 @@ // addMapCenter(); FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene //Initialize DBUS - //new CarAdaptor(car); + adaptorModel=new AdaptorModel(this); // Created and not deleted as documented in Qt + //adaptor->setModel (this); //connection.registerObject("/Car", car); - dbusConnection.registerService("org.insilmaril.vym"); - - + dbusConnection.registerService("org.insilmaril.VymModel"); + dbusConnection.sessionBus().registerObject ("/Object1",this); } void VymModel::makeTmpDirectories() @@ -168,7 +168,7 @@ } -MapEditor* VymModel::getMapEditor() // FIXME-2 VM better return favourite editor here +MapEditor* VymModel::getMapEditor() // FIXME-3 VM better return favourite editor here { return mapEditor; } @@ -1503,6 +1503,15 @@ } } +QString VymModel::getHeading() +{ + TreeItem *selti=getSelectedItem(); + if (selti) + return selti->getHeading(); + else + return QString(); +} + BranchItem* VymModel::findText (QString s, bool cs) { QTextDocument::FindFlags flags=0; @@ -3717,6 +3726,7 @@ void VymModel::exportImage(QString fname, bool askName, QString format) { +/* FIXME-2 export as image, but directly from mapEditor?! if (fname=="") { fname=getMapName()+".png"; @@ -3740,9 +3750,10 @@ } setExportMode (true); - QPixmap pix (getPixmap()); + QPixmap pix (mapEditor->getPixmap()); pix.save(fname, format); setExportMode (false); +*/ } @@ -3761,8 +3772,8 @@ // Create subdirectories makeSubDirs (dir); - // write to directory - QString saveFile=saveToDir (dir,mapName+"-",true,getTotalBBox().topLeft() ,NULL); + // write to directory //FIXME-4 check totalBBox here... + QString saveFile=saveToDir (dir,mapName+"-",true,mapEditor->getTotalBBox().topLeft() ,NULL); QFile file; file.setName ( dir + "/"+mapName+".xml"); @@ -4008,27 +4019,6 @@ } */ -QPixmap VymModel::getPixmap() -{ - QRectF mapRect=getTotalBBox(); - QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1); - QPainter pp (&pix); - - pp.setRenderHints(mapEditor->renderHints()); - - // Don't print the visualisation of selection - unselect(); - - mapScene->render ( &pp, - QRectF(0,0,mapRect.width()+2,mapRect.height()+2), - QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() )); - - // Restore selection - reselect(); - - return pix; -} - void VymModel::setMapLinkStyle (const QString & s) { @@ -4483,8 +4473,16 @@ } } - - +/* FIXME-3 +QDBusVariant VymModel::query (const QString &query) +{ + TreeItem *selti=getSelectedItem(); + if (selti) + return QDBusVariant (selti->getHeading()); + else + return QDBusVariant ("Nothing selected."); +} +*/ void VymModel::selectMapSelectionColor() { @@ -4559,17 +4557,6 @@ // FIXME-3 needed? scene()->update(); } - -QRectF VymModel::getTotalBBox() //FIXME-2 -{ - QRectF r; -/* - for (int i=0;ibranchCount(); i++) - r=addBBox (rootItem->getBranchNum(i)->getTotalBBox(), r); -*/ - return r; -} - ////////////////////////////////////////////// // Selection related //////////////////////////////////////////////