bool WeatherDataModel::readLocation(QString line)
{
    QStringList list = line.split(',');
    // Require 10 items in the list
    if(list.size() > 10) {
        LOG(warning) << "Location: Expected 10 entries, got " << list.size();
    } else if(list.size() != 10) {
        LOG(error) << "Location: Expected 10 entries, got " << list.size();
        return false;
    }
    setCity(list[1].toStdString());
    setStateProvinceRegion(list[2].toStdString());
    setCountry(list[3].toStdString());
    setSource(list[4].toStdString());
    setWMO(list[5].toStdString());
    if(!setLatitude(list[6].toStdString())) {
        LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[6]).toStdString();
        return false;
    }
    if(!setLongitude(list[7].toStdString())) {
        LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[7]).toStdString();
        return false;
    }
    if(!setTimeZone(list[8].toStdString())) {
        LOG(error) << QString("Location: Bad time zone value '%1'").arg(list[8]).toStdString();
        return false;
    }
    if(!setElevation(list[9].toStdString())) {
        LOG(error) << QString("Location: Bad elevation value '%1'").arg(list[9]).toStdString();
        return false;
    }
    return true;
}
void QDeclarativeGeoAddress::setAddress(const QGeoAddress& address)
{
    // Elaborate but takes care of emiting needed signals
    setCountry(address.country());
    setCountryCode(address.countryCode());
    setState(address.state());
    setCounty(address.county());
    setCity(address.city());
    setDistrict(address.district());
    setStreet(address.street());
    setPostcode(address.postcode());
    m_address = address;
}
示例#3
0
void AddressCluster::populateCountryComboBox()
{
  if(_x_metrics == 0)
    return;

  _country->clear();
  XSqlQuery country;
  country.prepare("SELECT -1, '','' AS country_name " 
                  "UNION "
                  "SELECT country_id, country_name, country_name "
                  "FROM country ORDER BY country_name;");
  country.exec();
  _country->populate(country);
  setCountry(_x_metrics->value("DefaultAddressCountry"));
}
示例#4
0
   void addAddress(Person* c, const QString& key, const QByteArray& fn) {
      auto addr = Person::Address();
      QList<QByteArray> fields = fn.split(VCardUtils::Delimiter::SEPARATOR_TOKEN[0]);
      QStringList keyFields = key.split(VCardUtils::Delimiter::SEPARATOR_TOKEN);

      if(keyFields.size() < 2 || fields.size() < 7) {
          qDebug() << "Malformatted Address";
          return;
      }

      addr.setType        (keyFields[1]                   );
      addr.setAddressLine (QString::fromUtf8(fields[2])   );
      addr.setCity        (QString::fromUtf8(fields[3])   );
      addr.setState       (QString::fromUtf8(fields[4])   );
      addr.setZipCode     (QString::fromUtf8(fields[5])   );
      addr.setCountry     (QString::fromUtf8(fields[6])   );

      c->addAddress(addr);
   }
