Commit 6c132ab6 authored by Volker Krause's avatar Volker Krause
Browse files

Remove the Platform::lines public member

parent 6a391dd0
Pipeline #95383 passed with stage
in 17 seconds
......@@ -125,8 +125,8 @@ private Q_SLOTS:
outFile.write("\n");
outFile.write(" level: " + QByteArray::number(platform.level()) + "\n");
outFile.write(QByteArray(" mode: ") + Platform::staticMetaObject.enumerator(0).valueToKey(platform.mode()) + "\n");
if (!platform.lines.empty()) {
outFile.write(" lines: " + platform.lines.join(QLatin1Char('|')).toUtf8() + "\n");
if (!platform.lines().empty()) {
outFile.write(" lines: " + platform.lines().join(QLatin1Char('|')).toUtf8() + "\n");
}
if (!platform.sections().empty()) {
outFile.write(" sections:\n");
......
......@@ -77,6 +77,7 @@ public:
int m_level = std::numeric_limits<int>::min(); // INT_MIN indicates not set, needed for merging
std::vector<PlatformSection> m_sections;
QByteArray m_ifopt;
QStringList m_lines;
static void appendSection(std::vector<PlatformSection> &sections, const Platform &p, PlatformSection &&sec, std::vector<const OSM::Node*> &edgePath, const OSM::DataSet &dataSet);
static double maxSectionDistance(const Platform &p, const std::vector<PlatformSection> &sections, const OSM::DataSet &dataSet);
......@@ -220,6 +221,23 @@ void Platform::setIfopt(const QByteArray &ifopt)
d->m_ifopt = ifopt;
}
QStringList Platform::lines() const
{
return d->m_lines;
}
void Platform::setLines(QStringList &&lines)
{
d.detach();
d->m_lines = std::move(lines);
}
QStringList&& Platform::takeLines()
{
d.detach();
return std::move(d->m_lines);
}
static bool conflictIfPresent(OSM::Element lhs, OSM::Element rhs)
{
return lhs && rhs && lhs != rhs;
......@@ -479,7 +497,7 @@ Platform Platform::merge(const Platform &lhs, const Platform &rhs, const OSM::Da
// TODO
p.d->m_mode = std::max(lhs.d->m_mode, rhs.d->m_mode);
p.lines = lhs.lines.isEmpty() ? std::move(rhs.lines) : std::move(lhs.lines);
p.d->m_lines = lhs.d->m_lines.isEmpty() ? std::move(rhs.d->m_lines) : std::move(lhs.d->m_lines);
std::vector<const OSM::Node*> edgePath;
std::vector<PlatformSection> sections;
......
......@@ -119,8 +119,10 @@ public:
QByteArray ifopt() const;
void setIfopt(const QByteArray &ifopt);
// TODO - clean up once PlatformModel is ported to PlatformFinder
QStringList lines;
/** Names of public transport lines stopping at this platform. */
QStringList lines() const;
void setLines(QStringList &&lines);
QStringList&& takeLines();
/** Checks if two instances refer to the same platform. */
static bool isSame(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet);
......
......@@ -191,10 +191,12 @@ void PlatformFinder::scanRoute(const OSM::Node& node, OSM::Element route)
if (lineName.isEmpty()) {
continue;
}
const auto it = std::lower_bound(p.lines.begin(), p.lines.end(), lineName, m_collator);
if (it == p.lines.end() || (*it) != lineName) {
p.lines.insert(it, lineName);
auto lines = p.takeLines();
const auto it = std::lower_bound(lines.begin(), lines.end(), lineName, m_collator);
if (it == lines.end() || (*it) != lineName) {
lines.insert(it, lineName);
}
p.setLines(std::move(lines));
}
break;
}
......
......@@ -93,7 +93,7 @@ QVariant PlatformModel::data(const QModelIndex &index, int role) const
case TransportModeRole:
return platform.mode();
case LinesRole:
return platform.lines;
return platform.lines();
case ArrivalPlatformRole:
return index.row() == m_arrivalPlatformRow;
case DeparturePlatformRole:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment