本文整理汇总了C++中QVariantMap::keys方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::keys方法的具体用法?C++ QVariantMap::keys怎么用?C++ QVariantMap::keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remapTextures
void RenderableModelEntityItem::remapTextures() {
if (!_model) {
return; // nothing to do if we don't have a model
}
if (!_model->isLoadedWithTextures()) {
return; // nothing to do if the model has not yet loaded it's default textures
}
if (!_originalTexturesRead && _model->isLoadedWithTextures()) {
const QSharedPointer<NetworkGeometry>& networkGeometry = _model->getGeometry();
if (networkGeometry) {
_originalTextures = networkGeometry->getTextureNames();
_originalTexturesRead = true;
}
}
if (_currentTextures == _textures) {
return; // nothing to do if our recently mapped textures match our desired textures
}
// since we're changing here, we need to run through our current texture map
// and any textures in the recently mapped texture, that is not in our desired
// textures, we need to "unset"
QJsonDocument currentTexturesAsJson = QJsonDocument::fromJson(_currentTextures.toUtf8());
QJsonObject currentTexturesAsJsonObject = currentTexturesAsJson.object();
QVariantMap currentTextureMap = currentTexturesAsJsonObject.toVariantMap();
QJsonDocument texturesAsJson = QJsonDocument::fromJson(_textures.toUtf8());
QJsonObject texturesAsJsonObject = texturesAsJson.object();
QVariantMap textureMap = texturesAsJsonObject.toVariantMap();
foreach(const QString& key, currentTextureMap.keys()) {
// if the desired texture map (what we're setting the textures to) doesn't
// contain this texture, then remove it by setting the URL to null
if (!textureMap.contains(key)) {
QUrl noURL;
qDebug() << "Removing texture named" << key << "by replacing it with no URL";
_model->setTextureWithNameToURL(key, noURL);
}
}
// here's where we remap any textures if needed...
foreach(const QString& key, textureMap.keys()) {
QUrl newTextureURL = textureMap[key].toUrl();
qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL;
_model->setTextureWithNameToURL(key, newTextureURL);
}
_currentTextures = _textures;
}
示例2: getPluginIsPermitted
bool Config::getPluginIsPermitted(QString pluginName, QString feature){
QVariantMap permissions = this->getPluginPermissions(pluginName);
if (permissions.keys().contains(feature))
return permissions[feature].toBool();
else
return false;
}
示例3: AutoResizeMixin
DeclarativeWindow::DeclarativeWindow (const QUrl& url, QVariantMap params,
const QPoint& orig, ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent)
: QDeclarativeView (parent)
{
new Util::AutoResizeMixin (orig, [viewMgr] () { return viewMgr->GetFreeCoords (); }, this);
if (!params.take ("keepOnFocusLeave").toBool ())
new Util::UnhoverDeleteMixin (this, SLOT (beforeDelete ()));
setStyleSheet ("background: transparent");
setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
setAttribute (Qt::WA_TranslucentBackground);
for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, ""))
engine ()->addImportPath (cand);
rootContext ()->setContextProperty ("colorProxy",
new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
for (const auto& key : params.keys ())
rootContext ()->setContextProperty (key, params [key]);
engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy));
setSource (url);
connect (rootObject (),
SIGNAL (closeRequested ()),
this,
SLOT (deleteLater ()));
}
示例4: updateColorThemeMenu
void ColorThemes::updateColorThemeMenu()
{
m_menu->clear();
const QSettings *s = Core::ICore::settings();
const QString currentTheme = s->value(Constants::C_SETTINGS_COLORSETTINGS_CURRENTCOLORTHEME, Constants::C_COLOR_SCHEME_DEFAULT).toString();
const QVariantMap data = s->value(Constants::C_SETTINGS_COLORSETTINGS_COLORTHEMES).toMap();
QStringList keys = data.keys();
keys.append(Constants::C_COLOR_SCHEME_SCXMLDOCUMENT);
keys.append(Constants::C_COLOR_SCHEME_DEFAULT);
for (const QString &key: keys) {
const QString actionText = key == Constants::C_COLOR_SCHEME_DEFAULT
? tr("Factory Default") : key == Constants::C_COLOR_SCHEME_SCXMLDOCUMENT
? tr("Colors from SCXML-document")
: key;
QAction *action = m_menu->addAction(actionText, this, [this, key]() {
selectColorTheme(key);
});
action->setData(key);
action->setCheckable(true);
}
m_menu->addSeparator();
m_menu->addAction(m_modifyAction);
m_toolButton->setMenu(m_menu);
selectColorTheme(currentTheme);
}
示例5: localStateFile
QList<Profile> FindChromeProfile::find()
{
QString configDirectory = QStringLiteral("%1/.config/%2")
.arg(m_homeDirectory, m_applicationName);
QString localStateFileName = QStringLiteral("%1/Local State")
.arg(configDirectory);
QList<Profile> profiles;
QFile localStateFile(localStateFileName);
if (!localStateFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
return profiles;
}
QJsonDocument jdoc = QJsonDocument::fromJson(localStateFile.readAll());
if(jdoc.isNull()) {
qDebug() << "error opening " << QFileInfo(localStateFile).absoluteFilePath();
return profiles;
}
QVariantMap localState = jdoc.object().toVariantMap();
QVariantMap profilesConfig = localState.value(QStringLiteral("profile")).toMap().value(QStringLiteral("info_cache")).toMap();
foreach(const QString &profile, profilesConfig.keys()) {
const QString profilePath = QStringLiteral("%1/%2").arg(configDirectory, profile);
const QString profileBookmarksPath = QStringLiteral("%1/%2").arg(profilePath, QStringLiteral("Bookmarks"));
profiles << Profile(profileBookmarksPath, FaviconFromBlob::chrome(profilePath, this));
}
return profiles;
}
示例6: request
bool ArbitraryRequestHandler::request(int requestType, const QString &requestUri, const QVariantMap &queryItems, const QString &postData)
{
if (reply) {
qWarning() << Q_FUNC_INFO << "Warning: cannot start arbitrary request: another arbitrary request is in progress";
return false;
}
QList<QPair<QString, QString> > qil;
QStringList queryItemKeys = queryItems.keys();
foreach (const QString &qik, queryItemKeys)
qil.append(qMakePair<QString, QString>(qik, queryItems.value(qik).toString()));
QUrl url(requestUri);
url.setQueryItems(qil);
QNetworkReply *sniReply = 0;
switch (requestType) {
case SocialNetworkInterface::Get: sniReply = q->d->qnam->get(QNetworkRequest(url)); break;
case SocialNetworkInterface::Post: sniReply = q->d->qnam->post(QNetworkRequest(url), QByteArray::fromBase64(postData.toLatin1())); break;
default: sniReply = q->d->qnam->deleteResource(QNetworkRequest(url)); break;
}
if (sniReply) {
reply = sniReply;
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(errorHandler(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrorsHandler(QList<QSslError>)));
connect(reply, SIGNAL(finished()), this, SLOT(finishedHandler()));
return true;
}
qWarning() << Q_FUNC_INFO << "Warning: cannot start arbitrary request: null reply";
return false;
}
示例7: pluginFinished
void CreateAccount::pluginFinished(const QString &screenName, const QString &secret, const QVariantMap &data)
{
// Set up the new identity
SignOn::IdentityInfo info;
info.setStoreSecret(true);
info.setUserName(screenName);
info.setSecret(secret, true);
info.setCaption(m_providerName);
info.setAccessControlList(QStringList(QLatin1String("*")));
info.setType(SignOn::IdentityInfo::Application);
Q_FOREACH (const QString &key, data.keys()) {
// If a key with __service/ prefix exists and its value is false,
// add it to m_disabledServices which will later be used for disabling
// the services contained in that list
if (key.startsWith(QLatin1String("__service/")) && !data.value(key).toBool()) {
m_disabledServices << key.mid(10);
}
m_account->setValue(key, data.value(key).toString());
}
m_identity = SignOn::Identity::newIdentity(info, this);
connect(m_identity, SIGNAL(info(SignOn::IdentityInfo)), SLOT(info(SignOn::IdentityInfo)));
m_done = true;
connect(m_identity, &SignOn::Identity::credentialsStored, m_identity, &SignOn::Identity::queryInfo);
m_identity->storeCredentials();
}
示例8: loadBookmarks
void BookmarksDialog::loadBookmarks()
{
QVariantMap map;
QFile jsonFile(bookmarksJsonPath);
if (!jsonFile.open(QIODevice::ReadOnly))
qWarning() << "[Bookmarks] cannot open" << QDir::toNativeSeparators(bookmarksJsonPath);
else
{
try
{
map = StelJsonParser::parse(jsonFile.readAll()).toMap();
jsonFile.close();
bookmarksCollection.clear();
QVariantMap bookmarksMap = map.value("bookmarks").toMap();
int i = 0;
for (auto bookmarkKey : bookmarksMap.keys())
{
QVariantMap bookmarkData = bookmarksMap.value(bookmarkKey).toMap();
bookmark bm;
QString JDs = "";
bm.name = bookmarkData.value("name").toString();
QString nameI18n = bookmarkData.value("nameI18n").toString();
if (!nameI18n.isEmpty())
bm.nameI18n = nameI18n;
QString JD = bookmarkData.value("jd").toString();
if (!JD.isEmpty())
{
bm.jd = JD;
JDs = StelUtils::julianDayToISO8601String(JD.toDouble() + core->getUTCOffset(JD.toDouble())/24.).replace("T", " ");
}
QString Location = bookmarkData.value("location").toString();
if (!Location.isEmpty())
bm.location = Location;
QString RA = bookmarkData.value("ra").toString();
if (!RA.isEmpty())
bm.ra = RA;
QString Dec = bookmarkData.value("dec").toString();
if (!Dec.isEmpty())
bm.dec = Dec;
bm.isVisibleMarker = bookmarkData.value("isVisibleMarker", false).toBool();
double fov = bookmarkData.value("fov").toDouble();
if (fov > 0.0)
bm.fov = fov;
bookmarksCollection.insert(bookmarkKey, bm);
addModelRow(i, bookmarkKey, bm.name, bm.nameI18n, JDs, Location);
i++;
}
}
catch (std::runtime_error &e)
{
qDebug() << "[Bookmarks] File format is wrong! Error: " << e.what();
return;
}
}
}
示例9: genChangelogText
QString CModListView::genChangelogText(CModEntry &mod)
{
QString headerTemplate = "<p><span style=\" font-weight:600;\">%1: </span></p>";
QString entryBegin = "<p align=\"justify\"><ul>";
QString entryEnd = "</ul></p>";
QString entryLine = "<li>%1</li>";
//QString versionSeparator = "<hr/>";
QString result;
QVariantMap changelog = mod.getValue("changelog").toMap();
QList<QString> versions = changelog.keys();
std::sort(versions.begin(), versions.end(), [](QString lesser, QString greater)
{
return !CModEntry::compareVersions(lesser, greater);
});
for (auto & version : versions)
{
result += headerTemplate.arg(version);
result += entryBegin;
for (auto & line : changelog.value(version).toStringList())
result += entryLine.arg(line);
result += entryEnd;
}
return result;
}
示例10: init
void WebDispatch::init()
{
QFile f( "sources.json" );
if( ! f.exists() )
{
__process_websources();
return;
}
QVariantMap qmap;
if( ! Assist::Json::json_read( f, qmap ) )
{
__process_websources();
return;
}
ELSE_DEBUG_P( "Sources is preconfigured." );
// Конвертируем QVariantMap в QMap<QString, QStringList>
QStringList keys = qmap.keys();
foreach( QString key, keys )
{
this->qmap.insert( key, qmap.value( key ).toStringList() );
}
示例11: modifyAccountObject
/**
* @brief FilePersistence::modifyAccountObject
* @param modifications
* @return
*/
bool FilePersistence::modifyAccountObject(const OptionTable &modifications)
{
int index = findAccountObj(modifications);
if (index < 0) {
m_error.append(QString("Could not modify Account object !\n"));
m_error.append(QString("There is no such an Account object.\n"));
return false;
}
QVariantMap modifyValues = variantMapFromOptionTable(modifications);
if (modifications.contains('i')) {
modifyValues.remove(optionToRealName('i'));
} else {
modifyValues.remove(optionToRealName('p'));
modifyValues.remove(optionToRealName('u'));
}
QVariantMap originObject = m_fileContent[index];
QStringList keyList = modifyValues.keys();
for (int index=0; index<keyList.size(); ++index) {
QVariant value = modifyValues.value(keyList[index]);
originObject.insert(keyList[index], value);
}
m_isModified = true;
return true;
}
示例12: insert
void VariantTable::insert(QVariantMap value)
{
QStringList col_names;
QStringList col_marks;
QVariantList col_values;
QString keyVal;
foreach (const QString &key, value.keys()) {
if (!blueprint.contains(key)) {
qCritical("Localstorage: variant table %s. Tried to insert an object that does not match the blueprint.",
qPrintable(name));
return;
}
col_names.append(key); //TODO type check
keyVal = blueprint.value(key).toString();
if( keyVal == "binary" || keyVal.contains("BLOB", Qt::CaseInsensitive) ) {
QVariant data (writeSerialized(value.value(key)));
col_values.append(data);
}
else col_values.append(value.value(key));
col_marks.append("?");
}
QString cmd("INSERT OR REPLACE INTO %1 (%2) VALUES (%3)");
cmd = cmd.arg(name)
.arg(col_names.join(", "))
.arg(col_marks.join(", "));
QSqlQuery query(db);
query.prepare(cmd);
foreach (QVariant col_value, col_values) {
query.addBindValue(col_value);
}
示例13: propertiesChanged
void RemoteActivatable::propertiesChanged(const QVariantMap &changedProperties)
{
Q_D(RemoteActivatable);
QStringList propKeys = changedProperties.keys();
QLatin1String deviceUniKey("deviceUni"),
activatableTypeKey("activatableType"),
sharedKey("shared");
QVariantMap::const_iterator it = changedProperties.find(deviceUniKey);
if (it != changedProperties.end())
{
d->deviceUni = it->toString();
propKeys.removeOne(deviceUniKey);
}
it = changedProperties.find(activatableTypeKey);
if (it != changedProperties.end())
{
d->activatableType = (Knm::Activatable::ActivatableType)it->toUInt();
propKeys.removeOne(activatableTypeKey);
}
it = changedProperties.find(sharedKey);
if (it != changedProperties.end())
{
d->shared = it->toBool();
propKeys.removeOne(sharedKey);
}
/*if (propKeys.count()) {
qDebug() << "Unhandled properties: " << propKeys;
}*/
}
示例14: QLabel
ItemData::ItemData(const QModelIndex &index, int maxBytes, QWidget *parent)
: QLabel(parent)
, ItemWidget(this)
{
setTextInteractionFlags(Qt::TextSelectableByMouse);
setContentsMargins(4, 4, 4, 4);
setTextFormat(Qt::RichText);
QString text;
const QVariantMap data = index.data(contentType::data).toMap();
foreach ( const QString &format, data.keys() ) {
QByteArray bytes = data[format].toByteArray();
const int size = bytes.size();
bool trimmed = size > maxBytes;
if (trimmed)
bytes = bytes.left(maxBytes);
bool hasText = format.startsWith("text/") ||
format.startsWith("application/x-copyq-owner-window-title");
const QString content = hasText ? escapeHtml(stringFromBytes(bytes, format)) : hexData(bytes);
text.append( QString("<p>") );
text.append( QString("<b>%1</b> (%2 bytes)<pre>%3</pre>")
.arg(format)
.arg(size)
.arg(content) );
text.append( QString("</p>") );
if (trimmed)
text.append( QString("<p>...</p>") );
}
setText(text);
}
示例15: onDataUpdated
void AuthPlugin::onDataUpdated(const QVariantMap &map)
{
QString command = map["command"].toString();
if (command == "login") {
QString key = map["token"].toString();
if (key.isEmpty() || key.isNull()) {
//request login UI
if (mWidget) {
Q_EMIT spawnView(mWidget);
mWidget->setVisible(true);
mWidget->createAuthDialog();
}
}
}
if (command == "friends") {
qDebug() << map.keys();
mContactUI->setFacebookContactData(map["data"].toHash());
}
if (command == "userinfo") {
mContactUI->addContact(map);
}
}