9 #include "branchitem.h"
11 #include "mainwindow.h"
13 #include "warningdialog.h"
14 #include "xlinkitem.h"
17 extern int statusbarTime;
18 extern Main *mainWindow;
19 extern QString tmpVymDir;
20 extern QString clipboardDir;
21 extern QString clipboardFile;
22 extern bool clipboardEmpty;
25 extern QMenu* branchContextMenu;
26 extern QMenu* floatimageContextMenu;
27 extern QMenu* canvasContextMenu;
29 extern Settings settings;
30 extern QString iconPath;
32 ///////////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////
34 MapEditor::MapEditor( VymModel *vm)
36 //cout << "Constructor ME "<<this<<endl;
37 mapScene= new QGraphicsScene(NULL);
38 mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern));
40 zoomFactor=zoomFactorTarget=1;
43 model->setScene (mapScene);
44 model->registerEditor(this);
45 model->makeDefault(); // No changes in model so far
51 // Create bitmap cursors, platform dependant
52 HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);
53 PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 );
54 CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 1,1 );
55 XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 1,7 );
57 //setFocusPolicy (Qt::StrongFocus); //FIXME-3
70 setAcceptDrops (true);
72 //model->reposition(); //FIXME-3 really still needed?
75 // Shortcuts and actions
77 a = new QAction("Select upper branch", this);
78 a->setShortcut (Qt::Key_Up );
79 a->setShortcutContext (Qt::WidgetShortcut);
81 connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) );
83 a = new QAction( "Select lower branch",this);
84 a->setShortcut ( Qt::Key_Down );
85 a->setShortcutContext (Qt::WidgetShortcut);
87 connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) );
89 a = new QAction( "Select left branch", this);
90 a->setShortcut (Qt::Key_Left );
91 // a->setShortcutContext (Qt::WindowShortcut);
92 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
94 connect( a, SIGNAL( triggered() ), this, SLOT( cursorLeft() ) );
96 a = new QAction( "Select child branch", this);
97 a->setShortcut (Qt::Key_Right);
98 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
100 connect( a, SIGNAL( triggered() ), this, SLOT( cursorRight() ) );
102 a = new QAction( "Select first branch", this);
103 a->setShortcut (Qt::Key_Home );
104 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
106 connect( a, SIGNAL( triggered() ), this, SLOT( cursorFirst() ) );
108 a = new QAction( "Select last branch",this);
109 a->setShortcut ( Qt::Key_End );
110 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
112 connect( a, SIGNAL( triggered() ), this, SLOT( cursorLast() ) );
114 // Action to embed LineEdit for heading in Scene
115 editingHeading=false;
118 a = new QAction( tr( "Edit heading","MapEditor" ), this);
119 a->setShortcut ( Qt::Key_Return ); //Edit heading
120 a->setShortcutContext (Qt::WidgetShortcut);
122 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
123 a = new QAction( tr( "Edit heading","MapEditor" ), this);
124 a->setShortcut ( Qt::Key_Enter); //Edit heading
126 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
129 selectionColor =QColor (255,255,0);
132 // Attributes //FIXME-2 testing only...
135 attrTable= new AttributeTable();
137 ad=attrTable->addKey (k,StringList);
141 sl <<"val 1"<<"val 2"<< "val 3";
142 ad->setValue (QVariant (sl));
144 //attrTable->addValue ("Key A","P 1");
145 //attrTable->addValue ("Key A","P 2");
146 //attrTable->addValue ("Key A","P 3");
147 //attrTable->addValue ("Key A","P 4");
149 ad=attrTable->addKey (k,FreeString);
152 //attrTable->addValue ("Key B","w1");
153 //attrTable->addValue ("Key B","w2");
155 k="C - UniqueString";
156 ad=attrTable->addKey (k,UniqueString);
159 //attrTable->addKey ("Key Prio");
160 //attrTable->addValue ("Key Prio","Prio 1");
161 //attrTable->addValue ("Key Prio","Prio 2");
165 MapEditor::~MapEditor()
167 //cout <<"Destructor MapEditor for "<<model->getMapName().toStdString()<<endl;
168 model->unregisterEditor(this);
171 VymModel* MapEditor::getModel()
176 QGraphicsScene * MapEditor::getScene()
181 void MapEditor::scrollTo (const QModelIndex &index)
185 LinkableMapObj* lmo=NULL;
186 TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
187 if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
188 lmo=((MapItem*)ti)->getLMO();
191 QRectF r=lmo->getBBox();
192 setScrollBarPosTarget (r);
197 void MapEditor::setScrollBarPosTarget (const QRectF &rect)
199 // Code copied from Qt sources
203 qreal width = viewport()->width();
204 qreal height = viewport()->height();
205 QRectF viewRect = matrix().mapRect(rect);
207 qreal left = horizontalScrollBar()->value();
208 qreal right = left + width;
209 qreal top = verticalScrollBar()->value();
210 qreal bottom = top + height;
212 scrollBarPosTarget=getScrollBarPos();
214 if (viewRect.left() <= left + xmargin) {
215 // need to scroll from the left
216 // if (!d->leftIndent)
217 scrollBarPosTarget.setX(int(viewRect.left() - xmargin - 0.5));
219 if (viewRect.right() >= right - xmargin) {
220 // need to scroll from the right
221 // if (!d->leftIndent)
222 scrollBarPosTarget.setX(int(viewRect.right() - width + xmargin + 0.5));
224 if (viewRect.top() <= top + ymargin) {
225 // need to scroll from the top
226 // if (!d->topIndent)
227 scrollBarPosTarget.setY(int(viewRect.top() - ymargin - 0.5));
229 if (viewRect.bottom() >= bottom - ymargin) {
230 // need to scroll from the bottom
231 // if (!d->topIndent)
232 scrollBarPosTarget.setY(int(viewRect.bottom() - height + ymargin + 0.5));
235 if (scrollBarPosTarget==getScrollBarPos()) return;
237 if (scrollBarPosAnimation.state()==QtAbstractAnimation::Running)
238 scrollBarPosAnimation.stop();
240 if (settings.value ("/animation/use/",true).toBool() )
242 scrollBarPosAnimation.setTargetObject (this);
243 scrollBarPosAnimation.setPropertyName ("scrollBarPos");
244 scrollBarPosAnimation.setDuration(1000);
245 scrollBarPosAnimation.setEasingCurve ( QtEasingCurve::OutQuint);
246 scrollBarPosAnimation.setStartValue(
247 QPointF (horizontalScrollBar()->value() ,
248 verticalScrollBar()->value() ) );
249 scrollBarPosAnimation.setEndValue(scrollBarPosTarget);
250 scrollBarPosAnimation.start();
252 setScrollBarPos (scrollBarPosTarget);
255 QPointF MapEditor::getScrollBarPosTarget()
257 return scrollBarPosTarget;
261 void MapEditor::setScrollBarPos(const QPointF &p)
264 horizontalScrollBar()->setValue(int(p.x()));
265 verticalScrollBar()->setValue(int(p.y()));
268 QPointF MapEditor::getScrollBarPos()
270 return QPointF (horizontalScrollBar()->value(),verticalScrollBar()->value());
271 //return scrollBarPos;
274 void MapEditor::setZoomFactorTarget (const qreal &zft)
276 zoomFactorTarget=zft;
277 if (zoomAnimation.state()==QtAbstractAnimation::Running)
278 zoomAnimation.stop();
279 if (settings.value ("/animation/use/",true).toBool() )
281 //zoomAnimation=QPropertyAnimation(this, "zoomFactor");
282 zoomAnimation.setTargetObject (this);
283 zoomAnimation.setPropertyName ("zoomFactor");
284 zoomAnimation.setDuration(1000);
285 zoomAnimation.setEasingCurve ( QtEasingCurve::OutQuint);
286 zoomAnimation.setStartValue(zoomFactor);
287 zoomAnimation.setEndValue(zft);
288 zoomAnimation.start();
293 qreal MapEditor::getZoomFactorTarget()
295 return zoomFactorTarget;
299 void MapEditor::setZoomFactor(const qreal &zf)
302 setMatrix (QMatrix(zf, 0, 0, zf, 0, 0),false );
305 qreal MapEditor::getZoomFactor()
310 void MapEditor::print()
314 printer = new QPrinter;
315 printer->setColorMode (QPrinter::Color);
316 printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
317 printer->setOutputFormat((QPrinter::OutputFormat)settings.value("/mainwindow/printerFormat",printer->outputFormat()).toInt());
318 printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString());
321 QRectF totalBBox=getTotalBBox();
323 // Try to set orientation automagically
324 // Note: Interpretation of generated postscript is amibiguous, if
325 // there are problems with landscape mode, see
326 // http://sdb.suse.de/de/sdb/html/jsmeix_print-cups-landscape-81.html
328 if (totalBBox.width()>totalBBox.height())
329 // recommend landscape
330 printer->setOrientation (QPrinter::Landscape);
332 // recommend portrait
333 printer->setOrientation (QPrinter::Portrait);
335 if ( printer->setup(this) )
336 // returns false, if printing is canceled
338 QPainter pp(printer);
340 pp.setRenderHint(QPainter::Antialiasing,true);
342 // Don't print the visualisation of selection
345 QRectF mapRect=totalBBox;
346 QGraphicsRectItem *frame=NULL;
350 // Print frame around map
351 mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10,
352 totalBBox.width()+20, totalBBox.height()+20);
353 frame=mapScene->addRect (mapRect, QPen(Qt::black),QBrush(Qt::NoBrush));
359 double paperAspect = (double)printer->width() / (double)printer->height();
360 double mapAspect = (double)mapRect.width() / (double)mapRect.height();
362 if (mapAspect>=paperAspect)
364 // Fit horizontally to paper width
365 //pp.setViewport(0,0, printer->width(),(int)(printer->width()/mapAspect) );
366 viewBottom=(int)(printer->width()/mapAspect);
369 // Fit vertically to paper height
370 //pp.setViewport(0,0,(int)(printer->height()*mapAspect),printer->height());
371 viewBottom=printer->height();
376 // Print footer below map
378 font.setPointSize(10);
380 QRectF footerBox(0,viewBottom,printer->width(),15);
381 // FIXME-3 fileName not any longer available here: pp.drawText ( footerBox,Qt::AlignLeft,"VYM - " +fileName);
382 pp.drawText ( footerBox, Qt::AlignRight, QDate::currentDate().toString(Qt::TextDate));
386 QRectF (0,0,printer->width(),printer->height()-15),
387 QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height())
390 // Viewport has paper dimension
391 if (frame) delete (frame);
396 // Save settings in vymrc
397 settings.writeEntry("/mainwindow/printerName",printer->printerName());
398 settings.writeEntry("/mainwindow/printerFormat",printer->outputFormat());
399 settings.writeEntry("/mainwindow/printerFileName",printer->outputFileName());
403 QRectF MapEditor::getTotalBBox()
407 pen.setCapStyle ( Qt::RoundCap );
411 BranchItem *cur=NULL;
412 BranchItem *prev=NULL;
413 model->nextBranch(cur,prev);
416 if (!cur->hasHiddenExportParent())
418 bo=(BranchObj*)(cur->getLMO());
419 if (bo && bo->isVisibleObj())
421 bo->calcBBoxSizeWithChildren();
423 //QRectF r1=bo->getBBoxSizeWithChildren();
424 QRectF r1=bo->getBBox();
425 //pen.setColor ( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8));
426 //mapScene->addRect (r1,pen);
428 if (rt.isNull()) rt=r1;
430 //FIXME-2 cout <<"ME: r1="<<r1<<" "<<cur->getHeadingStd()<<endl;
431 //cout <<" rt="<<rt<<endl;
434 model->nextBranch(cur,prev);
440 QImage MapEditor::getImage()
442 QRectF mapRect=getTotalBBox();
443 int w=mapRect.width()+2;
444 int h=mapRect.height()+2;
446 QImage pix (w,h,QImage::Format_RGB32);
450 pp.setRenderHints(renderHints());
451 mapScene->render ( &pp,
453 QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
458 void MapEditor::setAntiAlias (bool b)
460 setRenderHint(QPainter::Antialiasing,b);
463 void MapEditor::setSmoothPixmap(bool b)
465 setRenderHint(QPainter::SmoothPixmapTransform,b);
468 void MapEditor::setHideTmp (bool b) // FIXME-4 better use signals
473 setHideTmpMode (HideExport);
474 mapCenter->calcBBoxSizeWithChilds();
475 QRectF totalBBox=mapCenter->getTotalBBox();
476 //QRectF mapRect=totalBBox;
477 cout << " map has =("<<totalBBox.x()<<","<<totalBBox.y()<<","<<totalBBox.width()<<","<<totalBBox.height()<<")\n";
479 mapRect.setRect (totalBBox.x(), totalBBox.y(),
480 totalBBox.width(), totalBBox.height());
482 QCanvasRectangle *frame=new QCanvasRectangle (mapRect,mapScene);
483 frame->setBrush (QColor(white));
484 frame->setPen (QColor(black));
491 setHideTmpMode (HideNone);
493 cout <<" hidemode="<<hidemode<<endl;
497 if (hidemode==HideExport)
498 setHideTmpMode (HideNone);
500 setHideTmpMode (HideExport);
504 TreeItem* MapEditor::findMapItem (QPointF p,TreeItem *exclude)
506 // Start with mapcenter, no images allowed at rootItem
508 BranchItem *bi=model->getRootItem()->getFirstBranch();
509 TreeItem *found=NULL;
512 found=bi->findMapItem (p, exclude);
513 if (found) return found;
515 bi=model->getRootItem()->getBranchNum(i);
520 AttributeTable* MapEditor::attributeTable()
525 void MapEditor::testFunction1()
527 cout << "ME::test1 selected TI="<<model->getSelectedItem()<<endl;
528 model->setExportMode (true);
531 // Code copied from Qt sources
532 QRectF rect=model->getSelectedBranchObj()->getBBox();
536 qreal width = viewport()->width();
537 qreal height = viewport()->height();
538 QRectF viewRect = matrix().mapRect(rect);
540 qreal left = horizontalScrollBar()->value();
541 qreal right = left + width;
542 qreal top = verticalScrollBar()->value();
543 qreal bottom = top + height;
545 if (viewRect.left() <= left + xmargin) {
546 // need to scroll from the left
547 // if (!d->leftIndent)
548 horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
550 if (viewRect.right() >= right - xmargin) {
551 // need to scroll from the right
552 // if (!d->leftIndent)
553 horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
555 if (viewRect.top() <= top + ymargin) {
556 // need to scroll from the top
557 // if (!d->topIndent)
558 verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
560 if (viewRect.bottom() >= bottom - ymargin) {
561 // need to scroll from the bottom
562 // if (!d->topIndent)
563 verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
565 cout << "test1: hor="<<horizontalScrollBar()->value()<<endl;
566 cout << "test1: ver="<<verticalScrollBar()->value()<<endl;
571 QtPropertyAnimation *animation=new QtPropertyAnimation(this, "sceneRect");
572 animation->setDuration(5000);
573 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
574 animation->setEasingCurve ( QtEasingCurve::OutQuint);
575 animation->setStartValue(sceneRect() );
576 animation->setEndValue(QRectF(50, 50, 1000, 1000));
581 QDialog *dia= new QDialog (this);
582 dia->setGeometry (50,50,10,10);
587 QtPropertyAnimation *animation=new QtPropertyAnimation(dia, "geometry");
588 animation->setDuration(1000);
589 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
590 animation->setEasingCurve ( QtEasingCurve::OutQuint);
591 animation->setStartValue(QRect(50, 50, 10, 10));
592 animation->setEndValue(QRect(250, 250, 100, 100));
599 void MapEditor::testFunction2()
601 model->setExportMode (false);
604 // Create list with all bounding polygons
605 QList <LinkableMapObj*> mapobjects;
606 QList <ConvexPolygon> polys;
608 QList <Vector> vectors;
609 QList <Vector> orgpos;
610 QStringList headings; //FIXME-3 testing only
616 // Outer loop: Iterate until we no more changes in orientation
617 bool orientationChanged=true;
618 while (orientationChanged)
620 BranchItem *ri=model->getRootItem();
621 for (int i=0;i<ri->branchCount();++i)
623 bi=ri->getBranchNum (i);
624 bo=(BranchObj*)bi->getLMO();
627 mapobjects.append (bo);
628 p=bo->getBoundingPolygon();
631 vectors.append (QPointF(0,0));
632 orgpos.append (p.at(0));
633 headings.append (bi->getHeading());
635 for (int j=0;j<bi->branchCount();++j)
637 bi2=bi->getBranchNum (j);
638 bo=(BranchObj*)bi2->getLMO();
641 mapobjects.append (bo);
642 p=bo->getBoundingPolygon();
645 vectors.append (QPointF(0,0));
646 orgpos.append (p.at(0));
647 headings.append (bi2->getHeading());
652 // Iterate moving bounding polygons until we have no more collisions
657 for (int i=0; i<polys.size()-1; ++i)
659 for (int j=i+1; j<polys.size();++j)
661 if (polygonCollision (polys.at(i),polys.at(j), QPointF(0,0)).intersect )
664 //cout << "Collision: "<<headings[i].toStdString()<<" - "<<headings[j].toStdString()<<endl;
665 v=polys.at(j).centroid()-polys.at(i).centroid();
666 // Move also away if centroids are identical
669 //cout << "v==0="<<polys[i].centroid()<<polys[j].centroid()<<" "<<v<<endl;
670 v.setX (rand()%200 -100);
671 v.setY (rand()%200 -100);
676 //cout << " v="<<v<<endl;
683 for (int i=0;i<vectors.size();i++)
685 //cout << " v="<<vectors[i]<<" "<<headings[i].toStdString()<<endl;
686 polys[i].translate (vectors[i]);
688 cout << "Collisions: "<<collisions<<endl;
692 // Finally move the real objects and update
693 QList <LinkableMapObj::Orientation> orients;
694 for (int i=0;i<polys.size();i++)
696 Vector v=polys[i].at(0)-orgpos[i];
697 orients.append (mapobjects[i]->getOrientation());
698 mapobjects[i]->moveBy(v.x(),v.y() );
699 mapobjects[i]->setRelPos();
702 orientationChanged=false;
703 for (int i=0;i<polys.size();i++)
704 if (orients[i]!=mapobjects[i]->getOrientation())
706 orientationChanged=true;
709 cout << "Final: orientChanged="<<orientationChanged<<endl;
711 //orientationChanged=false;
712 } // loop if orientation has changed
714 model->emitSelectionChanged();
717 BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi)
722 if (i>0) return bi->parent()->getBranchNum(i-1);
727 BranchItem* MapEditor::getBranchAbove (BranchItem *selbi)
731 int dz=selbi->depth(); // original depth
733 if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
738 // Look for branch with same parent but directly above
740 bi=getBranchDirectBelow(selbi);
742 bi=getBranchDirectAbove (selbi);
745 // direct predecessor
748 // Go towards center and look for predecessor
749 while (selbi->depth()>0)
751 selbi=(BranchItem*)(selbi->parent());
752 if (selbi->depth()==1 && invert)
753 bi=getBranchDirectBelow (selbi);
755 bi=getBranchDirectAbove (selbi);
760 while (selbi->depth()<dz)
762 // try to get back to original depth dz
763 bi=selbi->getLastBranch();
777 BranchItem* MapEditor::getBranchDirectBelow(BranchItem *bi)
782 if (i+1<bi->parent()->branchCount()) return bi->parent()->getBranchNum(i+1);
787 BranchItem* MapEditor::getBranchBelow (BranchItem *selbi)
792 int dz=selbi->depth(); // original depth
794 if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
798 // Look for branch with same parent but directly below
800 bi=getBranchDirectAbove (selbi);
802 bi=getBranchDirectBelow (selbi);
808 // Go towards center and look for neighbour
809 while (selbi->depth()>0)
811 selbi=(BranchItem*)(selbi->parent());
812 if (selbi->depth()==1 && invert)
813 bi=getBranchDirectAbove (selbi);
815 bi=getBranchDirectBelow (selbi);
820 while (selbi->depth()<dz)
822 // try to get back to original depth dz
823 bi=selbi->getFirstBranch();
837 BranchItem* MapEditor::getLeftBranch (BranchItem *bi)
842 // Special case: use alternative selection index
843 return bi->getLastSelectedBranchAlt();
844 if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)
846 return (BranchItem*)(bi->parent());
849 if (bi->getType()== TreeItem::Branch )
850 return bi->getLastSelectedBranch();
855 BranchItem* MapEditor::getRightBranch(BranchItem *bi)
859 if (bi->depth()==0) return bi->getLastSelectedBranch();
860 if (bi->getBranchObj()->getOrientation()==LinkableMapObj::LeftOfCenter)
862 return (BranchItem*)(bi->parent());
865 if (bi->getType()== TreeItem::Branch )
866 return (BranchItem*)bi->getLastSelectedBranch();
873 void MapEditor::cursorUp()
875 BranchItem *bi=model->getSelectedBranch();
876 if (bi) model->select (getBranchAbove(bi));
879 void MapEditor::cursorDown()
882 BranchItem *bi=model->getSelectedBranch();
883 if (bi) model->select (getBranchBelow(bi));
886 void MapEditor::cursorLeft()
888 BranchItem *bi=getLeftBranch (model->getSelectedBranch());
889 if (bi) model->select (bi);
892 void MapEditor::cursorRight()
894 BranchItem *bi=getRightBranch (model->getSelectedBranch());
895 if (bi) model->select (bi);
898 void MapEditor::cursorFirst()
900 model->selectFirstBranch();
903 void MapEditor::cursorLast()
905 model->selectLastBranch();
909 void MapEditor::editHeading()
913 editHeadingFinished();
916 BranchObj *bo=model->getSelectedBranchObj();
917 BranchItem *bi=model->getSelectedBranch();
920 model->setSelectionBlocked(true);
922 lineEdit=new QLineEdit;
923 QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
924 pw->setZValue (Z_LINEEDIT);
926 lineEdit->setText (bi->getHeading());
927 QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
928 lineEdit->setGeometry(p.x(),p.y(),230,25);
929 //lineEdit->selectAll();
930 //lineEdit->setCursorPosition (1);
932 lineEdit->setFocus();
933 lineEdit->grabKeyboard();
938 void MapEditor::editHeadingFinished()
940 editingHeading=false;
941 lineEdit->releaseKeyboard();
942 lineEdit->clearFocus();
943 model->setHeading (lineEdit->text() );
944 model->setSelectionBlocked(false);
947 // Maybe reselect previous branch
948 mainWindow->editHeadingFinished (model);
952 void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
954 // Lineedits are already closed by preceding
955 // mouseEvent, we don't need to close here.
957 QPointF p = mapToScene(e->pos());
958 TreeItem *ti=findMapItem (p, NULL);
959 LinkableMapObj* lmo=NULL;
960 if (ti) lmo=((MapItem*)ti)->getLMO();
963 { // MapObj was found
964 if (model->getSelectedLMO() != lmo)
970 if (model->getSelectedBranchObj() )
972 // Context Menu on branch or mapcenter
973 branchContextMenu->popup(e->globalPos() );
976 if (model->getSelectedImage() )
978 // Context Menu on floatimage
979 floatimageContextMenu->popup(e->globalPos() );
983 { // No MapObj found, we are on the Canvas itself
984 // Context Menu on scene
986 // Open context menu synchronously to position new mapcenter
987 model->setContextPos (p);
988 canvasContextMenu->exec(e->globalPos() );
989 model->unsetContextPos ();
994 void MapEditor::keyPressEvent(QKeyEvent* e)
996 if (e->modifiers() & Qt::ControlModifier)
998 switch (mainWindow->getModMode())
1000 case Main::ModModeColor:
1001 setCursor (PickColorCursor);
1003 case Main::ModModeCopy:
1004 setCursor (CopyCursor);
1006 case Main::ModModeXLink:
1007 setCursor (XLinkCursor);
1010 setCursor (Qt::ArrowCursor);
1016 void MapEditor::keyReleaseEvent(QKeyEvent* e)
1018 if (!(e->modifiers() & Qt::ControlModifier))
1019 setCursor (Qt::ArrowCursor);
1022 void MapEditor::mousePressEvent(QMouseEvent* e)
1024 //cout << "ME::mousePressed\n"; //FIXME-3
1025 // Ignore right clicks, these will go to context menus
1026 if (e->button() == Qt::RightButton )
1028 //cout << " ME::ignoring right mouse event...\n";
1033 //Ignore clicks while editing heading
1034 if (model->isSelectionBlocked() )
1036 //cout << " ME::ignoring other mouse event...\n";
1041 QPointF p = mapToScene(e->pos());
1042 TreeItem *ti=findMapItem (p, NULL);
1043 LinkableMapObj* lmo=NULL;
1044 if (ti) lmo=((MapItem*)ti)->getLMO();
1049 //Take care of system flags _or_ modifier modes
1051 if (lmo && ti->isBranchLikeType() )
1053 QString foname=((BranchObj*)lmo)->getSystemFlagName(p);
1054 if (!foname.isEmpty())
1056 // systemFlag clicked
1057 model->select (lmo);
1058 if (foname=="system-url")
1060 if (e->state() & Qt::ControlModifier)
1061 mainWindow->editOpenURLTab();
1063 mainWindow->editOpenURL();
1065 else if (foname=="system-vymLink")
1067 mainWindow->editOpenVymLink();
1068 // tabWidget may change, better return now
1069 // before segfaulting...
1070 } else if (foname=="system-note")
1071 mainWindow->windowToggleNoteEditor();
1072 else if (foname=="hideInExport")
1073 model->toggleHideExport();
1074 // FIXME-3 needed? xelection.update();
1078 // Take care of xLink
1079 if (ti->xlinkCount()>0 && lmo->getBBox().width()>30)
1081 if ((lmo->getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20) ||
1082 (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) )
1084 // FIXME-4 if (ti->xlinkCount()>1)
1088 QList <QAction*> alist;
1089 for (int i=0;i<ti->xlinkCount();i++)
1090 alist.append (new QAction(ti->getXLinkNum(i)->getOtherBranch(ti)->getHeading(),&menu));
1091 menu.addActions (alist);
1092 QAction *ra=menu.exec (e->globalPos() );
1094 model->select (ti->getXLinkNum(alist.indexOf(ra))->getOtherBranch (ti));
1095 while (!alist.isEmpty())
1097 QAction *a=alist.takeFirst();
1103 model->select (ti->getXLinkNum(0)->getOtherBranch (ti));
1111 // No system flag clicked, take care of modmodes (CTRL-Click)
1112 if (e->state() & Qt::ControlModifier)
1114 if (mainWindow->getModMode()==Main::ModModeColor)
1117 setCursor (PickColorCursor);
1120 if (mainWindow->getModMode()==Main::ModModeXLink)
1122 BranchItem *bi_begin=model->getSelectedBranch();
1126 tmpXLink=model->createXLink(bi_begin,true);
1127 tmpXLink->setColor(model->getMapDefXLinkColor());
1128 tmpXLink->setWidth(model->getMapDefXLinkWidth());
1129 tmpXLink->setEnd (p);
1130 tmpXLink->updateXLink();
1134 } // End of modmodes
1139 cout << "ME::mouse pressed\n";
1140 cout << " lmo="<<lmo<<endl;
1141 cout << " ti="<<ti->getHeadingStd()<<endl;
1143 // Select the clicked object
1148 // Left Button Move Branches
1149 if (e->button() == Qt::LeftButton )
1151 movingObj_start.setX( p.x() - lmo->x() );
1152 movingObj_start.setY( p.y() - lmo->y() );
1153 movingObj_orgPos.setX (lmo->x() );
1154 movingObj_orgPos.setY (lmo->y() );
1156 movingObj_orgRelPos=lmo->getRelPos();
1158 // If modMode==copy, then we want to "move" the _new_ object around
1159 // then we need the offset from p to the _old_ selection, because of tmp
1160 if (mainWindow->getModMode()==Main::ModModeCopy &&
1161 e->state() & Qt::ControlModifier)
1163 BranchItem *bi=model->getSelectedBranch();
1167 //FIXME-2 TreeItem::addBranch (BranchItem still missing)
1168 //bi->addBranch (model->getSelectedBranch());
1170 model->select(bi->getLastBranch());
1171 model->reposition();
1175 movingObj=model->getSelectedLMO();
1177 // Middle Button Toggle Scroll
1178 // (On Mac OS X this won't work, but we still have
1179 // a button in the toolbar)
1180 if (e->button() == Qt::MidButton )
1181 model->toggleScroll();
1182 // model->updateActions(); FIXME-3 needed?
1183 // FIXME-3 needed? xelection.update();
1185 { // No MapObj found, we are on the scene itself
1186 // Left Button move Pos of sceneView
1187 if (e->button() == Qt::LeftButton )
1189 movingObj=NULL; // move Content not Obj
1190 movingObj_start=e->globalPos();
1191 movingCont_start=QPointF (
1192 horizontalScrollBar()->value(),
1193 verticalScrollBar()->value());
1194 movingVec=QPointF(0,0);
1195 setCursor(HandOpenCursor);
1200 void MapEditor::mouseMoveEvent(QMouseEvent* e)
1202 QPointF p = mapToScene(e->pos());
1203 TreeItem *seli=model->getSelectedItem();
1204 LinkableMapObj* lmosel=NULL;
1205 if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
1206 lmosel=((MapItem*)seli)->getLMO();
1208 // Move the selected MapObj
1209 if ( lmosel && movingObj)
1212 // reset cursor if we are moving and don't copy
1213 if (mainWindow->getModMode()!=Main::ModModeCopy)
1214 setCursor (Qt::ArrowCursor);
1216 // To avoid jumping of the sceneView, only
1217 // show selection, if not tmp linked
1218 /* FIXME-2 if (!lmosel->hasParObjTmp())
1219 model->emitShowSelection();
1222 // Now move the selection, but add relative position
1223 // (movingObj_start) where selection was chosen with
1224 // mousepointer. (This avoids flickering resp. jumping
1225 // of selection back to absPos)
1227 // Check if we could link
1228 TreeItem *ti=findMapItem (p, seli);
1229 BranchItem *dsti=NULL;
1230 LinkableMapObj* dst=NULL;
1231 if (ti && ti!=seli && ti->isBranchLikeType())
1233 dsti=(BranchItem*)ti;
1239 if (lmosel && seli->getType()==TreeItem::Image)
1241 FloatObj *fio=(FloatImageObj*)lmosel;
1242 fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1244 fio->updateLinkGeometry(); //no need for reposition, if we update link here
1245 model->emitSelectionChanged(); // position has changed
1247 // Relink float to new mapcenter or branch, if shift is pressed
1248 // Only relink, if selection really has a new parent
1249 if ( e->modifiers()==Qt::ShiftModifier && dsti && dsti != seli->parent() )
1251 // Also save the move which was done so far
1252 QString pold=qpointFToString(movingObj_orgRelPos);
1253 QString pnow=qpointFToString(fio->getRelPos());
1259 QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
1260 fio->getParObj()->requestReposition();
1261 model->reposition();
1263 model->relinkImage ((ImageItem*) seli,dsti);
1264 model->select (seli);
1265 //movingObj=lmosel; //FIXME-3
1266 //movingObj_orgRelPos=lmosel->getRelPos();
1268 model->reposition();
1271 { // selection != a FloatObj
1272 if (seli->depth()==0)
1275 lmosel->move (p-movingObj_start);
1276 if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
1278 // Move only mapcenter, leave its children where they are
1280 v=lmosel->getAbsPos();
1281 for (int i=0; i<seli->branchCount(); ++i)
1283 seli->getBranchObjNum(i)->setRelPos();
1284 seli->getBranchObjNum(i)->setOrientation();
1289 if (seli->depth()==1)
1292 if (!lmosel->hasParObjTmp())
1293 lmosel->move(p-movingObj_start);
1294 lmosel->setRelPos();
1297 // Move ordinary branch
1298 if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
1299 // Add width of bbox here, otherwise alignRelTo will cause jumping around
1300 lmosel->move(p.x() -movingObj_start.x() , //lmosel->getBBox().width(),
1301 p.y()-movingObj_start.y() +lmosel->getTopPad() );
1303 lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
1304 lmosel->setRelPos();
1308 // Maybe we can relink temporary?
1311 if (e->modifiers()==Qt::ControlModifier)
1313 // Special case: CTRL to link below dst
1314 lmosel->setParObjTmp (dst,p,+1);
1315 } else if (e->modifiers()==Qt::ShiftModifier)
1316 lmosel->setParObjTmp (dst,p,-1);
1318 lmosel->setParObjTmp (dst,p,0);
1321 lmosel->unsetParObjTmp();
1323 // reposition subbranch
1324 lmosel->reposition();
1326 QItemSelection sel=model->getSelectionModel()->selection();
1327 updateSelection(sel,sel); // position has changed
1329 } // no FloatImageObj
1333 } // selection && moving_obj
1335 // Draw a link from one branch to another
1338 tmpXLink->setEnd (p);
1339 tmpXLink->updateXLink();
1343 if (!movingObj && !pickingColor &&!drawingLink && e->buttons() == Qt::LeftButton )
1345 QPointF p=e->globalPos();
1346 movingVec.setX(-p.x() + movingObj_start.x() );
1347 movingVec.setY(-p.y() + movingObj_start.y() );
1348 horizontalScrollBar()->setSliderPosition((int)( movingCont_start.x()+movingVec.x() ));
1349 verticalScrollBar()->setSliderPosition((int)( movingCont_start.y()+movingVec.y() ) );
1354 void MapEditor::mouseReleaseEvent(QMouseEvent* e)
1356 QPointF p = mapToScene(e->pos());
1357 TreeItem *seli=model->getSelectedItem();
1359 TreeItem *dsti=NULL;
1360 if (seli) dsti=findMapItem(p, seli);
1361 LinkableMapObj* dst=NULL;
1362 if (dsti && dsti->isBranchLikeType ())
1363 dst=((MapItem*)dsti)->getLMO();
1368 // Have we been picking color?
1372 setCursor (Qt::ArrowCursor);
1373 // Check if we are over another branch
1376 if (e->state() & Qt::ShiftModifier)
1377 model->colorBranch (((BranchObj*)dst)->getColor());
1379 model->colorSubtree (((BranchObj*)dst)->getColor());
1384 // Have we been drawing a link?
1388 // Check if we are over another branch
1391 tmpXLink->setEnd ( ((BranchItem*)dsti) );
1392 tmpXLink->updateXLink();
1393 tmpXLink->activate();
1395 tmpXLink,QString("delete ()"),
1396 dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)),
1397 QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti))
1401 model->deleteItem(tmpXLink);
1407 // Have we been moving something?
1408 if ( seli && movingObj )
1410 if (seli->getType()==TreeItem::Image)
1412 FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO());
1415 // Moved FloatObj. Maybe we need to reposition
1416 QString pold=qpointFToString(movingObj_orgRelPos);
1417 QString pnow=qpointFToString(fio->getRelPos());
1423 QString("Move %1 to relative position %2").arg(model->getObjectName(seli)).arg(pnow));
1425 fio->getParObj()->requestReposition();
1426 model->reposition();
1430 BranchItem *bi=model->getSelectedBranch();
1431 if (bi && bi->depth()==0)
1433 if (movingObj_orgPos != bi->getBranchObj()->getAbsPos()) // FIXME-3 check getBO here...
1435 QString pold=qpointFToString(movingObj_orgPos);
1436 QString pnow=qpointFToString(bi->getBranchObj()->getAbsPos()); // FIXME-3 check getBO here...
1443 QString("Move mapcenter %1 to position %2").arg(model->getObjectName(bi)).arg(pnow));
1447 if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
1448 { // A branch was moved
1449 LinkableMapObj* lmosel=NULL;
1450 lmosel=((MapItem*)seli)->getLMO();
1452 // save the position in case we link to mapcenter
1453 QPointF savePos=QPointF (lmosel->getAbsPos() );
1455 // Reset the temporary drawn link to the original one
1456 lmosel->unsetParObjTmp();
1458 // For Redo we may need to save original selection
1459 QString preSelStr=model->getSelectString(seli);
1462 if (dsti && objectMoved)
1464 // We have a destination, relink to that
1466 BranchObj* bsel=model->getSelectedBranchObj();
1468 QString preParStr=model->getSelectString (bsel->getParObj());
1469 QString preNum=QString::number (seli->num(),10);
1470 QString preDstParStr;
1473 if (e->state() & Qt::ShiftModifier && dst->getParObj())
1475 preDstParStr=model->getSelectString (dst->getParObj());
1476 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num());
1478 if (e->state() & Qt::ControlModifier && dst->getParObj())
1481 preDstParStr=model->getSelectString (dst->getParObj());
1482 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num()+1);
1485 preDstParStr=model->getSelectString(dst);
1486 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
1487 if (dsti->depth()==0) bsel->move (savePos);
1491 QString postSelStr=model->getSelectString(lmosel);
1492 QString postNum=QString::number (seli->num(),10);
1494 QString undoCom="relinkTo (\""+
1495 preParStr+ "\"," + preNum +"," +
1496 QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
1498 QString redoCom="relinkTo (\""+
1499 preDstParStr + "\"," + postNum + "," +
1500 QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
1505 QString("Relink %1 to %2").arg(model->getObjectName(bsel)).arg(model->getObjectName(dst)) );
1510 // No destination, undo temporary move
1512 if (seli->depth()==1)
1514 // The select string might be different _after_ moving around.
1515 // Therefor reposition and then use string of old selection, too
1516 model->reposition();
1518 QPointF rp(lmosel->getRelPos());
1519 if (rp != movingObj_orgRelPos)
1521 QString ps=qpointFToString(rp);
1523 model->getSelectString(lmosel), "moveRel "+qpointFToString(movingObj_orgRelPos),
1524 preSelStr, "moveRel "+ps,
1525 QString("Move %1 to relative position %2").arg(model->getObjectName(lmosel)).arg(ps));
1529 // Draw the original link, before selection was moved around
1530 if (settings.value("/animation/use",true).toBool() && seli->depth()>1)
1532 lmosel->setRelPos(); // calc relPos first for starting point
1534 model->startAnimation(
1536 lmosel->getRelPos(),
1540 model->reposition();
1543 model->emitSelectionChanged(); //FIXME-3 needed? at least not after pos of selection has changed...
1544 // Finally resize scene, if needed
1550 // maybe we moved View: set old cursor
1551 setCursor (Qt::ArrowCursor);
1555 void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
1559 cout << "ME p="<<mapToScene (e->pos())<<" scrollBarPos="<<getScrollBarPos();
1560 cout << " min="<<QPointF(horizontalScrollBar()->minimum(),verticalScrollBar()->minimum());
1565 if (model->isSelectionBlocked() )
1571 if (e->button() == Qt::LeftButton )
1573 QPointF p = mapToScene(e->pos());
1574 TreeItem *ti=findMapItem (p, NULL);
1575 if (ti) { // MapObj was found
1576 // First select the MapObj than edit heading
1583 void MapEditor::resizeEvent (QResizeEvent* e)
1585 QGraphicsView::resizeEvent( e );
1588 void MapEditor::dragEnterEvent(QDragEnterEvent *event)
1590 //for (unsigned int i=0;event->format(i);i++) // Debug mime type
1591 // cerr << event->format(i) << endl;
1593 if (event->mimeData()->hasImage())
1594 event->acceptProposedAction();
1596 if (event->mimeData()->hasUrls())
1597 event->acceptProposedAction();
1600 void MapEditor::dragMoveEvent(QDragMoveEvent *)
1604 void MapEditor::dragLeaveEvent(QDragLeaveEvent *event)
1609 void MapEditor::dropEvent(QDropEvent *event)
1611 BranchItem *selbi=model->getSelectedBranch();
1616 foreach (QString format,event->mimeData()->formats())
1617 cout << "MapEditor: Dropped format: "<<qPrintable (format)<<endl;
1618 foreach (QString url,event->mimeData()->urls())
1619 cout << " URL:"<<url.toStdString()<<endl;
1620 //foreach (QString plain,event->mimeData()->text())
1621 // cout << " PLAIN:"<<plain.toStdString()<<endl;
1622 QByteArray ba=event->mimeData()->data("STRING");
1626 cout << " STRING:" <<s.toStdString()<<endl;
1628 ba=event->mimeData()->data("TEXT");
1630 cout << " TEXT:" <<s.toStdString()<<endl;
1632 ba=event->mimeData()->data("COMPOUND_TEXT");
1634 cout << " CTEXT:" <<s.toStdString()<<endl;
1636 ba=event->mimeData()->data("text/x-moz-url");
1638 cout << " x-moz-url:" <<s.toStdString()<<endl;
1640 if (b!=0) cout << "b="<<b<<endl;
1643 if (event->mimeData()->hasImage())
1645 QVariant imageData = event->mimeData()->imageData();
1646 model->addFloatImage (qvariant_cast<QPixmap>(imageData));
1648 if (event->mimeData()->hasUrls())
1650 //model->selectLastBranch();
1651 QList <QUrl> uris=event->mimeData()->urls();
1656 for (int i=0; i<uris.count();i++)
1658 // Workaround to avoid adding empty branches
1659 if (!uris.at(i).toString().isEmpty())
1661 bi=model->addNewBranch();
1665 QString u=uris.at(i).toString();
1666 s=uris.at(i).toLocalFile();
1669 QString file = QDir::fromNativeSeparators(s);
1670 heading = QFileInfo(file).baseName();
1672 if (file.endsWith(".vym", false))
1673 model->setVymLink(file);
1681 // Automatically try to fetch data from Bugzilla
1682 if (settings.value( "/mainwindow/showTestMenu",false).toBool()
1683 && u.contains ("https://bugzilla.novell.com"))
1684 model->getBugzillaData();
1688 if (!heading.isEmpty())
1689 model->setHeading(heading);
1691 model->setHeading(u);
1693 model->select (bi->parent());
1697 //model->reposition();
1700 event->acceptProposedAction();
1703 void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel)
1705 // Note: Here we are prepared for multiple selections, though this
1706 // is not yet implemented elsewhere
1708 // Here in MapEditor we can only select Branches and Images
1709 QList <TreeItem*> treeItemsNew;
1710 QList <TreeItem*> treeItemsOld;
1712 QModelIndex newIndex;
1714 bool do_reposition=false;
1717 foreach (ix,newsel.indexes() )
1719 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1720 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
1721 if (!treeItemsNew.contains(ti)) treeItemsNew.append (ti);
1723 foreach (ix,oldsel.indexes() )
1725 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1726 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
1727 if (!treeItemsOld.contains(ti)) treeItemsOld.append (ti);
1730 // Trim list of selection rectangles
1731 while (treeItemsNew.count() < selboxList.count() )
1732 delete selboxList.takeFirst();
1734 // Take care to tmp scroll/unscroll
1735 if (!oldsel.isEmpty())
1737 QModelIndex ix=oldsel.indexes().first();
1740 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1743 if (ti->isBranchLikeType() )
1745 // reset tmp scrolled branches
1746 BranchItem *bi=(BranchItem*)ti;
1747 if (bi->resetTmpUnscroll() )
1750 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1751 // Hide link if not needed
1752 ((MapItem*)ti)->getLMO()->updateVisibility();
1757 if (!treeItemsNew.isEmpty())
1759 QModelIndex ix=newsel.indexes().first();
1764 // Temporary unscroll if necessary
1765 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1766 if (ti->isBranchLikeType() )
1768 BranchItem *bi=(BranchItem*)ti;
1769 if (bi->hasScrolledParent(bi) )
1771 if (bi->parentBranch()->tmpUnscroll() )
1775 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1776 // Show link if needed
1777 ((MapItem*)ti)->getLMO()->updateVisibility();
1780 if (do_reposition) model->reposition();
1782 // Reduce rectangles
1783 while (treeItemsNew.count() < selboxList.count() )
1784 delete selboxList.takeFirst();
1786 // Add additonal rectangles
1787 QGraphicsRectItem *sb;
1788 while (treeItemsNew.count() > selboxList.count() )
1790 sb = mapScene->addRect(
1792 QPen(selectionColor),
1794 sb->setZValue(Z_SELBOX);
1796 selboxList.append (sb);
1799 // Reposition rectangles
1803 LinkableMapObj *lmo;
1804 for (int i=0; i<treeItemsNew.count();++i)
1806 lmo=((MapItem*)treeItemsNew.at(i) )->getLMO();
1807 bbox=lmo->getBBox();
1808 sb=selboxList.at(i);
1811 bbox.width(), bbox.height());
1812 sb->setPen (selectionColor);
1813 sb->setBrush (selectionColor);
1820 void MapEditor::updateData (const QModelIndex &sel)
1822 TreeItem *ti= static_cast<TreeItem*>(sel.internalPointer());
1825 cout << "ME::updateData\n";
1827 cout << " ti="<<ti<<endl;
1828 cout << " h="<<ti->getHeading().toStdString()<<endl;
1831 if (ti->isBranchLikeType())
1833 // cout << " ->updating...\n";
1834 BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO());
1839 void MapEditor::setSelectionColor (QColor col)
1842 QItemSelection sel=model->getSelectionModel()->selection();
1843 updateSelection(sel,sel);
1847 QColor MapEditor::getSelectionColor ()
1849 return selectionColor;