Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -53,48 +53,38 @@ public:
: m_framework(framework)
, m_drapeApi(m_framework.GetDrapeApi())
, m_bm(framework.GetBookmarkManager())
{
}
{}
void SetViewportCenter(m2::PointD const & center) override
{
m_framework.SetViewportCenter(center);
}
void SetViewportCenter(m2::PointD const & center) override { m_framework.SetViewportCenter(center); }
void DrawDecodedSegments(std::vector<m2::PointD> const & points) override
{
CHECK(!points.empty(), ("Points must not be empty."));
LOG(LINFO, ("Decoded segment", points));
m_drapeApi.AddLine(kDecodedLineId,
df::DrapeApiLineData(points, dp::Color(0, 0, 255, 255))
.Width(3.0f).ShowPoints(true /* markPoints */));
m_drapeApi.AddLine(
kDecodedLineId,
df::DrapeApiLineData(points, dp::Color(0, 0, 255, 255)).Width(3.0f).ShowPoints(true /* markPoints */));
}
void DrawEncodedSegment(std::vector<m2::PointD> const & points) override
{
LOG(LINFO, ("Encoded segment", points));
m_drapeApi.AddLine(kEncodedLineId,
df::DrapeApiLineData(points, dp::Color(255, 0, 0, 255))
.Width(3.0f).ShowPoints(true /* markPoints */));
m_drapeApi.AddLine(
kEncodedLineId,
df::DrapeApiLineData(points, dp::Color(255, 0, 0, 255)).Width(3.0f).ShowPoints(true /* markPoints */));
}
void DrawGoldenPath(std::vector<m2::PointD> const & points) override
{
m_drapeApi.AddLine(kGoldenLineId,
df::DrapeApiLineData(points, dp::Color(255, 127, 36, 255))
.Width(4.0f).ShowPoints(true /* markPoints */));
m_drapeApi.AddLine(
kGoldenLineId,
df::DrapeApiLineData(points, dp::Color(255, 127, 36, 255)).Width(4.0f).ShowPoints(true /* markPoints */));
}
void ClearGoldenPath() override
{
m_drapeApi.RemoveLine(kGoldenLineId);
}
void ClearGoldenPath() override { m_drapeApi.RemoveLine(kGoldenLineId); }
void ClearAllPaths() override
{
m_drapeApi.Clear();
}
void ClearAllPaths() override { m_drapeApi.Clear(); }
void VisualizePoints(std::vector<m2::PointD> const & points) override
{
@@ -104,10 +94,7 @@ public:
editSession.CreateUserMark<DebugMarkPoint>(p);
}
void ClearAllVisualizedPoints() override
{
m_bm.GetEditSession().ClearGroup(UserMark::Type::DEBUG_MARK);
}
void ClearAllVisualizedPoints() override { m_bm.GetEditSession().ClearGroup(UserMark::Type::DEBUG_MARK); }
private:
Framework & m_framework;
@@ -129,8 +116,7 @@ public:
, m_dataSource(const_cast<DataSource &>(GetDataSource()), nullptr /* numMwmIDs */)
, m_roadGraph(m_dataSource, routing::IRoadGraph::Mode::ObeyOnewayTag,
std::make_unique<routing::CarModelFactory>(storage::CountryParentGetter{}))
{
}
{}
std::vector<m2::PointD> GetAllJunctionPointsInViewport() const override
{
@@ -141,10 +127,8 @@ public:
if (!rect.IsPointInside(point))
return;
for (auto const & p : points)
{
if (PointsMatch(point, p))
return;
}
points.push_back(point);
};
@@ -155,11 +139,8 @@ public:
/// @todo Transported (railway=rail) are also present here :)
auto const roadClass = ftypes::GetHighwayClass(feature::TypesHolder(ft));
if (roadClass == ftypes::HighwayClass::Undefined ||
roadClass == ftypes::HighwayClass::Pedestrian)
{
if (roadClass == ftypes::HighwayClass::Undefined || roadClass == ftypes::HighwayClass::Pedestrian)
return;
}
ft.ForEachPoint(pushPoint, scales::GetUpperScale());
};
@@ -167,8 +148,7 @@ public:
return points;
}
std::pair<std::vector<FeaturePoint>, m2::PointD> GetCandidatePoints(
m2::PointD const & p) const override
std::pair<std::vector<FeaturePoint>, m2::PointD> GetCandidatePoints(m2::PointD const & p) const override
{
auto constexpr kInvalidIndex = std::numeric_limits<size_t>::max();
@@ -207,8 +187,7 @@ public:
std::vector<m2::PointD> GetReachablePoints(m2::PointD const & p) const override
{
routing::FeaturesRoadGraph::EdgeListT edges;
m_roadGraph.GetOutgoingEdges(geometry::PointWithAltitude(p, geometry::kDefaultAltitudeMeters),
edges);
m_roadGraph.GetOutgoingEdges(geometry::PointWithAltitude(p, geometry::kDefaultAltitudeMeters), edges);
std::vector<m2::PointD> points;
for (auto const & e : edges)
@@ -216,8 +195,7 @@ public:
return points;
}
ClickType CheckClick(m2::PointD const & clickPoint,
m2::PointD const & lastClickedPoint,
ClickType CheckClick(m2::PointD const & clickPoint, m2::PointD const & lastClickedPoint,
std::vector<m2::PointD> const & reachablePoints) const override
{
// == Comparison is safe here since |clickPoint| is adjusted by GetFeaturesPointsByPoint
@@ -225,10 +203,8 @@ public:
if (clickPoint == lastClickedPoint)
return ClickType::Remove;
for (auto const & p : reachablePoints)
{
if (PointsMatch(clickPoint, p))
return ClickType::Add;
}
return ClickType::Miss;
}
@@ -241,9 +217,7 @@ private:
};
} // namespace
MainWindow::MainWindow(Framework & framework)
: m_framework(framework)
MainWindow::MainWindow(Framework & framework) : m_framework(framework)
{
m_mapWidget = new MapWidget(m_framework, this /* parent */);
@@ -264,37 +238,37 @@ MainWindow::MainWindow(Framework & framework)
fileMenu->addAction("Open sample", QKeySequence("Ctrl+O"), this, &MainWindow::OnOpenTrafficSample);
m_closeTrafficSampleAction = fileMenu->addAction("Close sample", QKeySequence("Ctrl+W"), this, &MainWindow::OnCloseTrafficSample);
m_saveTrafficSampleAction = fileMenu->addAction("Save sample", QKeySequence("Ctrl+S"), this, &MainWindow::OnSaveTrafficSample);
m_closeTrafficSampleAction =
fileMenu->addAction("Close sample", QKeySequence("Ctrl+W"), this, &MainWindow::OnCloseTrafficSample);
m_saveTrafficSampleAction =
fileMenu->addAction("Save sample", QKeySequence("Ctrl+S"), this, &MainWindow::OnSaveTrafficSample);
fileMenu->addSeparator();
m_goldifyMatchedPathAction = fileMenu->addAction("Goldify", QKeySequence("Ctrl+G"), [this] { m_trafficMode->GoldifyMatchedPath(); });
m_startEditingAction = fileMenu->addAction("Edit", QKeySequence("Ctrl+E"),
[this] {
m_trafficMode->StartBuildingPath();
m_mapWidget->SetMode(MapWidget::Mode::TrafficMarkup);
m_commitPathAction->setEnabled(true /* enabled */);
m_cancelPathAction->setEnabled(true /* enabled */);
});
m_commitPathAction = fileMenu->addAction("Accept path",
QKeySequence("Ctrl+A"),
[this] {
m_trafficMode->CommitPath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_cancelPathAction = fileMenu->addAction("Revert path",
QKeySequence("Ctrl+R"),
[this] {
m_trafficMode->RollBackPath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_ignorePathAction = fileMenu->addAction("Ignore path",
QKeySequence("Ctrl+I"),
[this] {
m_trafficMode->IgnorePath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_goldifyMatchedPathAction =
fileMenu->addAction("Goldify", QKeySequence("Ctrl+G"), [this] { m_trafficMode->GoldifyMatchedPath(); });
m_startEditingAction = fileMenu->addAction("Edit", QKeySequence("Ctrl+E"), [this]
{
m_trafficMode->StartBuildingPath();
m_mapWidget->SetMode(MapWidget::Mode::TrafficMarkup);
m_commitPathAction->setEnabled(true /* enabled */);
m_cancelPathAction->setEnabled(true /* enabled */);
});
m_commitPathAction = fileMenu->addAction("Accept path", QKeySequence("Ctrl+A"), [this]
{
m_trafficMode->CommitPath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_cancelPathAction = fileMenu->addAction("Revert path", QKeySequence("Ctrl+R"), [this]
{
m_trafficMode->RollBackPath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_ignorePathAction = fileMenu->addAction("Ignore path", QKeySequence("Ctrl+I"), [this]
{
m_trafficMode->IgnorePath();
m_mapWidget->SetMode(MapWidget::Mode::Normal);
});
m_goldifyMatchedPathAction->setEnabled(false /* enabled */);
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
@@ -307,15 +281,12 @@ MainWindow::MainWindow(Framework & framework)
void MainWindow::CreateTrafficPanel(std::string const & dataFilePath)
{
m_trafficMode = new TrafficMode(dataFilePath,
m_framework.GetDataSource(),
std::make_unique<TrafficDrawerDelegate>(m_framework),
std::make_unique<PointsControllerDelegate>(m_framework));
m_trafficMode =
new TrafficMode(dataFilePath, m_framework.GetDataSource(), std::make_unique<TrafficDrawerDelegate>(m_framework),
std::make_unique<PointsControllerDelegate>(m_framework));
connect(m_mapWidget, &MapWidget::TrafficMarkupClick,
m_trafficMode, &TrafficMode::OnClick);
connect(m_trafficMode, &TrafficMode::EditingStopped,
this, &MainWindow::OnPathEditingStop);
connect(m_mapWidget, &MapWidget::TrafficMarkupClick, m_trafficMode, &TrafficMode::OnClick);
connect(m_trafficMode, &TrafficMode::EditingStopped, this, &MainWindow::OnPathEditingStop);
connect(m_trafficMode, &TrafficMode::SegmentSelected,
[](int segmentId) { QApplication::clipboard()->setText(QString::number(segmentId)); });
@@ -391,11 +362,7 @@ void MainWindow::OnSaveTrafficSample()
return;
if (!m_trafficMode->SaveSampleAs(fileName.toStdString()))
{
QMessageBox::critical(
this, "Saving error",
QString("Can't save file: ") + strerror(errno));
}
QMessageBox::critical(this, "Saving error", QString("Can't save file: ") + strerror(errno));
}
void MainWindow::OnPathEditingStop()

View File

@@ -16,7 +16,7 @@ namespace openlr
class MapWidget;
class TrafficMode;
class WebView;
}
} // namespace openlr
namespace df
{
@@ -52,7 +52,7 @@ private:
QAction * m_saveTrafficSampleAction = nullptr;
QAction * m_closeTrafficSampleAction = nullptr;
QAction * m_startEditingAction = nullptr;
QAction * m_commitPathAction = nullptr;
QAction * m_commitPathAction = nullptr;
QAction * m_cancelPathAction = nullptr;
QAction * m_ignorePathAction = nullptr;

View File

@@ -8,10 +8,7 @@
namespace openlr
{
MapWidget::MapWidget(Framework & framework, QWidget * parent)
: Base(framework, false /* screenshotMode */, parent)
{
}
MapWidget::MapWidget(Framework & framework, QWidget * parent) : Base(framework, false /* screenshotMode */, parent) {}
void MapWidget::mousePressEvent(QMouseEvent * e)
{

View File

@@ -29,10 +29,7 @@ public:
void SetMode(Mode const mode) { m_mode = mode; }
QSize sizeHint() const override
{
return QSize(800, 600);
}
QSize sizeHint() const override { return QSize(800, 600); }
signals:
void TrafficMarkupClick(m2::PointD const & p, Qt::MouseButton const b);

View File

@@ -28,13 +28,11 @@ public:
virtual std::vector<m2::PointD> GetAllJunctionPointsInViewport() const = 0;
/// Returns all junction points at a given location in the form of feature id and
/// point index in the feature.
virtual std::pair<std::vector<FeaturePoint>, m2::PointD> GetCandidatePoints(
m2::PointD const & p) const = 0;
virtual std::pair<std::vector<FeaturePoint>, m2::PointD> GetCandidatePoints(m2::PointD const & p) const = 0;
// Returns all points that are one step reachable from |p|.
virtual std::vector<m2::PointD> GetReachablePoints(m2::PointD const & p) const = 0;
virtual ClickType CheckClick(m2::PointD const & clickPoint,
m2::PointD const & lastClickedPoint,
virtual ClickType CheckClick(m2::PointD const & clickPoint, m2::PointD const & lastClickedPoint,
std::vector<m2::PointD> const & reachablePoints) const = 0;
};
} // namespace openlr

View File

@@ -19,11 +19,9 @@ SegmentCorrespondence::SegmentCorrespondence(SegmentCorrespondence const & sc)
m_status = sc.m_status;
}
SegmentCorrespondence::SegmentCorrespondence(openlr::LinearSegment const & segment,
uint32_t positiveOffset, uint32_t negativeOffset,
openlr::Path const & matchedPath,
openlr::Path const & fakePath,
openlr::Path const & goldenPath,
SegmentCorrespondence::SegmentCorrespondence(openlr::LinearSegment const & segment, uint32_t positiveOffset,
uint32_t negativeOffset, openlr::Path const & matchedPath,
openlr::Path const & fakePath, openlr::Path const & goldenPath,
pugi::xml_node const & partnerSegmentXML)
: m_partnerSegment(segment)
, m_positiveOffset(positiveOffset)

View File

@@ -18,12 +18,9 @@ public:
};
SegmentCorrespondence(SegmentCorrespondence const & sc);
SegmentCorrespondence(openlr::LinearSegment const & segment,
uint32_t positiveOffset, uint32_t negativeOffset,
openlr::Path const & matchedPath,
openlr::Path const & fakePath,
openlr::Path const & goldenPath,
pugi::xml_node const & partnerSegmentXML);
SegmentCorrespondence(openlr::LinearSegment const & segment, uint32_t positiveOffset, uint32_t negativeOffset,
openlr::Path const & matchedPath, openlr::Path const & fakePath,
openlr::Path const & goldenPath, pugi::xml_node const & partnerSegmentXML);
openlr::Path const & GetMatchedPath() const { return m_matchedPath; }
bool HasMatchedPath() const { return !m_matchedPath.empty(); }

View File

@@ -16,14 +16,12 @@ namespace
{
void RemovePointFromPull(m2::PointD const & toBeRemoved, std::vector<m2::PointD> & pool)
{
pool.erase(
remove_if(begin(pool), end(pool),
[&toBeRemoved](m2::PointD const & p) { return p.EqualDxDy(toBeRemoved, 1e-6); }),
end(pool));
pool.erase(remove_if(begin(pool), end(pool),
[&toBeRemoved](m2::PointD const & p) { return p.EqualDxDy(toBeRemoved, 1e-6); }),
end(pool));
}
std::vector<m2::PointD> GetReachablePoints(m2::PointD const & srcPoint,
std::vector<m2::PointD> const path,
std::vector<m2::PointD> GetReachablePoints(m2::PointD const & srcPoint, std::vector<m2::PointD> const path,
PointsControllerDelegateBase const & pointsDelegate,
size_t const lookbackIndex)
{
@@ -46,8 +44,7 @@ size_t const RoadPointCandidate::kInvalidId = std::numeric_limits<size_t>::max()
/// I.e. it is a set of all pairs <FeatureID, point index>
/// located at a specified coordinate.
/// Only one point at a time is considered active.
RoadPointCandidate::RoadPointCandidate(std::vector<FeaturePoint> const & points,
m2::PointD const & coord)
RoadPointCandidate::RoadPointCandidate(std::vector<FeaturePoint> const & points, m2::PointD const & coord)
: m_coord(coord)
, m_points(points)
{
@@ -98,8 +95,7 @@ void RoadPointCandidate::SetActivePoint(FeatureID const & fid)
// TrafficMode -------------------------------------------------------------------------------------
TrafficMode::TrafficMode(std::string const & dataFileName, DataSource const & dataSource,
std::unique_ptr<TrafficDrawerDelegateBase> drawerDelegate,
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate,
QObject * parent)
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate, QObject * parent)
: QAbstractTableModel(parent)
, m_dataSource(dataSource)
, m_drawerDelegate(std::move(drawerDelegate))
@@ -153,8 +149,7 @@ TrafficMode::TrafficMode(std::string const & dataFileName, DataSource const & da
{
if (auto const locationReference = method.child("olr:locationReference"))
{
if (auto const optionLinearLocationReference = locationReference
.child("olr:optionLinearLocationReference"))
if (auto const optionLinearLocationReference = locationReference.child("olr:optionLinearLocationReference"))
{
if (auto const positiveOffset = optionLinearLocationReference.child("olr:positiveOffset"))
positiveOffsetM = UintValueFromXML(positiveOffset);
@@ -166,8 +161,8 @@ TrafficMode::TrafficMode(std::string const & dataFileName, DataSource const & da
}
}
m_segments.emplace_back(segment, positiveOffsetM, negativeOffsetM, matchedPath, fakePath,
goldenPath, partnerSegmentXML);
m_segments.emplace_back(segment, positiveOffsetM, negativeOffsetM, matchedPath, fakePath, goldenPath,
partnerSegmentXML);
if (auto const status = xmlSegment.child("Ignored"))
{
if (status.text().as_bool())
@@ -198,9 +193,7 @@ bool TrafficMode::SaveSampleAs(std::string const & fileName) const
segment.append_copy(sc.GetPartnerXMLSegment());
if (sc.GetStatus() == SegmentCorrespondence::Status::Ignored)
{
segment.append_child("Ignored").text() = true;
}
if (sc.HasMatchedPath())
{
auto node = segment.append_child("Route");
@@ -222,14 +215,17 @@ bool TrafficMode::SaveSampleAs(std::string const & fileName) const
return true;
}
int TrafficMode::rowCount(const QModelIndex & parent) const
int TrafficMode::rowCount(QModelIndex const & parent) const
{
return static_cast<int>(m_segments.size());
}
int TrafficMode::columnCount(const QModelIndex & parent) const { return 4; }
int TrafficMode::columnCount(QModelIndex const & parent) const
{
return 4;
}
QVariant TrafficMode::data(const QModelIndex & index, int role) const
QVariant TrafficMode::data(QModelIndex const & index, int role) const
{
if (!index.isValid())
return QVariant();
@@ -255,8 +251,7 @@ QVariant TrafficMode::data(const QModelIndex & index, int role) const
return QVariant();
}
QVariant TrafficMode::headerData(int section, Qt::Orientation orientation,
int role /* = Qt::DisplayRole */) const
QVariant TrafficMode::headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const
{
if (orientation != Qt::Horizontal && role != Qt::DisplayRole)
return QVariant();
@@ -309,8 +304,7 @@ void TrafficMode::GoldifyMatchedPath()
{
if (!m_currentSegment->HasMatchedPath())
{
QMessageBox::information(nullptr /* parent */, "Error",
"The selected segment does not have a matched path");
QMessageBox::information(nullptr /* parent */, "Error", "The selected segment does not have a matched path");
return;
}
@@ -384,10 +378,10 @@ void TrafficMode::CommitPath()
auto const & prevFt = prevPoint.GetPoint();
auto const & ft = point.GetPoint();
path.push_back(Edge::MakeReal(
ft.first, prevFt.second < ft.second /* forward */, base::checked_cast<uint32_t>(prevFt.second),
geometry::PointWithAltitude(prevPoint.GetCoordinate(), 0 /* altitude */),
geometry::PointWithAltitude(point.GetCoordinate(), 0 /* altitude */)));
path.push_back(Edge::MakeReal(ft.first, prevFt.second < ft.second /* forward */,
base::checked_cast<uint32_t>(prevFt.second),
geometry::PointWithAltitude(prevPoint.GetCoordinate(), 0 /* altitude */),
geometry::PointWithAltitude(point.GetCoordinate(), 0 /* altitude */)));
}
m_currentSegment->SetGoldenPath(path);
@@ -417,9 +411,8 @@ void TrafficMode::IgnorePath()
if (m_currentSegment->HasGoldenPath())
{
auto const btn =
QMessageBox::question(nullptr /* parent */, "Override warning",
"The selected segment has a golden path. Do you want to discard it?");
auto const btn = QMessageBox::question(nullptr /* parent */, "Override warning",
"The selected segment has a golden path. Do you want to discard it?");
if (btn == QMessageBox::No)
return;
}
@@ -466,9 +459,7 @@ void TrafficMode::HandlePoint(m2::PointD clickPoint, Qt::MouseButton const butto
return;
auto const currentPathLength = GetPointsCount();
auto const lastClickedPoint = currentPathLength != 0
? GetLastPoint()
: m2::PointD::Zero();
auto const lastClickedPoint = currentPathLength != 0 ? GetLastPoint() : m2::PointD::Zero();
auto const & p = m_pointsDelegate->GetCandidatePoints(clickPoint);
auto const & candidatePoints = p.first;
@@ -476,14 +467,14 @@ void TrafficMode::HandlePoint(m2::PointD clickPoint, Qt::MouseButton const butto
if (candidatePoints.empty())
return;
auto reachablePoints = GetReachablePoints(clickPoint, GetGoldenPathPoints(), *m_pointsDelegate,
0 /* lookBackIndex */);
auto const & clickablePoints = currentPathLength != 0
? GetReachablePoints(lastClickedPoint, GetGoldenPathPoints(), *m_pointsDelegate,
1 /* lookbackIndex */)
// TODO(mgsergio): This is not quite correct since view port can change
// since first call to visualize points. But it's ok in general.
: m_pointsDelegate->GetAllJunctionPointsInViewport();
auto reachablePoints =
GetReachablePoints(clickPoint, GetGoldenPathPoints(), *m_pointsDelegate, 0 /* lookBackIndex */);
auto const & clickablePoints =
currentPathLength != 0
? GetReachablePoints(lastClickedPoint, GetGoldenPathPoints(), *m_pointsDelegate, 1 /* lookbackIndex */)
// TODO(mgsergio): This is not quite correct since view port can change
// since first call to visualize points. But it's ok in general.
: m_pointsDelegate->GetAllJunctionPointsInViewport();
using ClickType = PointsControllerDelegateBase::ClickType;
switch (m_pointsDelegate->CheckClick(clickPoint, lastClickedPoint, clickablePoints))
@@ -518,8 +509,8 @@ void TrafficMode::HandlePoint(m2::PointD clickPoint, Qt::MouseButton const butto
}
else
{
m_drawerDelegate->VisualizePoints(GetReachablePoints(
GetLastPoint(), GetGoldenPathPoints(), *m_pointsDelegate, 1 /* lookBackIndex */));
m_drawerDelegate->VisualizePoints(
GetReachablePoints(GetLastPoint(), GetGoldenPathPoints(), *m_pointsDelegate, 1 /* lookBackIndex */));
}
if (GetPointsCount() > 1)
@@ -546,9 +537,8 @@ bool TrafficMode::StartBuildingPathChecks() const
if (m_currentSegment->HasGoldenPath())
{
auto const btn = QMessageBox::question(
nullptr /* parent */, "Override warning",
"The selected segment already has a golden path. Do you want to override?");
auto const btn = QMessageBox::question(nullptr /* parent */, "Override warning",
"The selected segment already has a golden path. Do you want to override?");
if (btn == QMessageBox::No)
return false;
}

View File

@@ -18,7 +18,6 @@
#include <QAbstractTableModel>
class QItemSelection;
class Selection;
@@ -35,8 +34,7 @@ namespace impl
class RoadPointCandidate
{
public:
RoadPointCandidate(std::vector<openlr::FeaturePoint> const & points,
m2::PointD const & coord);
RoadPointCandidate(std::vector<openlr::FeaturePoint> const & points, m2::PointD const & coord);
void ActivateCommonPoint(RoadPointCandidate const & rpc);
openlr::FeaturePoint const & GetPoint() const;
@@ -64,25 +62,22 @@ public:
// TODO(mgsergio): Check we are on the right mwm. I.e. right mwm version and everything.
TrafficMode(std::string const & dataFileName, DataSource const & dataSource,
std::unique_ptr<TrafficDrawerDelegateBase> drawerDelegate,
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate,
QObject * parent = Q_NULLPTR);
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate, QObject * parent = Q_NULLPTR);
bool SaveSampleAs(std::string const & fileName) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
int rowCount(QModelIndex const & parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(QModelIndex const & parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex & index, int role) const Q_DECL_OVERRIDE;
QVariant data(QModelIndex const & index, int role) const Q_DECL_OVERRIDE;
Qt::ItemFlags flags(QModelIndex const & index) const Q_DECL_OVERRIDE;
bool IsBuildingPath() const { return m_buildingPath; }
void GoldifyMatchedPath();
void StartBuildingPath();
void PushPoint(m2::PointD const & coord,
std::vector<FeaturePoint> const & points);
void PushPoint(m2::PointD const & coord, std::vector<FeaturePoint> const & points);
void PopPoint();
void CommitPath();
void RollBackPath();
@@ -95,10 +90,7 @@ public:
public slots:
void OnItemSelected(QItemSelection const & selected, QItemSelection const &);
void OnClick(m2::PointD const & clickPoint, Qt::MouseButton const button)
{
HandlePoint(clickPoint, button);
}
void OnClick(m2::PointD const & clickPoint, Qt::MouseButton const button) { HandlePoint(clickPoint, button); }
signals:
void EditingStopped();

View File

@@ -11,10 +11,7 @@
namespace openlr
{
// ComboBoxDelegate --------------------------------------------------------------------------------
ComboBoxDelegate::ComboBoxDelegate(QObject * parent)
: QStyledItemDelegate(parent)
{
}
ComboBoxDelegate::ComboBoxDelegate(QObject * parent) : QStyledItemDelegate(parent) {}
QWidget * ComboBoxDelegate::createEditor(QWidget * parent, QStyleOptionViewItem const & option,
QModelIndex const & index) const
@@ -30,13 +27,12 @@ QWidget * ComboBoxDelegate::createEditor(QWidget * parent, QStyleOptionViewItem
void ComboBoxDelegate::setEditorData(QWidget * editor, QModelIndex const & index) const
{
auto const value = index.model()->data(index, Qt::EditRole).toString();
static_cast<QComboBox*>(editor)->setCurrentText(value);
static_cast<QComboBox *>(editor)->setCurrentText(value);
}
void ComboBoxDelegate::setModelData(QWidget * editor, QAbstractItemModel * model,
QModelIndex const & index) const
void ComboBoxDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, QModelIndex const & index) const
{
model->setData(index, static_cast<QComboBox*>(editor)->currentText(), Qt::EditRole);
model->setData(index, static_cast<QComboBox *>(editor)->currentText(), Qt::EditRole);
}
void ComboBoxDelegate::updateEditorGeometry(QWidget * editor, QStyleOptionViewItem const & option,
@@ -46,8 +42,7 @@ void ComboBoxDelegate::updateEditorGeometry(QWidget * editor, QStyleOptionViewIt
}
// TrafficPanel ------------------------------------------------------------------------------------
TrafficPanel::TrafficPanel(QAbstractItemModel * trafficModel, QWidget * parent)
: QWidget(parent)
TrafficPanel::TrafficPanel(QAbstractItemModel * trafficModel, QWidget * parent) : QWidget(parent)
{
CreateTable(trafficModel);
@@ -75,8 +70,7 @@ void TrafficPanel::CreateTable(QAbstractItemModel * trafficModel)
m_table->setModel(trafficModel);
m_table->setItemDelegate(new ComboBoxDelegate());
connect(m_table->selectionModel(),
SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)),
connect(m_table->selectionModel(), SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)),
trafficModel, SLOT(OnItemSelected(QItemSelection const &, QItemSelection const &)));
}
} // namespace openlr

View File

@@ -21,8 +21,7 @@ public:
void setEditorData(QWidget * editor, QModelIndex const & index) const Q_DECL_OVERRIDE;
void setModelData(QWidget * editor, QAbstractItemModel * model,
QModelIndex const & index) const Q_DECL_OVERRIDE;
void setModelData(QWidget * editor, QAbstractItemModel * model, QModelIndex const & index) const Q_DECL_OVERRIDE;
void updateEditorGeometry(QWidget * editor, QStyleOptionViewItem const & option,
QModelIndex const & index) const Q_DECL_OVERRIDE;

View File

@@ -14,9 +14,7 @@ std::string const kDataFilePath = "LastOpenlrAssessmentDataFilePath";
namespace openlr
{
TrafficModeInitDlg::TrafficModeInitDlg(QWidget * parent) :
QDialog(parent),
m_ui(new Ui::TrafficModeInitDlg)
TrafficModeInitDlg::TrafficModeInitDlg(QWidget * parent) : QDialog(parent), m_ui(new Ui::TrafficModeInitDlg)
{
m_ui->setupUi(this);
@@ -24,9 +22,8 @@ TrafficModeInitDlg::TrafficModeInitDlg(QWidget * parent) :
if (settings::Get(kDataFilePath, lastDataFilePath))
m_ui->dataFileName->setText(QString::fromStdString(lastDataFilePath));
connect(m_ui->chooseDataFileButton, &QPushButton::clicked, [this](bool) {
SetFilePathViaDialog(*m_ui->dataFileName, tr("Choose data file"), "*.xml");
});
connect(m_ui->chooseDataFileButton, &QPushButton::clicked,
[this](bool) { SetFilePathViaDialog(*m_ui->dataFileName, tr("Choose data file"), "*.xml"); });
}
TrafficModeInitDlg::~TrafficModeInitDlg()
@@ -41,8 +38,7 @@ void TrafficModeInitDlg::accept()
QDialog::accept();
}
void TrafficModeInitDlg::SetFilePathViaDialog(QLineEdit & dest, QString const & title,
QString const & filter)
void TrafficModeInitDlg::SetFilePathViaDialog(QLineEdit & dest, QString const & title, QString const & filter)
{
QFileDialog openFileDlg(nullptr, title, {} /* directory */, filter);
openFileDlg.exec();