本文整理汇总了C++中QVariantMap::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::clear方法的具体用法?C++ QVariantMap::clear怎么用?C++ QVariantMap::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTestCase
void TestUserInfo::initTestCase()
{
b_engine = new MockBaseEngine;
m_ipbxid = QString("testipbx");
m_linelist.append("23");
m_phoneidlist.append(QString("%0/%1").arg(m_ipbxid).arg("23"));
m_linelist.append("42");
m_phoneidlist.append(QString("%0/%1").arg(m_ipbxid).arg("42"));
m_phoneidlist.sort();
m_prop1["fullname"] = "testfullname";
m_prop1["voicemailid"] = "2345";
m_prop1["agentid"] = "1234";
m_prop1["enableclient"] = true;
m_prop1["enablevoicemail"] = true;
m_prop1["incallfilter"] = false;
m_prop1["enablednd"] = false;
m_prop1["enableunc"] = false;
m_prop1["enablerna"] = true;
m_prop1["destrna"] = "1002";
m_prop1["enablebusy"] = false;
m_prop1["mobilephonenumber"] = "4185555555";
m_prop1["linelist"] = m_linelist;
m_prop1["availstate"] = "available";
m_prop1["connection"] = "yes";
MockPhoneInfo * phoneinfo;
QVariantMap config;
phoneinfo = new MockPhoneInfo("asterisk", "p1");
config.clear();
config["identity"] = "SIP/sip1";
config["xchannels"] = "SIP/sip1-01";
config["number"] = "101";
phoneinfo->setConfig(config);
b_engine->setPhone("asterisk/p1", phoneinfo);
phoneinfo = new MockPhoneInfo("asterisk", "p2");
config.clear();
config["identity"] = "SIP/sip2";
config["xchannels"] = "SIP/sip2-02";
config["number"] = "102";
phoneinfo->setConfig(config);
b_engine->setPhone("asterisk/p2", phoneinfo);
MockChannelInfo *channelinfo;
channelinfo = new MockChannelInfo("asterisk", "SIP/sip1-01");
config.clear();
config["talkingto_id"] = "SIP/sip2-02";
channelinfo->setConfig(config);
b_engine->setChannel("SIP/sip1-01", channelinfo);
channelinfo = new MockChannelInfo("asterisk", "SIP/sip2-02");
config.clear();
config["talkingto_id"] = "SIP/sip1-01";
channelinfo->setConfig(config);
b_engine->setChannel("SIP/sip2-02", channelinfo);
}
示例2: test
bool FindValueOperation::test() const
{
QVariantMap testMap;
QVariantMap subKeys;
QVariantMap cur;
cur.insert(QLatin1String("testint2"), 53);
subKeys.insert(QLatin1String("subsubkeys"), cur);
subKeys.insert(QLatin1String("testbool"), true);
subKeys.insert(QLatin1String("testbool2"), false);
subKeys.insert(QLatin1String("otherint"), 53);
testMap.insert(QLatin1String("subkeys"), subKeys);
subKeys.clear();
testMap.insert(QLatin1String("subkeys2"), subKeys);
testMap.insert(QLatin1String("testint"), 23);
subKeys.clear();
QVariantList list1;
list1.append(QLatin1String("ignore this"));
list1.append(QLatin1String("ignore this2"));
QVariantList list2;
list2.append(QLatin1String("somevalue"));
subKeys.insert(QLatin1String("findMe"), QLatin1String("FindInList"));
list2.append(subKeys);
list2.append(QLatin1String("someothervalue"));
list1.append(QVariant(list2));
testMap.insert(QLatin1String("aList"), list1);
QStringList result;
result = findValue(testMap, QVariant(23));
if (result.count() != 1
|| !result.contains(QLatin1String("testint")))
return false;
result = findValue(testMap, QVariant(53));
if (result.count() != 2
|| !result.contains(QLatin1String("subkeys/subsubkeys/testint2"))
|| !result.contains(QLatin1String("subkeys/otherint")))
return false;
result = findValue(testMap, QVariant(23456));
if (!result.isEmpty())
return false;
result = findValue(testMap, QVariant(QString::fromLatin1("FindInList")));
if (result.count() != 1
|| !result.contains(QLatin1String("aList[2][1]/findMe")))
return false;
return true;
}
示例3: JsonHandler
StateHandler::StateHandler(QObject *parent) :
JsonHandler(parent)
{
QVariantMap params;
QVariantMap returns;
params.clear(); returns.clear();
setDescription("GetStateType", "Get the StateType for the given stateTypeId.");
params.insert("stateTypeId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
setParams("GetStateType", params);
returns.insert("deviceError", JsonTypes::deviceErrorRef());
returns.insert("o:stateType", JsonTypes::stateTypeRef());
setReturns("GetStateType", returns);
}
示例4: proRobotDevice
void CTransaction::proRobotDevice(ROBOT_DATA t_data, QByteArray s_data)
{
if(changing)
return;
int change = 0, i = 0;
for(i = 0; i < statusDataBuf.count();i++)
{
if(t_data.hrg_num == statusDataBuf[i].hrg_num)
{
t_data = checkMeaningful(statusDataBuf[i], t_data, change);
if(change)
{
statusDataBuf.removeAt(i);
i = 0;
}
break;
}
}
if(change == 1 ||
statusDataBuf.count() == i)
{
robotStatusData * deviceData= new robotStatusData(t_data);
QVariantMap deviceMap = toVariantMap(deviceData);
QVariant deviceJson = toJsonVariant(deviceMap);
emit uploadRobotDevice(deviceJson);
deviceMap.clear();
deviceJson.clear();
statusDataBuf.append(t_data);
if(deviceData != NULL)
{
delete deviceData;
deviceData = NULL;
}
}
}
示例5: setPluginConfig
void TestDevices::setPluginConfig()
{
QFETCH(PluginId, pluginId);
QFETCH(QVariant, value);
QFETCH(DeviceManager::DeviceError, error);
QVariantMap params;
params.insert("pluginId", pluginId);
QVariantList configuration;
QVariantMap configParam;
configParam.insert("name", "configParamInt");
configParam.insert("value", value);
configuration.append(configParam);
params.insert("configuration", configuration);
QVariant response = injectAndWait("Devices.SetPluginConfiguration", params);
verifyDeviceError(response, error);
if (error == DeviceManager::DeviceErrorNoError) {
params.clear();
params.insert("pluginId", pluginId);
response = injectAndWait("Devices.GetPluginConfiguration", params);
verifyDeviceError(response);
qDebug() << "222" << response.toMap().value("params").toMap().value("configuration").toList().first();
QVERIFY2(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("name") == "configParamInt", "Value not set correctly");
QVERIFY2(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("value") == value, "Value not set correctly");
}
}
示例6: test
bool FindKeyOperation::test() const
{
QVariantMap testMap;
QVariantMap subKeys;
QVariantMap cur;
cur.insert(QLatin1String("testint"), 53);
subKeys.insert(QLatin1String("subsubkeys"), cur);
subKeys.insert(QLatin1String("testbool"), true);
testMap.insert(QLatin1String("subkeys"), subKeys);
subKeys.clear();
testMap.insert(QLatin1String("subkeys2"), subKeys);
testMap.insert(QLatin1String("testint"), 23);
testMap.insert(QLatin1String("testbool"), true);
QStringList result;
result = findKey(testMap, QLatin1String("missing"));
if (!result.isEmpty())
return false;
result = findKey(testMap, QLatin1String("testint"));
if (result.count() != 2
|| !result.contains(QLatin1String("testint"))
|| !result.contains(QLatin1String("subkeys/subsubkeys/testint")))
return false;
result = findKey(testMap, QLatin1String("testbool"));
if (result.count() != 2
|| !result.contains(QLatin1String("testbool")))
return false;
return true;
}
示例7: stagePostFinished
void BaseOp::stagePostFinished()
{
if (isAborted() || m_reply == NULL) {
DBGLOG(LOG_DEBUG, 10, QString::fromUtf8("Aborted at 'post' stage"));
return report(WTFStatus_Aborted);
}
if (m_reply->error() != QNetworkReply::NoError) {
DBGLOG(LOG_ERROR, 2, QString::fromUtf8("Network error, code=%1").arg(m_reply->error()));
setProperty("varNetworkError", m_reply->error());
m_reply->deleteLater();
m_reply = NULL;
return report(WTFStatus_NetworkError);
}
QByteArray responseData = m_reply->readAll();
m_reply->deleteLater();
m_reply = NULL;
DBGLOG(LOG_DEBUG, 10, QString::fromUtf8("response data: %1").arg(QString::fromUtf8(responseData)));
QVariantMap result;
if (!parseResultXml(responseData, result)) {
DBGLOG(LOG_DEBUG, 2, QString::fromUtf8("parseResultXml failed!"));
result.clear();
}
report(processImpl(responseData, result));
}
示例8: readOra
QVariantList Core::readOra(const QString& oraPath) {
QZipReader zipReader(oraPath, QIODevice::ReadOnly);
QByteArray xmlByteArray = zipReader.fileData("stack.xml");
QXmlStreamReader stream(xmlByteArray);
QVariantMap map;
QVariantList list;
while (!stream.atEnd()) {
if (stream.isStartElement()) {
if (stream.name() == "layer") {
for (int i = 0; i < stream.attributes().size(); i++) {
map[stream.attributes().at(i).name().toString()] = stream.attributes().at(i).value().toString();
}
QByteArray ba = zipReader.fileData(stream.attributes().value("src").toString());
map["image"] = QString(ba.toBase64());
list.append(map);
map.clear();
}
}
stream.readNextStartElement();
}
zipReader.close();
return list;
}
示例9: test
bool GetOperation::test() const
{
QVariantMap testMap;
QVariantMap subKeys;
QVariantMap cur;
cur.insert(QLatin1String("testint2"), 53);
subKeys.insert(QLatin1String("subsubkeys"), cur);
subKeys.insert(QLatin1String("testbool"), true);
testMap.insert(QLatin1String("subkeys"), subKeys);
subKeys.clear();
testMap.insert(QLatin1String("subkeys2"), subKeys);
testMap.insert(QLatin1String("testint"), 23);
QVariant result;
result = get(testMap, QLatin1String("testint"));
if (result.toString() != QLatin1String("23"))
return false;
result = get(testMap, QLatin1String("subkeys/testbool"));
if (result.toString() != QLatin1String("true"))
return false;
result = get(testMap, QLatin1String("subkeys/subsubkeys"));
if (result.type() != QVariant::Map)
return false;
result = get(testMap, QLatin1String("nonexistant"));
if (result.isValid())
return false;
return true;
}
示例10: sendNotification
// Convienence function to send notifications. This function does some processing
// of the arguments. In these functions:
// expire_timeout: The amount of time in milliseconds the message is shown.
// A value of -1 means timeout is based on server's settings.
// overwrite : Will overwrite the previous message sent from this function.
// It will not overwrite notifications sent by other programs.
//
//
// Show notification with summary, app_name, and body text
void NotifyClient::sendNotification ()
{
// make sure we have a connection we can send the notification to.
if (! b_validconnection) return;
// variables
QString app_name = s_app_name;
quint32 replaces_id = 0;
QString app_icon = "";
QString body = "";
QString summary = s_summary;
QStringList actions = QStringList();
QVariantMap hints;
int expire_timeout = i_expire_timeout;
// set replaces_id
if (b_overwrite) replaces_id = current_id;
// assemble the hints
hints.clear();
hints.insert("urgency", QVariant::fromValue(static_cast<uchar>(i_urgency)) );
//if (! app_icon.isEmpty() ) hints.insert("image-path", QVariant::fromValue(app_icon));
// make sure we can display the text on this server
if (sl_capabilities.contains("body", Qt::CaseInsensitive) ) {
body = s_body;
if (! sl_capabilities.contains ("body-markup", Qt::CaseInsensitive) ) {
QTextDocument td;
td.setHtml(body);
body = td.toPlainText();
} // if server cannot display markup
} // if capabilities contains body
// process the icon, if we are using a fallback icon create a temporary file to hold it
QTemporaryFile tempfileicon;
if (! s_icon.isEmpty() ) {
if (sl_capabilities.filter("icon-", Qt::CaseInsensitive).count() > 0 ) {
if ( QIcon::hasThemeIcon(s_icon) ) app_icon = s_icon;
else {
if (QFile::exists(s_icon) ) {
if (tempfileicon.open() ) {
QPixmap px = QPixmap(s_icon);
px.save(tempfileicon.fileName(),"PNG");
app_icon = tempfileicon.fileName().prepend("file://");
} // if tempfileicon could be opened
} // if s_icon exists as a disk file
} // else not a theme icon
} // if capabilities support icons
} // if s_icon is not empty
QDBusReply<quint32> reply = notifyclient->call(QLatin1String("Notify"), app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout);
if (reply.isValid() )
current_id = reply.value();
else
qCritical("CMST - Error reply received to the Notify method: %s", qPrintable(reply.error().message()) );
return;
}
示例11: file
Playlist Read2Sources (const QString& path)
{
QFile file (path);
if (!file.open (QIODevice::ReadOnly))
{
qWarning () << Q_FUNC_INFO
<< "unable to open"
<< path
<< file.errorString ();
return {};
}
const auto& m3uDir = QFileInfo (path).absoluteDir ();
QVariantMap lastMetadata;
Playlist result;
while (!file.atEnd ())
{
const auto& line = file.readLine ().trimmed ();
if (line.startsWith ('#'))
{
const auto& pair = ParseMetadata (line);
if (!pair.first.isEmpty ())
lastMetadata [pair.first] = pair.second;
continue;
}
const auto& url = QUrl::fromEncoded (line);
auto src = QString::fromUtf8 (line);
const auto mdGuard = std::shared_ptr<void> (nullptr,
[&lastMetadata] (void*) { lastMetadata.clear (); });
#ifdef Q_OS_WIN32
if (url.scheme ().size () > 1)
#else
if (!url.scheme ().isEmpty ())
#endif
{
result.Append ({ url, lastMetadata });
continue;
}
src.replace ('\\', '/');
const QFileInfo fi (src);
if (fi.isRelative ())
src = m3uDir.absoluteFilePath (src);
if (fi.suffix () == "m3u" || fi.suffix () == "m3u8")
result += Read2Sources (src);
else
result.Append ({ src, lastMetadata });
}
return result;
}
示例12: JsonHandler
LoggingHandler::LoggingHandler(QObject *parent) :
JsonHandler(parent)
{
QVariantMap params;
QVariantMap returns;
QVariantMap timeFilter;
params.clear(); returns.clear();
setDescription("GetLogEntries", "Get the LogEntries matching the given filter. "
"Each list element of a given filter will be connected with OR "
"to each other. Each of the given filters will be connected with AND "
"to each other.");
timeFilter.insert("o:startDate", JsonTypes::basicTypeToString(JsonTypes::Int));
timeFilter.insert("o:endDate", JsonTypes::basicTypeToString(JsonTypes::Int));
params.insert("o:timeFilters", QVariantList() << timeFilter);
params.insert("o:loggingSources", QVariantList() << JsonTypes::loggingSourceRef());
params.insert("o:loggingLevels", QVariantList() << JsonTypes::loggingLevelRef());
params.insert("o:eventTypes", QVariantList() << JsonTypes::loggingEventTypeRef());
params.insert("o:typeIds", QVariantList() << JsonTypes::basicTypeToString(JsonTypes::Uuid));
params.insert("o:deviceIds", QVariantList() << JsonTypes::basicTypeToString(JsonTypes::Uuid));
params.insert("o:values", QVariantList() << JsonTypes::basicTypeToString(JsonTypes::Variant));
setParams("GetLogEntries", params);
returns.insert("loggingError", JsonTypes::loggingErrorRef());
returns.insert("o:logEntries", QVariantList() << JsonTypes::logEntryRef());
setReturns("GetLogEntries", returns);
// Notifications
params.clear();
setDescription("LogEntryAdded", "Emitted whenever an entry is appended to the logging system. ");
params.insert("logEntry", JsonTypes::logEntryRef());
setParams("LogEntryAdded", params);
params.clear();
setDescription("LogDatabaseUpdated", "Emitted whenever the database was updated. "
"The database will be updated when a log entry was deleted. A log "
"entry will be deleted when the corresponding device or a rule will "
"be removed, or when the oldest entry of the database was deleted to "
"keep to database in the size limits.");
setParams("LogDatabaseUpdated", params);
connect(GuhCore::instance()->logEngine(), &LogEngine::logEntryAdded, this, &LoggingHandler::logEntryAdded);
connect(GuhCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
}
示例13: generateLegend
QVariantList PieChart::generateLegend()
{
QVariantList list;
QVariantMap map;
for(PieSlice *slice: slicesList){
map.clear();
map.insert("name", slice->name());
map.insert("color", slice->color());
list.append(map);
}
return list;
}
示例14: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine("../EventManager/playground/qml_gui/MainWindow.qml");
QList<QObject *> Roots = engine.rootObjects();
assert(Roots.size() == 1);
QObject *MainWindow = Roots[0];
QObject *QmlFancyTab = MainWindow->findChild<QObject *>("FancyTabWidget");
assert(QmlFancyTab);
QVariantMap newElement; // QVariantMap will implicitly translates into JS-object
newElement.clear();
newElement.insert("name", "Im12age 13" );
newElement.insert("cost", "/mnt/freedata/home/Void/FFPics/1332603325_p04.jpg");
newElement.insert("componentName", "/mnt/freedata/home/Void/devel/EventManager/playground/qml_gui/SomeWidget1.qml");
QMetaObject::invokeMethod(QmlFancyTab, "addTab", Q_ARG(QVariant, QVariant::fromValue(newElement)));
newElement.clear();
newElement.insert("name", "Image 13" );
newElement.insert("cost", "/mnt/freedata/home/Void/FFPics/148.gif");
newElement.insert("componentName", "/mnt/freedata/home/Void/devel/Qt5Bin/5.1.0/gcc_64/qml/QtQuick/Controls/CheckBox.qml");
QMetaObject::invokeMethod(QmlFancyTab, "addTab", Q_ARG(QVariant, QVariant::fromValue(newElement)));
newElement.clear();
newElement.insert("name", "Im12age 13" );
newElement.insert("cost", "/mnt/freedata/home/Void/FFPics/1332603325_p04.jpg");
newElement.insert("componentName", "/mnt/freedata/home/Void/devel/EventManager/playground/qml_gui/SomeWidget2.qml");
QMetaObject::invokeMethod(QmlFancyTab, "addTab", Q_ARG(QVariant, QVariant::fromValue(newElement)));
QMetaObject::invokeMethod(QmlFancyTab, "showTab", Q_ARG(QVariant, QVariant::fromValue(0)));
// TQMLFancyTabWidget *FancyTabWidget = new TQMLFancyTabWidget;
// QObject::connect(QmlFancyTab, SIGNAL(clicked(int)), FancyTabWidget, SLOT(OnItemClicked(int)));
return app.exec();
}
示例15: QSettings
void Storage::readGroups2Map(QVariantMap& target, const QString &file)
{
target.clear();
QSettings* limits = new QSettings (file, QSettings::IniFormat, this);
QStringList groups = limits->childGroups();
if (groups.count()) {
foreach (const QString& group, groups) {
QVariantMap variantMap;
limits->beginGroup(group);
QStringList keylist = limits->allKeys();
foreach (const QString& key, keylist) {
variantMap.insert(key, limits->value(key));
}