bool QLandmarkFileHandlerLmx::writeAddressInfo(const QLandmark &landmark) { QGeoAddress address = landmark.address(); if (address.street().isEmpty() && address.city().isEmpty() && address.state().isEmpty() && address.country().isEmpty() && address.postcode().isEmpty() && landmark.phoneNumber().isEmpty()) return true; m_writer->writeStartElement(m_ns, "addressInfo"); if (!address.country().isEmpty()) m_writer->writeTextElement(m_ns, "country", address.country()); if (!address.state().isEmpty()) m_writer->writeTextElement(m_ns, "state", address.state()); if (!address.county().isEmpty()) m_writer->writeTextElement(m_ns, "county", address.county()); if (!address.city().isEmpty()) m_writer->writeTextElement(m_ns, "city", address.city()); if (!address.district().isEmpty()) m_writer->writeTextElement(m_ns, "district", address.district()); if (!address.postcode().isEmpty()) m_writer->writeTextElement(m_ns, "postalCode", address.postcode()); QString street; if (!address.street().isEmpty()) street.append(address.street()); if (!street.isEmpty()) m_writer->writeTextElement(m_ns, "street", street); if (!landmark.phoneNumber().isEmpty()) m_writer->writeTextElement(m_ns, "phoneNumber", landmark.phoneNumber()); m_writer->writeEndElement(); return true; }
// Initializes this landmark from the given landmark void QDeclarativeLandmark::setLandmark(const QLandmark& landmark) { // Elaborate but makes sure appropriate signals are sent // (this function is called when landmark updates). setPlace(landmark); // viewport, address, coordinate etc. setName(landmark.name()); setPhoneNumber(landmark.phoneNumber()); setDescription(landmark.description()); setRadius(landmark.radius()); setIconSource(landmark.iconUrl()); setUrl(landmark.url()); m_landmark = landmark; }
LandmarkAddDialog::LandmarkAddDialog(QWidget *parent, Qt::WindowFlags flags, const QLandmark &landmark) : QDialog(parent, flags) { setupUi(this); if (landmark != QLandmark()) { setWindowTitle("Edit Landmark"); lm = landmark; nameLineEdit->setText(landmark.name()); latitudeLineEdit->setText(QString::number(landmark.coordinate().latitude())); longitudeLineEdit->setText(QString::number(landmark.coordinate().longitude())); streetLineEdit->setText(landmark.address().street()); districtLineEdit->setText(landmark.address().district()); cityLineEdit->setText(landmark.address().city()); countyLineEdit->setText(landmark.address().county()); stateLineEdit->setText(landmark.address().state()); countryLineEdit->setText(landmark.address().country()); descriptionLineEdit->setText(landmark.description()); iconUrlLineEdit->setText(landmark.iconUrl().toString()); urlLineEdit->setText(landmark.url().toString()); phoneLineEdit->setText(landmark.phoneNumber()); radiusLineEdit->setText(QString::number(landmark.radius())); } else { setWindowTitle("Add Landmark"); } QLandmarkManager manager; QList<QLandmarkCategory> categories = manager.categories(); foreach( QLandmarkCategory category, categories) { QListWidgetItem *categoryItem = new QListWidgetItem(categoryList,QListWidgetItem::UserType + 1); categoryItem->setData(Qt::DisplayRole,category.name()); QVariant var; var.setValue(category.categoryId()); categoryItem->setData(Qt::UserRole, var); categoryItem->setFlags(Qt::ItemIsEnabled); if (landmark.categoryIds().contains(category.categoryId())) categoryItem->setCheckState(Qt::Checked); else categoryItem->setCheckState(Qt::Unchecked); }