本文整理汇总了C++中QVariantHash::insertMulti方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantHash::insertMulti方法的具体用法?C++ QVariantHash::insertMulti怎么用?C++ QVariantHash::insertMulti使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantHash
的用法示例。
在下文中一共展示了QVariantHash::insertMulti方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMapping
QVariantHash FSTReader::parseMapping(QIODevice* device) {
QVariantHash properties;
QByteArray line;
while (!(line = device->readLine()).isEmpty()) {
if ((line = line.trimmed()).startsWith('#')) {
continue; // comment
}
QList<QByteArray> sections = line.split('=');
if (sections.size() < 2) {
continue;
}
QByteArray name = sections.at(0).trimmed();
if (sections.size() == 2) {
properties.insertMulti(name, sections.at(1).trimmed());
} else if (sections.size() == 3) {
QVariantHash heading = properties.value(name).toHash();
heading.insertMulti(sections.at(1).trimmed(), sections.at(2).trimmed());
properties.insert(name, heading);
} else if (sections.size() >= 4) {
QVariantHash heading = properties.value(name).toHash();
QVariantList contents;
for (int i = 2; i < sections.size(); i++) {
contents.append(sections.at(i).trimmed());
}
heading.insertMulti(sections.at(1).trimmed(), contents);
properties.insert(name, heading);
}
}
return properties;
}
示例2: render
QByteArray ViewJson::render(Context *c) const
{
Q_D(const ViewJson);
QByteArray ret;
QJsonObject obj;
const QVariantHash stash = c->stash();
switch (d->exposeMode) {
case All:
obj = QJsonObject::fromVariantHash(stash);
break;
case String:
{
auto it = stash.constFind(d->exposeKey);
if (it != stash.constEnd()) {
obj.insert(d->exposeKey, QJsonValue::fromVariant(it.value()));
}
break;
}
case StringList:
{
QVariantHash exposedStash;
auto it = stash.constBegin();
while (it != stash.constEnd()) {
const QString key = it.key();
if (d->exposeKeys.contains(key)) {
exposedStash.insertMulti(it.key(), it.value());
}
++it;
}
obj = QJsonObject::fromVariantHash(exposedStash);
break;
}
case RegularExpression:
{
QVariantHash exposedStash;
QRegularExpression re = d->exposeRE; // thread safety
auto it = stash.constBegin();
while (it != stash.constEnd()) {
const QString key = it.key();
if (re.match(key).hasMatch()) {
exposedStash.insertMulti(key, it.value());
}
++it;
}
obj = QJsonObject::fromVariantHash(exposedStash);
break;
}
}
c->response()->setContentType(QStringLiteral("application/json"));
ret = QJsonDocument(obj).toJson(d->format);
return ret;
}
示例3: onSocketReadyRead
void Asterisk::onSocketReadyRead()
{
// qDebug("<ready-read>");
QVariantHash headers;
while (socket.canReadLine()) {
QByteArray line = socket.readLine();
// qDebug() << "Line:" << line;
if (line != "\r\n") {
QStringList header = QString(line.trimmed()).split(':');
headers.insertMulti(header[0], decodeValue(header[1].trimmed()));
} else {
if (headers.contains("Response"))
responses.insert(headers.take("ActionID").toString(), headers);
else if (headers.contains("Event"))
emit eventReceived(headers.take("Event").toString(), headers);
headers.clear();
}
}
// qDebug("</ready-read>");
}
示例4: originate
QVariantHash Asterisk::originate(QString channel,
QString exten,
QString context,
uint priority,
QString application,
QString data,
uint timeout,
QString callerId,
QVariantHash variables,
QString account,
bool earlyMedia,
bool async,
QStringList codecs)
{
QVariantHash headers;
headers["Channel"] = channel;
headers["EarlyMedia"] = earlyMedia;
headers["Async"] = async;
insertNotEmpty(&headers, "Timeout", timeout);
insertNotEmpty(&headers, "CallerID", callerId);
insertNotEmpty(&headers, "Account", account);
insertNotEmpty(&headers, "Codecs", codecs.join(","));
if (!exten.isEmpty() && !context.isEmpty() && priority > 0) {
headers["Exten"] = exten;
headers["Context"] = context;
headers["Priority"] = priority;
}
if (!application.isEmpty()) {
headers["Application"] = application;
insertNotEmpty(&headers, "Data", data);
}
if (!variables.isEmpty()) {
QHashIterator<QString, QVariant> variable(variables);
while (variable.hasNext()) {
variable.next();
headers.insertMulti("Variable", QString("%1=%2").arg(variable.key(), encodeValue(variable.value())));
}
}
return sendPacket("Originate", headers);
}
示例5: populateBasicMapping
void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename, const hfm::Model& hfmModel) {
// mixamo files - in the event that a mixamo file was edited by some other tool, it's likely the applicationName will
// be rewritten, so we detect the existence of several different blendshapes which indicate we're likely a mixamo file
bool likelyMixamoFile = hfmModel.applicationName == "mixamo.com" ||
(hfmModel.blendshapeChannelNames.contains("BrowsDown_Right") &&
hfmModel.blendshapeChannelNames.contains("MouthOpen") &&
hfmModel.blendshapeChannelNames.contains("Blink_Left") &&
hfmModel.blendshapeChannelNames.contains("Blink_Right") &&
hfmModel.blendshapeChannelNames.contains("Squint_Right"));
if (!mapping.contains(NAME_FIELD)) {
mapping.insert(NAME_FIELD, QFileInfo(filename).baseName());
}
if (!mapping.contains(FILENAME_FIELD)) {
QDir root(_modelFile.path());
mapping.insert(FILENAME_FIELD, root.relativeFilePath(filename));
}
if (!mapping.contains(TEXDIR_FIELD)) {
mapping.insert(TEXDIR_FIELD, ".");
}
if (!mapping.contains(SCRIPT_FIELD)) {
mapping.insert(SCRIPT_FIELD, ".");
}
// mixamo/autodesk defaults
if (!mapping.contains(SCALE_FIELD)) {
mapping.insert(SCALE_FIELD, 1.0);
}
QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
if (!joints.contains("jointEyeLeft")) {
joints.insert("jointEyeLeft", hfmModel.jointIndices.contains("jointEyeLeft") ? "jointEyeLeft" :
(hfmModel.jointIndices.contains("EyeLeft") ? "EyeLeft" : "LeftEye"));
}
if (!joints.contains("jointEyeRight")) {
joints.insert("jointEyeRight", hfmModel.jointIndices.contains("jointEyeRight") ? "jointEyeRight" :
hfmModel.jointIndices.contains("EyeRight") ? "EyeRight" : "RightEye");
}
if (!joints.contains("jointNeck")) {
joints.insert("jointNeck", hfmModel.jointIndices.contains("jointNeck") ? "jointNeck" : "Neck");
}
if (!joints.contains("jointRoot")) {
joints.insert("jointRoot", "Hips");
}
if (!joints.contains("jointLean")) {
joints.insert("jointLean", "Spine");
}
if (!joints.contains("jointLeftHand")) {
joints.insert("jointLeftHand", "LeftHand");
}
if (!joints.contains("jointRightHand")) {
joints.insert("jointRightHand", "RightHand");
}
if (!joints.contains("jointHead")) {
const char* topName = likelyMixamoFile ? "HeadTop_End" : "HeadEnd";
joints.insert("jointHead", hfmModel.jointIndices.contains(topName) ? topName : "Head");
}
mapping.insert(JOINT_FIELD, joints);
if (!mapping.contains(FREE_JOINT_FIELD)) {
mapping.insertMulti(FREE_JOINT_FIELD, "LeftArm");
mapping.insertMulti(FREE_JOINT_FIELD, "LeftForeArm");
mapping.insertMulti(FREE_JOINT_FIELD, "RightArm");
mapping.insertMulti(FREE_JOINT_FIELD, "RightForeArm");
}
// If there are no blendshape mappings, and we detect that this is likely a mixamo file,
// then we can add the default mixamo to "faceshift" mappings
if (!mapping.contains(BLENDSHAPE_FIELD) && likelyMixamoFile) {
QVariantHash blendshapes;
blendshapes.insertMulti("BrowsD_L", QVariantList() << "BrowsDown_Left" << 1.0);
blendshapes.insertMulti("BrowsD_R", QVariantList() << "BrowsDown_Right" << 1.0);
blendshapes.insertMulti("BrowsU_C", QVariantList() << "BrowsUp_Left" << 1.0);
blendshapes.insertMulti("BrowsU_C", QVariantList() << "BrowsUp_Right" << 1.0);
blendshapes.insertMulti("BrowsU_L", QVariantList() << "BrowsUp_Left" << 1.0);
blendshapes.insertMulti("BrowsU_R", QVariantList() << "BrowsUp_Right" << 1.0);
blendshapes.insertMulti("ChinLowerRaise", QVariantList() << "Jaw_Up" << 1.0);
blendshapes.insertMulti("ChinUpperRaise", QVariantList() << "UpperLipUp_Left" << 0.5);
blendshapes.insertMulti("ChinUpperRaise", QVariantList() << "UpperLipUp_Right" << 0.5);
blendshapes.insertMulti("EyeBlink_L", QVariantList() << "Blink_Left" << 1.0);
blendshapes.insertMulti("EyeBlink_R", QVariantList() << "Blink_Right" << 1.0);
blendshapes.insertMulti("EyeOpen_L", QVariantList() << "EyesWide_Left" << 1.0);
blendshapes.insertMulti("EyeOpen_R", QVariantList() << "EyesWide_Right" << 1.0);
blendshapes.insertMulti("EyeSquint_L", QVariantList() << "Squint_Left" << 1.0);
blendshapes.insertMulti("EyeSquint_R", QVariantList() << "Squint_Right" << 1.0);
blendshapes.insertMulti("JawFwd", QVariantList() << "JawForeward" << 1.0);
blendshapes.insertMulti("JawLeft", QVariantList() << "JawRotateY_Left" << 0.5);
blendshapes.insertMulti("JawOpen", QVariantList() << "MouthOpen" << 0.7);
blendshapes.insertMulti("JawRight", QVariantList() << "Jaw_Right" << 1.0);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "JawForeward" << 0.39);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "Jaw_Down" << 0.36);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "MouthNarrow_Left" << 1.0);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "MouthNarrow_Right" << 1.0);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "MouthWhistle_NarrowAdjust_Left" << 0.5);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "MouthWhistle_NarrowAdjust_Right" << 0.5);
blendshapes.insertMulti("LipsFunnel", QVariantList() << "TongueUp" << 1.0);
blendshapes.insertMulti("LipsLowerClose", QVariantList() << "LowerLipIn" << 1.0);
//.........这里部分代码省略.........