15GateModel::GateModel(
QObject *parent)
 
   20GateModel::~GateModel() = 
default;
 
   22MapData GateModel::mapData()
 const 
   27void GateModel::setMapData(
const MapData &data)
 
   36    if (!m_data.isEmpty()) {
 
   37        m_tagKeys.mxArrival = m_data.dataSet().makeTagKey(
"mx:arrival");
 
   38        m_tagKeys.mxDeparture = m_data.dataSet().makeTagKey(
"mx:departure");
 
   46bool GateModel::isEmpty()
 const 
   48    return rowCount() == 0;
 
   51int GateModel::rowCount(
const QModelIndex &parent)
 const 
   57    return m_gates.size();
 
   60QVariant GateModel::data(
const QModelIndex &index, 
int role)
 const 
   62    if (!
index.isValid()) {
 
   66    const auto &gate = m_gates[
index.row()];
 
   71            return QPointF(gate.node.coordinate.lonF(), gate.node.coordinate.latF());
 
   77            return index.row() == m_arrivalGateRow;
 
   78        case DepartureGateRole:
 
   79            return index.row() == m_departureGateRow;
 
   80        case HiddenElementRole:
 
   87QHash<int, QByteArray> GateModel::roleNames()
 const 
   90    n.insert(CoordinateRole, 
"coordinate");
 
   91    n.insert(ElementRole, 
"osmElement");
 
   92    n.insert(LevelRole, 
"level");
 
   93    n.insert(ArrivalGateRole, 
"isArrivalGate");
 
   94    n.insert(DepartureGateRole, 
"isDepartureGate");
 
   95    n.insert(HiddenElementRole, 
"hiddenElement");
 
   99void GateModel::populateModel()
 
  101    const auto aerowayKey = m_data.dataSet().tagKey(
"aeroway");
 
  102    if (aerowayKey.isNull()) { 
 
  106    for (
auto it = m_data.levelMap().begin(); it != m_data.levelMap().end(); ++it) {
 
  107        for (
const auto &e : (*it).second) {
 
  108            if (e.type() != OSM::Type::Node || e.tagValue(aerowayKey) != 
"gate") {
 
  112            const auto l = e.tagValue(
"ref").split(
';');
 
  113            for (
const auto &n : l) {
 
  120                gate.sourceElement = e;
 
  121                gate.node = *e.node();
 
  122                gate.node.id = m_data.dataSet().nextInternalId();
 
  124                gate.level = (*it).first.numericLevel();
 
  125                m_gates.push_back(gate);
 
  130    QCollator c{QLocale()};
 
  131    c.setNumericMode(
true);
 
  132    c.setIgnorePunctuation(
true);
 
  134    std::sort(m_gates.begin(), m_gates.end(), [&c](
const auto &lhs, 
const auto &rhs) {
 
  135        return c.compare(lhs.name, rhs.name) < 0;
 
  138    qDebug() << m_gates.size() << 
"gates found";
 
  143    m_arrivalGate = name;
 
 
  147void GateModel::setDepartureGate(
const QString &name)
 
  149    m_departureGate = name;
 
  155    return m_arrivalGateRow;
 
  158int GateModel::departureGateRow()
 const 
  160    return m_departureGateRow;
 
  163void GateModel::matchGates()
 
  165    setGateTag(m_arrivalGateRow, m_tagKeys.mxArrival, 
false);
 
  166    m_arrivalGateRow = matchGate(m_arrivalGate);
 
  167    setGateTag(m_arrivalGateRow, m_tagKeys.mxArrival, 
true);
 
  169    setGateTag(m_departureGateRow, m_tagKeys.mxDeparture, 
false);
 
  170    m_departureGateRow = matchGate(m_departureGate);
 
  171    setGateTag(m_departureGateRow, m_tagKeys.mxDeparture, 
true);
 
  173    Q_EMIT gateIndexChanged();
 
  174    if (m_arrivalGateRow >= 0) {
 
  177    if (m_departureGateRow >= 0) {
 
  182int GateModel::matchGate(
const QString &name)
 const 
  184    if (name.isEmpty()) {
 
  189    for (
const auto &g : m_gates) {
 
  190        if (g.name == name) {
 
  199void GateModel::setGateTag(
int idx, OSM::TagKey key, 
bool enabled)
 
  208#include "moc_gatemodel.cpp" 
Q_INVOKABLE void setArrivalGate(const QString &name)
Match arrival/departure gates against what we found in the map data.
 
int arrivalGateRow
Row indexes of the matched arrival/departure gates, if found and/or set, otherwise -1.
 
Raw OSM map data, separated by levels.
 
OSM-based multi-floor indoor maps for buildings.
 
void setTagValue(Elem &elem, TagKey key, QByteArray &&value)
Inserts a new tag, or updates an existing one.
 
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
 
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
 
virtual QModelIndex parent(const QModelIndex &index) const const=0
 
virtual QHash< int, QByteArray > roleNames() const const
 
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
 
QString fromUtf8(QByteArrayView str)
 
QByteArray toUtf8() const const
 
QVariant fromValue(T &&value)