本文整理汇总了C++中Station::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ Station::pos方法的具体用法?C++ Station::pos怎么用?C++ Station::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Station
的用法示例。
在下文中一共展示了Station::pos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: re_stations
void
StationsPluginLondon::handleInfos(const QByteArray & data)
{
QRegExp re_stations("station\\=\\{(.*)\\}\\;");
QRegExp re_items("\\s*(\\w+)\\s*:(.*),");
int ofs = 0;
re_stations.setMinimal(true);
re_items.setMinimal(true);
while ((ofs = re_stations.indexIn(data, ofs)) >= 0) {
bool ok;
int id;
QPointF pos;
Station *station;
QMap<QString, QString> values;
ofs += re_stations.matchedLength();
int station_ofs = 0;
QString station_data = re_stations.capturedTexts().at(1);
while ((station_ofs = re_items.indexIn(station_data, station_ofs)) >= 0) {
QStringList capt = re_items.capturedTexts();
if (capt.size() < 3)
continue ;
station_ofs += re_items.matchedLength();
values[capt.at(1)] = capt.at(2);
values[capt.at(1)].replace("\"", "");
}
id = values["id"].toInt(&ok);
pos = QPointF(values["lat"].toDouble(),
values["long"].toDouble());
if (!ok)
continue ;
station = getOrCreateStation(id);
if (station->name().isEmpty())
station->setName(values["name"]);
if (station->pos().isNull())
station->setPos(pos);
station->setBikes(values["nbBikes"].toInt());
station->setFreeSlots(values["nbEmptyDocks"].toInt());
station->setTotalSlots(station->bikes() + station->freeSlots());
storeOrDropStation(station);
}
emit stationsCreated(stations.values());
emit stationsUpdated(stations.values());
}
示例2: stationsCreated
void
StationsPluginWien::handleInfos(const QByteArray & data)
{
QDomDocument doc;
QDomNode node;
doc.setContent(data);
node = doc.firstChildElement("stations").firstChildElement("station");
while (!node.isNull()) {
Station *station;
QDomNamedNodeMap attrs = node.attributes();
int id;
bool ok;
qreal lat, lng;
id = node.firstChildElement("id").text().toInt(&ok);
if (!ok)
continue ;
station = getOrCreateStation(id);
station->setData(node.firstChildElement("internal_id").text().toInt());
if (station->name().isEmpty())
station->setName(node.firstChildElement("name").text());
if (station->description().isEmpty())
station->setDescription(node.firstChildElement("description").text());
lng = node.firstChildElement("longitude").text().toDouble();
lat = node.firstChildElement("latitude").text().toDouble();
if (station->pos().isNull())
station->setPos(QPointF(lat, lng));
station->setBikes(node.firstChildElement("free_bikes").text().toInt());
station->setFreeSlots(node.firstChildElement("free_boxes").text().toInt());
station->setTotalSlots(node.firstChildElement("boxes").text().toInt());
storeOrDropStation(station);
node = node.nextSiblingElement("station");
}
emit stationsCreated(stations.values());
emit stationsUpdated(stations.values());
}