本文整理汇总了C++中Station::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Station::setName方法的具体用法?C++ Station::setName怎么用?C++ Station::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Station
的用法示例。
在下文中一共展示了Station::setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例3: s
QList<Station>
LastFmUserSettings::recentStations()
{
MyQSettings s( this );
s.beginGroup( "RecentStations" );
QStringList const keys = s.childKeys();
s.endGroup();
QMap<int, Station> stations;
foreach (QString key, keys) {
Station station;
station.setUrl( s.value( "RecentStations/" + key ).toString() );
station.setName( s.value( "StationNames/" + station.url() ).toString() );
stations[key.toInt()] = station;
}
示例4: readStation
Station* StationsReader::readStation()
{
// Process the attributes
if (! mReader.attributes().hasAttribute("id"))
mReader.raiseError("station without id");
QString tGuid = mReader.attributes().value("id").toString();
Location tLocation;
if (mReader.attributes().hasAttribute("location"))
{
QStringRef tLocationString = mReader.attributes().value("location");
int tSeparator = tLocationString.toString().indexOf(" ");
// TODO: when Qt 4.8 gets released, QStringRef
// will natively implement these
// convenience functionality
// http://qt.gitorious.org/qt/qt/merge_requests/625
qreal tLongitude = tLocationString.toString().midRef(0, tSeparator).toString().toDouble();
qreal tLatitude = tLocationString.toString().midRef(tSeparator+1).toString().toDouble();
tLocation.setLongitude(tLongitude);
tLocation.setLatitude(tLatitude);
}
// Process the contents
QString tName = capitalize(mReader.readElementText());
if (mReader.isEndElement())
mReader.readNext();
// Construct the object
Station::Id tId;
tId.guid = tGuid;
Station* oStation = new Station(tId);
oStation->setName(tName);
oStation->setLocation(tLocation);
return oStation;
}