5 #include "branchitem.h"
7 #include "mainwindow.h"
9 #include "warningdialog.h"
10 #include "xlinkitem.h"
13 extern int statusbarTime;
14 extern Main *mainWindow;
15 extern QString tmpVymDir;
16 extern QString clipboardDir;
17 extern QString clipboardFile;
18 extern bool clipboardEmpty;
21 extern QMenu* branchContextMenu;
22 extern QMenu* floatimageContextMenu;
23 extern QMenu* canvasContextMenu;
25 extern Settings settings;
26 extern QString iconPath;
28 ///////////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////////
30 MapEditor::MapEditor( VymModel *vm)
32 //qDebug() << "Constructor ME "<<this;
33 mapScene= new QGraphicsScene(NULL);
34 mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern));
36 zoomFactor=zoomFactorTarget=1;
39 model->setScene (mapScene);
40 model->registerEditor(this);
41 model->makeDefault(); // No changes in model so far
47 // Create bitmap cursors, platform dependant
48 HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);
49 PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 );
50 CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 1,1 );
51 XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 1,7 );
53 //setFocusPolicy (Qt::StrongFocus); //FIXME-3
66 setAcceptDrops (true);
68 //model->reposition(); //FIXME-3 really still needed?
71 // Shortcuts and actions
73 a = new QAction("Select upper branch", this);
74 a->setShortcut (Qt::Key_Up );
75 a->setShortcutContext (Qt::WidgetShortcut);
77 connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) );
79 a = new QAction( "Select lower branch",this);
80 a->setShortcut ( Qt::Key_Down );
81 a->setShortcutContext (Qt::WidgetShortcut);
83 connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) );
85 a = new QAction( "Select left branch", this);
86 a->setShortcut (Qt::Key_Left );
87 // a->setShortcutContext (Qt::WindowShortcut);
88 // a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
90 connect( a, SIGNAL( triggered() ), this, SLOT( cursorLeft() ) );
92 a = new QAction( "Select child branch", this);
93 a->setShortcut (Qt::Key_Right);
94 // a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
96 connect( a, SIGNAL( triggered() ), this, SLOT( cursorRight() ) );
98 a = new QAction( "Select first branch", this);
99 a->setShortcut (Qt::Key_Home );
100 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
102 connect( a, SIGNAL( triggered() ), this, SLOT( cursorFirst() ) );
104 a = new QAction( "Select last branch",this);
105 a->setShortcut ( Qt::Key_End );
106 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
108 connect( a, SIGNAL( triggered() ), this, SLOT( cursorLast() ) );
110 // Action to embed LineEdit for heading in Scene
111 editingHeading=false;
114 a = new QAction( tr( "Edit heading","MapEditor" ), this);
115 a->setShortcut ( Qt::Key_Return ); //Edit heading
116 a->setShortcutContext (Qt::WidgetShortcut);
118 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
119 a = new QAction( tr( "Edit heading","MapEditor" ), this);
120 a->setShortcut ( Qt::Key_Enter); //Edit heading
122 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
125 selectionColor =QColor (255,255,0);
128 // Attributes //FIXME-2 testing only...
131 attrTable= new AttributeTable();
133 ad=attrTable->addKey (k,StringList);
137 sl <<"val 1"<<"val 2"<< "val 3";
138 ad->setValue (QVariant (sl));
140 //attrTable->addValue ("Key A","P 1");
141 //attrTable->addValue ("Key A","P 2");
142 //attrTable->addValue ("Key A","P 3");
143 //attrTable->addValue ("Key A","P 4");
145 ad=attrTable->addKey (k,FreeString);
148 //attrTable->addValue ("Key B","w1");
149 //attrTable->addValue ("Key B","w2");
151 k="C - UniqueString";
152 ad=attrTable->addKey (k,UniqueString);
155 //attrTable->addKey ("Key Prio");
156 //attrTable->addValue ("Key Prio","Prio 1");
157 //attrTable->addValue ("Key Prio","Prio 2");
161 MapEditor::~MapEditor()
163 //qDebug() <<"Destructor MapEditor for "<<model->getMapName();
164 model->unregisterEditor(this);
167 VymModel* MapEditor::getModel()
172 QGraphicsScene * MapEditor::getScene()
177 void MapEditor::scrollTo (const QModelIndex &index)
181 LinkableMapObj* lmo=NULL;
182 TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
183 if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
184 lmo=((MapItem*)ti)->getLMO();
187 QRectF r=lmo->getBBox();
188 setScrollBarPosTarget (r);
193 void MapEditor::setScrollBarPosTarget (const QRectF &rect)
195 // Code copied from Qt sources
199 qreal width = viewport()->width();
200 qreal height = viewport()->height();
201 QRectF viewRect = matrix().mapRect(rect);
203 qreal left = horizontalScrollBar()->value();
204 qreal right = left + width;
205 qreal top = verticalScrollBar()->value();
206 qreal bottom = top + height;
208 scrollBarPosTarget=getScrollBarPos();
210 if (viewRect.left() <= left + xmargin) {
211 // need to scroll from the left
212 // if (!d->leftIndent)
213 scrollBarPosTarget.setX(int(viewRect.left() - xmargin - 0.5));
215 if (viewRect.right() >= right - xmargin) {
216 // need to scroll from the right
217 // if (!d->leftIndent)
218 scrollBarPosTarget.setX(int(viewRect.right() - width + xmargin + 0.5));
220 if (viewRect.top() <= top + ymargin) {
221 // need to scroll from the top
222 // if (!d->topIndent)
223 scrollBarPosTarget.setY(int(viewRect.top() - ymargin - 0.5));
225 if (viewRect.bottom() >= bottom - ymargin) {
226 // need to scroll from the bottom
227 // if (!d->topIndent)
228 scrollBarPosTarget.setY(int(viewRect.bottom() - height + ymargin + 0.5));
231 if (scrollBarPosTarget==getScrollBarPos()) return;
233 if (scrollBarPosAnimation.state()==QAbstractAnimation::Running)
234 scrollBarPosAnimation.stop();
236 if (settings.value ("/animation/use/",true).toBool() )
238 scrollBarPosAnimation.setTargetObject (this);
239 scrollBarPosAnimation.setPropertyName ("scrollBarPos");
240 scrollBarPosAnimation.setDuration(1000);
241 scrollBarPosAnimation.setEasingCurve ( QEasingCurve::OutQuint);
242 scrollBarPosAnimation.setStartValue(
243 QPointF (horizontalScrollBar()->value() ,
244 verticalScrollBar()->value() ) );
245 scrollBarPosAnimation.setEndValue(scrollBarPosTarget);
246 scrollBarPosAnimation.start();
248 setScrollBarPos (scrollBarPosTarget);
251 QPointF MapEditor::getScrollBarPosTarget()
253 return scrollBarPosTarget;
257 void MapEditor::setScrollBarPos(const QPointF &p)
260 horizontalScrollBar()->setValue(int(p.x()));
261 verticalScrollBar()->setValue(int(p.y()));
264 QPointF MapEditor::getScrollBarPos()
266 return QPointF (horizontalScrollBar()->value(),verticalScrollBar()->value());
267 //return scrollBarPos;
270 void MapEditor::setZoomFactorTarget (const qreal &zft)
272 zoomFactorTarget=zft;
273 if (zoomAnimation.state()==QAbstractAnimation::Running)
274 zoomAnimation.stop();
275 if (settings.value ("/animation/use/",true).toBool() )
277 //zoomAnimation=QPropertyAnimation(this, "zoomFactor");
278 zoomAnimation.setTargetObject (this);
279 zoomAnimation.setPropertyName ("zoomFactor");
280 zoomAnimation.setDuration(1000);
281 zoomAnimation.setEasingCurve ( QEasingCurve::OutQuint);
282 zoomAnimation.setStartValue(zoomFactor);
283 zoomAnimation.setEndValue(zft);
284 zoomAnimation.start();
289 qreal MapEditor::getZoomFactorTarget()
291 return zoomFactorTarget;
295 void MapEditor::setZoomFactor(const qreal &zf)
298 setMatrix (QMatrix(zf, 0, 0, zf, 0, 0),false );
301 qreal MapEditor::getZoomFactor()
306 void MapEditor::print()
310 printer = new QPrinter;
311 printer->setColorMode (QPrinter::Color);
312 printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
313 printer->setOutputFormat((QPrinter::OutputFormat)settings.value("/mainwindow/printerFormat",printer->outputFormat()).toInt());
314 printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString());
317 QRectF totalBBox=getTotalBBox();
319 // Try to set orientation automagically
320 // Note: Interpretation of generated postscript is amibiguous, if
321 // there are problems with landscape mode, see
322 // http://sdb.suse.de/de/sdb/html/jsmeix_print-cups-landscape-81.html
324 if (totalBBox.width()>totalBBox.height())
325 // recommend landscape
326 printer->setOrientation (QPrinter::Landscape);
328 // recommend portrait
329 printer->setOrientation (QPrinter::Portrait);
331 if ( printer->setup(this) )
332 // returns false, if printing is canceled
334 QPainter pp(printer);
336 pp.setRenderHint(QPainter::Antialiasing,true);
338 // Don't print the visualisation of selection
341 QRectF mapRect=totalBBox;
342 QGraphicsRectItem *frame=NULL;
346 // Print frame around map
347 mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10,
348 totalBBox.width()+20, totalBBox.height()+20);
349 frame=mapScene->addRect (mapRect, QPen(Qt::black),QBrush(Qt::NoBrush));
355 double paperAspect = (double)printer->width() / (double)printer->height();
356 double mapAspect = (double)mapRect.width() / (double)mapRect.height();
358 if (mapAspect>=paperAspect)
360 // Fit horizontally to paper width
361 //pp.setViewport(0,0, printer->width(),(int)(printer->width()/mapAspect) );
362 viewBottom=(int)(printer->width()/mapAspect);
365 // Fit vertically to paper height
366 //pp.setViewport(0,0,(int)(printer->height()*mapAspect),printer->height());
367 viewBottom=printer->height();
372 // Print footer below map
374 font.setPointSize(10);
376 QRectF footerBox(0,viewBottom,printer->width(),15);
377 // FIXME-3 fileName not any longer available here: pp.drawText ( footerBox,Qt::AlignLeft,"VYM - " +fileName);
378 pp.drawText ( footerBox, Qt::AlignRight, QDate::currentDate().toString(Qt::TextDate));
382 QRectF (0,0,printer->width(),printer->height()-15),
383 QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height())
386 // Viewport has paper dimension
387 if (frame) delete (frame);
392 // Save settings in vymrc
393 settings.writeEntry("/mainwindow/printerName",printer->printerName());
394 settings.writeEntry("/mainwindow/printerFormat",printer->outputFormat());
395 settings.writeEntry("/mainwindow/printerFileName",printer->outputFileName());
399 QRectF MapEditor::getTotalBBox()
403 pen.setCapStyle ( Qt::RoundCap );
407 BranchItem *cur=NULL;
408 BranchItem *prev=NULL;
409 model->nextBranch(cur,prev);
412 if (!cur->hasHiddenExportParent())
414 bo=(BranchObj*)(cur->getLMO());
415 if (bo && bo->isVisibleObj())
417 bo->calcBBoxSizeWithChildren();
419 //QRectF r1=bo->getBBoxSizeWithChildren();
420 QRectF r1=bo->getBBox();
421 //pen.setColor ( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8));
422 //mapScene->addRect (r1,pen);
424 if (rt.isNull()) rt=r1;
426 //qDebug() <<"ME: r1="<<r1<<" "<<cur->getHeadingStd();
427 //qDebug() <<" rt="<<rt;
430 model->nextBranch(cur,prev);
436 QImage MapEditor::getImage()
438 QRectF mapRect=getTotalBBox();
439 int w=mapRect.width()+2;
440 int h=mapRect.height()+2;
442 QImage pix (w,h,QImage::Format_RGB32);
446 pp.setRenderHints(renderHints());
447 mapScene->render ( &pp,
449 QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
454 void MapEditor::setAntiAlias (bool b)
456 setRenderHint(QPainter::Antialiasing,b);
459 void MapEditor::setSmoothPixmap(bool b)
461 setRenderHint(QPainter::SmoothPixmapTransform,b);
465 void MapEditor::autoLayout()
467 // Create list with all bounding polygons
468 QList <LinkableMapObj*> mapobjects;
469 QList <ConvexPolygon> polys;
471 QList <Vector> vectors;
472 QList <Vector> orgpos;
473 QStringList headings; //FIXME-3 testing only
479 // Outer loop: Iterate until we no more changes in orientation
480 bool orientationChanged=true;
481 while (orientationChanged)
483 BranchItem *ri=model->getRootItem();
484 for (int i=0;i<ri->branchCount();++i)
486 bi=ri->getBranchNum (i);
487 bo=(BranchObj*)bi->getLMO();
490 mapobjects.append (bo);
491 p=bo->getBoundingPolygon();
494 vectors.append (QPointF(0,0));
495 orgpos.append (p.at(0));
496 headings.append (bi->getHeading());
498 for (int j=0;j<bi->branchCount();++j)
500 bi2=bi->getBranchNum (j);
501 bo=(BranchObj*)bi2->getLMO();
504 mapobjects.append (bo);
505 p=bo->getBoundingPolygon();
508 vectors.append (QPointF(0,0));
509 orgpos.append (p.at(0));
510 headings.append (bi2->getHeading());
515 // Iterate moving bounding polygons until we have no more collisions
520 for (int i=0; i<polys.size()-1; ++i)
522 for (int j=i+1; j<polys.size();++j)
524 if (polygonCollision (polys.at(i),polys.at(j), QPointF(0,0)).intersect )
527 if (debug) qDebug() << "Collision: "<<headings[i]<<" - "<<headings[j];
528 v=polys.at(j).centroid()-polys.at(i).centroid();
529 // Move also away if centroids are identical
532 v.setX (rand()%200 -100);
533 v.setY (rand()%200 -100);
535 // Add random direction
536 Vector w (cos (rand()%1000),sin(rand()%1000));
538 // Scale translation vector by area of polygons
540 vectors[j]=v*10000/polys.at(j).weight();
541 vectors[i]=v*10000/polys.at(i).weight();
543 //FIXME-3 outer loop, "i" get's changed several times...
544 // Better not move away from centroid of 2 colliding polys,
545 // but from centroid of _all_
549 for (int i=0;i<vectors.size();i++)
551 //qDebug() << " v="<<vectors[i]<<" "<<headings[i];
552 if (!vectors[i].isNull() )
553 polys[i].translate (vectors[i]);
555 if (debug) qDebug()<< "Collisions total: "<<collisions;
559 // Finally move the real objects and update
560 QList <LinkableMapObj::Orientation> orients;
561 for (int i=0;i<polys.size();i++)
563 Vector v=polys[i].at(0)-orgpos[i];
564 orients.append (mapobjects[i]->getOrientation());
567 if (debug) cout<<" Moving "<<polys.at(i).weight()<<" "<<mapobjects[i]->getAbsPos()<<" -> "<<mapobjects[i]->getAbsPos() + v<<" "<<headings[i].toStdString()<<endl;
568 //mapobjects[i]->moveBy(v.x(),v.y() );
569 //mapobjects[i]->setRelPos();
570 model->startAnimation ((BranchObj*)mapobjects[i], v);
571 if (debug) cout<<i<< " Weight: "<<polys.at(i).weight()<<" "<<v<<" "<<headings.at(i).toStdString()<<endl;
576 orientationChanged=false;
577 for (int i=0;i<polys.size();i++)
578 if (orients[i]!=mapobjects[i]->getOrientation())
580 orientationChanged=true;
587 //orientationChanged=false;
588 } // loop if orientation has changed
590 model->emitSelectionChanged();
593 TreeItem* MapEditor::findMapItem (QPointF p,TreeItem *exclude)
595 // Start with mapcenter, no images allowed at rootItem
597 BranchItem *bi=model->getRootItem()->getFirstBranch();
598 TreeItem *found=NULL;
601 found=bi->findMapItem (p, exclude);
602 if (found) return found;
604 bi=model->getRootItem()->getBranchNum(i);
609 AttributeTable* MapEditor::attributeTable()
614 void MapEditor::testFunction1()
617 qDebug()<< "ME::test1 selected TI="<<model->getSelectedItem();
618 model->setExportMode (true);
620 QLineEdit *le3=new QLineEdit;
621 mapScene->addWidget (le3);
622 le3->setGeometry (10,10,100,30);
623 le3->setText("LineEdit 3");
625 QLineEdit *le4=new QLineEdit;
626 mapScene->addWidget (le4);
627 le4->setGeometry (10,50,100,30);
628 le4->setText("LineEdit 4");
634 // Code copied from Qt sources
635 QRectF rect=model->getSelectedBranchObj()->getBBox();
639 qreal width = viewport()->width();
640 qreal height = viewport()->height();
641 QRectF viewRect = matrix().mapRect(rect);
643 qreal left = horizontalScrollBar()->value();
644 qreal right = left + width;
645 qreal top = verticalScrollBar()->value();
646 qreal bottom = top + height;
648 if (viewRect.left() <= left + xmargin) {
649 // need to scroll from the left
650 // if (!d->leftIndent)
651 horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
653 if (viewRect.right() >= right - xmargin) {
654 // need to scroll from the right
655 // if (!d->leftIndent)
656 horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
658 if (viewRect.top() <= top + ymargin) {
659 // need to scroll from the top
660 // if (!d->topIndent)
661 verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
663 if (viewRect.bottom() >= bottom - ymargin) {
664 // need to scroll from the bottom
665 // if (!d->topIndent)
666 verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
668 qDebug() << "test1: hor="<<horizontalScrollBar()->value();
669 qDebug() << "test1: ver="<<verticalScrollBar()->value();
674 QtPropertyAnimation *animation=new QtPropertyAnimation(this, "sceneRect");
675 animation->setDuration(5000);
676 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
677 animation->setEasingCurve ( QtEasingCurve::OutQuint);
678 animation->setStartValue(sceneRect() );
679 animation->setEndValue(QRectF(50, 50, 1000, 1000));
684 QDialog *dia= new QDialog (this);
685 dia->setGeometry (50,50,10,10);
690 QtPropertyAnimation *animation=new QtPropertyAnimation(dia, "geometry");
691 animation->setDuration(1000);
692 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
693 animation->setEasingCurve ( QtEasingCurve::OutQuint);
694 animation->setStartValue(QRect(50, 50, 10, 10));
695 animation->setEndValue(QRect(250, 250, 100, 100));
702 void MapEditor::testFunction2()
707 BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi)
712 if (i>0) return bi->parent()->getBranchNum(i-1);
717 BranchItem* MapEditor::getBranchAbove (BranchItem *selbi)
721 int dz=selbi->depth(); // original depth
723 if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
728 // Look for branch with same parent but directly above
730 bi=getBranchDirectBelow(selbi);
732 bi=getBranchDirectAbove (selbi);
735 // direct predecessor
738 // Go towards center and look for predecessor
739 while (selbi->depth()>0)
741 selbi=(BranchItem*)(selbi->parent());
742 if (selbi->depth()==1 && invert)
743 bi=getBranchDirectBelow (selbi);
745 bi=getBranchDirectAbove (selbi);
750 while (selbi->depth()<dz)
752 // try to get back to original depth dz
753 bi=selbi->getLastBranch();
767 BranchItem* MapEditor::getBranchDirectBelow(BranchItem *bi)
772 if (i+1<bi->parent()->branchCount()) return bi->parent()->getBranchNum(i+1);
777 BranchItem* MapEditor::getBranchBelow (BranchItem *selbi)
782 int dz=selbi->depth(); // original depth
784 if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
788 // Look for branch with same parent but directly below
790 bi=getBranchDirectAbove (selbi);
792 bi=getBranchDirectBelow (selbi);
798 // Go towards center and look for neighbour
799 while (selbi->depth()>0)
801 selbi=(BranchItem*)(selbi->parent());
802 if (selbi->depth()==1 && invert)
803 bi=getBranchDirectAbove (selbi);
805 bi=getBranchDirectBelow (selbi);
810 while (selbi->depth()<dz)
812 // try to get back to original depth dz
813 bi=selbi->getFirstBranch();
827 BranchItem* MapEditor::getLeftBranch (BranchItem *bi)
832 // Special case: use alternative selection index
833 return bi->getLastSelectedBranchAlt();
834 if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)
836 return (BranchItem*)(bi->parent());
839 if (bi->getType()== TreeItem::Branch )
840 return bi->getLastSelectedBranch();
845 BranchItem* MapEditor::getRightBranch(BranchItem *bi)
849 if (bi->depth()==0) return bi->getLastSelectedBranch();
850 if (bi->getBranchObj()->getOrientation()==LinkableMapObj::LeftOfCenter)
852 return (BranchItem*)(bi->parent());
855 if (bi->getType()== TreeItem::Branch )
856 return (BranchItem*)bi->getLastSelectedBranch();
863 void MapEditor::cursorUp()
865 BranchItem *bi=model->getSelectedBranch();
866 if (bi) model->select (getBranchAbove(bi));
869 void MapEditor::cursorDown()
872 BranchItem *bi=model->getSelectedBranch();
873 if (bi) model->select (getBranchBelow(bi));
876 void MapEditor::cursorLeft()
878 BranchItem *bi=getLeftBranch (model->getSelectedBranch());
879 if (bi) model->select (bi);
882 void MapEditor::cursorRight()
884 BranchItem *bi=getRightBranch (model->getSelectedBranch());
885 if (bi) model->select (bi);
888 void MapEditor::cursorFirst()
890 model->selectFirstBranch();
893 void MapEditor::cursorLast()
895 model->selectLastBranch();
899 void MapEditor::editHeading()
903 editHeadingFinished();
906 BranchObj *bo=model->getSelectedBranchObj();
907 BranchItem *bi=model->getSelectedBranch();
910 model->setSelectionBlocked(true);
912 lineEdit=new QLineEdit;
913 QGraphicsProxyWidget *pw=mapScene->addWidget (lineEdit);
914 pw->setZValue (Z_LINEEDIT);
915 lineEdit->setCursor(Qt::IBeamCursor);
916 lineEdit->setCursorPosition(1);
917 QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
918 lineEdit->setGeometry(p.x(),p.y(),230,25);
919 lineEdit->setText (bi->getHeading());
920 lineEdit->setFocus();
921 lineEdit->selectAll(); // Hack to enable cursor in lineEdit
922 lineEdit->deselect(); // probably a Qt bug...
923 //lineEdit->grabKeyboard();
928 void MapEditor::editHeadingFinished()
930 editingHeading=false;
931 //lineEdit->releaseKeyboard();
932 //lineEdit->clearFocus();
933 QString s=lineEdit->text();
934 s.replace (QRegExp ("\\n")," "); // Don't paste newline chars
935 model->setHeading (s);
936 model->setSelectionBlocked(false);
939 // Maybe reselect previous branch
940 mainWindow->editHeadingFinished (model);
944 void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
946 // Lineedits are already closed by preceding
947 // mouseEvent, we don't need to close here.
949 QPointF p = mapToScene(e->pos());
950 TreeItem *ti=findMapItem (p, NULL);
951 LinkableMapObj* lmo=NULL;
952 if (ti) lmo=((MapItem*)ti)->getLMO();
955 { // MapObj was found
956 if (model->getSelectedLMO() != lmo)
962 if (model->getSelectedBranchObj() )
964 // Context Menu on branch or mapcenter
965 branchContextMenu->popup(e->globalPos() );
968 if (model->getSelectedImage() )
970 // Context Menu on floatimage
971 floatimageContextMenu->popup(e->globalPos() );
975 { // No MapObj found, we are on the Canvas itself
976 // Context Menu on scene
978 // Open context menu synchronously to position new mapcenter
979 model->setContextPos (p);
980 canvasContextMenu->exec(e->globalPos() );
981 model->unsetContextPos ();
986 void MapEditor::keyPressEvent(QKeyEvent* e)
988 //qDebug()<<"ME::keyPressed";
990 if (e->modifiers() & Qt::ControlModifier)
992 switch (mainWindow->getModMode())
994 case Main::ModModeColor:
995 setCursor (PickColorCursor);
997 case Main::ModModeCopy:
998 setCursor (CopyCursor);
1000 case Main::ModModeXLink:
1001 setCursor (XLinkCursor);
1004 setCursor (Qt::ArrowCursor);
1008 QGraphicsView::keyPressEvent(e);
1011 void MapEditor::keyReleaseEvent(QKeyEvent* e)
1013 if (!(e->modifiers() & Qt::ControlModifier))
1014 setCursor (Qt::ArrowCursor);
1017 void MapEditor::mousePressEvent(QMouseEvent* e)
1019 // Ignore right clicks or wile editing heading
1020 if (e->button() == Qt::RightButton or model->isSelectionBlocked() )
1022 //qDebug() << " ME::ignoring right mouse event...\n";
1024 QGraphicsView::mousePressEvent(e);
1028 QPointF p = mapToScene(e->pos());
1029 TreeItem *ti=findMapItem (p, NULL);
1030 LinkableMapObj* lmo=NULL;
1031 if (ti) lmo=((MapItem*)ti)->getLMO();
1036 //Take care of system flags _or_ modifier modes
1038 if (lmo && ti->isBranchLikeType() )
1040 QString foname=((BranchObj*)lmo)->getSystemFlagName(p);
1041 if (!foname.isEmpty())
1043 // systemFlag clicked
1044 model->select (lmo);
1045 if (foname.contains("system-url"))
1047 if (e->state() & Qt::ControlModifier)
1048 mainWindow->editOpenURLTab();
1050 mainWindow->editOpenURL();
1052 else if (foname=="system-vymLink")
1054 mainWindow->editOpenVymLink();
1055 // tabWidget may change, better return now
1056 // before segfaulting...
1057 } else if (foname=="system-note")
1058 mainWindow->windowToggleNoteEditor();
1059 else if (foname=="hideInExport")
1060 model->toggleHideExport();
1061 // FIXME-3 needed? xelection.update();
1065 // Take care of xLink
1066 if (ti->xlinkCount()>0 && lmo->getBBox().width()>30)
1068 if ((lmo->getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20) ||
1069 (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) )
1071 // FIXME-4 if (ti->xlinkCount()>1)
1075 QList <QAction*> alist;
1076 for (int i=0;i<ti->xlinkCount();i++)
1077 alist.append (new QAction(ti->getXLinkNum(i)->getOtherBranch(ti)->getHeading(),&menu));
1078 menu.addActions (alist);
1079 QAction *ra=menu.exec (e->globalPos() );
1081 model->select (ti->getXLinkNum(alist.indexOf(ra))->getOtherBranch (ti));
1082 while (!alist.isEmpty())
1084 QAction *a=alist.takeFirst();
1090 model->select (ti->getXLinkNum(0)->getOtherBranch (ti));
1098 // No system flag clicked, take care of modmodes (CTRL-Click)
1099 if (e->state() & Qt::ControlModifier)
1101 if (mainWindow->getModMode()==Main::ModModeColor)
1104 setCursor (PickColorCursor);
1107 if (mainWindow->getModMode()==Main::ModModeXLink)
1109 BranchItem *bi_begin=model->getSelectedBranch();
1113 tmpXLink=model->createXLink(bi_begin,true);
1114 tmpXLink->setColor(model->getMapDefXLinkColor());
1115 tmpXLink->setWidth(model->getMapDefXLinkWidth());
1116 tmpXLink->setEnd (p);
1117 tmpXLink->updateXLink();
1121 } // End of modmodes
1126 qDebug() << "ME::mouse pressed\n";
1127 qDebug() << " lmo="<<lmo;
1128 qDebug() << " ti="<<ti->getHeadingStd();
1130 // Select the clicked object
1135 // Left Button Move Branches
1136 if (e->button() == Qt::LeftButton )
1138 movingObj_start.setX( p.x() - lmo->x() );
1139 movingObj_start.setY( p.y() - lmo->y() );
1140 movingObj_orgPos.setX (lmo->x() );
1141 movingObj_orgPos.setY (lmo->y() );
1143 movingObj_orgRelPos=lmo->getRelPos();
1145 // If modMode==copy, then we want to "move" the _new_ object around
1146 // then we need the offset from p to the _old_ selection, because of tmp
1147 if (mainWindow->getModMode()==Main::ModModeCopy &&
1148 e->state() & Qt::ControlModifier)
1150 BranchItem *bi=model->getSelectedBranch();
1154 //FIXME-2 TreeItem::addBranch (BranchItem still missing)
1155 //bi->addBranch (model->getSelectedBranch());
1157 model->select(bi->getLastBranch());
1158 model->reposition();
1162 movingObj=model->getSelectedLMO();
1164 // Middle Button Toggle Scroll
1165 // (On Mac OS X this won't work, but we still have
1166 // a button in the toolbar)
1167 if (e->button() == Qt::MidButton )
1168 model->toggleScroll();
1169 // model->updateActions(); FIXME-3 needed?
1170 // FIXME-3 needed? xelection.update();
1172 { // No MapObj found, we are on the scene itself
1173 // Left Button move Pos of sceneView
1174 if (e->button() == Qt::LeftButton )
1176 movingObj=NULL; // move Content not Obj
1177 movingObj_start=e->globalPos();
1178 movingCont_start=QPointF (
1179 horizontalScrollBar()->value(),
1180 verticalScrollBar()->value());
1181 movingVec=QPointF(0,0);
1182 setCursor(HandOpenCursor);
1185 QGraphicsView::mousePressEvent(e);
1188 void MapEditor::mouseMoveEvent(QMouseEvent* e)
1191 QPointF p = mapToScene(e->pos());
1192 TreeItem *seli=model->getSelectedItem();
1193 LinkableMapObj* lmosel=NULL;
1194 if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
1195 lmosel=((MapItem*)seli)->getLMO();
1197 // Move the selected MapObj
1198 if ( lmosel && movingObj)
1201 // reset cursor if we are moving and don't copy
1202 if (mainWindow->getModMode()!=Main::ModModeCopy)
1203 setCursor (Qt::ArrowCursor);
1205 // To avoid jumping of the sceneView, only
1206 // show selection, if not tmp linked
1207 /* FIXME-2 if (!lmosel->hasParObjTmp())
1208 model->emitShowSelection();
1211 // Now move the selection, but add relative position
1212 // (movingObj_start) where selection was chosen with
1213 // mousepointer. (This avoids flickering resp. jumping
1214 // of selection back to absPos)
1216 // Check if we could link
1217 TreeItem *ti=findMapItem (p, seli);
1218 BranchItem *dsti=NULL;
1219 LinkableMapObj* dst=NULL;
1220 if (ti && ti!=seli && ti->isBranchLikeType())
1222 dsti=(BranchItem*)ti;
1228 if (lmosel && seli->getType()==TreeItem::Image)
1230 FloatObj *fio=(FloatImageObj*)lmosel;
1231 fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1233 fio->updateLinkGeometry(); //no need for reposition, if we update link here
1234 model->emitSelectionChanged(); // position has changed
1236 // Relink float to new mapcenter or branch, if shift is pressed
1237 // Only relink, if selection really has a new parent
1238 if ( e->modifiers()==Qt::ShiftModifier && dsti && dsti != seli->parent() )
1240 // Also save the move which was done so far
1241 QString pold=qpointFToString(movingObj_orgRelPos);
1242 QString pnow=qpointFToString(fio->getRelPos());
1248 QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
1249 fio->getParObj()->requestReposition();
1250 model->reposition();
1252 model->relinkImage ((ImageItem*) seli,dsti);
1253 model->select (seli);
1254 //movingObj=lmosel; //FIXME-3
1255 //movingObj_orgRelPos=lmosel->getRelPos();
1257 model->reposition();
1260 { // selection != a FloatObj
1261 if (seli->depth()==0)
1264 lmosel->move (p-movingObj_start);
1265 if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
1267 // Move only mapcenter, leave its children where they are
1269 v=lmosel->getAbsPos();
1270 for (int i=0; i<seli->branchCount(); ++i)
1272 seli->getBranchObjNum(i)->setRelPos();
1273 seli->getBranchObjNum(i)->setOrientation();
1278 if (seli->depth()==1)
1281 if (!lmosel->hasParObjTmp())
1282 lmosel->move(p-movingObj_start);
1283 lmosel->setRelPos();
1286 // Move ordinary branch
1287 if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
1288 // Add width of bbox here, otherwise alignRelTo will cause jumping around
1289 lmosel->move(p.x() -movingObj_start.x() , //lmosel->getBBox().width(),
1290 p.y()-movingObj_start.y() +lmosel->getTopPad() );
1292 lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
1293 lmosel->setRelPos();
1297 // Maybe we can relink temporary?
1300 if (e->modifiers()==Qt::ControlModifier)
1302 // Special case: CTRL to link below dst
1303 lmosel->setParObjTmp (dst,p,+1);
1304 } else if (e->modifiers()==Qt::ShiftModifier)
1305 lmosel->setParObjTmp (dst,p,-1);
1307 lmosel->setParObjTmp (dst,p,0);
1310 lmosel->unsetParObjTmp();
1312 // reposition subbranch
1313 lmosel->reposition();
1315 QItemSelection sel=model->getSelectionModel()->selection();
1316 updateSelection(sel,sel); // position has changed
1318 } // no FloatImageObj
1322 } // selection && moving_obj
1324 // Draw a link from one branch to another
1327 tmpXLink->setEnd (p);
1328 tmpXLink->updateXLink();
1332 if (!movingObj && !pickingColor &&!drawingLink && e->buttons() == Qt::LeftButton )
1334 QPointF p=e->globalPos();
1335 movingVec.setX(-p.x() + movingObj_start.x() );
1336 movingVec.setY(-p.y() + movingObj_start.y() );
1337 horizontalScrollBar()->setSliderPosition((int)( movingCont_start.x()+movingVec.x() ));
1338 verticalScrollBar()->setSliderPosition((int)( movingCont_start.y()+movingVec.y() ) );
1340 QGraphicsView::mouseMoveEvent (e);
1344 void MapEditor::mouseReleaseEvent(QMouseEvent* e)
1346 QPointF p = mapToScene(e->pos());
1347 TreeItem *seli=model->getSelectedItem();
1349 TreeItem *dsti=NULL;
1350 if (seli) dsti=findMapItem(p, seli);
1351 LinkableMapObj* dst=NULL;
1352 if (dsti && dsti->isBranchLikeType ())
1353 dst=((MapItem*)dsti)->getLMO();
1358 // Have we been picking color?
1362 setCursor (Qt::ArrowCursor);
1363 // Check if we are over another branch
1366 if (e->state() & Qt::ShiftModifier)
1367 model->colorBranch (((BranchObj*)dst)->getColor());
1369 model->colorSubtree (((BranchObj*)dst)->getColor());
1374 // Have we been drawing a link?
1378 // Check if we are over another branch
1381 tmpXLink->setEnd ( ((BranchItem*)dsti) );
1382 tmpXLink->updateXLink();
1383 tmpXLink->activate();
1385 tmpXLink,QString("delete ()"),
1386 dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)),
1387 QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti))
1391 model->deleteItem(tmpXLink);
1397 // Have we been moving something?
1398 if ( seli && movingObj )
1400 if (seli->getType()==TreeItem::Image)
1402 FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO());
1405 // Moved FloatObj. Maybe we need to reposition
1406 QString pold=qpointFToString(movingObj_orgRelPos);
1407 QString pnow=qpointFToString(fio->getRelPos());
1413 QString("Move %1 to relative position %2").arg(model->getObjectName(seli)).arg(pnow));
1415 fio->getParObj()->requestReposition();
1416 model->reposition();
1420 BranchItem *bi=model->getSelectedBranch();
1421 if (bi && bi->depth()==0)
1423 if (movingObj_orgPos != bi->getBranchObj()->getAbsPos()) // FIXME-3 check getBO here...
1425 QString pold=qpointFToString(movingObj_orgPos);
1426 QString pnow=qpointFToString(bi->getBranchObj()->getAbsPos()); // FIXME-3 check getBO here...
1433 QString("Move mapcenter %1 to position %2").arg(model->getObjectName(bi)).arg(pnow));
1437 if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
1438 { // A branch was moved
1439 LinkableMapObj* lmosel=NULL;
1440 lmosel=((MapItem*)seli)->getLMO();
1442 // save the position in case we link to mapcenter
1443 QPointF savePos=QPointF (lmosel->getAbsPos() );
1445 // Reset the temporary drawn link to the original one
1446 lmosel->unsetParObjTmp();
1448 // For Redo we may need to save original selection
1449 QString preSelStr=model->getSelectString(seli);
1452 if (dsti && objectMoved)
1454 // We have a destination, relink to that
1456 BranchObj* bsel=model->getSelectedBranchObj();
1458 QString preParStr=model->getSelectString (bsel->getParObj());
1459 QString preNum=QString::number (seli->num(),10);
1460 QString preDstParStr;
1463 if (e->state() & Qt::ShiftModifier && dst->getParObj())
1465 preDstParStr=model->getSelectString (dst->getParObj());
1466 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num());
1468 if (e->state() & Qt::ControlModifier && dst->getParObj())
1471 preDstParStr=model->getSelectString (dst->getParObj());
1472 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num()+1);
1475 preDstParStr=model->getSelectString(dst);
1476 relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
1477 if (dsti->depth()==0) bsel->move (savePos);
1481 QString postSelStr=model->getSelectString(lmosel);
1482 QString postNum=QString::number (seli->num(),10);
1484 QString undoCom="relinkTo (\""+
1485 preParStr+ "\"," + preNum +"," +
1486 QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
1488 QString redoCom="relinkTo (\""+
1489 preDstParStr + "\"," + postNum + "," +
1490 QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
1495 QString("Relink %1 to %2").arg(model->getObjectName(bsel)).arg(model->getObjectName(dst)) );
1500 // No destination, undo temporary move
1502 if (seli->depth()==1)
1504 // The select string might be different _after_ moving around.
1505 // Therefor reposition and then use string of old selection, too
1506 model->reposition();
1508 QPointF rp(lmosel->getRelPos());
1509 if (rp != movingObj_orgRelPos)
1511 QString ps=qpointFToString(rp);
1513 model->getSelectString(lmosel), "moveRel "+qpointFToString(movingObj_orgRelPos),
1514 preSelStr, "moveRel "+ps,
1515 QString("Move %1 to relative position %2").arg(model->getObjectName(lmosel)).arg(ps));
1519 // Draw the original link, before selection was moved around
1520 if (settings.value("/animation/use",true).toBool()
1522 // && distance (lmosel->getRelPos(),movingObj_orgRelPos)<3
1525 lmosel->setRelPos(); // calc relPos first for starting point
1527 model->startAnimation(
1529 lmosel->getRelPos(),
1533 model->reposition();
1536 model->emitSelectionChanged(); //FIXME-3 needed? at least not after pos of selection has changed...
1537 // Finally resize scene, if needed
1543 // maybe we moved View: set old cursor
1544 setCursor (Qt::ArrowCursor);
1546 QGraphicsView::mouseReleaseEvent(e);
1549 void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
1553 qDebug()<< "ME p="<<mapToScene (e->pos())<<" scrollBarPos="<<getScrollBarPos() <<
1554 " min="<<QPointF(horizontalScrollBar()->minimum(),verticalScrollBar()->minimum());
1559 if (model->isSelectionBlocked() )
1565 if (e->button() == Qt::LeftButton )
1567 QPointF p = mapToScene(e->pos());
1568 TreeItem *ti=findMapItem (p, NULL);
1569 if (ti) { // MapObj was found
1570 // First select the MapObj than edit heading
1577 void MapEditor::resizeEvent (QResizeEvent* e)
1579 QGraphicsView::resizeEvent( e );
1582 void MapEditor::dragEnterEvent(QDragEnterEvent *event)
1584 //for (unsigned int i=0;event->format(i);i++) // Debug mime type
1585 // cerr << event->format(i) << endl;
1587 if (event->mimeData()->hasImage())
1588 event->acceptProposedAction();
1590 if (event->mimeData()->hasUrls())
1591 event->acceptProposedAction();
1594 void MapEditor::dragMoveEvent(QDragMoveEvent *)
1598 void MapEditor::dragLeaveEvent(QDragLeaveEvent *event)
1603 void MapEditor::dropEvent(QDropEvent *event)
1605 BranchItem *selbi=model->getSelectedBranch();
1610 foreach (QString format,event->mimeData()->formats())
1611 qDebug()<< "MapEditor: Dropped format: "<<qPrintable (format);
1612 foreach (QString url,event->mimeData()->urls())
1613 qDebug()<< " URL:"<<url;
1614 //foreach (QString plain,event->mimeData()->text())
1615 // qDebug()<< " PLAIN:"<<plain;
1616 QByteArray ba=event->mimeData()->data("STRING");
1620 qDebug() << " STRING:" <<s;
1622 ba=event->mimeData()->data("TEXT");
1624 qDebug() << " TEXT:" <<s;
1626 ba=event->mimeData()->data("COMPOUND_TEXT");
1628 qDebug() << " CTEXT:" <<s;
1630 ba=event->mimeData()->data("text/x-moz-url");
1632 qDebug() << " x-moz-url:" <<s;
1634 if (b!=0) qDebug() << "b="<<b;
1637 if (event->mimeData()->hasImage())
1639 QVariant imageData = event->mimeData()->imageData();
1640 model->addFloatImage (qvariant_cast<QPixmap>(imageData));
1642 if (event->mimeData()->hasUrls())
1644 //model->selectLastBranch();
1645 QList <QUrl> uris=event->mimeData()->urls();
1650 for (int i=0; i<uris.count();i++)
1652 // Workaround to avoid adding empty branches
1653 if (!uris.at(i).toString().isEmpty())
1655 bi=model->addNewBranch();
1659 QString u=uris.at(i).toString();
1660 s=uris.at(i).toLocalFile();
1663 QString file = QDir::fromNativeSeparators(s);
1664 heading = QFileInfo(file).baseName();
1666 if (file.endsWith(".vym", false))
1667 model->setVymLink(file);
1675 // Automatically try to fetch data from Bugzilla
1676 if (settings.value( "/mainwindow/showTestMenu",false).toBool()
1677 && u.contains ("https://bugzilla.novell.com"))
1678 model->getBugzillaData();
1682 if (!heading.isEmpty())
1683 model->setHeading(heading);
1685 model->setHeading(u);
1687 model->select (bi->parent());
1691 //model->reposition();
1694 event->acceptProposedAction();
1697 void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel)
1699 // Note: Here we are prepared for multiple selections, though this
1700 // is not yet implemented elsewhere
1702 // Here in MapEditor we can only select Branches and Images
1703 QList <TreeItem*> treeItemsNew;
1704 QList <TreeItem*> treeItemsOld;
1706 QModelIndex newIndex;
1708 bool do_reposition=false;
1711 foreach (ix,newsel.indexes() )
1713 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1714 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
1715 if (!treeItemsNew.contains(ti)) treeItemsNew.append (ti);
1717 foreach (ix,oldsel.indexes() )
1719 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1720 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
1721 if (!treeItemsOld.contains(ti)) treeItemsOld.append (ti);
1724 // Trim list of selection rectangles
1725 while (treeItemsNew.count() < selboxList.count() )
1726 delete selboxList.takeFirst();
1728 // Take care to tmp scroll/unscroll
1729 if (!oldsel.isEmpty())
1731 QModelIndex ix=oldsel.indexes().first();
1734 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1737 if (ti->isBranchLikeType() )
1739 // reset tmp scrolled branches
1740 BranchItem *bi=(BranchItem*)ti;
1741 if (bi->resetTmpUnscroll() )
1744 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1745 // Hide link if not needed
1746 ((MapItem*)ti)->getLMO()->updateVisibility();
1751 if (!treeItemsNew.isEmpty())
1753 QModelIndex ix=newsel.indexes().first();
1758 // Temporary unscroll if necessary
1759 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1760 if (ti->isBranchLikeType() )
1762 BranchItem *bi=(BranchItem*)ti;
1763 if (bi->hasScrolledParent(bi) )
1765 if (bi->parentBranch()->tmpUnscroll() )
1769 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1770 // Show link if needed
1771 ((MapItem*)ti)->getLMO()->updateVisibility();
1774 if (do_reposition) model->reposition();
1776 // Reduce rectangles
1777 while (treeItemsNew.count() < selboxList.count() )
1778 delete selboxList.takeFirst();
1780 // Add additonal rectangles
1781 QGraphicsRectItem *sb;
1782 while (treeItemsNew.count() > selboxList.count() )
1784 sb = mapScene->addRect(
1786 QPen(selectionColor),
1788 sb->setZValue(Z_SELBOX);
1790 selboxList.append (sb);
1793 // Reposition rectangles
1797 LinkableMapObj *lmo;
1798 for (int i=0; i<treeItemsNew.count();++i)
1800 lmo=((MapItem*)treeItemsNew.at(i) )->getLMO();
1801 bbox=lmo->getBBox();
1802 sb=selboxList.at(i);
1805 bbox.width(), bbox.height());
1806 sb->setPen (selectionColor);
1807 sb->setBrush (selectionColor);
1814 void MapEditor::updateData (const QModelIndex &sel)
1816 TreeItem *ti= static_cast<TreeItem*>(sel.internalPointer());
1819 qDebug() << "ME::updateData\n";
1821 qDebug() << " ti="<<ti;
1822 qDebug() << " h="<<ti->getHeading();
1825 if (ti->isBranchLikeType())
1827 // qDebug() << " ->updating...\n";
1828 BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO());
1833 void MapEditor::setSelectionColor (QColor col)
1836 QItemSelection sel=model->getSelectionModel()->selection();
1837 updateSelection(sel,sel);
1841 QColor MapEditor::getSelectionColor ()
1843 return selectionColor;