/** * Ways can be ordered by id and version. * Note that we use the absolute value of the id for a * better ordering of objects with negative ids. */ inline bool operator<(const Way& lhs, const Way& rhs) { if (lhs.id() == rhs.id()) { return lhs.version() < rhs.version(); } else { return abs(lhs.id()) < abs(rhs.id()); } }
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); } }
void CreateRoundaboutInteraction::mousePressEvent(QMouseEvent * event) { if (event->buttons() & Qt::LeftButton) { if (!HaveCenter) { HaveCenter = true; view()->setInteracting(true); Center = XY_TO_COORD(event->pos()); } else { calculatePoints(); if (Points.size() == 0) return; QPointF Prev = Points[0]; Node* First = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(Prev.toPoint())); Way* R = g_backend.allocWay(theMain->document()->getDirtyOrOriginLayer()); CommandList* L = new CommandList(MainWindow::tr("Create Roundabout %1").arg(R->id().numId), R); L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),R,true)); R->add(First); L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),First,true)); if (M_PREFS->getAutoSourceTag()) { QStringList sl = theMain->document()->getCurrentSourceTags(); if (sl.size()) R->setTag("source", sl.join(";")); } // "oneway" is implied on roundabouts //R->setTag("oneway","yes"); if (DockData.type->currentIndex() == 0) R->setTag("junction","roundabout"); for (int i = 1; i < Points.size(); i++ ) { QPointF Next = Points[i]; Node* New = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(Next.toPoint())); L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),New,true)); R->add(New); } R->add(First); for (FeatureIterator it(document()); !it.isEnd(); ++it) { Way* W1 = CAST_WAY(it.get()); if (W1 && (W1 != R)) Way::createJunction(theMain->document(), L, R, W1, true); } theMain->properties()->setSelection(R); document()->addHistory(L); view()->setInteracting(false); view()->invalidate(true, true, false); theMain->launchInteraction(0); } } else Interaction::mousePressEvent(event); }