本文整理汇总了C++中QMapIterator类的典型用法代码示例。如果您正苦于以下问题:C++ QMapIterator类的具体用法?C++ QMapIterator怎么用?C++ QMapIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMapIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canvasMap
int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)
{
QwtScaleMap map[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
map[axis] = canvasMap(axis);
double dmin = 1.0e10;
int key = -1;
for (QMapIterator<int, QwtPlotCurve *> it = d_curves.begin(); it != d_curves.end(); ++it )
{
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
if (!c)
continue;
for (int i=0; i<c->dataSize(); i++)
{
double cx = map[c->xAxis()].xTransform(c->x(i)) - double(xpos);
double cy = map[c->yAxis()].xTransform(c->y(i)) - double(ypos);
double f = qwtSqr(cx) + qwtSqr(cy);
if (f < dmin)
{
dmin = f;
key = it.key();
point = i;
}
}
}
dist = int(sqrt(dmin));
return key;
}
示例2: if
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');
}
}
}
}
示例3: Anchor
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;
}
}
示例4: boundingRect
QwtDoubleRect Plot::boundingRect ()
{
QMapIterator<int, QwtPlotCurve *> it = d_curves.begin();
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
double minX = c->minXValue();
double minY = c->minYValue();
double maxX = c->maxXValue();
double maxY = c->maxYValue();
it++;
for (it; it != d_curves.end(); ++it)
{
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
if (!c)
continue;
minX = (c->minXValue() < minX) ? c->minXValue() : minX;
maxX = (c->maxXValue() > maxX) ? c->maxXValue() : maxX;
minY = (c->minYValue() < minY) ? c->minYValue() : minY;
maxY = (c->maxYValue() > maxY) ? c->maxYValue() : maxY;
}
QwtDoubleRect r;
r.setLeft(minX);
r.setRight(maxX);
r.setTop(minY);
r.setBottom(maxY);
return r;
}
示例5: cl
void ReportWindow::colorList() {
//
// ADD CODE HERE TO CHECK FOR CHANGES TO DOCUMENT
//
QMap<QString, QColor> cm = _colorMap;
ColorList cl(this);
cl.init(&_colorMap);
cl.exec();
if(cm.count() == _colorMap.count()) {
// the two lists have the same number of items so
// we will have to check each item for equality
// to see if a change was made
QMapIterator<QString, QColor> cit;
for(cit = cm.begin(); cit != cm.end(); ++cit) {
if(!_colorMap.contains(cit.key()) || _colorMap[cit.key()] != cm[cit.key()]) {
setModified(TRUE);
break;
}
}
} else {
// they don't have the same number of items
// so we can just assume the list was changed
setModified(TRUE);
}
}
示例6: lit
//---------------------------------------------------------------------------
// 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));
}
示例7: regExp
qReal::IdList Repository::elementsByPropertyContent(const QString &propertyValue, bool sensitivity
, bool regExpression) const
{
const Qt::CaseSensitivity caseSensitivity = sensitivity ? Qt::CaseSensitive : Qt::CaseInsensitive;
const QRegExp regExp(propertyValue, caseSensitivity);
IdList result;
for (Object * const element : mObjects.values()) {
QMapIterator<QString, QVariant> iterator = element->propertiesIterator();
if (regExpression) {
while (iterator.hasNext()) {
if (iterator.next().value().toString().contains(regExp)) {
result.append(mObjects.key(element));
break;
}
}
} else {
while (iterator.hasNext()) {
if (iterator.next().value().toString().contains(propertyValue, caseSensitivity)) {
result.append(mObjects.key(element));
break;
}
}
}
}
return result;
}
示例8: 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();
}
}
示例9: drawPoints
bool tGraph::drawPoints() {
//return _drawPoints;
QMapIterator<int, ORStyleData> mit = _setStyle.begin();
for( ; mit != _setStyle.end(); ++mit) {
if(mit.data().point) return TRUE;
}
return FALSE;
}
示例10: clear
void DraggerManagerPrivate::clear()
{
QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
QMapIterator<WidgetProperties *, QDeclarativeItem *>(draggers);
while (iterator.hasNext()) {
iterator.next();
iterator.value()->deleteLater();
}
draggers.clear();
}
示例11: Q_D
void DraggerManager::disableDraggers()
{
Q_D(DraggerManager);
QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
QMapIterator<WidgetProperties *, QDeclarativeItem *>(d->draggers);
while (iterator.hasNext()) {
iterator.next();
iterator.value()->setVisible(false);
}
}
示例12: SQLQuery
/**
\param val
**/
void BlSearchWidget::setFieldValue ( QString campo, QString val )
{
BL_FUNC_DEBUG
BlDebug::blDebug ( "BlSearchWidget::setcifprofesor", 0, val );
QString SQLQuery("");
SQLQuery = "SELECT * FROM " + m_tabla + " WHERE " + campo + " = $1";
BlDbRecordSet *cur = mainCompany() ->load ( SQLQuery, val );
if ( !cur->eof() ) {
/// Inicializamos los valores de vuelta a ""
QMapIterator<QString, QString> i ( m_valores );
while ( i.hasNext() ) {
i.next();
m_valores.insert ( i.key(), cur->value( i.key() ) );
} // end while
} else {
/// Inicializamos los valores de vuelta a ""
QMapIterator<QString, QString> i ( m_valores );
while ( i.hasNext() ) {
i.next();
m_valores.insert ( i.key(), "" );
} // end while
} // end if
delete cur;
pinta();
}
示例13: LOG
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;
}
示例14: usedValues
/*!
Lists values used during initialization
*/
QStringList TEIniFile::usedValues()
{
QStringList sl;
QMapIterator<QString, type_ValueList> it;
for(it=SectionListDef.begin();it!=SectionListDef.end();++it)
{
type_ValueListIterator it1;
for(it1=(*it).begin();it1!=(*it).end();++it1)
sl << it.key()+"->"+it1.key();
}
return sl;
}
示例15: i18n
void
QueueManager::addQueuedItem( PlaylistItem *item )
{
Playlist *pl = Playlist::instance();
if( !pl ) return; //should never happen
const int index = pl->m_nextTracks.findRef( item );
QListViewItem *after;
if( !index ) after = 0;
else
{
int find = m_listview->childCount();
if( index - 1 <= find )
find = index - 1;
after = m_listview->itemAtIndex( find );
}
QValueList<PlaylistItem*> current = m_map.values();
QValueListIterator<PlaylistItem*> newItem = current.find( item );
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
if( newItem == current.end() ) //avoid duplication
{
after = new QueueItem( m_listview, after, title );
m_map[ after ] = item;
}
else //track is in the queue, remove it.
{
QListViewItem *removableItem = m_listview->findItem( title, 0 );
if( removableItem )
{
//Remove the key from the map, so we can re-queue the item
QMapIterator<QListViewItem*, PlaylistItem*> end( m_map.end() );
for( QMapIterator<QListViewItem*, PlaylistItem*> it = m_map.begin(); it != end; ++it )
{
if( it.data() == item )
{
m_map.remove( it );
//Remove the item from the queuelist
m_listview->takeItem( removableItem );
delete removableItem;
return;
}
}
}
}
}