本文整理汇总了C++中QMultiHash::values方法的典型用法代码示例。如果您正苦于以下问题:C++ QMultiHash::values方法的具体用法?C++ QMultiHash::values怎么用?C++ QMultiHash::values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMultiHash
的用法示例。
在下文中一共展示了QMultiHash::values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSuffixesList
QStringList createSuffixesList()
{
QStringList list;
list.append( PartOfSpeechCategories.values( suffix ) );
list.append( PartOfSpeechCategories.values( nounSuffix ) );
return list;
}
示例2: createExpressionsList
QStringList createExpressionsList()
{
QStringList list;
list.append( PartOfSpeechCategories.values( expression ) );
list.append( PartOfSpeechCategories.values( idiomaticExpression ) );
return list;
}
示例3: qt_metacall
int QxtRPCServiceIntrospector::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
// Qt's signal dispatch mechanism invokes qt_metacall for each slot connected to the object.
// The metacall protocol expects slots to be checked from the bottom up, starting with QObject and proceeding to
// the more derived classes. qt_metacall returns a negative number to indicate that the request was processed or a
// positive number to indicate the greatest method ID that was checked. moc-generated qt_metacall implementations
// subtract the return value from _id so that slots on a given class can be counted starting at 0, allowing the
// subclasses to add new signals or slots without breaking compatibility. QxtRPCService doesn't need this because
// it just asks its base class how many methods it has before adding slots.
if(QObject::qt_metacall(_c, _id, _a) < 0)
return _id;
// qt_metacall is also used for other behaviors besides just invoking methods; we don't implement any of these, so
// we just return here.
if(_c != QMetaObject::InvokeMetaMethod)
return _id;
// Construct an array of QVariants based on the parameters passed through _a.
QVariant v[8];
const QList<int>& types = signalParameters.at(idToParams.value(_id));
int ct = types.count();
for(int i = 0; i < ct; i++) {
// The qt_metacall implementation is expected to already know the data types in _a, so that's why we tracked it.
v[i] = QVariant(types.at(i), _a[i+1]);
}
foreach(const QString& rpcName, idToRpc.values(_id)) {
// Invoke each RPC message connected to the requested dynamic slot ID.
rpc->call(rpcName, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
}
// Inform the calling function that we handled the call.
return -1;
}
示例4: addProject
bool ProjectCollection::addProject(const QString& name, const QString& author, const QString& description, const QMultiHash<int, QString> & users)
{
if (!k->db->exists(name)) {
if (!k->projects.contains(name)) {
QMultiHash<SProject::UserType, QString> newusers;
foreach (int type, users.uniqueKeys()) {
foreach (QString login, users.values(type))
newusers.insert( SProject::UserType(type), login);
}
if (newusers.values(SProject::Owner).empty())
return false;
SProject *project = new SProject( kAppProp->cacheDir() +"/"+ k->db->nextFileName());
project->setProjectName(name);
project->setAuthor(author);
project->setDescription(description);
bool okAddProject = false;
project->setUsers(newusers);
bool okSaveProject = project->save();
if (okSaveProject)
okAddProject = k->db->addProject(project);
delete project;
return okAddProject;
}
}
示例5:
// Return the current class info list.
QList<ClassInfo> qpycore_get_class_info_list()
{
PyFrameObject *frame = PyEval_GetFrame();
QList<ClassInfo> class_info_list = class_info_hash.values(frame);
class_info_hash.remove(frame);
return class_info_list;
}
示例6: createVerbsList
QStringList createVerbsList()
{
QStringList list;
list.append( PartOfSpeechCategories.values( verb ) );
list.append( IchidanVerbs );
list.append( GodanVerbs );
list.append( FukisokuVerbs );
return list;
}
示例7: menuSessionsAboutToShow
void MainWindow::menuSessionsAboutToShow()
{
if (m_sessionsGroup)
{
m_sessionsGroup->deleteLater();
QAction *saveSessionAction = m_ui->menuSessions->actions().at(0);
saveSessionAction->setParent(this);
QAction *manageSessionsAction = m_ui->menuSessions->actions().at(1);
manageSessionsAction->setParent(this);
m_ui->menuSessions->clear();
m_ui->menuSessions->addAction(saveSessionAction);
m_ui->menuSessions->addAction(manageSessionsAction);
m_ui->menuSessions->addSeparator();
}
m_sessionsGroup = new QActionGroup(this);
m_sessionsGroup->setExclusive(true);
const QStringList sessions = SessionsManager::getSessions();
QMultiHash<QString, SessionInformation> information;
for (int i = 0; i < sessions.count(); ++i)
{
const SessionInformation session = SessionsManager::getSession(sessions.at(i));
information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
}
const QList<SessionInformation> sorted = information.values();
const QString currentSession = SessionsManager::getCurrentSession();
for (int i = 0; i < sorted.count(); ++i)
{
int windows = 0;
for (int j = 0; j < sorted.at(i).windows.count(); ++j)
{
windows += sorted.at(i).windows.at(j).windows.count();
}
QAction *action = m_ui->menuSessions->addAction(tr("%1 (%n tab(s))", "", windows).arg(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : QString(sorted.at(i).title).replace(QLatin1Char('&'), QLatin1String("&&"))));
action->setData(sorted.at(i).path);
action->setCheckable(true);
action->setChecked(sorted.at(i).path == currentSession);
m_sessionsGroup->addAction(action);
}
}
示例8: Dialog
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
m_ui(new Ui::SessionsManagerDialog)
{
m_ui->setupUi(this);
m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(QLatin1String("Sessions/OpenInExistingWindow")).toBool());
const QStringList sessions = SessionsManager::getSessions();
QMultiHash<QString, SessionInformation> information;
for (int i = 0; i < sessions.count(); ++i)
{
const SessionInformation session = SessionsManager::getSession(sessions.at(i));
information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
}
const QList<SessionInformation> sorted = information.values();
const QString currentSession = SessionsManager::getCurrentSession();
int index = 0;
m_ui->sessionsWidget->setRowCount(sorted.count());
for (int i = 0; i < sorted.count(); ++i)
{
int windows = 0;
for (int j = 0; j < sorted.at(i).windows.count(); ++j)
{
windows += sorted.at(i).windows.at(j).windows.count();
}
if (sorted.at(i).path == currentSession)
{
index = i;
}
m_ui->sessionsWidget->setItem(i, 0, new QTableWidgetItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title));
m_ui->sessionsWidget->setItem(i, 1, new QTableWidgetItem(sorted.at(i).path));
m_ui->sessionsWidget->setItem(i, 2, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(sorted.at(i).windows.count()).arg(windows)));
}
connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
connect(m_ui->sessionsWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentChanged(int)));
m_ui->sessionsWidget->setCurrentCell(index, 0);
}
示例9: foreach
QList<Action *> Menu::findActions(const QMultiHash<int, QVariant> AData, bool ASearchInSubMenu /*= false*/) const
{
QList<Action *> actionList;
QList<int> keys = AData.keys();
foreach(Action *action,FActions)
{
foreach (int key, keys)
{
if (AData.values(key).contains(action->data(key)))
{
actionList.append(action);
break;
}
}
if (ASearchInSubMenu && action->menu())
actionList += action->menu()->findActions(AData,ASearchInSubMenu);
}
示例10: QDialog
MergeConfirmationDialog::MergeConfirmationDialog(DatabaseManager* dbm, const QList<long long>& BIDs,
OutParams* outParams, QWidget* parent) :
QDialog(parent), ui(new Ui::MergeConfirmationDialog), dbm(dbm),
canShowTheDialog(false), outParams(outParams)
{
ui->setupUi(this);
QStringList bookmarkNames;
QMultiHash<long long, QString> bookmarkURLs;
canShowTheDialog = dbm->bms.RetrieveBookmarkNames(BIDs, bookmarkNames);
if (!canShowTheDialog)
return;
canShowTheDialog = dbm->bms.RetrieveBookmarkFullURLs(BIDs, bookmarkURLs);
if (!canShowTheDialog)
return;
radioContext = new RichRadioButtonContext();
for (int i = 0; i < BIDs.count(); i++)
{
long long BID = BIDs[i];
//Create formatted URLs for display.
//Reverse the urls to get the original order, as QMultiHash docs say:
// "The items that share the same key are available from most recently to least recently inserted."
QStringList urls = bookmarkURLs.values(BID);
std::reverse(urls.begin(), urls.end());
QString urlsSeparated = "";
const QString sep = "";
foreach (const QString& url, urls)
urlsSeparated += "<li style=\"color: blue;\">" + Util::FullyPercentDecodedUrl(url).toHtmlEscaped() + "</li>" + sep;
urlsSeparated.chop(sep.length());
QString radioText = QString("<strong>%1</strong>\n<ul>%2</ul>").arg(bookmarkNames[i], urlsSeparated);
RichRadioButton* bmRadio = new RichRadioButton(radioText, BID, (i == 0), radioContext);
ui->mainVerticalLayout->insertWidget(ui->mainVerticalLayout->count() -2, bmRadio);
}
}
示例11: onContactsFetched
void PersonsModel::onContactsFetched()
{
Q_D(PersonsModel);
KABC::Addressee::Map addresseeMap;
//fetch all already loaded contacts from plugins
Q_FOREACH (const AllContactsMonitorPtr &contactWatcher, d->m_sourceMonitors) {
addresseeMap.unite(contactWatcher->contacts());
}
//add metacontacts
QMultiHash<QString, QString> contactMapping = PersonManager::instance()->allPersons();
Q_FOREACH (const QString &key, contactMapping.uniqueKeys()) {
KABC::Addressee::Map contacts;
Q_FOREACH (const QString &contact, contactMapping.values(key)) {
d->contactToPersons[contact] = key;
if (addresseeMap.contains(contact)) {
contacts[contact] = addresseeMap.take(contact);
}
}
if (!contacts.isEmpty()) {
addPerson(MetaContact(key, contacts));
}
}
//add remaining contacts
KABC::Addressee::Map::const_iterator i;
for (i = addresseeMap.constBegin(); i != addresseeMap.constEnd(); ++i) {
addPerson(MetaContact(i.key(), i.value()));
}
Q_FOREACH(const AllContactsMonitorPtr monitor, d->m_sourceMonitors) {
connect(monitor.data(), SIGNAL(contactAdded(QString,KABC::Addressee)), SLOT(onContactAdded(QString,KABC::Addressee)));
connect(monitor.data(), SIGNAL(contactChanged(QString,KABC::Addressee)), SLOT(onContactChanged(QString,KABC::Addressee)));
connect(monitor.data(), SIGNAL(contactRemoved(QString)), SLOT(onContactRemoved(QString)));
}
}
示例12: main
int main()
{
QSet<QString *> s;
qDeleteAll(s);
qDeleteAll(s.begin(), s.end());
qDeleteAll(s.values()); // warning
QHash<int, QString *> h;
qDeleteAll(h);
qDeleteAll(h.begin(), h.end());
qDeleteAll(h.values()); // warning
QMap<int*, QString *> m;
qDeleteAll(m);
qDeleteAll(m.begin(), m.end());
qDeleteAll(m.values()); // warning
QMultiHash<int, QString *> mh;
qDeleteAll(mh);
qDeleteAll(mh.begin(), mh.end());
qDeleteAll(mh.values()); // warning
QMultiMap<int, QString *> mm;
qDeleteAll(mm);
qDeleteAll(mm.begin(), mm.end());
qDeleteAll(mm.values()); // warning
qDeleteAll(values()); // ok
Foo foo;
qDeleteAll(foo.values()); // ok
qDeleteAll(foo.doSomethingWithValues(h.values())); // ok
qDeleteAll(m.keys()); // warning
qDeleteAll(keys()); // ok
qDeleteAll(h.values(1)); // warning
}
示例13: ParseDirectoryFinished
void IcecastService::ParseDirectoryFinished(
QFuture<IcecastBackend::StationList> future) {
IcecastBackend::StationList all_stations = future.result();
sort(all_stations.begin(), all_stations.end(),
StationSorter<IcecastBackend::Station>());
// Remove duplicates by name. These tend to be multiple URLs for the same
// station.
IcecastBackend::StationList::iterator it =
unique(all_stations.begin(), all_stations.end(),
StationEquality<IcecastBackend::Station>());
all_stations.erase(it, all_stations.end());
// Cluster stations by genre.
QMultiHash<QString, IcecastBackend::Station*> genres;
// Add stations.
for (int i = 0; i < all_stations.count(); ++i) {
IcecastBackend::Station& s = all_stations[i];
genres.insert(s.genre, &s);
}
QSet<QString> genre_set = genres.keys().toSet();
// Merge genres with only 1 or 2 stations into "Other".
for (const QString& genre : genre_set) {
if (genres.count(genre) < 3) {
const QList<IcecastBackend::Station*>& small_genre = genres.values(genre);
for (IcecastBackend::Station* s : small_genre) {
s->genre = "Other";
}
}
}
backend_->ClearAndAddStations(all_stations);
app_->task_manager()->SetTaskFinished(load_directory_task_id_);
load_directory_task_id_ = 0;
}
示例14: eventLayer
bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
{
if ( !lineLayer || !eventLayer || !lineLayer->isValid() || !eventLayer->isValid() )
{
return false;
}
//create line field / id map for line layer
QMultiHash< QString, QgsFeature > lineLayerIdMap; //1:n possible (e.g. several linear reference geometries for one feature in the event layer)
QgsFeatureIterator fit = lineLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << lineField ) );
QgsFeature fet;
while ( fit.nextFeature( fet ) )
{
lineLayerIdMap.insert( fet.attribute( lineField ).toString(), fet );
}
//create output datasource or attributes in memory provider
QgsVectorFileWriter* fileWriter = nullptr;
QgsFeatureList memoryProviderFeatures;
if ( !memoryProvider )
{
QgsWkbTypes::Type memoryProviderType = QgsWkbTypes::MultiLineString;
if ( locationField2 == -1 )
{
memoryProviderType = forceSingleGeometry ? QgsWkbTypes::Point : QgsWkbTypes::MultiPoint;
}
else
{
memoryProviderType = forceSingleGeometry ? QgsWkbTypes::LineString : QgsWkbTypes::MultiLineString;
}
fileWriter = new QgsVectorFileWriter( outputLayer,
eventLayer->dataProvider()->encoding(),
eventLayer->fields(),
memoryProviderType,
lineLayer->crs(),
outputFormat );
}
else
{
memoryProvider->addAttributes( eventLayer->fields().toList() );
}
//iterate over eventLayer and write new features to output file or layer
fit = eventLayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ) );
QgsGeometry lrsGeom;
double measure1, measure2 = 0.0;
int nEventFeatures = eventLayer->featureCount();
int featureCounter = 0;
int nOutputFeatures = 0; //number of output features for the current event feature
if ( p )
{
p->setWindowModality( Qt::WindowModal );
p->setMinimum( 0 );
p->setMaximum( nEventFeatures );
p->show();
}
while ( fit.nextFeature( fet ) )
{
nOutputFeatures = 0;
//update progress dialog
if ( p )
{
if ( p->wasCanceled() )
{
break;
}
p->setValue( featureCounter );
++featureCounter;
}
measure1 = fet.attribute( locationField1 ).toDouble();
if ( locationField2 != -1 )
{
measure2 = fet.attribute( locationField2 ).toDouble();
if ( qgsDoubleNear(( measure2 - measure1 ), 0.0 ) )
{
continue;
}
}
QList<QgsFeature> featureIdList = lineLayerIdMap.values( fet.attribute( eventField ).toString() );
QList<QgsFeature>::iterator featureIdIt = featureIdList.begin();
for ( ; featureIdIt != featureIdList.end(); ++featureIdIt )
{
if ( locationField2 == -1 )
{
lrsGeom = locateAlongMeasure( measure1, featureIdIt->geometry() );
}
else
{
lrsGeom = locateBetweenMeasures( measure1, measure2, featureIdIt->geometry() );
}
if ( !lrsGeom.isEmpty() )
{
//.........这里部分代码省略.........
示例15: Preprocess
bool UnicodeTournamentTrie::Preprocess( IImporter* importer, QString dir )
{
QString filename = fileInDirectory( dir, "Unicode Tournament Trie" );
QFile subTrieFile( filename + "_sub" );
QFile wayFile( filename + "_ways" );
if ( !openQFile( &subTrieFile, QIODevice::WriteOnly ) )
return false;
if ( !openQFile( &wayFile, QIODevice::WriteOnly ) )
return false;
std::vector< IImporter::Place > inputPlaces;
std::vector< IImporter::Address > inputAddress;
std::vector< UnsignedCoordinate > inputWayBuffer;
std::vector< QString > inputWayNames;
if ( !importer->GetAddressData( &inputPlaces, &inputAddress, &inputWayBuffer, &inputWayNames ) )
return false;
Timer time;
std::sort( inputAddress.begin(), inputAddress.end() );
qDebug() << "Unicode Tournament Trie: sorted addresses by importance:" << time.restart() << "ms";
std::vector< UnsignedCoordinate > wayBuffer;
std::vector< utt::Node > trie( 1 );
unsigned address = 0;
// build address name index
QMultiHash< unsigned, unsigned > addressByName;
for ( ; address < inputAddress.size(); address++ ) {
addressByName.insert( inputAddress[address].name, address );
}
// compute way lengths
QList< unsigned > uniqueNames = addressByName.uniqueKeys();
std::vector< std::pair< double, unsigned > > wayLengths;
for ( unsigned name = 0; name < ( unsigned ) uniqueNames.size(); name++ ) {
QList< unsigned > segments = addressByName.values( uniqueNames[name] );
double distance = 0;
for( unsigned segment = 0; segment < ( unsigned ) segments.size(); segment++ ) {
const IImporter::Address segmentAddress = inputAddress[segment];
for ( unsigned coord = 1; coord < segmentAddress.pathLength; ++coord ) {
GPSCoordinate sourceGPS = inputWayBuffer[segmentAddress.pathID + coord - 1].ToProjectedCoordinate().ToGPSCoordinate();
GPSCoordinate targetGPS = inputWayBuffer[segmentAddress.pathID + coord].ToProjectedCoordinate().ToGPSCoordinate();
distance += sourceGPS.ApproximateDistance( targetGPS );
}
}
wayLengths.push_back( std::pair< double, unsigned >( distance, name ) );
}
// sort ways by aggregate lengths
std::sort( wayLengths.begin(), wayLengths.end() );
std::vector< unsigned > wayImportance( uniqueNames.size() );
for ( unsigned way = 0; way < wayLengths.size(); way++ )
wayImportance[wayLengths[way].second] = way;
wayLengths.clear();
std::vector< utt::Node > subTrie( 1 );
for ( unsigned name = 0; name < ( unsigned ) uniqueNames.size(); name++ ) {
QList< unsigned > segments = addressByName.values( uniqueNames[name] );
// build edge connector data structures
std::vector< EdgeConnector< UnsignedCoordinate>::Edge > connectorEdges;
std::vector< unsigned > resultSegments;
std::vector< unsigned > resultSegmentDescriptions;
std::vector< bool > resultReversed;
for ( unsigned segment = 0; segment < ( unsigned ) segments.size(); segment++ ) {
const IImporter::Address& segmentAddress = inputAddress[segments[segment]];
EdgeConnector< UnsignedCoordinate >::Edge newEdge;
newEdge.source = inputWayBuffer[segmentAddress.pathID];
newEdge.target = inputWayBuffer[segmentAddress.pathID + segmentAddress.pathLength - 1];
newEdge.reverseable = true;
connectorEdges.push_back( newEdge );
}
EdgeConnector< UnsignedCoordinate >::run( &resultSegments, &resultSegmentDescriptions, &resultReversed, connectorEdges );
// string places with the same name together
unsigned nextID = 0;
for ( unsigned segment = 0; segment < resultSegments.size(); segment++ ) {
utt::Data subEntry;
subEntry.start = wayBuffer.size();
for ( unsigned description = 0; description < resultSegments[segment]; description++ ) {
unsigned segmentID = resultSegmentDescriptions[nextID + description];
const IImporter::Address& segmentAddress = inputAddress[segments[segmentID]];
std::vector< UnsignedCoordinate > path;
for ( unsigned pathID = 0; pathID < segmentAddress.pathLength; pathID++ )
path.push_back( inputWayBuffer[pathID + segmentAddress.pathID]);
if ( resultReversed[segmentID] )
std::reverse( path.begin(), path.end() );
int skipFirst = description == 0 ? 0 : 1;
assert( skipFirst == 0 || wayBuffer.back() == path.front() );
wayBuffer.insert( wayBuffer.end(), path.begin() + skipFirst, path.end() );
}
utt::PlaceData placeData;
//.........这里部分代码省略.........