void EditInteraction::snapMousePressEvent(QMouseEvent * ev, Feature* aLast) { Qt::KeyboardModifiers modifiers = ev->modifiers(); if (!view()->isSelectionLocked()) { if (modifiers) { if (modifiersForToggle(modifiers) && aLast) PROPERTIES(toggleSelection(aLast)); if (modifiersForAdd(modifiers) && aLast) PROPERTIES(addSelection(aLast)); if (g_Merk_Segment_Mode && aLast) { PROPERTIES(setSelection(aLast)); } } else { StackSnap = SnapList; // if (aLast) // PROPERTIES(setSelection(aLast)); } if (!aLast && modifiersForDrag(modifiers)) { EndDrag = StartDrag = XY_TO_COORD(ev->pos()); Dragging = true; } PROPERTIES(checkMenuStatus()); view()->update(); } }
EditInteraction::EditInteraction(MapView* theView) : FeatureSnapInteraction(theView), Dragging(false), StartDrag(0,0), EndDrag(0,0) { defaultCursor = QCursor(Qt::ArrowCursor); connect(main(),SIGNAL(remove_triggered()),this,SLOT(on_remove_triggered())); connect(main(),SIGNAL(reverse_triggered()), this,SLOT(on_reverse_triggered())); PROPERTIES(checkMenuStatus()); if (!M_PREFS->getSeparateMoveMode()) { setDontSelectVirtual(false); } }
void EditInteraction::snapMouseReleaseEvent(QMouseEvent * ev , Feature* aLast) { Qt::KeyboardModifiers modifiers = ev->modifiers(); if (ev->button() != Qt::LeftButton) return; if (Dragging) { QList<Feature*> List; EndDrag = XY_TO_COORD(ev->pos()); CoordBox DragBox(StartDrag, EndDrag); for (VisibleFeatureIterator it(document()); !it.isEnd(); ++it) { if (it.get()->isReadonly()) continue; if (modifiersForGreedyAdd(modifiers)) { if (!DragBox.intersects(it.get()->boundingBox())) continue; if (DragBox.contains(it.get()->boundingBox())) List.push_back(it.get()); else { Coord A, B; if (Way* R = dynamic_cast<Way*>(it.get())) { for (int j=1; j<R->size(); ++j) { A = R->getNode(j-1)->position(); B = R->getNode(j)->position(); if (CoordBox::visibleLine(DragBox, A, B)) { List.push_back(R); break; } } } else if (Relation* r = dynamic_cast<Relation*>(it.get())) { for (int k=0; k<r->size(); ++k) { if (Way* R = dynamic_cast<Way*>(r->get(k))) { for (int j=1; j<R->size(); ++j) { A = R->getNode(j-1)->position(); B = R->getNode(j)->position(); if (CoordBox::visibleLine(DragBox, A, B)) { List.push_back(r); break; } } } } } } } else { if (DragBox.contains(it.get()->boundingBox())) List.push_back(it.get()); } } if (!List.isEmpty() || (!modifiersForAdd(modifiers) && !modifiersForToggle(modifiers))) PROPERTIES(setSelection(List)); PROPERTIES(checkMenuStatus()); Dragging = false; view()->update(); } else { if (!panning() && !modifiers) { PROPERTIES(setSelection(aLast)); PROPERTIES(checkMenuStatus()); view()->update(); } } }
void PropertiesDock::resetValues() { Highlighted.clear(); // Tables that might need column sizing CurrentTagView = NULL; CurrentMembersView = NULL; // to prevent slots to change the values also QList<Feature*> Current = Selection; Selection.clear(); if (FullSelection.size() == 1) { Main->info()->setHtml(FullSelection[0]->toHtml()); Node* Pt = dynamic_cast<Node*>(FullSelection[0]); Way* R = dynamic_cast<Way*>(FullSelection[0]); Relation* L = dynamic_cast<Relation*>(FullSelection[0]); if ((Pt) && (NowShowing == TrackPointUiShowing)) { TrackPointUi.Id->setText(QString::number(Pt->id().numId)); TrackPointUi.Latitude->setText(COORD2STRING(Pt->position().y())); TrackPointUi.Longitude->setText(COORD2STRING(Pt->position().x())); TrackPointUi.TagView->setModel(theModel); TrackPointUi.TagView->setItemDelegate(delegate); QWidget* w; for (int i=0; i<TrackPointUi.variableLayout->count(); ++i) { w = TrackPointUi.variableLayout->itemAt(i)->widget(); if (w) { w->hide(); w->deleteLater(); } } if (theTemplates) { w = theTemplates->getWidget(Pt, Main->view()); w->installEventFilter(shortcutFilter); TrackPointUi.variableLayout->addWidget(w); } CurrentTagView = TrackPointUi.TagView; #ifdef GEOIMAGE Main->geoImage()->setImage(Pt); #endif } else if ((R) && (NowShowing == RoadUiShowing)) { RoadUi.Id->setText(QString::number(R->id().numId)); //RoadUi.Name->setText(R->tagValue("name","")); RoadUi.TagView->setModel(theModel); RoadUi.TagView->setItemDelegate(delegate); QWidget* w; for (int i=0; i<RoadUi.variableLayout->count(); ++i) { w = RoadUi.variableLayout->itemAt(i)->widget(); if (w) { w->hide(); w->deleteLater(); } } if (theTemplates) { w = theTemplates->getWidget(R, Main->view()); w->installEventFilter(shortcutFilter); RoadUi.variableLayout->addWidget(w); } CurrentTagView = RoadUi.TagView; } else if ((L) && (NowShowing == RelationUiShowing)) { RelationUi.MembersView->setModel(L->referenceMemberModel(Main)); RelationUi.TagView->setModel(theModel); RelationUi.TagView->setItemDelegate(delegate); QWidget* w; for (int i=0; i<RelationUi.variableLayout->count(); ++i) { w = RelationUi.variableLayout->itemAt(i)->widget(); if (w) { w->hide(); w->deleteLater(); } } if (theTemplates) { w = theTemplates->getWidget(L, Main->view()); w->installEventFilter(shortcutFilter); RelationUi.variableLayout->addWidget(w); } CurrentTagView = RelationUi.TagView; CurrentMembersView = RelationUi.MembersView; } if (theTemplates) theTemplates->apply(FullSelection[0]); } else if ((FullSelection.size() > 1) && (NowShowing == MultiShowing)) { Main->info()->setHtml(""); #ifdef GEOIMAGE Main->geoImage()->setImage((Node *)NULL); #endif MultiUi.TagView->setModel(theModel); MultiUi.TagView->setItemDelegate(delegate); CurrentTagView = MultiUi.TagView; } theModel->setFeature(Current); Selection = Current; checkMenuStatus(); emit selectionChanged(); /* If we have standard TableViews in the current UI, set it so that the */ /* first column is the width of the default text (Edit this to add...) */ /* And the rest of the space is assigned to the second column */ if (CurrentTagView) { if (M_PREFS->getTagListFirstColumnWidth() > 20 && M_PREFS->getTagListFirstColumnWidth() < CurrentTagView->width()) CurrentTagView->setColumnWidth( 0, M_PREFS->getTagListFirstColumnWidth() ); else CurrentTagView->setColumnWidth( 0, CurrentTagView->fontMetrics().width(theModel->newKeyText())+10 ); CurrentTagView->horizontalHeader()->setStretchLastSection(true); CurrentTagView->installEventFilter(shortcutFilter); } if (CurrentMembersView) { CurrentMembersView->setColumnWidth( 0, CurrentMembersView->fontMetrics().width(theModel->newKeyText())+10 ); CurrentMembersView->horizontalHeader()->setStretchLastSection(true); CurrentMembersView->installEventFilter(shortcutFilter); } }