QStringList ConfigQml::Cities(int country_index, int index) { QStringList l; Core::listdata * list = db->create_stations_list(getRegionId(country_index, index)); if (list->size() == 0) return l; Core::listdata::iterator cur; for (cur=list->begin(); cur<list->end(); cur++) l << QString::fromStdString((*cur).second); return l; }
void CityModel::populate(QString source, QString region) { beginInsertRows(QModelIndex(), rowCount(), rowCount()); _list.clear(); std::string path(Core::AbstractConfig::prefix); path += Core::AbstractConfig::sharePath; path += "db/"; if (source == "") return ; QString filename(source); filename.append(".db"); filename.prepend(path.c_str()); Core::DatabaseSqlite *db; db = new Core::DatabaseSqlite(""); qDebug() << "filename = " << filename; if (db) { db->set_databasename(filename.toStdString()); }else { qDebug() << "error db"; } if (!db->open_database()){ qDebug() << "error open database"; return; } Core::listdata * list = db->create_stations_list(region.toInt()); if (list->size() == 0) return; Core::listdata::iterator cur; for (cur=list->begin(); cur<list->end(); cur++){ QString str = QString::fromUtf8((*cur).second.c_str()); _list.append(new SelectData(str, QString::fromStdString((*cur).first), str.left(1))); } endInsertRows(); //reset(); endResetModel(); }
QStringList ConfigQml::Countries(QString source) { QStringList l; std::string path(Core::AbstractConfig::prefix); path += Core::AbstractConfig::sharePath; path += "db/"; if (source == "") return l; QString filename(source); filename.append(".db"); filename.prepend(path.c_str()); if (!this->db) { this->db->set_databasename(filename.toStdString()); }else { this->db->set_databasename(filename.toStdString()); } if (!this->db->open_database()){ l << "error open db"; return l; } Core::listdata * list = db->create_countries_list(); Core::listdata::iterator cur; if (!list) return l; for (cur=list->begin(); cur<list->end(); cur++){ l << QString::fromStdString((*cur).second); /*if (isKeys) { l << QString::fromStdString((*cur).first); }else { l << QString::fromStdString((*cur).second); }*/ } return l; }