SearchWidget::SearchWidget(QWidget *parent) : QWidget(parent), m_addrLookup(0), m_cityCoordinates(), m_loaded(false), m_city(new QLineEdit(this)), m_cityList(new QListWidget(this)), m_street(new QLineEdit(this)), m_streetList(new QListWidget(this)) { QGridLayout *layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_city, 0, 0, 1, 2); connect(m_city, SIGNAL(textEdited(QString)), this, SLOT(cityChanged(QString))); connect(m_city, SIGNAL(editingFinished()), this, SLOT(cityEntered())); layout->addWidget(m_cityList, 1, 0, 1, 2); connect(m_cityList, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(citySelected(QListWidgetItem*))); #if QT_VERSION >= 0x040700 m_city->setPlaceholderText("Enter city name"); m_street->setPlaceholderText("Enter street name"); #endif layout->addWidget(m_street, 2, 0, 1, 2); connect(m_street, SIGNAL(textEdited(QString)), this, SLOT(streetChanged(QString))); layout->addWidget(m_streetList, 3, 0, 1, 2); connect(m_streetList, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(streetSelected(QListWidgetItem*))); QPushButton *back = new QPushButton("&Back", this); back->setIcon(QIcon(":cancel.png")); layout->addWidget(back, 4, 1); connect(back, SIGNAL(clicked()), this, SIGNAL(back())); QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat); set.beginGroup("monav"); QString dataDir = set.value("datadir").toString(); QString addrLookupLib = set.value("addresslookup", "/usr/lib/monav/libunicodetournamenttrieclient.so").toString(); set.endGroup(); QSettings pluginSettings(dataDir+"/plugins.ini", QSettings::IniFormat); QString addrLookupName = pluginSettings.value("addressLookup").toString(); QPluginLoader Loader(addrLookupLib); QObject *plugin = Loader.instance(); if (plugin) { m_addrLookup = qobject_cast<IAddressLookup*>(plugin); if (m_addrLookup) { m_addrLookup->SetInputDirectory(dataDir); m_loaded = m_addrLookup->LoadData(); } } resize(320, 240); }
/*! Creates and returns a source with the specified \a parent that reads from the system's default source of satellite update information, or the highest priority available plugin. Returns 0 if the system has no default source and no valid plugins could be found. Note: Symbian applications will need to have the Location capability otherwise this will return 0. \since 1.0 */ QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent) { QSettings pluginSettings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat")); QVariant value = pluginSettings.value("position.plugin.operator.whitelist"); if (value.isValid()) { QStringList parts = value.toString().split(","); if (parts.size() == 4) { QGeoSatelliteInfoSource *source = createSource(parts.at(0), parent); if (source) return source; } } #if defined(Q_OS_SYMBIAN) CQGeoSatelliteInfoSourceS60 *ret = NULL; TRAPD(error, QT_TRYCATCH_LEAVING(ret = CQGeoSatelliteInfoSourceS60::NewL(parent))); if (error == KErrNone) return ret; #elif defined(Q_OS_WINCE) return new QGeoSatelliteInfoSourceWinCE(parent); #elif (defined(Q_WS_MAEMO_6)) || (defined(Q_WS_MAEMO_5)) QGeoSatelliteInfoSourceMaemo *source = new QGeoSatelliteInfoSourceMaemo(parent); int status = source->init(); if (status != -1) return source; else delete source; #elif defined(QT_SIMULATOR) return new QGeoSatelliteInfoSourceSimulator(parent); #elif defined(Q_WS_MEEGO) // Use Maemo6 backend if available, otherwise use Gypsy backend QSettings maemo6Settings(QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSatMaemo6")); if (!maemo6Settings.value("maemo6satelliteavailable").isValid()) { QGeoSatelliteInfoSourceMaemo *maemoSource = new QGeoSatelliteInfoSourceMaemo(parent); int status = maemoSource->init(); if (status == -1) { delete maemoSource; maemoSource = 0; maemo6Settings.setValue("maemo6satelliteavailable", false); } else { return maemoSource; } } #ifdef GYPSY_AVAILABLE QGeoSatelliteInfoSourceGypsy* gypsySource = new QGeoSatelliteInfoSourceGypsy(parent); int status = gypsySource->init(); if (status >= 0) return gypsySource; delete gypsySource; #endif // GYPSY_AVAILABLE #endif foreach (QGeoPositionInfoSourceFactory *f, QGeoSatelliteInfoSourcePrivate::pluginsSorted()) { QGeoSatelliteInfoSource *src = f->satelliteInfoSource(parent); if (src) return src; }
void Config::loadConfigFile() { #ifdef DEBUG_MODE qDebug("[Config::loadConfigFile]"); #endif bool ok; CliErrorReporter::printNotification("[INFO] Loading configuration file.."); QSettings pluginSettings(QSettings::IniFormat, QSettings::UserScope, "GameZoo", "AgathaServer"); // AGATHA SERVER pluginSettings.beginGroup("server"); int srvPort = pluginSettings.value("port").toInt(&ok); if (!ok) { CliErrorReporter::printError(CliErrorReporter::APPLICATION, CliErrorReporter::WARNING, "Invalid server port. Using default (1337)"); srvPort = 1337; } m_serverConfigStruct.port = srvPort; pluginSettings.endGroup(); // COUCHDB pluginSettings.beginGroup("agathaNode"); m_couchDbStruct.ip = pluginSettings.value("ip").toString(); int dbPort = pluginSettings.value("port").toInt(&ok); if (!ok) { CliErrorReporter::printError(CliErrorReporter::APPLICATION, CliErrorReporter::WARNING, "Invalid couchDB port. Using default (5984)"); dbPort = 5984; // set to default couchdb port } m_couchDbStruct.port = dbPort; m_couchDbStruct.dbName = pluginSettings.value("databaseName").toString(); pluginSettings.endGroup(); qDebug() << "AGATHA SERVER PORT: " << m_serverConfigStruct.port; qDebug() << "COUCHDB : " << m_couchDbStruct.ip; qDebug() << "COUCHDB : " << m_couchDbStruct.port; qDebug() << "COUCHDB : " << m_couchDbStruct.dbName; // check if the db name is supported if (m_allowedDbs.contains(m_couchDbStruct.dbName)) { CliErrorReporter::printNotification("[INFO] Done!"); } else { CliErrorReporter::printError(CliErrorReporter::APPLICATION , CliErrorReporter::ERROR , "Database '" + m_couchDbStruct.dbName + "' not supported"); std::exit(1); } }