void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k) { const QString name = ProjectExplorer::Project::makeUnique( QString::fromLatin1("qtc_") + k->fileSystemFriendlyName(), m_settings->profiles()); setProfileForKit(name, k); addQtProfileFromKit(name, k); // set up properties: QVariantMap data = m_defaultPropertyProvider->properties(k, QVariantMap()); QList<PropertyProvider *> providerList = ExtensionSystem::PluginManager::getObjects<PropertyProvider>(); foreach (PropertyProvider *provider, providerList) { if (provider->canHandle(k)) data = provider->properties(k, data); } addProfile(name, data); }
void QSyncable::set(QVariantMap &data, const QStringList &path, const QVariant &value) { QString key = path[0]; if (path.size() == 1) { data[key] = value; } else { if (!data.contains(key) || !data[key].canConvert<QVariantMap>()) { data[key] = QVariantMap(); } QStringList nextPath = path; nextPath.removeFirst(); QVariantMap map = data[key].toMap(); set(map, nextPath, value); data[key] = map; } }
QVariantMap QmlChoiseModel::get(int row) { qDebug() << Q_FUNC_INFO << "get" << row; if (row < 0 || row > _choiseItems.size() - 1) { qWarning() << Q_FUNC_INFO << "Invalid row " << row << "max" << _choiseItems.size(); return QVariantMap(); } QVariantMap map; const ChoiseItem &item = _choiseItems.at(row); map[_roleToProperty[IdRole]] = item.itemId; map[_roleToProperty[ShortDescriptionChoiseRole]] = item.shortDescription; map[_roleToProperty[LongDescriptionChoiseRole]] = item.longDescription; return map; }
QVariantMap ThemeConfig::save() { QModelIndex index = configUi->themesListView->currentIndex(); if (!index.isValid()) { return QVariantMap(); } QVariantMap args; args["sddm.conf/Theme/Current"] = index.data(ThemesModel::IdRole); if (!mThemeConfigPath.isEmpty()) { args["theme.conf.user/General/background"] = mBackgroundPath; } return args; }
TranslationInterface::~TranslationInterface() { #ifdef WITH_ANALYTICS if (m_privacyLevel == NoPrivacy) { m_analytics->trackEvent("Session End", QVariantMap(), true); } #endif delete m_service; delete m_services; delete m_sourceLanguages; delete m_targetLanguages; delete m_sourceLanguage; delete m_targetLanguage; delete m_dict; delete m_settings; }
QVariantMap CardChecker::courseCodesForRunId(int run_id) { QVariantMap ret; if(run_id <= 0) { qfError() << "Run ID == 0"; return ret; } qf::qmlwidgets::framework::MainWindow *fwk = qf::qmlwidgets::framework::MainWindow::frameWork(); auto runs_plugin = qobject_cast<Runs::RunsPlugin *>(fwk->plugin("Runs")); QF_ASSERT(runs_plugin != nullptr, "Bad plugin", return QVariantMap()); int course_id = runs_plugin->courseForRun(run_id); if(course_id <= 0) { qfError() << "Course ID == 0"; return ret; } { qfs::QueryBuilder qb; qb.select2("courses", "*") .from("courses") .where("courses.id=" QF_IARG(course_id)); qfs::Query q; q.exec(qb.toString(), qf::core::Exception::Throw); if(q.next()) ret = q.values(); } { qfs::QueryBuilder qb; qb.select2("coursecodes", "position") .select2("codes", "code, altCode, outOfOrder") .from("coursecodes") .join("coursecodes.codeId", "codes.id") .where("coursecodes.courseId=" QF_IARG(course_id)) .orderBy("coursecodes.position"); qfs::Query q; //qfWarning() << qb.toString(); q.exec(qb.toString(), qf::core::Exception::Throw); QVariantList codes; while (q.next()) { codes << q.values(); } ret["codes"] = codes; } return ret; }
void DownloadRequestDialog::showPluginSettingsDialog(const QString &title, const QVariantList &settings) { PluginSettingsDialog dialog(settings, this); dialog.setWindowTitle(title); dialog.setTimeout(DownloadRequestModel::instance()->requestedSettingsTimeout()); connect(DownloadRequestModel::instance(), SIGNAL(statusChanged(DownloadRequestModel::Status)), &dialog, SLOT(close())); switch (dialog.exec()) { case QDialog::Accepted: DownloadRequestModel::instance()->submitSettingsResponse(dialog.settings()); break; case QDialog::Rejected: DownloadRequestModel::instance()->submitSettingsResponse(QVariantMap()); break; default: break; } }
void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k) { const QString name = QString::fromLatin1("qtc_%1_%2").arg(k->fileSystemFriendlyName().left(8), QString::number(k->id().uniqueIdentifier(), 16)); qbs::Profile(name, settings()).removeProfile(); setProfileForKit(name, k); addQtProfileFromKit(name, k); // set up properties: QVariantMap data = m_defaultPropertyProvider->properties(k, QVariantMap()); QList<PropertyProvider *> providerList = ExtensionSystem::PluginManager::getObjects<PropertyProvider>(); foreach (PropertyProvider *provider, providerList) { if (provider->canHandle(k)) data = provider->properties(k, data); } addProfile(name, data); }
void SessionAgent::createSession() { if (m_manager->isAvailable()) { QDBusObjectPath obpath = m_manager->createSession(QVariantMap(),agentPath); if (!obpath.path().isEmpty()) { m_session = new Session(obpath.path(), this); new SessionNotificationAdaptor(this); QDBusConnection::systemBus().unregisterObject(agentPath); if (!QDBusConnection::systemBus().registerObject(agentPath, this)) { qDebug() << "Could not register agent object"; } } else { qDebug() << "agentPath is not valid" << agentPath; } } else { qDebug() << Q_FUNC_INFO << "manager not valid"; } }
void GenerateDNASequenceTask::run( ) { if ( seed < 0 ) { qsrand( QDateTime::currentDateTime( ).toTime_t( ) ); } else { qsrand( seed ); } dbiRef = AppContext::getDbiRegistry( )->getSessionTmpDbiRef( stateInfo ); CHECK_OP( stateInfo, ); DbiConnection con( dbiRef, stateInfo ); CHECK_OP( stateInfo, ); results.reserve( count ); for ( int seqCount = 0; seqCount < count; seqCount++ ) { U2SequenceImporter seqImporter( QVariantMap( ), true ); QByteArray sequenceChunk; if( window > length ) { window = length; } seqImporter.startSequence(stateInfo, dbiRef, U2ObjectDbi::ROOT_FOLDER, QString( "default" ), false); CHECK_OP_BREAK( stateInfo ); for( int chunkCount = 0; chunkCount < length / window && !isCanceled( ); chunkCount++ ) { DNASequenceGenerator::generateSequence( baseContent, window, sequenceChunk ); seqImporter.addBlock( sequenceChunk.constData( ), sequenceChunk.length( ), stateInfo ); CHECK_OP_BREAK( stateInfo ); const int currentProgress = int( 100 * ( seqCount + chunkCount * double ( window ) / double ( length ) ) / double( count ) ); stateInfo.setProgress( currentProgress ); } // append last chunk DNASequenceGenerator::generateSequence( baseContent, length % window, sequenceChunk ); seqImporter.addBlock( sequenceChunk.constData( ), sequenceChunk.length( ), stateInfo ); CHECK_OP_BREAK( stateInfo ); U2Sequence seq = seqImporter.finalizeSequence( stateInfo ); CHECK_OP_BREAK( stateInfo ); results.append( seq ); stateInfo.setProgress( seqCount / count * 100 ); } }
QColor Theme::color(const QString& name) { if(d->colorCache.contains(name)) return d->colorCache.value(name); QStringList parts = name.split('/'); QColor result; if(!parts.isEmpty()) { QVariantMap map = d->colors; QString current = parts.takeFirst(); while(map.contains(current)) { QVariant value = map.value(current); if(value.type() == QVariant::Map) { if(parts.isEmpty()) break; map = value.toMap(); current = parts.takeFirst(); } else { result = value.value<QColor>(); map = QVariantMap(); } } } if(!result.isValid() && d->inheritedTheme) { result = d->inheritedTheme->color(name); } if(!result.isValid()) { qWarning() << "Unable to find color" << name; } else { d->colorCache.insert(name, result); } return result; }
QVariantMap FileTransferChannelCreationProperties::createRequest() const { if (!isValid()) { warning() << "Invalid file transfer creation properties"; return QVariantMap(); } QVariantMap request; request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"), TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER); request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"), (uint) Tp::HandleTypeContact); request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Filename"), suggestedFileName()); request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentType"), contentType()); request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Size"), size()); if (hasContentHash()) { request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentHashType"), (uint) contentHashType()); request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentHash"), contentHash()); } if (hasDescription()) { request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Description"), description()); } if (hasLastModificationTime()) { request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Date"), (qulonglong) lastModificationTime().toTime_t()); } if (hasUri()) { request.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".URI"), uri()); } return request; }
QVariantMap authActionModifyUser(int i, QIODevice *connection, const QSqlDatabase& db, const QSqlDatabase& user_db, const QVariantMap& action, const QString& email) { Q_UNUSED(i); Q_UNUSED(db); Q_UNUSED(user_db); Q_UNUSED(connection); QString target_email = action.value("email").toString(); QString new_email = action.value("new_email").toString(); QString name = action.value("name").toString(); QString pass = action.value("pass").toString(); QVariantMap perms = action.value("perms").toMap(); auth->modifyUser(email, target_email, new_email, name, pass, perms); return QVariantMap(); }
bool QgsProcessingProvider::addAlgorithm( QgsProcessingAlgorithm *algorithm ) { if ( !algorithm ) return false; if ( mAlgorithms.contains( algorithm->name() ) ) { QgsMessageLog::logMessage( tr( "Duplicate algorithm name %1 for provider %2" ).arg( algorithm->name(), id() ), QObject::tr( "Processing" ) ); return false; } // init the algorithm - this allows direct querying of the algorithm's parameters // and outputs from the provider's copy algorithm->initAlgorithm( QVariantMap() ); algorithm->setProvider( this ); mAlgorithms.insert( algorithm->name(), algorithm ); return true; }
template<> QgsGeometryCheck *QgsGeometryCheckFactoryT<QgsGeometryTypeCheck>::createInstance( QgsGeometryCheckContext *context, const Ui::QgsGeometryCheckerSetupTab &ui ) const { QgsSettings().setValue( sSettingsGroup + "checkTypePoint", ui.checkBoxPoint->isChecked() ); QgsSettings().setValue( sSettingsGroup + "checkTypeMultipoint", ui.checkBoxMultipoint->isChecked() ); QgsSettings().setValue( sSettingsGroup + "checkTypeLine", ui.checkBoxLine->isChecked() ); QgsSettings().setValue( sSettingsGroup + "checkTypeMultiline", ui.checkBoxMultiline->isChecked() ); QgsSettings().setValue( sSettingsGroup + "checkTypePolygon", ui.checkBoxPolygon->isChecked() ); QgsSettings().setValue( sSettingsGroup + "checkTypeMultipolygon", ui.checkBoxMultipolygon->isChecked() ); int allowedTypes = 0; if ( ui.checkBoxPoint->isEnabled() && ui.checkBoxPoint->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::Point; } if ( ui.checkBoxMultipoint->isEnabled() && ui.checkBoxMultipoint->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::MultiPoint; } if ( ui.checkBoxLine->isEnabled() && ui.checkBoxLine->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::LineString; } if ( ui.checkBoxMultiline->isEnabled() && ui.checkBoxMultiline->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::MultiLineString; } if ( ui.checkBoxPolygon->isEnabled() && ui.checkBoxPolygon->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::Polygon; } if ( ui.checkBoxMultipolygon->isEnabled() && ui.checkBoxMultipolygon->isChecked() ) { allowedTypes |= 1 << QgsWkbTypes::MultiPolygon; } if ( allowedTypes != 0 ) { return new QgsGeometryTypeCheck( context, QVariantMap(), allowedTypes ); } else { return nullptr; } }
QVariantMap load(QString fn, bool *ok) { if (ok) *ok = false; QFile f(fn); if (!f.open(QFile::ReadOnly)) { qDebug() << "JSONFile::load: file not found"; return QVariantMap(); } bool ok1; QTextStream ts(&f); ts.setCodec("UTF-8"); QVariantMap res = read(ts.readAll(), &ok1); if (!ok1) qDebug() << "(while reading: " << fn << ")"; if (ok) *ok = ok1; return res; }
void DesktopNotificationsFactory::showNotifications(const QPixmap &icon, const QString &heading, const QString &text) { if (!m_enabled) { return; } switch (m_notifType) { case PopupWidget: if (!m_desktopNotif) { m_desktopNotif = new DesktopNotification(); } m_desktopNotif.data()->setPixmap(icon); m_desktopNotif.data()->setHeading(heading); m_desktopNotif.data()->setText(text); m_desktopNotif.data()->setTimeout(m_timeout); m_desktopNotif.data()->move(m_position); m_desktopNotif.data()->show(); break; case DesktopNative: #ifdef Q_WS_X11 QFile tmp(QDir::tempPath() + "/qupzilla_notif.png"); tmp.open(QFile::WriteOnly); icon.save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append("qupzilla"); args.append(m_uint); args.append(tmp.fileName()); args.append(heading); args.append(text); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args); QVariantList list = message.arguments(); if (list.count() > 0) { m_uint = list.at(0).toInt(); } #endif break; } }
void ProtoWrapper::RegisterAccount (const QString& name, const QList<QWidget*>& widgets) { auto fpg = qobject_cast<AccountRegFirstPage*> (widgets.value (0)); if (!fpg) { qWarning () << Q_FUNC_INFO << "incorrect first page" << widgets; return; } const QVariantMap& params = GetParamsFromWidgets (widgets); auto pending = AM_->createAccount (CM_->name (), ProtoName_, name, params, QVariantMap ()); connect (pending, SIGNAL (finished (Tp::PendingOperation*)), this, SLOT (handleAccountCreated (Tp::PendingOperation*))); PendingSettings_ [pending] = GetSettingsFromWidgets (widgets); }
void MixedTest::test_mixed() { QVariantMap map; map["booleans"] = QVariantList() << false << true; map["list2"] = QVariantList() << (QVariantList() << "abc" << "def") << (QVariantList() << "qwe" << "rty"); map["integers"] = QVariantList() << 0 << 127 << -31 << 128 << 777; map["bytearray"] = QByteArray("bytes"); QVariantMap map2; map2["one"] = 1; map2["two"] = QVariantMap(); map["map2"] = map2; QByteArray arr = MsgPack::pack(map); QVariant unpacked = MsgPack::unpack(arr); QVERIFY(unpacked.toMap() == map); }
Preferences QDesignerSettings::preferences() const { Preferences rc; #ifdef Q_WS_WIN const UIMode defaultMode = DockedMode; #else const UIMode defaultMode = TopLevelMode; #endif rc.m_uiMode = static_cast<UIMode>(value(QLatin1String("UI/currentMode"), defaultMode).toInt()); rc.m_writingSystem = static_cast<QFontDatabase::WritingSystem>(value(QLatin1String("UI/writingSystem"), QFontDatabase::Any).toInt()); rc.m_font = qVariantValue<QFont>(value(QLatin1String("UI/font"))); rc.m_useFont = value(QLatin1String("UI/useFont"), QVariant(false)).toBool(); const QVariantMap defaultGridMap = value(QLatin1String(defaultGridKey), QVariantMap()).toMap(); if (!defaultGridMap.empty()) rc.m_defaultGrid.fromVariantMap(defaultGridMap); rc.m_additionalTemplatePaths = additionalFormTemplatePaths(); rc.m_previewConfigurationWidgetState = previewConfigurationWidgetState(); rc.m_previewConfiguration = previewConfiguration(); return rc; }
/*! \qmlmethod bool FacebookUser::uploadAlbum(const QString &name, const QString &message, const QVariantMap &privacy) Initiates a "post album" operation on the user. The album will be created with the given \a name and be described by the given \a message, and will have the specified \a privacy. If the network request was started successfully, the function will return true and the status of the user will change to \c SocialNetwork::Busy. Otherwise, the function will return false. Once the network request completes, the \c responseReceived() signal will be emitted. The \c data parameter of the signal will contain the \c id of the newly uploaded album. */ bool FacebookUserInterface::uploadAlbum(const QString &name, const QString &message, const QVariantMap &privacy) { Q_D(FacebookUserInterface); QVariantMap postData; postData.insert("name", name); if (!message.isEmpty()) postData.insert("message", message); if (privacy != QVariantMap()) postData.insert("privacy", privacy); bool requestMade = request(IdentifiableContentItemInterface::Post, identifier(), QLatin1String("albums"), QStringList(), postData); if (!requestMade) return false; d->action = FacebookInterfacePrivate::UploadAlbumAction; d->connectFinishedAndErrors(); return true; }
MapFile::MapFile(QString filename, QObject *parent) : QObject(parent), _filename(filename) { Q_ASSERT(!filename.isEmpty()); QFile load_file(_filename); try { if (load_file.exists()){ if (load_file.open(QIODevice::ReadOnly)){ loadDataMap(load_file); } } else { if (load_file.open(QIODevice::ReadWrite)) { QJsonDocument data_doc = QJsonDocument(QJsonObject::fromVariantMap(QVariantMap())); load_file.write(data_doc.toJson()); loadDataMap(load_file); } } } catch (QException e) { //TODO: handle catch } }
bool RmToolChainOperation::test() const { // Add toolchain: QVariantMap map = AddToolChainOperation::initializeToolChains(); map = AddToolChainOperation::addToolChain(map, QLatin1String("testId"), QLatin1String("name"), QLatin1String("/tmp/test"), QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"), KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue")))); map = AddToolChainOperation::addToolChain(map, QLatin1String("testId2"), QLatin1String("other name"), QLatin1String("/tmp/test2"), QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"), KeyValuePairList()); QVariantMap result = rmToolChain(QVariantMap(), QLatin1String("nonexistant")); if (!result.isEmpty()) return false; result = rmToolChain(map, QLatin1String("nonexistant")); if (result != map) return false; result = rmToolChain(map, QLatin1String("testId2")); if (result == map || result.value(QLatin1String(COUNT), 0).toInt() != 1 || !result.contains(QLatin1String("ToolChain.0")) || result.value(QLatin1String("ToolChain.0")) != map.value(QLatin1String("ToolChain.0"))) return false; result = rmToolChain(map, QLatin1String("testId")); if (result == map || result.value(QLatin1String(COUNT), 0).toInt() != 1 || !result.contains(QLatin1String("ToolChain.0")) || result.value(QLatin1String("ToolChain.0")) != map.value(QLatin1String("ToolChain.1"))) return false; result = rmToolChain(result, QLatin1String("testId2")); if (result == map || result.value(QLatin1String(COUNT), 0).toInt() != 0) return false; return true; }
void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QString &heading, const QString &text) { if (!m_enabled) { return; } switch (m_notifType) { case PopupWidget: if (!m_desktopNotif) { m_desktopNotif = new DesktopNotification(); } m_desktopNotif.data()->setPixmap(icon); m_desktopNotif.data()->setHeading(heading); m_desktopNotif.data()->setText(text); m_desktopNotif.data()->setTimeout(m_timeout); m_desktopNotif.data()->move(m_position); m_desktopNotif.data()->show(); break; case DesktopNative: #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS) QFile tmp(DataPaths::path(DataPaths::Temp) + QLatin1String("/qupzilla_notif.png")); tmp.open(QFile::WriteOnly); icon.save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append(QLatin1String("qupzilla")); args.append(m_uint); args.append(tmp.fileName()); args.append(heading); args.append(text); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError))); #endif break; } }
QVariantMap Qdl::getTransfer(const QString &id, bool includeChildren) { const QModelIndex index = getTransferModelIndexById(id); if (index.isValid()) { QVariantMap transfer = TransferModel::instance()->itemDataWithRoleNames(index); if (includeChildren) { QVariantList children; const int count = TransferModel::instance()->rowCount(index); for (int i = 0; i < count; i++) { children << TransferModel::instance()->itemDataWithRoleNames(TransferModel::instance()->index(i, 0, index)); } transfer["children"] = children; } return transfer; } return QVariantMap(); }
void dtkDistributedControllerSubmitView::onSubmit(void) { if(!d->controller) return; if(d->cluster.isEmpty()) return; QVariantMap resources; resources.insert("cores", d->ppn_spin->text()); resources.insert("nodes", d->node_spin->text()); QVariantMap job; job.insert("resources", resources); job.insert("properties", QVariantMap()); job.insert("walltime", d->time_edit->time().toString("hh:mm:ss")); job.insert("application", d->application +" "+d->cluster); QByteArray data = QJsonDocument(QJsonObject::fromVariantMap(job)).toJson(); d->controller->submit(QUrl(d->cluster), data); }
void ServiceChoooserWidget::loadImpl() { clear(); ConfigGroup group = Config().group("services"); QVariantMap selected = group.value("list", QVariantMap()); QStandardItem *parent_item = m_model->invisibleRootItem(); ExtensionInfoList exts = extensionList(); QStringList helper; for (int i = 0; i < exts.size(); ++i) { const ExtensionInfo &info = exts.at(i); const char *serviceName = MetaObjectBuilder::info(info.generator()->metaObject(), "Service"); if (serviceName && *serviceName) { if (!m_service_items.contains(serviceName)) { QString localizedName = QT_TRANSLATE_NOOP("Service",serviceName).toString(); int index = qLowerBound(helper, localizedName) - helper.constBegin(); helper.insert(index, localizedName); ServiceItem *item = new ServiceItem(Icon(serviceIcon(serviceName)),localizedName); item->setData(true,ServiceItem::ExclusiveRole); parent_item->insertRow(index, item); m_service_items.insert(serviceName,item); } QIcon icon = !info.icon().name().isEmpty() ? info.icon() : Icon("applications-system"); ServiceItem *item = new ServiceItem(icon,info.name()); item->setToolTip(ServiceChoooser::html(info)); item->setCheckable(true); item->setData(info.description().toString(),DescriptionRole); if (selected.value(serviceName).toString() == ServiceChoooser::className(info)) item->setCheckState(Qt::Checked); item->setData(qVariantFromValue(info), ServiceItem::ExtentionInfoRole); m_service_items.value(serviceName)->appendRow(item); } } }
void Settings::setValue(const QString &key, const QVariant &value) { if (!m_group.isEmpty()) { if (value.isNull()) { if (m_data.contains(m_group) && m_data[m_group].contains(key)) { m_data[m_group].remove(key); } } else { if (!m_data.contains(m_group)) { m_data[m_group] = QVariantMap(); } m_data[m_group][key] = value; } } }
void TestCommand::testAsyncCommandExecution() { unsigned long mainThread = QThread::currentThreadId(); KeePassxDriveSync::Command fakeCommand = remoteDriveApi->fakeAsyncCommand(); QSignalSpy spy(fakeCommand.data(), SIGNAL(finished())); fakeCommand->executeAsync(QVariantMap()); int waitTime = 0; while (spy.count() == 0 && waitTime < 10000) { QTest::qWait(200); waitTime += 200; } // make sure finished was emitted QCOMPARE(spy.count(), 1); QVariantList result = fakeCommand->getResult(); unsigned long commandThreadId = result.at(0).value<unsigned long>(); // threads should be the same since command invoked through execute method QVERIFY(mainThread != commandThreadId); QVERIFY(fakeCommand->getErrorCode() == Errors::NO_ERROR); }
QVariantMap AddKeysOperation::addKeys(const QVariantMap &map, const KeyValuePairList &additions) { // Insert data: QVariantMap result = map; foreach (const KeyValuePair &p, additions) { QList<QVariantMap> stack; // Set up a stack of QVariantMaps along the path we take: stack.append(result); for (int i = 0; i < p.key.count() - 1; ++i) { QVariantMap subMap; if (stack.last().contains(p.key.at(i))) subMap = stack.last().value(p.key.at(i)).toMap(); stack.append(subMap); } // insert Q_ASSERT(stack.count() == p.key.count()); if (stack.last().contains(p.key.last())) { std::cerr << "DEBUG: Adding key " << qPrintable(p.key.join(QLatin1String("/"))) << " which already exists." << std::endl; return QVariantMap(); } stack.last().insert(p.key.last(), p.value); // Generate new resultset by folding maps back in: QVariantMap foldBack = stack.takeLast(); for (int i = p.key.count() - 2; i >= 0; --i) { // skip last key, that is already taken care of const QString k = p.key.at(i); QVariantMap current = stack.takeLast(); current.insert(k, foldBack); foldBack = current; } Q_ASSERT(stack.count() == 0); Q_ASSERT(foldBack != map); result = foldBack; }