bool QBBVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event)
{
    if (bps_event_get_code(event) == LOCALE_INFO) {
        const QString language = QString::fromAscii(locale_event_get_language(event));
        const QString country  = QString::fromAscii(locale_event_get_country(event));

#if defined(QBBVIRTUALKEYBOARD_DEBUG)
        qDebug() << Q_FUNC_INFO << "current language/country" << languageId() << "/" << countryId()
                 << "new language/country=" << language << "/" << country;
#endif
        setLanguage(language);
        setCountry(country);
        return true;
    }

#if defined(QBBVIRTUALKEYBOARD_DEBUG)
    qDebug() << "QBB: Unhandled locale event. code=" << bps_event_get_code(event);
#endif

    return false;
}
示例#6
0
void AddressCluster::silentSetId(const int pId)
{
    if (pId == -1)
    {
      _id = pId;
      _valid = false;
      clear();
    }
    else
    {
      clear();
      XSqlQuery idQ;
      idQ.prepare("SELECT * from addr WHERE addr_id = :id;");
      idQ.bindValue(":id", pId);
      idQ.exec();
      if (idQ.first())
      {
        _id = pId;
        _valid = true;
        _number->setText(idQ.value("addr_number").toString());
        _addr1->setText(idQ.value("addr_line1").toString());
        _addr2->setText(idQ.value("addr_line2").toString());
        _addr3->setText(idQ.value("addr_line3").toString());
        _city->setText(idQ.value("addr_city").toString());
        _postalcode->setText(idQ.value("addr_postalcode").toString());

        // set country before state or populateStateComboBox may clear the state
        setCountry(idQ.value("addr_country").toString());
        setState(idQ.value("addr_state").toString());

        _active->setChecked(idQ.value("addr_active").toBool());
        _notes = idQ.value("addr_notes").toString();

        if (_mapper->model())
        {
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)), _number->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_active)), _active->isChecked());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr1)), _addr1->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr2)), _addr2->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr3)), _addr3->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_city)), _city->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_state)), _state->currentText());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_postalcode)), _postalcode->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_country)), _country->currentText());    
        }

        c_number     = _number->text();
        c_addr1      = _addr1->text();
        c_addr2      = _addr2->text();
        c_addr3      = _addr3->text();
        c_city       = _city->text();
        c_state      = _state->currentText();
        c_postalcode = _postalcode->text();
        c_country    = _country->currentText();
        c_active     = _active->isChecked();
        c_notes      = _notes;
      }
      else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Setting Id"),
                                    idQ, __FILE__, __LINE__))
        return;
  }

    // _parsed = true;
}
示例#7
0
void JabberContact::deserializeLine(const QString& key, const QString& value)
{

    QString val = value;
    if(val.startsWith('\"') && val.endsWith('\"'))
        val = val.mid(1, val.length() - 2);
    if(key == "ID") {
        setId(val);
    }
    else if(key == "Node") {
        setNode(val);
    }
    else if(key == "Resource") {
        setResource(val);
    }
    else if(key == "Name") {
        setName(val);
    }
    else if(key == "FirstName") {
        setFirstName(val);
    }
    else if(key == "Nick") {
        setNick(val);
    }
    else if(key == "Desc") {
        setDesc(val);
    }
    else if(key == "BirthDay") {
        setBirthday(val);
    }
    else if(key == "Url") {
        setUrl(val);
    }
    else if(key == "OrgName") {
        setOrgName(val);
    }
    else if(key == "OrgUnit") {
        setOrgUnit(val);
    }
    else if(key == "Title") {
        setTitle(val);
    }
    else if(key == "Role") {
        setRole(val);
    }
    else if(key == "Street") {
        setStreet(val);
    }
    else if(key == "ExtAddr") {
        setExtAddr(val);
    }
    else if(key == "City") {
        setCity(val);
    }
    else if(key == "Region") {
        setRegion(val);
    }
    else if(key == "PCode") {
        setPCode(val);
    }
    else if(key == "Country") {
        setCountry(val);
    }
    else if(key == "EMail") {
        setEmail(val);
    }
    else if(key == "Phone") {
        setPhone(val);
    }
    else if(key == "StatusTime") {
        setStatusTime(val.toUInt());
    }
    else if(key == "OnlineTime") {
        setOnlineTime(val.toUInt());
    }
    else if(key == "Subscribe") {
        setSubscribe(val.toUInt());
    }
    else if(key == "Group") {
        setGroup(val);
    }
    else if(key == "PhotoWidth") {
        setPhotoWidth(val.toUInt());
    }
    else if(key == "PhotoHeight") {
        setPhotoHeight(val.toUInt());
    }
    else if(key == "LogoWidth") {
        setLogoWidth(val.toUInt());
    }
    else if(key == "LogoHeight") {
        setLogoHeight(val.toUInt());
    }
    else if(key == "AutoReply") {
        setAutoReply(val);
    }
}
示例#8
0
void AddressCluster::silentSetId(const int pId)
{
    if (pId == -1)
    {
      _id = pId;
      _valid = false;
      clear();
    }
    else
    {
      clear();
      XSqlQuery idQ;
      idQ.prepare("SELECT * from addr WHERE addr_id = :id;");
      idQ.bindValue(":id", pId);
      idQ.exec();
      if (idQ.first())
      {
        _id = pId;
        _valid = true;
        _number->setText(idQ.value("addr_number").toString());
        _addr1->setText(idQ.value("addr_line1").toString());
        _addr2->setText(idQ.value("addr_line2").toString());
        _addr3->setText(idQ.value("addr_line3").toString());
        _city->setText(idQ.value("addr_city").toString());
        _postalcode->setText(idQ.value("addr_postalcode").toString());

        // set country before state or populateStateComboBox may clear the state
        setCountry(idQ.value("addr_country").toString());
        setState(idQ.value("addr_state").toString());

        _active->setChecked(idQ.value("addr_active").toBool());
        _notes = idQ.value("addr_notes").toString();

        if (_mapper->model())
        {
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)), _number->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_active)), _active->isChecked());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr1)), _addr1->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr2)), _addr2->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_addr3)), _addr3->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_city)), _city->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_state)), _state->currentText());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_postalcode)), _postalcode->text());
           _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_country)), _country->currentText());    
        }

        c_number     = _number->text();
        c_addr1      = _addr1->text();
        c_addr2      = _addr2->text();
        c_addr3      = _addr3->text();
        c_city       = _city->text();
        c_state      = _state->currentText();
        c_postalcode = _postalcode->text();
        c_country    = _country->currentText();
        c_active     = _active->isChecked();
        c_notes      = _notes;
      }
      else if (idQ.lastError().type() != QSqlError::NoError)
          QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
                                        .arg(__FILE__)
                                        .arg(__LINE__),
                                idQ.lastError().databaseText());
  }

    // _parsed = TRUE;
}
示例#9
0
文件: klocale.cpp 项目: vasi/kdelibs
bool KLocale::setCountry(const QString &country, KConfig *config)
{
    return d->setCountry(country, config);
}
示例#10
0
文件: rominfo.cpp 项目: MythTV/mythtv
void RomInfo::fillData()
{
    if (m_gamename == "")
    {
        return;
    }

    MSqlQuery query(MSqlQuery::InitCon());

    QString systemtype;
    if (m_system != "") {
        systemtype  += " AND system = :SYSTEM ";
    }

    QString thequery = "SELECT system,gamename,genre,year,romname,favorite,"
                       "rompath,country,crc_value,diskcount,gametype,plot,publisher,"
                       "version,screenshot,fanart,boxart,inetref,intid FROM gamemetadata "
                       "WHERE gamename = :GAMENAME "
                       + systemtype + " ORDER BY diskcount DESC";

    query.prepare(thequery);
    query.bindValue(":SYSTEM", m_system);
    query.bindValue(":GAMENAME", m_gamename);

    if (query.exec() && query.next())
    {
        setSystem(query.value(0).toString());
        setGamename(query.value(1).toString());
        setGenre(query.value(2).toString());
        setYear(query.value(3).toString());
        setRomname(query.value(4).toString());
        setField("favorite",query.value(5).toString());
        setRompath(query.value(6).toString());
        setCountry(query.value(7).toString());
        setCRC_VALUE(query.value(8).toString());
        setDiskCount(query.value(9).toInt());
        setGameType(query.value(10).toString());
        setPlot(query.value(11).toString());
        setPublisher(query.value(12).toString());
        setVersion(query.value(13).toString());
        setScreenshot(query.value(14).toString());
        setFanart(query.value(15).toString());
        setBoxart(query.value(16).toString());
        setInetref(query.value(17).toString());
        setId(query.value(18).toInt());
    }

    setRomCount(romInDB(m_romname,m_gametype));

    // If we have more than one instance of this rom in the DB fill in all
    // systems available to play it.
    if (RomCount() > 1)
    {
        query.prepare("SELECT DISTINCT system FROM gamemetadata "
                      "WHERE romname = :ROMNAME");
        query.bindValue(":ROMNAME", Romname());
        if (!query.exec())
            MythDB::DBError("RomInfo::fillData - selecting systems", query);

        while (query.next())
        {
            if (m_allsystems.isEmpty())
                m_allsystems = query.value(0).toString();
            else
                m_allsystems += "," + query.value(0).toString();
        }
    }
    else
    {
        m_allsystems = m_system;
    }
}
示例#11
0
bool MessageModel::load(const QString &fileName)
{
    MetaTranslator tor;
    bool ok = tor.load(fileName);
    if (ok) {
        if(tor.codecForTr())
            m_codecForTr = tor.codecForTr()->name();
        int messageCount = 0;
        clearContextList();
        m_numFinished = 0;
        m_numNonobsolete = 0;

        TML all = tor.messages();
        QHash<QString, ContextItem*> contexts;

        m_srcWords = 0;
        m_srcChars = 0;
        m_srcCharsSpc = 0;

        foreach(MetaTranslatorMessage mtm, all) {
            QCoreApplication::processEvents();
            ContextItem *c;
            if (contexts.contains(QLatin1String(mtm.context()))) {
                c = contexts.value( QLatin1String(mtm.context()));
            }
            else {
                c = createContextItem(tor.toUnicode(mtm.context(), mtm.utf8()));;
                appendContextItem(c);
                contexts.insert(QLatin1String(mtm.context()), c);
            }
            if (QByteArray(mtm.sourceText()) == ContextComment) {
                c->appendToComment(tor.toUnicode(mtm.comment(), mtm.utf8()));
            }
            else {
                MessageItem *tmp = new MessageItem(mtm, tor.toUnicode(mtm.sourceText(),
                    mtm.utf8()), tor.toUnicode(mtm.comment(), mtm.utf8()), c);
                if (mtm.type() != MetaTranslatorMessage::Obsolete) {
                    m_numNonobsolete++;
                    //if (mtm.type() == MetaTranslatorMessage::Finished)
                        //tmp->setFinished(true);
                        //++m_numFinished;
                    doCharCounting(tmp->sourceText(), m_srcWords, m_srcChars, m_srcCharsSpc);
                }
                else {
                    c->incrementObsoleteCount();
                }
                c->appendMessageItem(tmp);
                ++messageCount;
            }
        }

        // Try to detect the correct language in the following order
        // 1. Look for the language attribute in the ts 
        //   if that fails
        // 2. Guestimate the language from the filename (expecting the qt_{en,de}.ts convention)
        //   if that fails
        // 3. Retrieve the locale from the system.
        QString lang = tor.languageCode();
        if (lang.isEmpty()) {
            int pos_sep = fileName.indexOf(QLatin1Char('_'));
            if (pos_sep != -1 && pos_sep + 3 <= fileName.length()) {
                lang = fileName.mid(pos_sep + 1, 2);
            }
        }
        QLocale::Language l;
        QLocale::Country c;
        MetaTranslator::languageAndCountry(lang, &l, &c);
        if (l == QLocale::C) {
            QLocale sys;
            l = sys.language();
            c = sys.country();
        }
        setLanguage(l);
        setCountry(c);

        m_numMessages = messageCount;
        updateAll();
        setModified(false);
    }
示例#12
0
Config::Config(const std::string country, const std::string config_file, const std::string runtime_dir)
{

    string debug_message = "";

    this->loaded = false;


    string configFile;

    char* envConfigFile;
    envConfigFile = getenv (ENV_VARIABLE_CONFIG_FILE);
    if (config_file.compare("") != 0)
    {
        // User has supplied a config file.  Use that.
        configFile = config_file;
        debug_message = "Config file location provided via API";
    }
    else if (envConfigFile != NULL)
    {
        // Environment variable is non-empty.  Use that.
        configFile = envConfigFile;
        debug_message = "Config file location provided via environment variable: " + string(ENV_VARIABLE_CONFIG_FILE);
    }
    else if (DirectoryExists(getExeDir().c_str()) && fileExists((getExeDir() + CONFIG_FILE).c_str()))
    {
        configFile = getExeDir() + CONFIG_FILE;
        debug_message = "Config file location provided via exe location";
    }
    else
    {
        // Use the default
        configFile = DEFAULT_CONFIG_FILE;
        debug_message = "Config file location provided via default location";
    }

    //string configFile = (this->runtimeBaseDir + CONFIG_FILE);

    if (fileExists(configFile.c_str()) == false)
    {
        std::cerr << "--(!) Config file '" << configFile << "' does not exist!" << endl;
        std::cerr << "--(!)             You can specify the configuration file location via the command line " << endl;
        std::cerr << "--(!)             or by setting the environment variable '" << ENV_VARIABLE_CONFIG_FILE << "'" << endl;
        return;
    }
    else if (DirectoryExists(configFile.c_str()))
    {
        std::cerr << "--(!) Config file '" << configFile << "' was specified as a directory, rather than a file!" << endl;
        std::cerr << "--(!)             Please specify the full path to the 'openalpr.conf file'" << endl;
        std::cerr << "--(!)             e.g., /etc/openalpr/openalpr.conf" << endl;
        return;
    }


    loadCommonValues(configFile);

    if (runtime_dir.compare("") != 0)
    {
        // User provided a runtime directory directly into the library.  Use this.
        this->runtimeBaseDir = runtime_dir;
    }

    if ((DirectoryExists(this->runtimeBaseDir.c_str()) == false) &&
            (DirectoryExists((getExeDir() + RUNTIME_DIR).c_str())))
    {
        // Runtime dir in the config is invalid and there is a runtime dir in the same dir as the exe.
        this->runtimeBaseDir = getExeDir() + RUNTIME_DIR;

    }

    if (DirectoryExists(this->runtimeBaseDir.c_str()) == false)
    {
        std::cerr << "--(!) Runtime directory '" << this->runtimeBaseDir << "' does not exist!" << endl;
        std::cerr << "--(!)                   Please update the OpenALPR config file: '" << configFile << "'" << endl;
        std::cerr << "--(!)                   to point to the correct location of your runtime_dir" << endl;
        return;
    }

    this->loaded_countries = this->parse_country_string(country);

    if (this->loaded_countries.size() == 0)
    {
        std::cerr << "--(!) Country not specified." << endl;
        return;
    }
    for (unsigned int i = 0; i < loaded_countries.size(); i++)
    {
        bool country_loaded = setCountry(this->loaded_countries[i]);
        if (!country_loaded)
        {
            return;
        }
    }
    setCountry(this->loaded_countries[0]);


    if (this->debugGeneral)
    {
        std::cout << debug_message << endl;
    }

    this->loaded = true;
}