quint32 MUtils::Translation::get_country(const QString &langId) { QReadLocker readLockTranslations(&g_translation_lock); const QString key = langId.simplified().toLower(); if(key.isEmpty() || g_translation_data.isNull() || (!g_translation_data->contains(key))) { return 0; } return (*g_translation_data)[key].second.second; }
QString MUtils::Translation::get_name(const QString &langId) { QReadLocker readLockTranslations(&g_translation_lock); const QString key = langId.simplified().toLower(); if(key.isEmpty() || g_translation_data.isNull() || (!g_translation_data->contains(key))) { return QString(); } return (*g_translation_data)[key].first.first; }
/* * Check for tool */ bool lamexp_tools_check(const QString &toolName) { QReadLocker readLock(&g_lamexp_tools_lock); if(!g_lamexp_tools_data.isNull()) { const QString key = toolName.simplified().toLower(); return g_lamexp_tools_data->contains(key); } return false; }
bool MUtils::Translation::install_translator(const QString &langId) { QReadLocker readLockTranslations(&g_translation_lock); const QString key = langId.simplified().toLower(); if(key.isEmpty() || g_translation_data.isNull() || (!g_translation_data->contains(key))) { return false; } const QString qmFile = (*g_translation_data)[key].first.second; readLockTranslations.unlock(); return install_translator_from_file(qmFile); }
QgsGeometry* QgsMapToolDeleteRing::ringUnderPoint( QgsPoint p, QgsFeatureId& fid, int& partNum, int& ringNum ) { //There is no clean way to find if we are inside the ring of a feature, //so we iterate over all the features visible in the canvas //If several rings are found at this position, the smallest one is chosen, //in order to be able to delete a ring inside another ring QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( toLayerCoordinates( vlayer, mCanvas->extent() ) ) ); QgsFeature f; const QgsGeometry* g; QScopedPointer<QgsGeometry> ringGeom; QgsMultiPolygon pol; QgsPolygon tempPol; QScopedPointer<QgsGeometry> tempGeom; double area = std::numeric_limits<double>::max(); while ( fit.nextFeature( f ) ) { g = f.constGeometry(); if ( !g ) continue; if ( g->wkbType() == QGis::WKBPolygon || g->wkbType() == QGis::WKBPolygon25D ) { pol = QgsMultiPolygon() << g->asPolygon(); } else { pol = g->asMultiPolygon(); } for ( int i = 0; i < pol.size() ; ++i ) {//for each part if ( pol[i].size() > 1 ) { for ( int j = 1; j < pol[i].size();++j ) { tempPol = QgsPolygon() << pol[i][j]; tempGeom.reset( QgsGeometry::fromPolygon( tempPol ) ); if ( tempGeom->area() < area && tempGeom->contains( &p ) ) { fid = f.id(); partNum = i; ringNum = j; area = tempGeom->area(); ringGeom.reset( tempGeom.take() ); } } } } } return ringGeom.take(); }
/* * Lookup tool path */ const QString &lamexp_tools_lookup(const QString &toolName) { QReadLocker readLock(&g_lamexp_tools_lock); if(!g_lamexp_tools_data.isNull()) { const QString key = toolName.simplified().toLower(); if(g_lamexp_tools_data->contains(key)) { return (*g_lamexp_tools_data)[key].first->filePath(); } } return g_null_string; }
bool MUtils::Translation::insert(const QString &langId, const QString &qmFile, const QString &langName, const quint32 &systemId, const quint32 &country) { QWriteLocker writeLockTranslations(&g_translation_lock); const QString key = langId.simplified().toLower(); if(key.isEmpty() || qmFile.isEmpty() || langName.isEmpty() || (systemId < 1)) { return false; } if(g_translation_data.isNull()) { g_translation_data.reset(new translation_store_t()); } if(g_translation_data->contains(key)) { qWarning("Translation store already contains entry for '%s', going to replace!", MUTILS_UTF8(key)); } g_translation_data->insert(key, MAKE_ENTRY(langName, qmFile, systemId, country)); return true; }
/* * Register tool */ void lamexp_tools_register(const QString &toolName, LockedFile *const file, const quint32 &version, const QString &tag) { QWriteLocker writeLock(&g_lamexp_tools_lock); if(!file) { MUTILS_THROW("lamexp_register_tool: Tool file must not be NULL!"); } if(g_lamexp_tools_data.isNull()) { g_lamexp_tools_data.reset(new tool_hash_t()); atexit(lamexp_tools_clean_up); } const QString key = toolName.simplified().toLower(); if(g_lamexp_tools_data->contains(key)) { MUTILS_THROW("lamexp_register_tool: Tool is already registered!"); } g_lamexp_tools_data->insert(key, MAKE_ENTRY(file, version, tag)); }
/* * Lookup tool version */ const quint32 &lamexp_tools_version(const QString &toolName, QString *const tagOut) { QReadLocker readLock(&g_lamexp_tools_lock); if(!g_lamexp_tools_data.isNull()) { const QString key = toolName.simplified().toLower(); if(g_lamexp_tools_data->contains(key)) { const tool_info_t &info = (*g_lamexp_tools_data)[key].second; if(tagOut) { *tagOut = info.second; } return info.first; } } if(tagOut) { tagOut->clear(); } return g_max_uint32; }