QT_BEGIN_NAMESPACE static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio) { // We might use the fileName for loading if url loading fails // try to make sure it is a valid file path. // Also, QFile{Info}::exists works only on filepaths (not urls) if (url->isValid()) { if (url->scheme() == QLatin1Literal("qrc")) { fileName = fileName.right(fileName.length() - 3); } else if (url->scheme() == QLatin1Literal("file")) { fileName = url->toLocalFile(); } } if (targetDevicePixelRatio <= 1.0) return fileName; // try to find a 2x version const int dotIndex = fileName.lastIndexOf(QLatin1Char('.')); if (dotIndex != -1) { QString at2xfileName = fileName; at2xfileName.insert(dotIndex, QStringLiteral("@2x")); if (QFile::exists(at2xfileName)) { fileName = at2xfileName; *url = QUrl(fileName); } } return fileName; }
void message_handler(QtMsgType type, const QMessageLogContext & context, const QString & message) { QString formated_message; QString (*formater)(const QString & message_type, const QMessageLogContext & context, const QString & message); // formater = format_log; #ifdef ANDROID formater = format_log; #else formater = format_log_with_ansi; #endif switch (type) { case QtDebugMsg: formated_message = formater(QLatin1Literal("Debug"), context, message); break; case QtInfoMsg: formated_message = formater(QLatin1Literal("Info"), context, message); break; case QtWarningMsg: formated_message = formater(QLatin1Literal("Warning"), context, message); break; case QtCriticalMsg: formated_message = formater(QLatin1Literal("Critical"), context, message); break; case QtFatalMsg: formated_message = formater(QLatin1Literal("Fatal"), context, message); } // stderr fprintf(stdout, formated_message.toStdString().c_str()); // # QByteArray local_message = message.toLocal8Bit(); if (type == QtFatalMsg) abort(); }
void GameScene::updateSvgIds() { //Needed so new boundingRects() are read for all SVG elements after a theme change // Sanity check, see if game elements already exist if (!m_kapmanItem) { return; } // Set the element Id to the right value m_mazeItem->setElementId(QLatin1Literal("maze")); // Create the KapmanItem m_kapmanItem->setElementId(QLatin1Literal("kapman_0")); // Corrects the position of the KapmanItem m_kapmanItem->update(m_game->getKapman()->getX(), m_game->getKapman()->getY()); for (int i = 0; i < m_ghostItems.size(); ++i) { GhostItem *ghost = m_ghostItems[i]; ghost->setElementId(m_game->getGhosts()[i]->getImageId()); ghost->update(m_game->getGhosts()[i]->getX(), m_game->getGhosts()[i]->getY()); } for (int i = 0; i < m_game->getMaze()->getNbRows(); ++i) { for (int j = 0; j < m_game->getMaze()->getNbColumns(); ++j) { if (m_elementItems[i][j] != NULL) { ElementItem *element = m_elementItems[i][j]; element->setElementId(m_game->getMaze()->getCell(i, j).getElement()->getImageId()); element->update(m_game->getMaze()->getCell(i, j).getElement()->getX(), m_game->getMaze()->getCell(i, j).getElement()->getY()); } } } }
QVariantMap PersonInfoData::data() const { QResource res(QLatin1Literal(":/devels/") % ocsUsername % QLatin1Literal(".json")); if (!res.isValid()) res.setFileName(QLatin1Literal(":/contributers/") % ocsUsername % QLatin1Literal(".json")); return qutim_resource_open(res); }
void KSecretServiceTest::testItems() { auto NEW_ITEM_NAME = QLatin1Literal("Test Item1"); auto NEW_ITEM_VALUE = QLatin1Literal("highly secret value"); QDateTime testTime = QDateTime::currentDateTime(); KSecrets::Secret secret; secret.setValue(NEW_ITEM_VALUE); auto createRes = collection->createItem(NEW_ITEM_NAME, secret).result(); QVERIFY(createRes); auto foundItems = collection->searchItems(NEW_ITEM_NAME).result(); QVERIFY(foundItems.length() == 1); auto theItem = foundItems.first(); QCOMPARE(theItem->label().result(), NEW_ITEM_NAME); QVERIFY(theItem->createdTime().result() > testTime); QVERIFY(theItem->modifiedTime().result() > testTime); QDateTime oldModifiedTime = theItem->modifiedTime().result(); QVERIFY(theItem->setLabel(NEW_ITEM_NAME).result()); QVERIFY(theItem->modifiedTime().result() == oldModifiedTime); // name was the same so item should have stayed // the same auto NEW_ITEM_SECOND_NAME = QLatin1Literal("Test Item2"); QVERIFY(theItem->setLabel(NEW_ITEM_SECOND_NAME).result()); QCOMPARE(theItem->label().result(), NEW_ITEM_SECOND_NAME); QVERIFY(theItem->modifiedTime().result() > oldModifiedTime); auto theSecret = theItem->getSecret().result(); QCOMPARE(theSecret->value().toString(), NEW_ITEM_VALUE); }
void GhostItem::updateState() { // Stop timers if (m_startBlinkingTimer->isActive()) { m_startBlinkingTimer->stop(); } if (m_blinkTimer->isActive()) { m_blinkTimer->stop(); } switch (((Ghost *)getModel())->getState()) { case Ghost::PREY: updateBlinkTimersDuration(); setElementId(QLatin1Literal("scaredghost")); m_startBlinkingTimer->start(); // The ghosts are now weaker than the kapman, so they are under him setZValue(1); break; case Ghost::HUNTER: setElementId(((Ghost *)getModel())->getImageId()); // The ghosts are stronger than the kapman, they are above him setZValue(3); break; case Ghost::EATEN: setElementId(QLatin1Literal("ghosteye")); // The ghosts are now weaker than the kapman, so they are under him setZValue(1); break; } }
void test_byteArray_equals_latin1Literal() { Pillow::ByteArray ba; ba = QByteArray("Some-string"); QVERIFY(ba == QLatin1Literal("Some-string")); QVERIFY(!(ba == QLatin1Literal("Some-other-string"))); QVERIFY(ba != QLatin1Literal("Some-other-string")); QVERIFY(!(ba != QLatin1Literal("Some-string"))); }
void RssFeedNode::render(Grantlee::OutputStream* stream, Grantlee::Context* c) { QNetworkAccessManager *mgr = new QNetworkAccessManager(this); QUrl url(Grantlee::getSafeString(m_url.resolve(c))); QNetworkReply *reply = mgr->get(QNetworkRequest(url)); QEventLoop eLoop; connect( mgr, SIGNAL( finished( QNetworkReply * ) ), &eLoop, SLOT( quit() ) ); eLoop.exec( QEventLoop::ExcludeUserInputEvents ); c->push(); foreach(Grantlee::Node *n, m_childNodes) { if (!n->inherits(XmlNamespaceNode::staticMetaObject.className())) continue; Grantlee::OutputStream _dummy; n->render(&_dummy, c); } QXmlQuery query; QByteArray ba = reply->readAll(); QBuffer buffer; buffer.setData(ba); buffer.open(QIODevice::ReadOnly); query.bindVariable("inputDocument", &buffer); QString ns; QHash<QString, QVariant> h = c->lookup("_ns").toHash(); QHash<QString, QVariant>::const_iterator it = h.constBegin(); const QHash<QString, QVariant>::const_iterator end = h.constEnd(); for ( ; it != end; ++it ) { if (it.key().isEmpty()) { ns += QLatin1Literal( "declare default element namespace " ) + QLatin1Literal( " \"" ) + it.value().toString() + QLatin1Literal( "\";\n" ); } else { ns += QLatin1Literal( "declare namespace " ) + it.key() + QLatin1Literal( " = \"" ) + it.value().toString() + QLatin1Literal( "\";\n" ); } } query.setQuery(ns + "doc($inputDocument)" + Grantlee::getSafeString(m_query.resolve(c)).get()); QXmlResultItems result; query.evaluateTo(&result); QXmlItem item(result.next()); int count = 0; while (!item.isNull()) { if (count++ > 20) break; query.setFocus(item); c->push(); foreach(Grantlee::Node *n, m_childNodes) { if (n->inherits(XmlNamespaceNode::staticMetaObject.className())) continue; c->insert("_q", QVariant::fromValue(query)); n->render(stream, c); } c->pop(); item = result.next(); } c->pop(); }
void SqlBulkInsert::flush() { if (_pending.size() > 0) { double start = Tgs::Time::getTime(); QString sql; // the value 22 was found experimentally sql.reserve(_pending.size() * _columns.size() * 22); sql.append(QLatin1Literal("INSERT INTO ") % _tableName % QLatin1Literal(" (") % _columns.join(",") % QLatin1Literal(") VALUES ")); QLatin1String firstOpenParen("("), openParen(",("), closeParen(")"), comma(","); for (int i = 0; i < _pending.size(); i++) { if (i == 0) { sql.append(firstOpenParen); } else { sql.append(openParen); } for (int j = 0; j < _columns.size(); j++) { if (j == 0) { sql.append(_escape(_pending[i][j])); } else { sql.append(comma % _escape(_pending[i][j])); } } sql.append(closeParen); } //LOG_VAR(sql.size()); QSqlQuery q(_db); if (q.exec(sql) == false) { throw HootException(QString("Error executing bulk insert: %1 (%2)").arg(q.lastError().text()). arg(sql)); } q.finish(); _pending.clear(); double elapsed = Tgs::Time::getTime() - start; _time += elapsed; } }
void GhostItem::blink() { CharacterItem::blink(); if (m_nbBlinks % 2 == 0) { setElementId(QLatin1Literal("scaredghost")); } else { setElementId(QLatin1Literal("whitescaredghost")); } }
void init_qt_late() { QApplication *application = qApp; // tell Qt to use system proxies // note: on Linux, "system" == "environment variables" QNetworkProxyFactory::setUseSystemConfiguration(true); // for Win32 and Qt5 we try to set the locale codec to UTF-8. // this makes QFile::encodeName() work. #ifdef Q_OS_WIN QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106)); #endif QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); // enable user specific settings (based on command line argument) if (settings_suffix) { if (verbose) qDebug() << "using custom config for" << QString("Subsurface-%1").arg(settings_suffix); QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix)); } else { QCoreApplication::setApplicationName("Subsurface"); } // find plugins installed in the application directory (without this SVGs don't work on Windows) SettingsObjectWrapper::instance()->load(); QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); QLocale loc; QString uiLang = uiLanguage(&loc); QLocale::setDefault(loc); qtTranslator = new QTranslator; QString translationLocation; #if defined(Q_OS_ANDROID) translationLocation = QLatin1Literal("assets:/translations"); #elif defined(Q_OS_IOS) translationLocation = QLatin1Literal(":/translations/"); #else translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath); #endif if (qtTranslator->load(loc, "qt", "_", translationLocation)) { application->installTranslator(qtTranslator); } else { if (uiLang != "en_US" && uiLang != "en-US") qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << translationLocation; } ssrfTranslator = new QTranslator; if (ssrfTranslator->load(loc, "subsurface", "_") || ssrfTranslator->load(loc, "subsurface", "_", translationLocation) || ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) || ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) { application->installTranslator(ssrfTranslator); } else { qDebug() << "can't find Subsurface localization for locale" << uiLang; } }
int main(int argc, char ** argv) { QCoreApplication app(argc, argv); #if defined(Q_OS_UNIX) catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP}); #endif app.setApplicationName("helloworld"); app.setApplicationVersion("1.0.0"); QCommandLineParser parser; parser.setApplicationDescription("a HelloWorld example for http client and server."); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("mode", "working mode: server, client or weather. default: server"); // parser.addOption({ // {"l", "listen"}, // "listening tcp port number in server mode (default 8080)", // "portNo", "8080"}); // parser.addOption({ // {"u", "url"}, // "fetch url data in client mode", // "address", "http://www.google.com"}); // parser.addOption({ // {"g", "geolocation"}, // "a city name [,country name] in weather mode, default: Tehran", // "city", "Tehran"}); parser.process(app); QStringList posArgs = parser.positionalArguments(); if ( posArgs.size() != 1 ) { parser.showHelp(0); } else { const auto& mode = posArgs.at(0); if ( mode == QLatin1Literal("server") ) runServer(parser.value("listen")); #if defined(QHTTP_HAS_CLIENT) else if ( mode == QLatin1Literal("client") ) runClient(parser.value("url")); else if ( mode == QLatin1Literal("weather") ) runWeatherClient(parser.value("geolocation")); #else else if ( mode == QLatin1Literal("client") || mode == QLatin1Literal("weather") ) qDebug("qhttp::client has not been enabled at build time"); #endif // QHTTP_HAS_CLIENT } return 0; }
void MainWindow::setupActions() { KStandardGameAction::gameNew(m_main, SLOT(newGame()), actionCollection()); KStandardGameAction::restart(m_main, SLOT(restart()), actionCollection()); KStandardGameAction::highscores(m_main, SLOT(highscores()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); QAction* action; action = new QAction(i18n("&Single Player"), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconLocal))); actionCollection()->addAction(QLatin1Literal("game_local"), action); connect(action, &QAction::triggered, m_main, &PlayField::localGame); action = new QAction(i18n("&Host Game..."), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconServer))); actionCollection()->addAction(QLatin1Literal("game_create_server"), action); connect(action, &QAction::triggered, m_main, &PlayField::createServer); action = new QAction(i18n("&Connect to Game..."), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconClient))), actionCollection()->addAction(QLatin1Literal("game_create_client"), action); connect(action, &QAction::triggered, m_main, &PlayField::createClient); // settings action = new QAction(i18n("Change &Nickname..."), this); actionCollection()->addAction(QLatin1Literal("options_nickname"), action); connect(action, &QAction::triggered, m_main, &PlayField::changeNick); action = new KToggleAction(i18n("&Play Sounds"), this); action->setChecked(Settings::enableSounds()); actionCollection()->addAction(QLatin1Literal("options_sounds"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleSounds); // This action will be disabled when a game is being run action = new KToggleAction(i18n("&Adjacent Ships"), this); action->setChecked(Settings::adjacentShips()); actionCollection()->addAction(QLatin1Literal("options_adjacent"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleAdjacent); // This action will be disabled when a game is being run action = new KToggleAction(i18n("&Multiple Ships"), this); action->setChecked(Settings::severalShips()); actionCollection()->addAction(QLatin1Literal("options_multiple_ships"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleMultiple); // config end of game message action = new KToggleAction(i18n("Show End-of-Game Message"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_show_endgame_message"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleEndOfGameMessage); // actions for grid action = new KToggleAction(i18n("Show &Left Grid"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_showleftgrid"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleLeftGrid); action = new KToggleAction(i18n("Show &Right Grid"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_showrightgrid"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleRightGrid); setupGUI(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow()) { ui->setupUi(this); PositioningMenuBar *menuBar = new PositioningMenuBar(ui->menuBar); QMenu *menuOptions = menuBar->addMenu(QLatin1Literal("&Options")); menuOptions->addAction(QLatin1Literal("About Qt")); }
void ShaderParamsDialog::onShaderLoadPresetClicked() { QString path; QString filter; QByteArray pathArray; struct video_shader *menu_shader = NULL; struct video_shader *video_shader = NULL; const char *pathData = NULL; settings_t *settings = config_get_ptr(); enum rarch_shader_type type = RARCH_SHADER_NONE; bool is_preset = false; if (!settings) return; getShaders(&menu_shader, &video_shader); if (!menu_shader) return; filter = "Shader Preset ("; /* NOTE: Maybe we should have a way to get a list of all shader types instead of hard-coding this? */ if (video_shader_is_supported(RARCH_SHADER_CG) && video_shader_get_type_from_ext(file_path_str(FILE_PATH_CGP_EXTENSION), &is_preset) != RARCH_SHADER_NONE) filter += QLatin1Literal("*") + file_path_str(FILE_PATH_CGP_EXTENSION); if (video_shader_is_supported(RARCH_SHADER_GLSL) && video_shader_get_type_from_ext(file_path_str(FILE_PATH_GLSLP_EXTENSION), &is_preset) != RARCH_SHADER_NONE) filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_GLSLP_EXTENSION); if (video_shader_is_supported(RARCH_SHADER_SLANG) && video_shader_get_type_from_ext(file_path_str(FILE_PATH_SLANGP_EXTENSION), &is_preset) != RARCH_SHADER_NONE) filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_SLANGP_EXTENSION); filter += ")"; path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter); if (path.isEmpty()) return; pathArray = path.toUtf8(); pathData = pathArray.constData(); type = video_shader_parse_type(pathData, RARCH_SHADER_NONE); menu_shader_manager_set_preset(menu_shader, type, pathData); }
// Qt::convertFromPlainText doesn't do precisely what we want static QString plainTextToHTML(const QString & plain, bool multiLine, bool forceNoQuote = false) { int col = 0; bool quote = false; QString rich; for (int i = 0; i < plain.length(); ++i) { if (plain[i] == QLatin1Char('\n')){ if (multiLine) { rich += QLatin1String("<br>\n"); } else { rich += QLatin1String("\\n"); } col = 0; quote = true; } else { if (plain[i] == QLatin1Char('\t')){ if (multiLine) { rich += QChar(0x00a0U); ++col; while (col % 8) { rich += QChar(0x00a0U); ++col; } } else { rich += QLatin1String("\\t"); } quote = true; } else if (plain[i].isSpace()) { rich += QChar(0x00a0U); quote = true; } else if (plain[i] == QLatin1Char('<')) { rich += QLatin1String("<"); } else if (plain[i] == QLatin1Char('>')) { rich += QLatin1String(">"); } else if (plain[i] == QLatin1Char('&')) { rich += QLatin1String("&"); } else { rich += plain[i]; } ++col; } } if (quote && !forceNoQuote) { return QLatin1Literal("\"") + rich + QLatin1Literal("\""); } return rich; }
QcGermanyPlugin::QcGermanyPlugin() : QcWmtsPlugin(PLUGIN_NAME, PLUGIN_TITLE, new QcMercatorTileMatrixSet(NUMBER_OF_LEVELS, TILE_SIZE)) { int map_id = -1; add_layer(new QcGermanyLayer(this, ++map_id, // 1 1, QLatin1Literal("Map"), QLatin1Literal("webatlasde"), QLatin1Literal("png") )); }
QStaticText ApiTraceCall::staticText() const { if (m_staticText && !m_staticText->text().isEmpty()) return *m_staticText; QVariantList argValues = arguments(); QString richText = QString::fromLatin1( "<span style=\"font-weight:bold\">%1</span>(").arg(m_name); for (int i = 0; i < m_argNames.count(); ++i) { richText += QLatin1String("<span style=\"color:#0000ff\">"); QString argText = apiVariantToString(argValues[i]); //if arguments are really long (e.g. shader text), cut them // and elide it if (argText.length() > 40) { QString shortened = argText.mid(0, 40); shortened[argText.length() - 5] = '.'; shortened[argText.length() - 4] = '.'; shortened[argText.length() - 3] = '.'; shortened[argText.length() - 2] = argText[argText.length() - 2]; shortened[argText.length() - 1] = argText[argText.length() - 1]; richText += shortened; } else { richText += argText; } richText += QLatin1String("</span>"); if (i < m_argNames.count() - 1) richText += QLatin1String(", "); } richText += QLatin1String(")"); if (m_returnValue.isValid()) { richText += QLatin1Literal(" = ") % QLatin1Literal("<span style=\"color:#0000ff\">") % apiVariantToString(m_returnValue) % QLatin1Literal("</span>"); } if (!m_staticText) m_staticText = new QStaticText(richText); else m_staticText->setText(richText); QTextOption opt; opt.setWrapMode(QTextOption::NoWrap); m_staticText->setTextOption(opt); m_staticText->prepare(); return *m_staticText; }
void BearerPropertiesTest::initTestCase() { fakeModem = new FakeModem(); modem = new Modem(); modem->setAccessTechnologies(16); modem->SetCurrentBands({0}); modem->SetCurrentCapabilities(4); modem->SetCurrentModes({MM_MODEM_MODE_ANY, MM_MODEM_MODE_NONE}); modem->setDevice(QLatin1String("/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2")); modem->setDeviceIdentifier(QLatin1String("1c435eb6d74494b5f78d7221e2c5ae9ec526a981")); modem->setDrivers({QLatin1String("option1")}); modem->setEquipmentIdentifier(QLatin1String("353475021085110")); modem->setManufacturer(QLatin1String("huawei")); modem->setMaxActiveBearers(1); modem->setMaxBearers(1); modem->setModel(QLatin1String("K2540")); //modem->setOwnNumbers(); modem->setPlugin(QLatin1String("Huawei")); modem->setPorts({{QLatin1String("ttyUSB0"), MM_MODEM_PORT_TYPE_AT}, {QLatin1String("ttyUSB1"), MM_MODEM_PORT_TYPE_QCDM}, {QLatin1String("ttyUSB2"), MM_MODEM_PORT_TYPE_AT}}); modem->SetPowerState(3); modem->setPrimaryPort(QLatin1String("ttyUSB2")); modem->setRevision(QLatin1String("11.001.05.00.11")); modem->setSignalQuality({93, true}); modem->setSim(QDBusObjectPath("/org/kde/fakemodem/SIM/1")); modem->setState(8); modem->setStateFailedReason(0); modem->setSupportedBands({0}); modem->setSupportedCapabilities({4}); modem->setSupportedIpFamilies(3); ModemManager::SupportedModesType supportedModes; ModemManager::CurrentModesType supportedMode1 = {MM_MODEM_MODE_4G & MM_MODEM_MODE_3G & MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE}; ModemManager::CurrentModesType supportedMode2 = {MM_MODEM_MODE_4G & MM_MODEM_MODE_3G & MM_MODEM_MODE_2G, MM_MODEM_MODE_2G}; ModemManager::CurrentModesType supportedMode3 = {MM_MODEM_MODE_4G & MM_MODEM_MODE_3G & MM_MODEM_MODE_2G, MM_MODEM_MODE_3G}; supportedModes << supportedMode1 << supportedMode2 << supportedMode3; modem->setSupportedModes(supportedModes); modem->setUnlockRequired(1); modem->setUnlockRetries({{MM_MODEM_LOCK_SIM_PIN, 3}, {MM_MODEM_LOCK_SIM_PIN2, 3}, {MM_MODEM_LOCK_SIM_PUK, 10}, {MM_MODEM_LOCK_SIM_PUK2, 10}}); QSignalSpy addModemSpy(ModemManager::notifier(), SIGNAL(modemAdded(QString))); fakeModem->addModem(modem); QVERIFY(addModemSpy.wait()); bearer = new Bearer(); // We need to set some default values bearer->setConnected(false); bearer->setInterface(QLatin1String("ttyUSB0")); bearer->setIp4Config({{QLatin1String("method"), MM_BEARER_IP_METHOD_PPP}}); bearer->setIp6Config({{QLatin1String("method"), MM_BEARER_IP_METHOD_UNKNOWN}}); bearer->setIpTimeout(20); bearer->setProperties({{QLatin1String("apn"),QLatin1String("internet")},{QLatin1Literal("ip-type"), 1}, {QLatin1String("number"), QLatin1String("*99#")}}); bearer->setSuspended(false); #if MM_CHECK_VERSION(1, 2, 0) ModemManager::Modem::Ptr modemInterface = ModemManager::modemDevices().first()->modemInterface(); QCOMPARE(modemInterface->listBearers().count(), 0); QSignalSpy bearerAddedSpy(modemInterface.data(), SIGNAL(bearerAdded(QString))); fakeModem->addBearer(bearer); QVERIFY(bearerAddedSpy.wait()); #endif }
void TemplKatalogListView::slFreshupItem( QTreeWidgetItem *item, FloskelTemplate *tmpl, bool remChildren ) { if( !(item && tmpl) ) return; Geld g = tmpl->unitPrice(); const QString ck = tmpl->calcKindString(); const QString t = Portal::textWrap(tmpl->getText(), 72, 4); item->setText( 0, t ); if( t.endsWith(QLatin1Literal("..."))) { item->setToolTip(0, Portal::textWrap(tmpl->getText(), 72, 22)); } QString h; h = QString( "%1 / %2" ).arg( g.toString( catalog()->locale() ) ) .arg( tmpl->unit().einheitSingular() ); item->setText( 1, h ); item->setText( 2, ck ); // item->setText( 4, QString::number(tmpl->getTemplID())); if( remChildren ) { /* remove all children and insert them again afterwards. * That updates the view */ for( int i = 0; i < item->childCount(); i++ ) { QTreeWidgetItem *it = item->child(i); if( it ) { item->removeChild( it ); delete it; } } addCalcParts(tmpl); // Insert to update the view again. } }
KGameChat::KGameChat(QWidget* parent) : KChatBase(parent), d( new KGameChatPrivate ) { QLoggingCategory::setFilterRules(QLatin1Literal("games.private.kgame.debug = true")); init(0, -1); }
KGameChat::KGameChat(KGame* g, int msgid, QWidget* parent, KChatBaseModel* model, KChatBaseItemDelegate* delegate) : KChatBase(parent, model, delegate), d( new KGameChatPrivate ) { QLoggingCategory::setFilterRules(QLatin1Literal("games.private.kgame.debug = true")); init(g, msgid); }
/*! Clear the cache and remove cached files on disk * */ void QcFileTileCache::clear_all() { m_texture_cache.clear(); m_memory_cache.clear(); m_disk_cache.clear(); QStringList string_list; string_list << QLatin1Literal("*-*-*-*.*"); // tile pattern string_list << QLatin1Literal("queue?"); QDir directory(m_directory); directory.setNameFilters(string_list); directory.setFilter(QDir::Files); for(QString file : directory.entryList()) directory.remove(file); }
void DbusPopupHandler::onNameOwnerChanged(QString AName, QString /*empty*/, QString /*ANewOwner*/) { if (AName != QLatin1Literal("org.freedesktop.Notifications")) { return; } initNotifyInterface(); }
Qt::PenStyle KBBThemeManager::style(const KBBScalableGraphicWidget::itemType itemType) { if (value(itemType, QLatin1Literal("stroke-dasharray"))==QLatin1String("none")) { return Qt::SolidLine; } else return Qt::DotLine; }
void HexySerial::kill(quint32 flags) { //Trivial reject: kill ALL if(isConnected()) { if(0xFFFFFFFF==flags) { writeData("K\n"); } else { QString data; quint32 f=1; for(quint32 i=0; i<SERVO_COUNT; ++i) { if((flags & f)>0) { data += QLatin1Literal("#") + QString::number(i) + QLatin1String("L\n"); } else { //data+="LOL"; } f<<=1; } qDebug()<<"KILL: "<<data<<" foir "<<flags; writeData(data.toLatin1()); } } else { qWarning()<<"ERROR: Trying to kill servo via serial when not connected"; } }
Model::Root::Ptr ProjectImpl::parseFile(const QString& fileName) { LexicalAnalyzer::Ptr la = analyze(fileName); if (!hasErrors()) { Q_ASSERT(la); Model::Root::Ptr model = parseStream(la->tokenStream()); if (model) { if (testOption(optDumpCodeModel)) { QFileInfo fi(fileName); QString modelFileName = fi.absolutePath() % fi.completeBaseName() % QLatin1Literal(".pmodel"); if (!model->exportModel(modelFileName)) { errors()->emitError("Could not export model for file.", fileName); } } return model; } } return NULL; }
void NatGeoProvider::checkForNewPhoto() { const QUrl pageUrl = QString( QLatin1Literal("http://photography.nationalgeographic.com/photography/photo-of-the-day/") ); qDebug() << "NatGeo: requesting page"; m_data[cPageUrlKey] = pageUrl; connect( KIO::storedGet( pageUrl, KIO::Reload, KIO::HideProgressInfo ), &KJob::result, [this] ( KJob *job ) { qDebug() << "NatGeo: Page received. Error: " << job->error(); if( 0 != job->error() ) { emit error(job->errorString()); } else { auto *storedJob = qobject_cast<KIO::StoredTransferJob*>(job); Q_ASSERT(storedJob != nullptr); this->parseWebPage( storedJob->data() ); } job->deleteLater(); //NOTE: "The default for any KJob is to automatically delete itself." } ); }
LexicalAnalyzer::Ptr ProjectImpl::analyze(const QString& fileName) { LexicalAnalyzer::Ptr la = newAnalyzer(fileName); if (la->analyze()) { if (testOption(optDumpTokenStreams)) { QFileInfo fi(fileName); QString tokFileName = fi.absolutePath() % fi.completeBaseName() % QLatin1Literal(".ptokens"); la->tokenStream()->dump(tokFileName); } return la; } if (!hasErrors()) { // In case the lexer did fail without setting an error, set one now errors()->emitError("Failed to analye source", fileName); } return NULL; }
Grantlee::SafeString Grantlee::toString( const QVariantList &list ) { QString output( QLatin1Char( '[' ) ); QVariantList::const_iterator it = list.constBegin(); const QVariantList::const_iterator end = list.constEnd(); while ( it != end ) { const QVariant item = *it; if ( isSafeString( item ) ) { output += QLatin1Literal( "u\'" ) + static_cast<QString>( getSafeString( item ).get() ) + QLatin1Char( '\'' ); } if ( ( item.type() == QVariant::Int ) || ( item.type() == QVariant::UInt ) || ( item.type() == QVariant::Double ) || ( item.userType() == QMetaType::Float ) || ( item.type() == QVariant::LongLong ) || ( item.type() == QVariant::ULongLong ) ) { output += item.toString(); } if ( item.type() == QVariant::List ) { output += static_cast<QString>( toString( item.toList() ).get() ); } if ( ( it + 1 ) != end ) output += QLatin1String( ", " ); ++it; } return output.append( QLatin1Char( ']' ) ); }