本文整理汇总了C++中Locale::countrycode方法的典型用法代码示例。如果您正苦于以下问题:C++ Locale::countrycode方法的具体用法?C++ Locale::countrycode怎么用?C++ Locale::countrycode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::countrycode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void CalculateTaskScore::run()
{
qDebug() << "CalculateTaskScore: Starting new thread";
ConfigParser settings;
QDateTime started = QDateTime::currentDateTime();
ctemplate::TemplateDictionary dict("user_task_score");
db = MySQLHandler::getInstance();
QMultiMap<int, LCCode> users = UserDao::getUserNativeLCCodes(db);
QList<QSharedPointer<Task> > tasks = this->getTasks(); //Must use custom function to check message for task id
QMultiMap<int, LCCode> userSecondaryLanguages = UserDao::getUserLCCodes(db);
QMultiMap<int, int> userTags = UserDao::getUserTagIds(db);
QMultiMap<int, int> taskTags = TaskDao::getTaskTagIds(db);
if(users.count() > 0) {
for(QMultiMap<int, LCCode>::ConstIterator usersIter = users.constBegin(); usersIter != users.constEnd(); ++usersIter) {
if(tasks.length() > 0) {
const LCCode userNativeLCCode = users.value(usersIter.key());
QList<TaskScore> taskScores;
foreach(QSharedPointer<Task> task, tasks) {
int score = 0;
Locale taskSourceLocale = task->sourcelocale();
if(userNativeLCCode.first == taskSourceLocale.languagecode()) {
score += 750;
if(userNativeLCCode.second == taskSourceLocale.countrycode()) {
score += 75;
}
}
Locale taskTargetLocale = task->targetlocale();
if(userNativeLCCode.first == taskTargetLocale.languagecode()) {
score += 1000;
if(userNativeLCCode.second == taskTargetLocale.countrycode()) {
score += 100;
}
}
if(userSecondaryLanguages.contains(usersIter.key())) {
const QList<LCCode> lcCodes = userSecondaryLanguages.values(usersIter.key());
if(lcCodes.end() != std::find_if(lcCodes.begin(), lcCodes.end(), LidMatch(taskSourceLocale.languagecode()))) {
score += 500;
if(lcCodes.end() != std::find_if(lcCodes.begin(), lcCodes.end(), CidMatch(taskSourceLocale.countrycode())) ) {
score += 50;
}
}
if(lcCodes.end() != std::find_if(lcCodes.begin(), lcCodes.end(), LidMatch(taskTargetLocale.languagecode()))) {
score += 500;
if(lcCodes.end() != std::find_if(lcCodes.begin(), lcCodes.end(), CidMatch(taskTargetLocale.countrycode())) ) {
score += 50;
}
}
}
if(userTags.contains(usersIter.key()) && taskTags.contains(task->id())) {
int increment_value = 250;
QList<int> userTagIds = userTags.values(usersIter.key());
QList<int> userTaskTagIds = taskTags.values(task->id());
foreach(int userTagId, userTagIds) {
if(userTaskTagIds.contains(userTagId)) {
score += increment_value;
increment_value *= 0.75;
}
}
}
QDateTime created_time = QDateTime::fromString(
QString::fromStdString(task->createdtime()), Qt::ISODate);
//increase score by one per day since created time
score += created_time.daysTo(QDateTime::currentDateTime());
taskScores.append(TaskScore(task->id(), score));
}
this->saveUserTaskScore(usersIter.key(),taskScores);
} else {