本文整理汇总了C++中QMultiHash类的典型用法代码示例。如果您正苦于以下问题:C++ QMultiHash类的具体用法?C++ QMultiHash怎么用?C++ QMultiHash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMultiHash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WRITE_TRACE
void CDspVmAutoTaskManagerBase::Init()
{
WRITE_TRACE( DBG_DEBUG, "Initializing %s manager", getManagerName() );
QMultiHash<QString , SmartPtr<CVmConfiguration> > hashAllVms
= CDspService::instance()->getVmDirHelper().getAllVmList();
QMultiHash<QString , SmartPtr<CVmConfiguration> >::iterator it;
for(it = hashAllVms.begin(); it != hashAllVms.end(); ++it)
{
SmartPtr<CVmConfiguration> pVmConfig = it.value();
PRL_ASSERT(pVmConfig);
if (isEnabled(pVmConfig, true))
{
PRL_RESULT res = tryToRegisterVm(pVmConfig, it.key());
if (PRL_FAILED(res))
WRITE_TRACE(DBG_FATAL,
"Can't register VM %s in Auto-task Manager during starting dispetcher."
"Error: 0x%x, (%s).",
QSTR2UTF8(pVmConfig->getVmIdentification()->getVmUuid()),
res, PRL_RESULT_TO_STRING(res) );
}
}
m_bInitialized = true;
}
示例2: 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;
}
}
示例3: collectFuzzyDepend
void CodeAtlas::FuzzyDependBuilder::buildProjDepend( const SymbolNode::Ptr& proj )
{
QList<SymbolNode::Ptr> globalSymList;
SymbolTree::getGlobalSymbols(proj, globalSymList);
ProjectAttr::Ptr projAttr = proj->getOrAddAttr<ProjectAttr>();
projAttr->setGlobalSymList(globalSymList);
QMultiHash<QString, ChildPack> childList;
bool* isNonVar = new bool[globalSymList.size()];
for (int ithGloSym = 0; ithGloSym < globalSymList.size(); ++ithGloSym)
{
ChildPack p;
SymbolNode::Ptr pSym = globalSymList[ithGloSym];
pSym->getOrAddAttr<GlobalSymAttr>();
p.m_info = pSym->getSymInfo();
p.m_code = collectFuzzyDepend(pSym);
p.m_pNode = pSym;
p.m_index = ithGloSym;
childList.insertMulti(p.m_info.name(), p);
isNonVar[ithGloSym] = (p.m_info.elementType() & SymbolInfo::Variable) == 0;
}
FuzzyDependAttr::Ptr pAttr = proj->getOrAddAttr<FuzzyDependAttr>();
buildChildDepend(childList,pAttr->vtxEdgeMatrix(), pAttr->edgeWeightVector(), pAttr->dependPairList());
buildSubGraphLevel(pAttr->vtxEdgeMatrix(), isNonVar, globalSymList.size(), pAttr->levelVector());
delete[] isNonVar;
}
示例4: getAllOfflineMessage
/*!
* \brief The OfflineMessageManager::offlineMessageManagerReply method parse an offline message query an return response
* \param iqXML
* \param iqFrom
* \return QByteArray
*/
QByteArray OfflineMessageManager::offlineMessageManagerReply(QDomDocument document, QString iqFrom)
{
QString id = document.documentElement().attribute("id", Utils::generateId());
QString offlineFirstChildTagName = document.documentElement().firstChildElement().firstChildElement().tagName();
if (offlineFirstChildTagName == "fetch")
{
QMultiHash<QString, QByteArray> messageList = getAllOfflineMessage(Utils::getBareJid(iqFrom));
QList<QString> keyList = messageList.keys();
QByteArray allMessages;
foreach (QString key, keyList)
{
QDomDocument document;
document.setContent(messageList.value(key));
QDomElement offlineElement = document.createElement("offline");
offlineElement.setAttribute("xmlns", "http://jabber.org/protocol/offline");
QDomElement item = document.createElement("item");
item.setAttribute("node", key);
offlineElement.appendChild(item);
document.documentElement().appendChild(offlineElement);
allMessages += document.toByteArray();
}
示例5: searchInCoordinateIndex
void searchInCoordinateIndex(QString const &pathToIndex, QString const &pathToCoordinateIndex)
{
IndexLoader loader(pathToIndex);
QMultiHash<QString, QString> hashTable = loader.loadedIndex();
if (hashTable.isEmpty()) {
qDebug() << "Index is not loaded";
}
CoordinateIndexLoader coordinateLoader(pathToCoordinateIndex);
QHash<QString, QMultiHash<QString, QString>> coordinateHashTable = coordinateLoader.loadedIndex();
if (coordinateHashTable.isEmpty()) {
qDebug() << "Coordinate index is not loaded";
}
qDebug() << "Requests: \n";
QString line = "";
Searcher search(hashTable);
CoordinateIndexSearcher coordinateSearch(coordinateHashTable);
QTextStream in(stdin);
in.setCodec(QTextCodec::codecForName("IBM 866"));
do {
line = in.readLine();
if (line != ":q") {
QStringList result = search.processRequest(line);
coordinateSearch.processRequest(result, line);
}
} while (line != ":q");
}
示例6: saveClusters
void XKCommon::saveClusters(QDataStream&stream,SuperVoxelClusters&clusters)
{
QMultiHash<uint32_t,QByteArray> qClusters;
foreach (SuperVoxelClusters::value_type v, clusters) {
QByteArray data;
QDataStream stream(&data,QIODevice::WriteOnly);
saveSuperVoxel(stream,*v.second);
qClusters.insert(v.first,data);
}
示例7: sizeof
void CodeAtlas::FuzzyDependBuilder::buildChildDepend( QMultiHash<QString, ChildPack>& childList ,
Eigen::SparseMatrix<double>& vtxEdgeMat,
Eigen::VectorXd& edgeWeightVec,
QList<FuzzyDependAttr::DependPair>& dependPair)
{
QStringList codeList;
QVector<ChildPack*> childPackPtr;
for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin();
pChild != childList.end(); ++pChild)
{
codeList.push_back(pChild.value().m_code);
childPackPtr.push_back(&pChild.value());
}
std::vector<Triplet> tripletArray;
QVector<double> edgeWeightArray;
// add dependency edges between child nodes
int ithSrc = 0;
for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin();
pChild != childList.end(); ++pChild, ++ithSrc)
{
// for each child, find number of occurrences of this child's name
ChildPack& srcChild = pChild.value();
const QString& srcName = pChild.key();
QVector<int> occurence;
WordExtractor::findOccurrence(srcName, codeList, occurence);
for (int ithTar = 0; ithTar < childPackPtr.size(); ++ithTar)
{
int nOccur = occurence[ithTar];
if (nOccur == 0 || ithTar == ithSrc)
continue;
ChildPack& tarChild = *childPackPtr[ithTar];
SymbolEdge::Ptr pEdge = SymbolTree::getOrAddEdge(srcChild.m_pNode, tarChild.m_pNode, SymbolEdge::EDGE_FUZZY_DEPEND);
pEdge->clear();
pEdge->strength() = nOccur;
int nEdge = tripletArray.size()/2;
tripletArray.push_back(Triplet(srcChild.m_index, nEdge ,1.0));
tripletArray.push_back(Triplet(tarChild.m_index, nEdge ,-1.0));
edgeWeightArray.push_back(nOccur);
dependPair.push_back(FuzzyDependAttr::DependPair(srcChild.m_pNode, tarChild.m_pNode, nOccur));
}
}
if (int nEdges = tripletArray.size()/2)
{
vtxEdgeMat.resize(childList.size(),nEdges);
vtxEdgeMat.setFromTriplets(tripletArray.begin(), tripletArray.end());
edgeWeightVec.resize(nEdges);
memcpy(edgeWeightVec.data(), edgeWeightArray.data(), sizeof(double)* nEdges);
}
}
示例8: xapianDocToComponent
Component xapianDocToComponent(Xapian::Document document) {
Component component;
// kind
QString kindString = value (document, XapianValues::TYPE);
component.setKind(Component::stringToKind(kindString));
// Identifier
QString id = value(document, XapianValues::IDENTIFIER);
component.setId(id);
// Component name
QString name = value(document,XapianValues::CPTNAME);
component.setName(name);
// Package name
QStringList packageNames = value(document,XapianValues::PKGNAME).split("\n",QString::SkipEmptyParts);
component.setPackageNames(packageNames);
// URLs
QString concatUrlStrings = value(document, XapianValues::URLS);
QStringList urlStrings = concatUrlStrings.split('\n',QString::SkipEmptyParts);
if(urlStrings.size() %2 == 0) {
QMultiHash<Component::UrlKind, QUrl> urls;
for(int i = 0; i < urlStrings.size(); i=i+2) {
Component::UrlKind ukind = Component::stringToUrlKind(urlStrings.at(i));
QUrl url = QUrl::fromUserInput(urlStrings.at(i+1));
urls.insertMulti(ukind, url);
}
component.setUrls(urls);
} else {
qWarning("Bad url strings for component: '%s' (%s)", qPrintable(id), qPrintable(concatUrlStrings));
}
// Provided items
QString concatProvides = value(document, XapianValues::PROVIDED_ITEMS);
QStringList providesList = concatProvides.split('\n',QString::SkipEmptyParts);
QList<Provides> provideslist;
Q_FOREACH(const QString& string, providesList) {
QStringList providesParts = string.split(';',QString::SkipEmptyParts);
if(providesParts.size() < 2) {
qWarning("Bad component parts for component: '%s' (%s)", qPrintable(id), qPrintable(string));
continue;
}
QString kindString = providesParts.takeFirst();
Provides::Kind kind = Provides::stringToKind(kindString);
Provides provides;
provides.setKind(kind);
QString value = providesParts.takeFirst();
provides.setValue(value);
QString extraData = providesParts.join(";");
provides.setExtraData(extraData);
provideslist << provides;
}
示例9: QActionGroup
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);
}
}
示例10: 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);
}
示例11: 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);
}
示例12: typeParameterName
void tst_QVersitProperty::testParameters()
{
QString typeParameterName(QLatin1String("TYPE"));
QString name(QLatin1String("type"));
QString value1(QLatin1String("home"));
mVersitProperty->insertParameter(name,value1);
QMultiHash<QString,QString> parameters = mVersitProperty->parameters();
QCOMPARE(parameters.count(), 1);
QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));
QString value2(QLatin1String("voice"));
mVersitProperty->insertParameter(name,value2);
parameters = mVersitProperty->parameters();
QCOMPARE(parameters.count(), 2);
QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));
QVERIFY(parameters.contains(typeParameterName,QLatin1String("voice")));
mVersitProperty->removeParameter(name,value1);
QCOMPARE(mVersitProperty->parameters().count(), 1);
QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));
mVersitProperty->removeParameter(name,value2);
QCOMPARE(mVersitProperty->parameters().count(), 0);
mVersitProperty->insertParameter(name, value1);
mVersitProperty->insertParameter(name, value2);
QCOMPARE(mVersitProperty->parameters().count(), 2);
mVersitProperty->removeParameters(name);
QCOMPARE(mVersitProperty->parameters().count(), 0);
}
示例13: propertyProcessed
bool QVCardRestoreHandler::propertyProcessed(
const QVersitProperty& property,
QList<QContactDetail>* updatedDetails)
{
bool success = false;
QString group;
if (!property.groups().isEmpty())
group = property.groups().first();
if (property.name() == PropertyName) {
if (property.groups().size() != 1)
return false;
QMultiHash<QString, QString> parameters = property.parameters();
QContactDetail::DetailType detailType = QContactDetail::DetailType(parameters.value(DetailTypeParameter).toUInt());
QString fieldName = parameters.value(FieldParameter);
// Find a detail previously seen with the same definitionName, which was generated from
// a property from the same group
QContactDetail detail(detailType);
foreach (const QContactDetail& previousDetail, mDetailGroupMap.detailsInGroup(group)) {
if (previousDetail.type() == detailType) {
detail = previousDetail;
}
}
// If not found, it's a new empty detail with the definitionName set.
detail.setValue(fieldName.toInt(), deserializeValue(property));
// Replace the equivalent detail in updatedDetails with the new one
QMutableListIterator<QContactDetail> it(*updatedDetails);
while (it.hasNext()) {
if (it.next().key() == detail.key()) {
it.remove();
break;
}
}
updatedDetails->append(detail);
success = true;
}
if (!group.isEmpty()) {
// Keep track of which details were generated from which Versit groups
foreach (const QContactDetail& detail, *updatedDetails) {
mDetailGroupMap.insert(group, detail);
}
}
示例14: 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);
}
}
示例15: mythfile_open_register_callback
void mythfile_open_register_callback(const char *pathname, void* object,
callback_t func)
{
m_callbackLock.lock();
QString path(pathname);
if (m_fileOpenCallbacks.contains(path))
{
// if we already have a callback registered for this path with this
// object then remove the callback and return (i.e. end callback)
QMutableHashIterator<QString,Callback> it(m_fileOpenCallbacks);
while (it.hasNext())
{
it.next();
if (object == it.value().m_object)
{
it.remove();
VERBOSE(VB_PLAYBACK, LOC +
QString("Removing fileopen callback for %1").arg(path));
VERBOSE(VB_PLAYBACK, LOC + QString("%1 callbacks remaining")
.arg(m_fileOpenCallbacks.size()));
m_callbackLock.unlock();
return;
}
}
}
Callback new_callback(object, func);
m_fileOpenCallbacks.insert(path, new_callback);
VERBOSE(VB_PLAYBACK, LOC +
QString("Added fileopen callback for %1").arg(path));
VERBOSE(VB_PLAYBACK, LOC + QString("%1 callbacks open")
.arg(m_fileOpenCallbacks.size()));
m_callbackLock.unlock();
}