本文整理汇总了C++中QMapIterator::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QMapIterator::value方法的具体用法?C++ QMapIterator::value怎么用?C++ QMapIterator::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMapIterator
的用法示例。
在下文中一共展示了QMapIterator::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wit
//---------------------------------------------------------------------------
// getWordItems
//
//! Construct a list of word items to be inserted into a word list, based on
//! the results of a list of searches.
//
//! @param searchSpecs the list of search specifications
//! @return a list of word items
//---------------------------------------------------------------------------
QList<WordTableModel::WordItem>
WordVariationDialog::getWordItems(const QList<SearchSpec>& searchSpecs) const
{
QList<WordTableModel::WordItem> wordItems;
QMap<QString, QString> wordMap;
QListIterator<SearchSpec> lit (searchSpecs);
while (lit.hasNext()) {
QStringList wordList = wordEngine->search(lexicon, lit.next(), false);
QStringListIterator wit (wordList);
while (wit.hasNext()) {
QString str = wit.next();
wordMap.insert(str.toUpper(), str);
}
}
QMapIterator<QString, QString> mit (wordMap);
while (mit.hasNext()) {
mit.next();
QString value = mit.value();
QList<QChar> wildcardChars;
for (int i = 0; i < value.length(); ++i) {
QChar c = value[i];
if (c.isLower())
wildcardChars.append(c);
}
QString wildcard;
if (!wildcardChars.isEmpty()) {
qSort(wildcardChars.begin(), wildcardChars.end(),
Auxil::localeAwareLessThanQChar);
foreach (const QChar& c, wildcardChars)
wildcard.append(c.toUpper());
}
wordItems.append(WordTableModel::WordItem(
mit.key(), WordTableModel::WordNormal, wildcard));
}
示例2: splitByAnchors
void LocationTable::splitByAnchors(const PreprocessedContents& text, const Anchor& textStartPosition, QList<PreprocessedContents>& strings, QList<Anchor>& anchors) const {
Anchor currentAnchor = Anchor(textStartPosition);
size_t currentOffset = 0;
QMapIterator<std::size_t, Anchor> it = m_offsetTable;
while (currentOffset < (size_t)text.size())
{
Anchor nextAnchor(KDevelop::CursorInRevision::invalid());
size_t nextOffset;
if(it.hasNext()) {
it.next();
nextOffset = it.key();
nextAnchor = it.value();
}else{
nextOffset = text.size();
nextAnchor = Anchor(KDevelop::CursorInRevision::invalid());
}
if( nextOffset-currentOffset > 0 ) {
strings.append(text.mid(currentOffset, nextOffset-currentOffset));
anchors.append(currentAnchor);
}
currentOffset = nextOffset;
currentAnchor = nextAnchor;
}
}
示例3: storeClass
void Emotions::storeClass(QString klassName, NaiveBayesClassifier *classifier){
double acc=0;
if(klassName.contains("calm") || klassName.contains("exited")){
acc=EMOTION_AROUSAL_ACCURACY;
}else if(klassName.contains("positive") || klassName.contains("negative")){
acc=EMOTION_VALENCE_ACCURACY;
}else{
return;
}
if(classifier->getTrainedClasses().contains(klassName)){
QFile file(_dataPath+"."+klassName);
if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "Emotions : cannot open file "+file.fileName()+" : "
<< qPrintable(file.errorString()) << file.fileName()<< endl;
return;
}
QMapIterator<double, double>* clasIt = new QMapIterator<double,double>(*classifier->getTrainedClasses().value(klassName));
while(clasIt->hasNext()){
clasIt->next();
for(int j=0;j<clasIt->value();++j){
QString* strVal=new QString("");
strVal->setNum(clasIt->key(),'f', acc);
file.write(strVal->toAscii());
file.putChar('\n');
}
}
}
}
示例4: exportProperties
void SingleXmlSerializer::exportProperties(const Id&id, QDomDocument &doc, QDomElement &root
, QHash<Id, Object *> const &objects)
{
QDomElement props = doc.createElement("properties");
const GraphicalObject * const graphicalObject = dynamic_cast<const GraphicalObject *>(objects[id]);
const LogicalObject * const logicalObject
= dynamic_cast<const LogicalObject *>(objects[graphicalObject->logicalId()]);
QMap<QString, QVariant> properties;
QMapIterator<QString, QVariant> i = logicalObject->propertiesIterator();
while (i.hasNext()) {
i.next();
properties[i.key()] = i.value();
}
i = graphicalObject->propertiesIterator();
while (i.hasNext()) {
i.next();
properties[i.key()] = i.value();
}
foreach (const QString &key, properties.keys()) {
QDomElement prop = doc.createElement("property");
QString typeName = properties[key].typeName();
QVariant value = properties[key];
if (typeName == "qReal::IdList" && (value.value<IdList>().size() != 0)) {
QDomElement list = ValuesSerializer::serializeIdList("list", value.value<IdList>(), doc);
prop.appendChild(list);
} else if (typeName == "qReal::Id"){
prop.setAttribute("value", value.value<Id>().toString());
} else if (value.toString().isEmpty()) {
continue;
} else {
prop.setAttribute("value", properties[key].toString());
}
prop.setAttribute("name", key);
props.appendChild(prop);
}
root.appendChild(props);
}
示例5: keyProcessing
bool InformWindow::keyProcessing(const int &key)
{
QMapIterator<int, Command*> it (kbCommand);
while (it.hasNext())
{
it.next();
if (key == it.key())
{
if (it.value() != NULL)
{
it.value()->execute();
return true;
}
}
}
return false;
}
示例6: dump
void LocationTable::dump() const
{
QMapIterator<std::size_t, Anchor> it = m_offsetTable;
qCDebug(RPP) << "Location Table:";
while (it.hasNext()) {
it.next();
qCDebug(RPP) << it.key() << " => " << it.value().castToSimpleCursor();
}
}
示例7: clear
void DraggerManagerPrivate::clear()
{
QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
QMapIterator<WidgetProperties *, QDeclarativeItem *>(draggers);
while (iterator.hasNext()) {
iterator.next();
iterator.value()->deleteLater();
}
draggers.clear();
}
示例8: disableDraggers
void DraggerManager::disableDraggers()
{
Q_D(DraggerManager);
QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
QMapIterator<WidgetProperties *, QDeclarativeItem *>(d->draggers);
while (iterator.hasNext()) {
iterator.next();
iterator.value()->setVisible(false);
}
}
示例9: exec
bool MSqlQuery::exec()
{
// Database connection down. Try to restart it, give up if it's still
// down
if (!m_db)
{
// Database structure's been deleted
return false;
}
if (!m_db->isOpen() && !m_db->Reconnect())
{
LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
return false;
}
bool result = QSqlQuery::exec();
// if the query failed with "MySQL server has gone away"
// Close and reopen the database connection and retry the query if it
// connects again
if (!result && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())
result = QSqlQuery::exec();
if (VERBOSE_LEVEL_CHECK(VB_DATABASE) && logLevel <= LOG_DEBUG)
{
QString str = lastQuery();
// Database logging will cause an infinite loop here if not filtered
// out
if (!str.startsWith("INSERT INTO logging "))
{
// Sadly, neither executedQuery() nor lastQuery() display
// the values in bound queries against a MySQL5 database.
// So, replace the named placeholders with their values.
QMapIterator<QString, QVariant> b = boundValues();
while (b.hasNext())
{
b.next();
str.replace(b.key(), '\'' + b.value().toString() + '\'');
}
LOG(VB_DATABASE, LOG_DEBUG,
QString("MSqlQuery::exec(%1) %2%3")
.arg(m_db->MSqlDatabase::GetConnectionName()).arg(str)
.arg(isSelect() ? QString(" <<<< Returns %1 row(s)")
.arg(size()) : QString()));
}
}
return result;
}
示例10: tuiLaunched
void ClientPrivate::tuiLaunched () {
qDebug () << "ClientPrivate::tuiLaunched";
QMapIterator<QString, Transfer *> iter (transfers);
if (transfers.count() == 0) {
// There are no transfers
return;
}
while (iter.hasNext()) {
iter.next();
Transfer *transfer = iter.value ();
if (iter.key() != transfer->transferId ()) {
qCritical () <<
"Client::tuiLaunched -> Key does not match transfer id";
}
QDBusReply<bool> exists =
interface->transferExists (transfer->transferId ());
if (exists.isValid ()) {
if (exists.value () == true) {
qDebug() << transfer->transferId () << "exists in TUI"
<< "- not registering this. Moving to next";
// Transfer exists in TUI - go to next transfer
continue;
}
} else {
qCritical() << "Got invalid reply when checking if transfer "
<< transfer->transferId () << " exists in TUI";
continue;
}
QDBusReply<QString> reply =
interface->registerTransientTransfer (transfer->transferId ());
if (reply.isValid()) {
if (reply.value () == transfer->transferId ()) {
transfer->tuiLaunched ();
} else {
qCritical() << "Got " << reply.value () <<
" as reply from registerPersistentTransfer instead of "
<< "expected value of " << transfer->transferId ();
}
} else {
qWarning() << "Transfer with tracker uri" << transfer->transferId ()
<< "not found.";
}
}
}
示例11: ChildNeedUpdate
void QtPropertyDataIntrospection::ChildNeedUpdate()
{
QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *> i = QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *>(childVariantMembers);
while(i.hasNext())
{
i.next();
QtPropertyDataDavaVariant *childData = i.key();
DAVA::VariantType childCurValue = i.value()->Value(object);
if(childCurValue != childData->GetVariantValue())
{
childData->SetVariantValue(childCurValue);
}
}
}
示例12:
QHash<QString, QVariant> RefactoringApplier::properties(Id const &id) const
{
QHash<QString, QVariant> result;
QMapIterator<QString, QVariant> properties =
(mLogicalModelApi.isLogicalId(id))
? mLogicalModelApi.logicalRepoApi().propertiesIterator(id)
: mLogicalModelApi.logicalRepoApi().propertiesIterator(
mGraphicalModelApi.logicalId(id));
while (properties.hasNext()) {
properties.next();
if (!defaultProperties.contains(properties.key())) {
result.insert(properties.key(), properties.value());
}
}
return result;
}
示例13: while
void ViewManager::ViewManagerPrivate::slotLockedChanged(bool locked)
{
if(locked) {
// When the view is locked, all draggers should be destroyed
QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
QMapIterator<WidgetProperties *, QDeclarativeItem *>(registeredDraggers);
while (iterator.hasNext()) {
iterator.next();
QDeclarativeItem *item = iterator.value();
registeredDraggers.remove(iterator.key());
item->deleteLater();
}
q->setCurrentDraggedWidget("");
} else {
// For each item in the current page, a dragger should
// be created
DisplayedPageWidgetsModel * pageModel = displayedPagesModel->pageModel(currentPageIndex);
for (int i = 0; i < pageModel->rowCount(); i++) {
emit q->requestCreateDragger(pageModel->widget(i));
}
}
}
示例14: setFilterAnisotropy
void Material::setFilterAnisotropy( float anisotropy )
{
if( anisotropy > filterAnisotropyMaximum() )
anisotropy = filterAnisotropyMaximum();
else if( anisotropy < 1.0f )
anisotropy = 1.0f;
QHashIterator< QString, QWeakPointer<MaterialData> > mi( Material::cache() );
while( mi.hasNext() )
{
mi.next();
QSharedPointer<MaterialData> d = mi.value().toStrongRef();
if( d.isNull() )
continue;
QMapIterator<QString,GLuint> ti (d->textures());
while( ti.hasNext() )
{
ti.next();
glBindTexture( GL_TEXTURE_2D, ti.value() );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy );
}
}
sFilterAnisotropy = anisotropy;
}
示例15: exec
bool MSqlQuery::exec()
{
if (!m_db)
{
// Database structure's been deleted
return false;
}
if (m_last_prepared_query.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR,
"MSqlQuery::exec(void) called without a prepared query.");
return false;
}
#if DEBUG_RECONNECT
if (random() < RAND_MAX / 50)
{
LOG(VB_GENERAL, LOG_INFO,
"MSqlQuery disconnecting DB to test reconnection logic");
m_db->m_db.close();
}
#endif
// Database connection down. Try to restart it, give up if it's still
// down
if (!m_db->isOpen() && !Reconnect())
{
LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
return false;
}
QElapsedTimer timer;
timer.start();
bool result = QSqlQuery::exec();
qint64 elapsed = timer.elapsed();
// if the query failed with "MySQL server has gone away"
// Close and reopen the database connection and retry the query if it
// connects again
if (!result && QSqlQuery::lastError().number() == 2006 && Reconnect())
result = QSqlQuery::exec();
if (!result)
{
QString err = MythDB::GetError("MSqlQuery", *this);
MSqlBindings tmp = QSqlQuery::boundValues();
bool has_null_strings = false;
for (MSqlBindings::iterator it = tmp.begin(); it != tmp.end(); ++it)
{
if (it->type() != QVariant::String)
continue;
if (it->isNull() || it->toString().isNull())
{
has_null_strings = true;
*it = QVariant(QString(""));
}
}
if (has_null_strings)
{
bindValues(tmp);
timer.restart();
result = QSqlQuery::exec();
elapsed = timer.elapsed();
}
if (result)
{
LOG(VB_GENERAL, LOG_ERR,
QString("Original query failed, but resend with empty "
"strings in place of NULL strings worked. ") +
"\n" + err);
}
}
if (VERBOSE_LEVEL_CHECK(VB_DATABASE, LOG_INFO))
{
QString str = lastQuery();
// Database logging will cause an infinite loop here if not filtered
// out
if (!str.startsWith("INSERT INTO logging "))
{
// Sadly, neither executedQuery() nor lastQuery() display
// the values in bound queries against a MySQL5 database.
// So, replace the named placeholders with their values.
QMapIterator<QString, QVariant> b = boundValues();
while (b.hasNext())
{
b.next();
str.replace(b.key(), '\'' + b.value().toString() + '\'');
}
LOG(VB_DATABASE, LOG_INFO,
QString("MSqlQuery::exec(%1) %2%3%4")
.arg(m_db->MSqlDatabase::GetConnectionName()).arg(str)
.arg(QString(" <<<< Took %1ms").arg(QString::number(elapsed)))
.arg(isSelect() ? QString(", Returned %1 row(s)")
.arg(size()) : QString()));
//.........这里部分代码省略.........