本文整理汇总了C++中QMultiMap::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ QMultiMap::begin方法的具体用法?C++ QMultiMap::begin怎么用?C++ QMultiMap::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMultiMap
的用法示例。
在下文中一共展示了QMultiMap::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseHits
void parseHits(QXmlStreamReader & in, Task & task, const QString subtask)
{
QMultiMap<int, Task::Hit> sortedHits;
while(!in.atEnd()) {
QXmlStreamReader::TokenType token = in.readNext();
if (token == QXmlStreamReader::StartElement) {
QString elementName = in.name().toString();
if (0) {
} else if (elementName.compare("h", Qt::CaseInsensitive) == 0){
Task::Hit hit;
QXmlStreamAttributes attrs = in.attributes();
hit.timestamp = QDateTime::fromString(attrs.value("t").toString(), DATETIMEFORMAT);
hit.duration = attrs.value("d").toString().toUInt();
sortedHits.insertMulti(hit.timestamp.toTime_t(), hit);
}
} else if (token == QXmlStreamReader::EndElement && in.name().toString().compare("hits", Qt::CaseInsensitive) == 0) {
break;
}
}
// remove duplicates
QMultiMap<int, Task::Hit>::iterator itr = sortedHits.begin();
Task::Hit prev;
while(itr != sortedHits.end()) {
if (itr.value() == prev)
itr = sortedHits.erase(itr);
else {
prev = itr.value();
itr++;
}
}
task.hits[subtask] = sortedHits.values();
}
示例2: updateTrains
void MainApplication::updateTrains()
{
QDateTime currentDateTime = QDateTime::currentDateTime();
qDebug() << "update trains: current time:" << currentDateTime;
southboundTrainModel_->removeTrainsOlderThan(currentDateTime.time());
northboundTrainModel_->removeTrainsOlderThan(currentDateTime.time());
QDateTime endTime = currentDateTime.addSecs(90*60);
QMultiMap<QTime, Caltrains::Train> currentTrains = caltrains_.getTrainsByTime(currentDateTime, endTime);
QList<Caltrains::Train> northboundTrainsList;
QList<Caltrains::Train> southboundTrainsList;
QMultiMap<QTime, Caltrains::Train>::iterator i;
for (i = currentTrains.begin(); i != currentTrains.end(); ++i)
{
if (i.value().direction == Caltrains::North) {
northboundTrainsList.append(i.value());
}
else {
southboundTrainsList.append(i.value());
}
}
qDebug() << "update trains: south:" << southboundTrainsList;
qDebug() << "update trains: north:" << northboundTrainsList;
southboundTrainModel_->addCaltrains(southboundTrainsList);
northboundTrainModel_->addCaltrains(northboundTrainsList);
}
示例3: cleanResultList
void QgsSnapper::cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const
{
QgsPoint currentResultPoint;
QgsSnappingResult currentSnappingResult;
QList<double> keysToRemove;
QMultiMap<double, QgsSnappingResult>::iterator result_it = list.begin();
for ( ; result_it != list.end(); ++result_it )
{
currentSnappingResult = result_it.value();
if ( currentSnappingResult.snappedVertexNr != -1 )
{
currentResultPoint = currentSnappingResult.snappedVertex;
if ( excludeList.contains( currentResultPoint ) )
{
keysToRemove.push_back( result_it.key() );
}
}
}
QList<double>::const_iterator remove_it = keysToRemove.constBegin();
for ( ; remove_it != keysToRemove.constEnd(); ++remove_it )
{
list.remove( *remove_it );
}
}
示例4: moveSelectedVertexes
void QgsSelectedFeature::moveSelectedVertexes( QgsVector v )
{
int nUpdates = 0;
Q_FOREACH ( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nUpdates++;
}
if ( nUpdates == 0 )
return;
mVlayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
beginGeometryChange();
QMultiMap<double, QgsSnappingResult> currentResultList;
for ( int i = mVertexMap.size() - 1; i > -1 && nUpdates > 0; i-- )
{
QgsVertexEntry *entry = mVertexMap.value( i, nullptr );
if ( !entry || !entry->isSelected() )
continue;
if ( topologicalEditing )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( entry->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
}
// only last update should trigger the geometry update
// as vertex selection gets lost on the update
if ( --nUpdates == 0 )
endGeometryChange();
QgsPointV2 p = entry->point();
p.setX( p.x() + v.x() );
p.setY( p.y() + v.y() );
mVlayer->moveVertex( p, mFeatureId, i );
if ( topologicalEditing )
{
QMultiMap<double, QgsSnappingResult>::iterator resultIt = currentResultList.begin();
for ( ; resultIt != currentResultList.end(); ++resultIt )
{
// move all other
if ( mFeatureId != resultIt.value().snappedAtGeometry )
mVlayer->moveVertex( p, resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}
}
}
if ( nUpdates > 0 )
endGeometryChange();
mVlayer->endEditCommand();
}
示例5: enabled
void tst_QWebPluginDatabase::enabled()
{
QMultiMap<QString, QWebPluginInfo> pluginsMap;
QWebPluginDatabase* database = QWebSettings::pluginDatabase();
QList<QWebPluginInfo> plugins = database->plugins();
for (int i = 0; i < plugins.count(); ++i) {
QWebPluginInfo plugin = plugins.at(i);
QList<MimeType> mimeTypes = plugin.mimeTypes();
for (int j = 0; j < mimeTypes.count(); ++j) {
QString mimeType = mimeTypes.at(j).name;
pluginsMap.insert(mimeType, plugin);
QVERIFY(plugin.supportsMimeType(mimeType));
}
}
QMultiMap<QString, QWebPluginInfo>::iterator it = pluginsMap.begin();
while (it != pluginsMap.end()) {
QString mimeType = it.key();
QWebPluginInfo plugin = it.value();
QWebPluginInfo pluginForMimeType = database->pluginForMimeType(mimeType);
QVERIFY(pluginsMap.count(mimeType) > 0);
if (pluginsMap.count(mimeType) == 1) {
QCOMPARE(plugin, pluginForMimeType);
QVERIFY(plugin.isEnabled());
QVERIFY(pluginForMimeType.isEnabled());
plugin.setEnabled(false);
QVERIFY(!plugin.isEnabled());
QVERIFY(!pluginForMimeType.isEnabled());
} else {
QVERIFY(plugin.isEnabled());
QVERIFY(pluginForMimeType.isEnabled());
plugin.setEnabled(false);
QVERIFY(!plugin.isEnabled());
}
QVERIFY(!plugin.isNull());
QVERIFY(!pluginForMimeType.isNull());
QWebPluginInfo pluginForMimeType2 = database->pluginForMimeType(mimeType);
if (pluginsMap.count(mimeType) == 1) {
QVERIFY(pluginForMimeType2 != plugin);
QVERIFY(pluginForMimeType2.isNull());
} else {
QVERIFY(pluginForMimeType2 != plugin);
QVERIFY(!pluginForMimeType2.isNull());
}
plugin.setEnabled(true);
++it;
}
}
示例6: removeAllButThese
/**
* Removes all but the given properties from the combined properties
* collected so far.
*/
void RPropertyEditor::removeAllButThese(
const QMultiMap<QString, QString>& propertyTitles, bool customOnly) {
// iterate through all groups of properties (e.g. "Start Point", "End Point", ...):
QStringList removableGroups;
RPropertyGroupMap::iterator it;
for (it = combinedProperties.begin(); it != combinedProperties.end(); ++it) {
// iterate through all properties in the current group (e.g. "X", "Y"):
QStringList removableProperties;
RPropertyMap::iterator it2;
for (it2 = it.value().begin(); it2 != it.value().end(); ++it2) {
if (customOnly && !it2.value().second.getPropertyTypeId().isCustom()) {
continue;
}
bool keep = false;
// check if the current property is among the given properties
// we want to keep:
QMultiMap<QString, QString>::const_iterator it3;
for (it3 = propertyTitles.begin(); it3 != propertyTitles.end(); ++it3) {
if (it3.key() == it.key() && it3.value() == it2.key()) {
keep = true;
break;
}
}
if (keep == false) {
// schedule property for removal:
removableProperties.push_back(it2.key());
}
}
// remove all properties in the current group that are scheduled for removal:
QStringList::iterator it4;
for (it4 = removableProperties.begin(); it4
!= removableProperties.end(); ++it4) {
it.value().remove(*it4);
propertyOrder[it.key()].removeAll(*it4);
}
// schedule empty groups for removal:
if (it.value().empty()) {
removableGroups.push_back(it.key());
}
}
// remove all groups that are scheduled for removal:
QStringList::iterator it5;
for (it5 = removableGroups.begin(); it5 != removableGroups.end(); ++it5) {
combinedProperties.remove(*it5);
groupOrder.removeAll(*it5);
}
}
示例7: convertMapToString
QString SDBCache::convertMapToString(QMultiMap<uint, uint> &map){
QStringList tmp;
QMultiMap<uint,uint>::iterator it = map.begin();
while(it != map.end()){
tmp.append(QString::number(it.key()));
tmp.append(QString::number(it.value()));
it++;
}
return tmp.join(",");
}
示例8: updateDestination
void Transact::updateDestination()
{
// TODO: should be a Qt model.
ui->destination->clear();
ui->destination->addItem("(Create Contract)");
QMultiMap<QString, QString> in;
for (Address const& a: m_main->allKnownAddresses())
in.insert(QString::fromStdString(m_main->toName(a) + " (" + ICAP(a).encoded() + ")"), QString::fromStdString(a.hex()));
for (auto i = in.begin(); i != in.end(); ++i)
ui->destination->addItem(i.key(), i.value());
}
示例9: update
void EntityTreeWidget::update()
{
this->clear();
QMultiMap<QString, QString> entityCatalogue;
_entityModelHash = ModelsManager::getOrCreate()->getEntityModelHash();
QStringList availableEntities = ModelsManager::getOrCreate()->getAvailableEntities().keys();
foreach (NtgEntityModel entityModel, _entityModelHash)
{
if (entityModel.browsable && availableEntities.contains(entityModel.name))
{
entityCatalogue.insert(entityModel.category,entityModel.name);
}
}
QTreeWidgetItem * categoryItem = NULL;
EntityTreeWidgetItem * entityItem = NULL;
QList<QTreeWidgetItem *> treeWidgetList;
QMultiMap<QString, QString>::iterator i = entityCatalogue.begin();
while (i != entityCatalogue.end())
{
QString categoryName = i.key();
QString entityName = i.value();
treeWidgetList = findItems(categoryName,Qt::MatchExactly,0);
if (treeWidgetList.size() == 0)
{
categoryItem = new QTreeWidgetItem(this);
categoryItem->setText(0,categoryName);
}
else
{
categoryItem = treeWidgetList.at(0);
}
entityItem = new EntityTreeWidgetItem(categoryItem);
QString uuidName = entityName.toLower().simplified().replace(" ","");
entityItem->setText(0, _entityModelHash.value(entityName).longName);
entityItem->setText(1, entityName);
QPixmap pixmap;
pixmap.loadFromData(_entityModelHash.value(entityName).imagePNG,"PNG");
entityItem->setIcon(0, QIcon(pixmap));
++i;
}
sortItems (0, Qt::AscendingOrder);
expandAll();
}
示例10: toClean
DailyCleaning DirtiestCleaner::toClean(QDate date, const FacilityState &state)
{
QMultiMap<double,unsigned int> loops;
for(unsigned int loop=0;loop<state.getFacility().loopNumber;loop++)
loops.insert(state.getCleanliness(loop),loop);
DailyCleaning toReturn;
unsigned int day=loopsperday, night=loopspernight;
for(auto loop=loops.begin();loop!=loops.end();loop++){
if(day){toReturn.dayTruck.append(loop.value()); day--;}
else if(night){toReturn.nightTruck.append(loop.value()); night--;}
else break;
}
return toReturn;
}
示例11: QDialog
CreateIndexDialog::CreateIndexDialog(DBBrowserDB* db, QWidget* parent)
: QDialog(parent),
pdb(db),
ui(new Ui::CreateIndexDialog)
{
// Create UI
ui->setupUi(this);
// Get list of tables, sort it alphabetically and fill the combobox
QMultiMap<QString, DBBrowserObject> dbobjs;
QList<DBBrowserObject> tables = pdb->objMap.values("table");
for(QList<DBBrowserObject>::ConstIterator it=tables.begin();it!=tables.end();++it)
dbobjs.insert((*it).getname(), (*it));
for(QMultiMap<QString, DBBrowserObject>::ConstIterator it=dbobjs.begin(); it != dbobjs.end(); ++it)
ui->comboTableName->addItem(QIcon(QString(":icons/table")), (*it).getname());
}
示例12: parseRuleReferences
bool AbstractRuleBinder::parseRuleReferences(QString& strRule)
{
QMultiMap<size_t, QMap<size_t,size_t> > mapLookups;
if (!ruleCheckerPtr->parseRule(strRule,mapLookups)) return false;
if (mapLookups.size()>0){
QMultiMap<size_t, QMap<size_t,size_t> >::iterator j = mapLookups.begin();
while (j != mapLookups.end()) {
QString strResult;
size_t field=j.value().begin().value();
size_t mapper=j.value().begin().key();
QVariant var=getVal(field,mapper);
if (var.type()==QVariant::Invalid) return false;
if (var.type()==QVariant::String) strResult=tr("'") + var.toString() + tr("'");
else strResult=var.toString();
QString searchStr=StrRulePtr + tr("(") + QVariant(j.key()).toString() + tr(")");
strRule=strRule.replace(searchStr,
strResult);
++j;
}
}
//search for references to the current sample
QMap<QString, QString> mapSample;
if (!parseSample(strRule,mapSample)) return false;
QMap<QString, QString>::iterator j = mapSample.begin();
while (j != mapSample.end()) {
QString searchStr=StrRuleSample + tr("(") + QVariant(j.key()).toString() + tr(")");
strRule=strRule.replace(searchStr,
j.value());
//qDebug() << strRule << endl;
++j;
}
return true;
}
示例13: writeToGui
void multipleCheckDialog::writeToGui()
{
QMultiMap<QString,contactWidgetFastBook*> fastList;
QString filter = ui->lineEdit->text();
for (libJackSMS::dataTypes::phoneBookType::const_iterator i = rubrica.begin(); i != rubrica.end(); ++i) {
//Controllo che non sia già presente nella lista destinatari
if (!padre->isInRecipients(i.value().getPhone()))
{
if (i->getName().contains(filter, Qt::CaseInsensitive))
{
QIcon ico;
libJackSMS::dataTypes::configuredServicesType::const_iterator x = elencoServiziConfigurati.find(i->getAccount());
if (x == elencoServiziConfigurati.end())
{
ico = QIcon(":/resource/ico_contact.png");
}
else
{
QString serv = x.value().getService();
libJackSMS::dataTypes::servicesType::const_iterator tmp = elencoServizi.find(serv);
ico = tmp->getIcon();
}
contactWidgetFastBook *ww = new contactWidgetFastBook(i.value(), ico.pixmap(16,16), true);
fastList.insert(i->getName().toUpper(), ww);
}
}
}
if (fastList.size() > 0)
{
for (QMultiMap<QString,contactWidgetFastBook*>::ConstIterator xx = fastList.begin(); xx != fastList.end(); ++xx)
{
QListWidgetItem *item = new QListWidgetItem;
item->setSizeHint(xx.value()->size());
ui->listWidget->addItem(item);
ui->listWidget->setItemWidget(item, xx.value());
}
}
}
示例14: snappedOffsetForLines
double Snapper::snappedOffsetForLines(const SnapLineMap &snappingLineMap,
double value) const
{
QMultiMap<double, double> minimumSnappingLineMap;
SnapLineMapIterator snappingLineIterator(snappingLineMap);
while (snappingLineIterator.hasNext()) {
snappingLineIterator.next();
double snapLine = snappingLineIterator.key();
double offset = value - snapLine;
double distance = qAbs(offset);
if (distance < snappingDistance())
minimumSnappingLineMap.insert(distance, offset);
}
if (!minimumSnappingLineMap.isEmpty())
return minimumSnappingLineMap.begin().value();
return std::numeric_limits<double>::max();
}
示例15: snappedOffsetForOffsetLines
double Snapper::snappedOffsetForOffsetLines(const SnapLineMap &snappingOffsetMap,
Qt::Orientation orientation,
double value,
double lowerLimit,
double upperLimit) const
{
QMultiMap<double, double> minimumSnappingLineMap;
SnapLineMapIterator snappingOffsetIterator(snappingOffsetMap);
while (snappingOffsetIterator.hasNext()) {
snappingOffsetIterator.next();
double snapLine = snappingOffsetIterator.key();
const QRectF &formEditorItemRect(snappingOffsetIterator.value().first);
double formEditorItemRectLowerLimit;
double formEditorItemRectUpperLimit;
if (orientation == Qt::Horizontal) {
formEditorItemRectLowerLimit = formEditorItemRect.left();
formEditorItemRectUpperLimit = formEditorItemRect.right();
} else {
formEditorItemRectLowerLimit = formEditorItemRect.top();
formEditorItemRectUpperLimit = formEditorItemRect.bottom();
}
double offset = value - snapLine;
double distance = qAbs(offset);
if (distance < snappingDistance() &&
!(lowerLimit > formEditorItemRectUpperLimit ||
upperLimit < formEditorItemRectLowerLimit)) {
minimumSnappingLineMap.insert(distance, offset);
}
}
if (!minimumSnappingLineMap.isEmpty()) {
return minimumSnappingLineMap.begin().value();
}
return std::numeric_limits<double>::max();
}