本文整理汇总了C++中QValueList::constBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueList::constBegin方法的具体用法?C++ QValueList::constBegin怎么用?C++ QValueList::constBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueList
的用法示例。
在下文中一共展示了QValueList::constBegin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getProbability
double NaiveBayesianClassifier::getProbability(QString category, const QStringList &text) {
long totalWordCount = 0;
// TODO: do caching
QValueList<QString> categories = m_categories.keys();
for( QValueList<QString>::const_iterator it = categories.constBegin(); it != categories.constEnd(); ++it ) {
totalWordCount += getCount(*it);
}
double catCount = log(getCount(category));
double probability = catCount;
probability -= log(totalWordCount);
for ( QStringList::ConstIterator iter = text.constBegin(); iter != text.constEnd(); ++iter ) {
long wordCount = getWordCount(category, *iter);
if( wordCount != 0) {
//long wordProbability = wordCount;
probability -= log(wordCount);
probability += catCount;
} else {
probability -= log(MIN_CLASS_OCCURRENCE);
probability += catCount;
}
}
return probability;
}
示例2: appendFilters
//-----------------------------------------------------------------------------
void KMFilterMgr::appendFilters(const QValueList<KMFilter *> &filters,
bool replaceIfNameExists)
{
mDirtyBufferedFolderTarget = true;
beginUpdate();
if(replaceIfNameExists)
{
QValueListConstIterator<KMFilter *> it1 = filters.constBegin();
for(; it1 != filters.constEnd() ; ++it1)
{
QValueListConstIterator<KMFilter *> it2 = mFilters.constBegin();
for(; it2 != mFilters.constEnd() ; ++it2)
{
if((*it1)->name() == (*it2)->name())
{
mFilters.remove((*it2));
it2 = mFilters.constBegin();
}
}
}
}
mFilters += filters;
writeConfig(true);
endUpdate();
}
示例3: kdDebug
QMap<QString,double> NaiveBayesianClassifier::getProbabilities(const QString &text)
{
QStringList splitted = this->parse(text);
QMap<QString,double> probabilities = QMap<QString,double>();
QValueList<QString> categories = m_categories.keys();
for( QValueList<QString>::const_iterator it = categories.constBegin(); it != categories.constEnd(); ++it ) {
double probability = this->getProbability(*it, splitted);
kdDebug() << "NaiveBayesianClassifiers::" << *it << " = " << probability << endl;
probabilities.insert(*it, probability);
}
return probabilities;
}
示例4: cacheIndex
void DocumentationPlugin::cacheIndex(DocumentationCatalogItem *item)
{
kdDebug() << "Creating index cache for " << item->text(0) << endl;
QString cacheName = locateLocal("data", QString("kdevdocumentation/index/cache_") + item->text(0));
QFile cacheFile(cacheName);
if (!cacheFile.open(IO_WriteOnly))
return;
QTextStream str(&cacheFile);
str.setEncoding(QTextStream::Unicode);
str << CACHE_VERSION << endl;
QValueList<IndexItemProto*> catalogIndexes = indexes[item];
for (QValueList<IndexItemProto*>::const_iterator it = catalogIndexes.constBegin();
it != catalogIndexes.constEnd(); ++it)
{
str << (*it)->text() << endl;
str << (*it)->description() << endl;
str << (*it)->url().url() << endl;
}
cacheFile.close();
}
示例5: slotEditMember
void TeamMembersDlg::slotEditMember()
{
QListViewItem *item =membersListView->currentItem();
if (!item) return;
KDialogBase editDlg(this, "edit_member", true, i18n("Edit Member"), KDialogBase::Ok | KDialogBase::Cancel);
MemberEditDlg memberDlg(&editDlg);
memberDlg.selectMember(item->text(NAME_COL));
memberDlg.nicknameEdit->setText(item->text(NICKNAME_COL));
memberDlg.emailEdit->setText(item->text(EMAIL_COL));
QString role = item->text(ROLE_COL);
for (int i = 0; i < memberDlg.roleCombo->count(); i++)
{
if (memberDlg.roleCombo->text(i) == role)
{
memberDlg.roleCombo->setCurrentItem(i);
memberDlg.slotRoleSelected(role);
break;
}
}
memberDlg.taskEdit->setText(item->text(TASK_COL));
int idx = 0;
int subprojectIdx = 0;
QValueList<SubProject> *subprojects = Project::ref()->subprojects();
for (QValueList<SubProject>::ConstIterator it = subprojects->constBegin(); it != subprojects->constEnd(); ++it)
{
if (item->text(SUBPROJECT_COL) == (*it).name)
{
subprojectIdx = idx;
break;
}
idx++;
}
memberDlg.subprojectCombo->setCurrentItem(subprojectIdx);
editDlg.setMainWidget(&memberDlg);
bool result;
do {
result = editDlg.exec();
if (result)
{
QString name = memberDlg.nameCombo->currentText();
QString nickName = memberDlg.nicknameEdit->text();
QString email = memberDlg.emailEdit->text();
QString role = memberDlg.roleCombo->currentText();
QString task = memberDlg.taskEdit->text();
QString subProject = memberDlg.subprojectCombo->currentText();
if (name.isEmpty())
{
KMessageBox::error(this, i18n("The member name cannot be empty."));
editDlg.show();
} else
if (nickName.isEmpty())
{
KMessageBox::error(this, i18n("The nickname cannot be empty as it is used as a unique identifier."));
editDlg.show();
} else
if (!checkDuplicates(item, name, nickName, email, role, task, subProject))
{
editDlg.show();
} else
{
item->setText(NAME_COL, name);
item->setText(NICKNAME_COL, nickName);
item->setText(EMAIL_COL, email);
item->setText(ROLE_COL, role);
item->setText(TASK_COL, task);
if (memberDlg.subprojectCombo->isEnabled())
item->setText(SUBPROJECT_COL, subProject);
result = false;
}
}
} while (result);
}