void initializeFormatForMimeType() { if (formatForMimeType.isEmpty()) { QString filename("/etc/mime.types"); if (QFile::exists(filename)) readMimeTypeData(filename); readMimeTypeData(":/mime.types"); } }
const QHash<QString, QString> &IcqAccountMainSettings::defaultSslServers() const { static QHash<QString, QString> list; if (list.isEmpty()) { list.insert("login.icq.com", "slogin.icq.com"); list.insert("login.oscar.aol.com", "slogin.oscar.aol.com"); } return list; }
QgsRasterBandStats QgsGrassRasterProvider::bandStatistics( int bandNo, int stats, const QgsRectangle &boundingBox, int sampleSize, QgsRasterBlockFeedback * ) { QgsDebugMsg( QString( "theBandNo = %1 sampleSize = %2" ).arg( bandNo ).arg( sampleSize ) ); QgsRasterBandStats myRasterBandStats; initStatistics( myRasterBandStats, bandNo, stats, boundingBox, sampleSize ); const auto constMStatistics = mStatistics; for ( const QgsRasterBandStats &stats : constMStatistics ) { if ( stats.contains( myRasterBandStats ) ) { QgsDebugMsg( "Using cached statistics." ); return stats; } } QgsRectangle extent = myRasterBandStats.extent; int sampleRows = myRasterBandStats.height; int sampleCols = myRasterBandStats.width; // With stats we have to be careful about timeout, empirical value, // 0.001 / cell should be sufficient using 0.005 to be sure + constant (ms) int timeout = 30000 + 0.005 * xSize() * ySize(); QString error; QHash<QString, QString> info = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrassObject::Raster, QStringLiteral( "stats" ), extent, sampleRows, sampleCols, timeout, error ); if ( info.isEmpty() || !error.isEmpty() ) { return myRasterBandStats; } myRasterBandStats.sum = info[QStringLiteral( "SUM" )].toDouble(); myRasterBandStats.elementCount = info[QStringLiteral( "COUNT" )].toInt(); myRasterBandStats.minimumValue = info[QStringLiteral( "MIN" )].toDouble(); myRasterBandStats.maximumValue = info[QStringLiteral( "MAX" )].toDouble(); myRasterBandStats.range = myRasterBandStats.maximumValue - myRasterBandStats.minimumValue; myRasterBandStats.sumOfSquares = info[QStringLiteral( "SQSUM" )].toDouble(); myRasterBandStats.mean = info[QStringLiteral( "MEAN" )].toDouble(); myRasterBandStats.stdDev = info[QStringLiteral( "STDEV" )].toDouble(); QgsDebugMsg( QString( "min = %1" ).arg( myRasterBandStats.minimumValue ) ); QgsDebugMsg( QString( "max = %1" ).arg( myRasterBandStats.maximumValue ) ); QgsDebugMsg( QString( "count = %1" ).arg( myRasterBandStats.elementCount ) ); QgsDebugMsg( QString( "stdev = %1" ).arg( myRasterBandStats.stdDev ) ); myRasterBandStats.statsGathered = QgsRasterBandStats::Min | QgsRasterBandStats::Max | QgsRasterBandStats::Range | QgsRasterBandStats::Mean | QgsRasterBandStats::Sum | QgsRasterBandStats::SumOfSquares | QgsRasterBandStats::StdDev; mStatistics.append( myRasterBandStats ); return myRasterBandStats; }
IrcCommand* CommandParser::parseCommand(const QString& receiver, const QString& text) { if (text.startsWith("//") || text.startsWith("/ ") || !text.startsWith('/')) { QString message = text; if (message.startsWith('/')) message.remove(0, 1); return IrcCommand::createMessage(receiver, message.trimmed()); } else { typedef IrcCommand*(*ParseFunc)(const QString&, const QStringList&); static QHash<QString, ParseFunc> parseFunctions; if (parseFunctions.isEmpty()) { parseFunctions.insert("ADMIN", &CommandParser::parseAdmin); parseFunctions.insert("AWAY", &CommandParser::parseAway); parseFunctions.insert("INFO", &CommandParser::parseInfo); parseFunctions.insert("INVITE", &CommandParser::parseInvite); parseFunctions.insert("KICK", &CommandParser::parseKick); parseFunctions.insert("KNOCK", &CommandParser::parseKnock); parseFunctions.insert("LIST", &CommandParser::parseList); parseFunctions.insert("ME", &CommandParser::parseMe); parseFunctions.insert("MODE", &CommandParser::parseMode); parseFunctions.insert("MOTD", &CommandParser::parseMotd); parseFunctions.insert("NAMES", &CommandParser::parseNames); parseFunctions.insert("NICK", &CommandParser::parseNick); parseFunctions.insert("NOTICE", &CommandParser::parseNotice); parseFunctions.insert("PART", &CommandParser::parsePart); parseFunctions.insert("PING", &CommandParser::parsePing); parseFunctions.insert("QUIT", &CommandParser::parseQuit); parseFunctions.insert("QUOTE", &CommandParser::parseQuote); parseFunctions.insert("STATS", &CommandParser::parseStats); parseFunctions.insert("TIME", &CommandParser::parseTime); parseFunctions.insert("TOPIC", &CommandParser::parseTopic); parseFunctions.insert("TRACE", &CommandParser::parseTrace); parseFunctions.insert("USERS", &CommandParser::parseUsers); parseFunctions.insert("VERSION", &CommandParser::parseVersion); parseFunctions.insert("WHO", &CommandParser::parseWho); parseFunctions.insert("WHOIS", &CommandParser::parseWhois); parseFunctions.insert("WHOWAS", &CommandParser::parseWhowas); } const QString expanded = expandAlias(receiver, text.mid(1)); const QStringList words = expanded.split(" ", QString::SkipEmptyParts); const QString command = words.value(0).toUpper(); ParseFunc parseFunc = parseFunctions.value(command); if (parseFunc) { IrcCommand* cmd = parseFunc(receiver, words.mid(1)); if (cmd) return cmd; } else if (command_syntaxes().contains(command.toUpper())) { return parseCustomCommand(command, words.mid(1), command_syntaxes().value(command.toUpper())); } } // unknown command return 0; }
void tst_QScriptValueGenerated::qscriptvalue_castqint32_makeData(const char* expr) { static QHash<QString, qint32> value; if (value.isEmpty()) { value.reserve(148); for (unsigned i = 0; i < 148; ++i) value.insert(qscriptvalue_castqint32_tagArray[i], qscriptvalue_castqint32_valueArray[i]); } newRow(expr) << value.value(expr); }
Types::UnitsOfLength Types::unitOfLenthFromString(const QString &string) { static QHash<QString, UnitsOfLength> hash; if (hash.isEmpty()) { const QList<UnitsOfLength> units = unitsOfLength().keys(); foreach (UnitsOfLength unit, units) hash.insert(unitsOfLength().value(unit).first, unit); } return hash.value(string); }
QHash<int,QByteArray> ChainOfTrustModel::roleNames() const { static QHash<int,QByteArray> roles; if (roles.isEmpty()) { roles[(int) Role::OBJECT] = "object"; } return roles; }
// =============================== // ====== PRIVATE SLOTS ====== // =============================== // Internal Process Management void PBIBackend::checkProcesses(){ //Check whether to startup the next pending process if( !PKGRUN.isEmpty() || PENDING.isEmpty() ){ return; } //currently running or nothing to do //Parse the next PENDING command PKGRUN = PENDING[0].section("::::",0,0); PKGCMD = PENDING[0].section("::::",1,1); PKGJAIL = PENDING[0].section("::::",2,2); PENDING.removeAt(0); //remove this from the pending list if( PKGCMD.startsWith("pbi_add") || PKGCMD.startsWith("pc-pkg install") ){ PROCTYPE = 0; } //install else if( PKGCMD.startsWith("pbi_delete") || PKGCMD.startsWith("pc-pkg remove") ){ PROCTYPE = 1; } //remove else{ PROCTYPE = -1; } //other type of command (no special checks later) PROCCANCELLED = false; PKGRUNSTAT.clear(); PROCLOG.clear(); bool injail = !PKGJAIL.isEmpty(); QHash<QString, NGApp> hash; if(JAILPKGS.contains(PKGJAIL) && PKGJAIL!="--newjail"){ hash = JAILPKGS[PKGJAIL]; } else if(APPHASH.contains(PKGRUN)){ hash = APPHASH; } else if(PKGHASH.contains(PKGRUN)){ hash = PKGHASH; } //Check that this is a valid entry/command bool skip = false; //need to skip this PENDING entry for some reason if( hash.isEmpty() ){ skip = true; qDebug() << PKGRUN+":" << "pkg not on repo";} //invalid pkg on the repo else if( PROCTYPE==0 && hash.value(PKGRUN).isInstalled && PKGJAIL!="--newjail"){ skip = true; qDebug() << PKGRUN+":" << "already installed"; } //already installed else if( PROCTYPE==1 && !hash.value(PKGRUN).isInstalled ){ skip = true; qDebug() << PKGRUN+":" << "already uninstalled"; } //not installed if(skip){ qDebug() << "Requested Process Invalid:" << PKGRUN << PKGCMD; emit PBIStatusChange(PKGRUN); PKGRUN.clear(); PKGCMD.clear(); QTimer::singleShot(1,this,SLOT(checkProcesses()) ); //restart this function to check the next command return; } //Now run any pre-remove commands (if not an in-jail removal, or raw pkg mode) if(PROCTYPE==1 && !injail && PKGCMD.startsWith("pc-pkg ") ){ Extras::getCmdOutput("pbi_icon del-desktop del-menu del-mime "+PKGRUN); //don't care about result }else if( PROCTYPE==0 && injail && RUNNINGJAILS.contains(PKGJAIL) && PKGJAIL!="--newjail"){ //For installations, make sure the jail pkg config is synced with the current system pkg config qDebug() << "Syncing pkg config in jail:" << PKGJAIL; emit devMessage( "** Syncing pkg config in jail: " +PKGJAIL+" **" ); Extras::getCmdOutput("pc-updatemanager -j "+RUNNINGJAILS[PKGJAIL]+" syncconf"); } qDebug() << "Starting Process:" << PKGRUN << PKGCMD; //Set the new status if(PROCTYPE==0){ PKGRUNSTAT=tr("Starting Installation"); } else if(PROCTYPE==1){ PKGRUNSTAT=tr("Starting Removal"); } else{ PKGRUNSTAT.clear(); } emit PBIStatusChange(PKGRUN); //Now start the command emit devMessage( "** Starting Process: \""+PKGCMD+"\" **" ); pkgProc->start(PKGCMD); }
static QString findFontFile(const QString &faceName) { static QHash<QString, QString> fontCache; if (fontCache.isEmpty()) { QSettings settings(QSettings::SystemScope, fontSettingsOrganization(), fontSettingsApplication()); settings.beginGroup(fontSettingsGroup()); foreach (const QString &fontName, settings.allKeys()) fontCache.insert(fontName, settings.value(fontName).toString()); settings.endGroup(); }
QHash<int, QByteArray> ResultModel::roleNames() const { static QHash<int, QByteArray> roleNames; if (roleNames.isEmpty()) { roleNames[ExpressionRole] = "expression"; roleNames[ResultRole] = "result"; roleNames[TagRole] = "tag"; roleNames[IndexRole] = "index"; } return roleNames; }
void CDTpAccountCacheWriter::run() { const QString accountPath = mAccount->account()->objectPath(); const QString rosterFileName = CDTpAccountCache::cacheFilePath(mAccount); const QHash<QString, CDTpContact::Info> cache = mAccount->rosterCache(); if (cache.isEmpty()) { QFile(rosterFileName).remove(); return; } QTemporaryFile tempFile(rosterFileName); tempFile.setAutoRemove(false); if (not tempFile.open()) { warning() << "Could not open file" << tempFile.fileName() << "for writing:" << tempFile.errorString(); tempFile.setAutoRemove(true); return; } QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); QDataStream stream(&buffer); stream << CDTpAccountCache::Version; stream << cache; buffer.close(); if (tempFile.write(data) != data.size()) { warning() << "Could not write roster cache for account" << accountPath << ":" << tempFile.errorString(); tempFile.setAutoRemove(true); return; } if (not tempFile.flush() || (::fsync(tempFile.handle()) != 0) || (tempFile.close(), false)) { warning() << "Could not finalize roster cache for account" << accountPath << ":" << tempFile.errorString(); tempFile.setAutoRemove(true); return; } if (::rename(tempFile.fileName().toLocal8Bit(), rosterFileName.toLocal8Bit()) != 0) { warning() << "Could not write roster cache for account" << accountPath << ":" << strerror(errno); tempFile.setAutoRemove(true); return; } debug() << "Wrote" << mAccount->rosterCache().size() << "contacts to cache for account" << accountPath; }
QgsRasterBandStats QgsGrassRasterProvider::bandStatistics( int theBandNo, int theStats, const QgsRectangle & theExtent, int theSampleSize ) { QgsDebugMsg( QString( "theBandNo = %1 theSampleSize = %2" ).arg( theBandNo ).arg( theSampleSize ) ); QgsRasterBandStats myRasterBandStats; initStatistics( myRasterBandStats, theBandNo, theStats, theExtent, theSampleSize ); foreach ( QgsRasterBandStats stats, mStatistics ) { if ( stats.contains( myRasterBandStats ) ) { QgsDebugMsg( "Using cached statistics." ); return stats; } } QgsRectangle extent = myRasterBandStats.extent; int sampleRows = myRasterBandStats.height; int sampleCols = myRasterBandStats.width; // With stats we have to be careful about timeout, empirical value, // 0.001 / cell should be sufficient using 0.005 to be sure + constant (ms) int timeout = 30000 + 0.005 * xSize() * ySize(); QHash<QString, QString> info = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrass::Raster, "stats", extent, sampleRows, sampleCols, timeout ); if ( info.isEmpty() ) { return myRasterBandStats; } myRasterBandStats.sum = info["SUM"].toDouble(); myRasterBandStats.elementCount = info["COUNT"].toInt(); myRasterBandStats.minimumValue = info["MIN"].toDouble(); myRasterBandStats.maximumValue = info["MAX"].toDouble(); myRasterBandStats.range = myRasterBandStats.maximumValue - myRasterBandStats.minimumValue; myRasterBandStats.sumOfSquares = info["SQSUM"].toDouble(); myRasterBandStats.mean = info["MEAN"].toDouble(); myRasterBandStats.stdDev = info["STDEV"].toDouble(); QgsDebugMsg( QString( "min = %1" ).arg( myRasterBandStats.minimumValue ) ); QgsDebugMsg( QString( "max = %1" ).arg( myRasterBandStats.maximumValue ) ); QgsDebugMsg( QString( "count = %1" ).arg( myRasterBandStats.elementCount ) ); QgsDebugMsg( QString( "stdev = %1" ).arg( myRasterBandStats.stdDev ) ); myRasterBandStats.statsGathered = QgsRasterBandStats::Min | QgsRasterBandStats::Max | QgsRasterBandStats::Range | QgsRasterBandStats::Mean | QgsRasterBandStats::Sum | QgsRasterBandStats::SumOfSquares | QgsRasterBandStats::StdDev; mStatistics.append( myRasterBandStats ); return myRasterBandStats; }
inline QMMapView::MapType fromJsMapType(QString &type) { static QHash<QString, QMMapView::MapType> types; if (types.isEmpty()) { types.insert("hybrid", QMMapView::Hybrid); types.insert("roadmap", QMMapView::RoadMap); types.insert("satellite", QMMapView::Satellite); types.insert("terrain", QMMapView::Terrain); } return types.value(type, initialValues.mapType); }
QHash<int,QByteArray> QMainNavigationModel::roleNames() const { static QHash<int, QByteArray> roleNames; if (roleNames.isEmpty()) { roleNames[StringRole] = "submodelName"; roleNames[SubModelTypeRole] = "submodelType"; } return roleNames; }
QString getLogo(QString name) { static QHash<QString,QString> l; if(l.isEmpty()){ QFile file(":/Text/DATA"); file.open(QIODevice::ReadOnly|QIODevice::Text); QJsonObject data=QJsonDocument::fromJson(file.readAll()).object()["Logo"].toObject(); for(auto iter=data.begin();iter!=data.end();++iter){ l[iter.key()]=iter.value().toString(); } } return l[name]; }
void TabManagerWidget::closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash) { if (tabsHash.isEmpty()) { return; } const QList<BrowserWindow*> &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { QList<WebTab*> tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->requestCloseTab(webTab->tabIndex()); }
static void initFadeTypes (void) { if (g_fadeTypes.isEmpty()) { const QPixmap pmFadeIn(":/images/fadeIn.png"); const QPixmap pmFadeOut(":/images/fadeOut.png"); for (int i = 0; g_aFadeTypeNames[i]; ++i) { FadeTypeInfo& info = g_fadeTypes[i]; info.name = QObject::tr(g_aFadeTypeNames[i], "fadeType"); info.iconFadeIn = pmFadeIn.copy(i << 4, 0, 16, 16); info.iconFadeOut = pmFadeOut.copy(i << 4, 0, 16, 16); } } }
/*! Sets variables according to the values set in the package.xml file of \a package. Also loads UI files, licenses and translations if they are referenced in the package.xml. */ void Component::loadDataFromPackage(const Package &package) { Q_ASSERT(&package); setValue(scName, package.data(scName).toString()); setValue(scDisplayName, package.data(scDisplayName).toString()); setValue(scDescription, package.data(scDescription).toString()); setValue(scDefault, package.data(scDefault).toString()); setValue(scAutoDependOn, package.data(scAutoDependOn).toString()); setValue(scCompressedSize, package.data(scCompressedSize).toString()); setValue(scUncompressedSize, package.data(scUncompressedSize).toString()); setValue(scRemoteVersion, package.data(scRemoteVersion).toString()); setValue(scInheritVersion, package.data(scInheritVersion).toString()); setValue(scDependencies, package.data(scDependencies).toString()); setValue(scDownloadableArchives, package.data(scDownloadableArchives).toString()); setValue(scVirtual, package.data(scVirtual).toString()); setValue(scSortingPriority, package.data(scSortingPriority).toString()); setValue(scEssential, package.data(scEssential).toString()); setValue(scUpdateText, package.data(scUpdateText).toString()); setValue(scNewComponent, package.data(scNewComponent).toString()); setValue(scRequiresAdminRights, package.data(scRequiresAdminRights).toString()); setValue(scScriptTag, package.data(scScriptTag).toString()); setValue(scReplaces, package.data(scReplaces).toString()); setValue(scReleaseDate, package.data(scReleaseDate).toString()); QString forced = package.data(scForcedInstallation, scFalse).toString().toLower(); if (PackageManagerCore::noForceInstallation()) forced = scFalse; setValue(scForcedInstallation, forced); if (forced == scTrue) { setCheckable(false); setCheckState(Qt::Checked); } setLocalTempPath(QInstaller::pathFromUrl(package.sourceInfoUrl())); const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString() .split(QInstaller::commaRegExp(), QString::SkipEmptyParts); if (!uis.isEmpty()) loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis); const QStringList qms = package.data(QLatin1String("Translations")).toString() .split(QInstaller::commaRegExp(), QString::SkipEmptyParts); if (!qms.isEmpty()) loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms); QHash<QString, QVariant> licenseHash = package.data(QLatin1String("Licenses")).toHash(); if (!licenseHash.isEmpty()) loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash); }
QIcon IconDecorator::getIconByName(const QString &name) { static QHash<QString, QIcon> icons; if (icons.isEmpty()) { icons.insert(QLatin1String("Dir.Headers"), createIcon(QStyle::SP_DirIcon, QIcon(QLatin1String(":/cov/icons/headers.png")))); icons.insert(QLatin1String("Dir.Sources"), createIcon(QStyle::SP_DirIcon, QIcon(QLatin1String(":/cov/icons/sources.png")))); icons.insert(QLatin1String("Dir.Project"), createIcon(QStyle::SP_DirIcon, QIcon(QLatin1String(":/cov/icons/qt_project.png")))); icons.insert(QLatin1String("Dir.Other"), createIcon(QStyle::SP_DirIcon, QIcon())); icons.insert(QLatin1String("File.Headers"), createIcon(QStyle::SP_FileIcon, QIcon(QLatin1String(":/cov/icons/headers.png")))); icons.insert(QLatin1String("File.Sources"), createIcon(QStyle::SP_FileIcon, QIcon(QLatin1String(":/cov/icons/sources.png")))); } return icons.value(name); }
int Ecma::RegExp::flagFromChar(const QChar &ch) { static QHash<QChar, int> flagsHash; if (flagsHash.isEmpty()) { flagsHash[QLatin1Char('g')] = Global; flagsHash[QLatin1Char('i')] = IgnoreCase; flagsHash[QLatin1Char('m')] = Multiline; } QHash<QChar, int>::const_iterator it; it = flagsHash.constFind(ch); if (it == flagsHash.constEnd()) return 0; return it.value(); }
QVariantMap MessageView::toVariantMap(bool isMuc, bool formatted) const { static QHash<Type, QString> types; if (types.isEmpty()) { types.insert(Message, "message"); types.insert(System, "system"); types.insert(Status, "status"); types.insert(Subject, "subject"); types.insert(Urls, "urls"); } QVariantMap m; m["time"] = _dateTime; m["type"] = types.value(_type); switch (_type) { case Message: m["message"] = formatted?formattedText():_text; m["emote"] = _emote; m["local"] = _local; m["sender"] = _nick; m["userid"] = _userId; m["spooled"] = _spooled; m["id"] = _messageId; if (isMuc) { // maybe w/o conditions ? m["alert"] = _alert; } else { m["awaitingReceipt"] = _awaitingReceipt; } break; case Status: m["sender"] = _nick; m["status"] = _status; m["priority"] = _statusPriority; m["message"] = _text; m["usertext"] = formatted?formattedUserText():_userText; break; case System: case Subject: m["message"] = formatted?formattedText():_text; m["usertext"] = formatted?formattedUserText():_userText; break; case Urls: QVariantMap vmUrls; foreach (const QString &u, _urls.keys()) { vmUrls[u] = _urls.value(u); } m["urls"] = vmUrls; break; } return m; }
QalfHandler::KeyStatus QalfHandler::keyStatus(QString &email) { QalfDb * db = QalfDb::getDbObject() ; qDebug() << "checking key for :"<< email ; QHash<QString,QString> keyInfo = db->getKeyInfo(email) ; if(keyInfo.isEmpty()) { return KeyUnknown ; } else { if(keyInfo["trusted"] == "0") { return KeyUntrusted ; } else { return KeyTrusted ; } } }
/*** PUBLIC SLOTS ***/ static bool compareDatasets(const QString &a, const QString &b) { static QHash<QString,int> knownDatasets; if (knownDatasets.isEmpty()) { knownDatasets["MEDS"] = 0; knownDatasets["PCSO"] = 1; knownDatasets["Good"] = 2; knownDatasets["Bad"] = 3; knownDatasets["Ugly"] = 4; } if (!knownDatasets.contains(b)) return knownDatasets.contains(a); if (!knownDatasets.contains(a)) return false; return knownDatasets[a] < knownDatasets[b]; }
QString PrimitiveTypeEntry::javaObjectName() const { static QHash<QString, QString> table; if (table.isEmpty()) { table["boolean"] = "Boolean"; table["byte"] = "Byte"; table["char"] = "Character"; table["short"] = "Short"; table["int"] = "Integer"; table["long"] = "Long"; table["float"] = "Float"; table["double"] = "Double"; } Q_ASSERT(table.contains(targetLangName())); return table[targetLangName()]; }
void Ut_NotificationPreviewPresenter::testShowingOnlyCriticalNotifications() { NotificationPreviewPresenter presenter; QSignalSpy changedSpy(&presenter, SIGNAL(notificationChanged())); QSignalSpy presentedSpy(&presenter, SIGNAL(notificationPresented(uint))); // Create normal urgency notification LipstickNotification *notification = new LipstickNotification; QVariantHash hints; hints.insert(NotificationManager::HINT_PREVIEW_SUMMARY, "previewSummary"); hints.insert(NotificationManager::HINT_PREVIEW_BODY, "previewBody"); hints.insert(NotificationManager::HINT_URGENCY, 1); notification->setHints(hints); notificationManagerNotification.insert(1, notification); QCOMPARE(homeWindowVisible.isEmpty(), true); // When the screen or device is locked and the urgency is not high enough, so the notification shouldn't be shown gQmLocksStub->stubSetReturnValue("getState", MeeGo::QmLocks::Locked); presenter.updateNotification(1); QCOMPARE(changedSpy.count(), 0); QCOMPARE(homeWindowVisible.isEmpty(), true); // The notification should be considered presented QCOMPARE(presentedSpy.count(), 1); QCOMPARE(presentedSpy.last().at(0).toUInt(), (uint)1); // Urgency set to critical, so the notification should be shown hints.insert(NotificationManager::HINT_URGENCY, 2); notification->setHints(hints); presenter.updateNotification(1); QCOMPARE(changedSpy.count(), 1); QCOMPARE(homeWindowVisible.isEmpty(), false); QCOMPARE(homeWindowVisible[homeWindows.first()], true); QCOMPARE(presentedSpy.count(), 2); QCOMPARE(presentedSpy.last().at(0).toUInt(), (uint)1); }
void SearchController::checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo) { if (updateInfo.isEmpty()) { LogMsg(tr("All plugins are already up to date."), Log::INFO); return; } LogMsg(tr("Updating %1 plugins").arg(updateInfo.size()), Log::INFO); SearchPluginManager *const pluginManager = SearchPluginManager::instance(); for (const QString &pluginName : asConst(updateInfo.keys())) { LogMsg(tr("Updating plugin %1").arg(pluginName), Log::INFO); pluginManager->updatePlugin(pluginName); } }
/** * Set a list of values for the properties * @param presetValues :: A string containing a list of "name=value" pairs with * each separated by an '|' character */ void AlgorithmDialog::setPresetValues( const QHash<QString, QString> &presetValues) { if (presetValues.isEmpty()) return; QHashIterator<QString, QString> itr(presetValues); m_python_arguments.clear(); while (itr.hasNext()) { itr.next(); QString name = itr.key(); m_python_arguments.append(name); QString value = itr.value(); storePropertyValue(name, value); } setPropertyValues(); }
void ActionInstance::setArrayKeyValue(const QString &name, const QHash<QString, QString> &hashKeyValue) { if(hashKeyValue.isEmpty()) return; QScriptValue back = d->scriptEngine->newArray(hashKeyValue.count()); QHashIterator<QString, QString> it(hashKeyValue); while (it.hasNext()) { it.next(); back.setProperty(it.key(), it.value()); } setVariable(name, back); }
/// sets the captures void TmLanguageParser::addCapturesToGrammarRule(TextGrammarRule* rule, QHash<QString, QVariant> captures, bool endCapture) { if( captures.isEmpty() ){ return; } QHashIterator<QString,QVariant> itr(captures); while( itr.hasNext() ) { itr.next(); QHash<QString,QVariant> fields = itr.value().toHash(); int keyIndex = itr.key().toInt(); QString name = fields.value("name").toString(); if( endCapture ) { rule->setEndCapture(keyIndex,name); } else { rule->setCapture(keyIndex,name); } } }
SeasideNameGroupModel::SeasideNameGroupModel(QObject *parent) : QAbstractListModel(parent) , m_requiredProperty(NoPropertyRequired) { SeasideCache::registerNameGroupChangeListener(this); const QStringList &allGroups = SeasideCache::allNameGroups(); QHash<QString, QSet<quint32> > existingGroups = SeasideCache::nameGroupMembers(); if (!existingGroups.isEmpty()) { for (int i=0; i<allGroups.count(); i++) m_groups << SeasideNameGroup(allGroups[i], existingGroups.value(allGroups[i])); } else { for (int i=0; i<allGroups.count(); i++) m_groups << SeasideNameGroup(allGroups[i]); } }