本文整理汇总了C++中QVariantHash::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantHash::remove方法的具体用法?C++ QVariantHash::remove怎么用?C++ QVariantHash::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantHash
的用法示例。
在下文中一共展示了QVariantHash::remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setValue
void Session::setValue(Cutelyst::Context *c, const QString &key, const QVariant &value)
{
QVariantHash session = SessionPrivate::loadSession(c).toHash();
if (value.isNull()) {
session.remove(key);
} else {
session.insert(key, value);
}
c->setProperty(SESSION_VALUES, session);
c->setProperty(SESSION_SAVE, true);
}
示例2: if
void
SpotifyAccount::delayedInit()
{
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( resolverInstalled( QString ) ) );
const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId );
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
const QString path = configuration().value( "path" ).toString(); // Manual path override
if ( !checkForResolver() && state != AtticaManager::Uninstalled )
{
// If the user manually deleted the resolver, mark it as uninstalled, so we re-fetch for the user
QVariantHash conf = configuration();
conf.remove( "path" );
setConfiguration( conf );
sync();
AtticaManager::instance()->uninstallResolver( res );
}
else if ( state == AtticaManager::Installed || !path.isEmpty() )
{
if ( !path.isEmpty() )
{
QFileInfo info( path );
// Resolver was deleted, so abort and remove our manual override, as it's no longer valid
if ( !info.exists() )
{
QVariantHash conf = configuration();
conf.remove( "path" );
setConfiguration( conf );
sync();
return;
}
}
hookupResolver();
}
}
示例3: save
void ModifyPrinter::save()
{
if (m_changes) {
QVariantHash args = m_changedValues;
QString fileName;
qCDebug(PM_CONFIGURE_PRINTER) << args;
if (args.contains("ppd-name") &&
args["ppd-name"].type() == QVariant::Bool) {
fileName = ui->makeCB->itemData(ui->makeCB->currentIndex(), PPDFile).toString();
args.remove("ppd-name");
}
qCDebug(PM_CONFIGURE_PRINTER) << fileName;
QPointer<KCupsRequest> request = new KCupsRequest;
if (m_isClass) {
request->addOrModifyClass(m_destName, args);
} else {
request->addOrModifyPrinter(m_destName, args, fileName);
}
request->waitTillFinished();
if (request) {
if (!request->hasError()) {
if (m_changedValues.contains("ppd-name")) {
emit ppdChanged();
}
request->getPrinterAttributes(m_destName, m_isClass, neededValues());
request->waitTillFinished();
if (!request->hasError() && !request->printers().isEmpty()) {
KCupsPrinter printer = request->printers().first();
setValues(printer);
}
} else {
KMessageBox::detailedSorry(this,
m_isClass ? i18nc("@info", "Failed to configure class") :
i18nc("@info", "Failed to configure printer"),
request->errorMsg(),
i18nc("@title:window", "Failed"));
}
request->deleteLater();
}
}
}
示例4: createActivity
void TemplatesPlugin::createActivity(const QDBusVariant &_values)
{
using namespace kamd::utils;
QVariantHash values = _values.variant().toHash();
auto takeStringValue = [&values] (const QString &key) {
auto result = values[key].toString();
values.remove(key);
return result;
};
const QString name = takeStringValue("activity.name");
const QString description = takeStringValue("activity.description");
const QString icon = takeStringValue("activity.icon");
// Creating the activity, and getting the id
const QString id = Plugin::retrieve<QString>(
m_activities, "AddActivity", "QString",
Q_ARG(QString, name));
// Saving the provided data to the configuration file
KConfigGroup pluginConfig(config());
KConfigGroup activityConfig(&pluginConfig, id);
for_each_assoc(values, [&activityConfig] (const QString &key, const QVariant &value) {
activityConfig.writeEntry(key, value);
});
activityConfig.sync();
// Changing the icon and description of the activity
Plugin::invoke<Qt::DirectConnection>(
m_activities, "SetActivityDescription",
Q_ARG(QString, id),
Q_ARG(QString, description));
Plugin::invoke<Qt::DirectConnection>(
m_activities, "SetActivityIcon",
Q_ARG(QString, id),
Q_ARG(QString, icon));
}
示例5: deleteValue
void Session::deleteValue(Context *c, const QString &key)
{
QVariant session = c->property(SESSION_VALUES);
if (session.isNull()) {
session = SessionPrivate::loadSession(c);
if (session.isNull()) {
static Session *plugin = c->plugin<Session*>();
if (!plugin) {
qCCritical(C_SESSION) << "Session plugin not registered";
return;
}
SessionPrivate::createSessionIdIfNeeded(plugin, c, plugin->d_ptr->sessionExpires);
session = SessionPrivate::initializeSessionData(plugin, c);
}
}
QVariantHash data = session.toHash();
data.remove(key);
c->setProperty(SESSION_VALUES, data);
c->setProperty(SESSION_UPDATED, true);
}
示例6: testSections
void TestMustache::testSections()
{
QVariantHash map = contactInfo("John Smith", "[email protected]");
QVariantList contacts;
contacts << contactInfo("James Dee", "[email protected]");
contacts << contactInfo("Jim Jones", "[email protected]");
map["contacts"] = contacts;
QString _template = "Name: {{name}}, Email: {{email}}\n"
"{{#contacts}} {{name}} - {{email}}\n{{/contacts}}"
"{{^contacts}} No contacts{{/contacts}}";
QString expectedOutput = "Name: John Smith, Email: [email protected]\n"
" James Dee - [email protected]\n"
" Jim Jones - [email protected]\n";
Mustache::Renderer renderer;
Mustache::QtVariantContext context(map);
QString output = renderer.render(_template, &context);
QCOMPARE(output, expectedOutput);
// test inverted sections
map.remove("contacts");
context = Mustache::QtVariantContext(map);
output = renderer.render(_template, &context);
expectedOutput = "Name: John Smith, Email: [email protected]\n"
" No contacts";
QCOMPARE(output, expectedOutput);
// test with an empty list instead of an empty key
map["contacts"] = QVariantHash();
context = Mustache::QtVariantContext(map);
output = renderer.render(_template, &context);
QCOMPARE(output, expectedOutput);
}