void QuickInspector::renderScene() { if (!m_clientConnected || !m_window) return; QImage img; if (m_window->windowState() != Qt::WindowMinimized) img = m_window->grabWindow(); if (m_currentItem) { QQuickItem *parent = m_currentItem->parentItem(); QVariantMap geometryData; if (parent) geometryData.insert("itemRect", m_currentItem->parentItem()->mapRectToScene(QRectF(m_currentItem->x(), m_currentItem->y(), m_currentItem->width(), m_currentItem->height()))); else geometryData.insert("itemRect", QRectF(0, 0, m_currentItem->width(), m_currentItem->height())); geometryData.insert("boundingRect", m_currentItem->mapRectToScene(m_currentItem->boundingRect())); geometryData.insert("childrenRect", m_currentItem->mapRectToScene(m_currentItem->childrenRect())); geometryData.insert("transformOriginPoint", m_currentItem->mapToScene(m_currentItem->transformOriginPoint())); #ifdef HAVE_SG_INSPECTOR QQuickAnchors *anchors = m_currentItem->property("anchors").value<QQuickAnchors*>(); if (anchors) { QQuickAnchors::Anchors usedAnchors = anchors->usedAnchors(); geometryData.insert("left", (bool)(usedAnchors & QQuickAnchors::LeftAnchor) || anchors->fill()); geometryData.insert("right", (bool)(usedAnchors & QQuickAnchors::RightAnchor) || anchors->fill()); geometryData.insert("top", (bool)(usedAnchors & QQuickAnchors::TopAnchor) || anchors->fill()); geometryData.insert("bottom", (bool)(usedAnchors & QQuickAnchors::BottomAnchor) || anchors->fill()); geometryData.insert("baseline", (bool)(usedAnchors & QQuickAnchors::BaselineAnchor)); geometryData.insert("horizontalCenter", (bool)(usedAnchors & QQuickAnchors::HCenterAnchor) || anchors->centerIn()); geometryData.insert("verticalCenter", (bool)(usedAnchors & QQuickAnchors::VCenterAnchor) || anchors->centerIn()); geometryData.insert("leftMargin", anchors->leftMargin()); geometryData.insert("rightMargin", anchors->rightMargin()); geometryData.insert("topMargin", anchors->topMargin()); geometryData.insert("bottomMargin", anchors->bottomMargin()); geometryData.insert("horizontalCenterOffset", anchors->horizontalCenterOffset()); geometryData.insert("verticalCenterOffset", anchors->verticalCenterOffset()); geometryData.insert("baselineOffset", anchors->baselineOffset()); geometryData.insert("margins", anchors->margins()); } #endif geometryData.insert("x", m_currentItem->x()); geometryData.insert("y", m_currentItem->y()); #ifdef HAVE_SG_INSPECTOR QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(m_currentItem); geometryData.insert("transform", itemPriv->itemToWindowTransform()); if (parent) { QQuickItemPrivate *parentPriv = QQuickItemPrivate::get(parent); geometryData.insert("parentTransform", parentPriv->itemToWindowTransform()); } #endif emit sceneRendered(img, geometryData); } else { emit sceneRendered(img, QVariantMap()); } }
void IconGridActivity::create_window(const QRectF &window_geometry, const QString &window_title, const QPointF &window_pos) { if (d->m_activity_window_ptr) { return; } d->m_auto_scale_frame = false; d->m_activity_window_ptr = new UIKit::Window(); d->m_activity_window_ptr->set_window_title(window_title); d->m_activity_window_ptr->setGeometry(window_geometry); d->m_grid_view = new UIKit::ItemView(d->m_activity_window_ptr, UIKit::ItemView::kGridModel); d->m_grid_view->set_view_geometry(window_geometry); d->m_grid_view->on_item_removed([](UIKit::ModelViewItem *a_item) { if (a_item) delete a_item; }); on_arguments_updated([this]() { if (has_attribute("data")) { QVariantMap data = attributes()["data"].toMap(); foreach(const QVariant & var, data.values()) { QVariantMap _item = var.toMap(); Action *l_action_item = new Action; d->m_action_list.append(l_action_item); l_action_item->onActionActivated([this](const Action *aAction) { d->m_activity_result.clear(); d->m_activity_result["controller"] = aAction->controller_name(); d->m_activity_result["action"] = aAction->label(); d->mSelection = aAction->label(); update_action(); }); UIKit::ModelViewItem *grid_item = new UIKit::ModelViewItem(); grid_item->on_view_removed([](UIKit::ModelViewItem *a_item) { if (a_item && a_item->view()) { UIKit::Widget *view = a_item->view(); if (view) delete view; } }); grid_item->set_view(l_action_item->createActionItem( _item["icon"].toString(), _item["label"].toString(), _item["controller"].toString())); d->m_grid_view->insert(grid_item); d->m_grid_view->updateGeometry(); QRectF _content_rect = d->m_grid_view->boundingRect(); set_geometry(_content_rect); d->m_activity_window_ptr->setGeometry(_content_rect); } } if (has_attribute("auto_scale")) { d->m_auto_scale_frame = attributes()["auto_scale"].toBool(); } if (d->m_auto_scale_frame) { QRectF _content_rect = d->m_grid_view->boundingRect(); _content_rect.setHeight(_content_rect.height() + 64); set_geometry(_content_rect); d->m_activity_window_ptr->setGeometry(_content_rect); } });
static bool commentLessThan(const QVariantMap &a, const QVariantMap &b) { return a.value("cid").toInt() < b.value("cid").toInt(); }
QString ToolChainFactory::idFromMap(const QVariantMap &data) { return data.value(QLatin1String(ID_KEY)).toString(); }
void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected) { data.insert(QLatin1String(AUTODETECT_KEY), detected); }
void ProtoSlaveCurrentBuilds::handle(QVariantMap jsonObject, Management *management, QTcpSocket *masterSocket){ if(!jsonObject.value("subHandler").toString().compare("Rechecker")) Rechecker(management, masterSocket); }
static void serializeEdge(QVariantMap & map, tikz::core::EllipsePath * ellipse) { Q_ASSERT(ellipse != 0); map.insert("center", ellipse->metaPos().toString()); }
void TestTools::testBuildConfigMerging() { Settings settings((QString())); TemporaryProfile tp(QLatin1String("tst_tools_profile"), &settings); Profile profile = tp.p; profile.setValue(QLatin1String("topLevelKey"), QLatin1String("topLevelValue")); profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc")); profile.setValue(QLatin1String("qbs.architecture"), QLatin1String("Jean-Claude Pillemann")); profile.setValue(QLatin1String("cpp.treatWarningsAsErrors"), true); QVariantMap overrideMap; overrideMap.insert(QLatin1String("qbs.toolchain"), QLatin1String("clang")); overrideMap.insert(QLatin1String("qbs.installRoot"), QLatin1String("/blubb")); SetupProjectParameters params; params.setTopLevelProfile(profile.name()); params.setBuildVariant(QLatin1String("debug")); params.setOverriddenValues(overrideMap); const ErrorInfo error = params.expandBuildConfiguration(); QVERIFY2(!error.hasError(), qPrintable(error.toString())); const QVariantMap finalMap = params.finalBuildConfigurationTree(); QCOMPARE(finalMap.count(), 3); QCOMPARE(finalMap.value(QLatin1String("topLevelKey")).toString(), QString::fromLatin1("topLevelValue")); const QVariantMap finalQbsMap = finalMap.value(QLatin1String("qbs")).toMap(); QCOMPARE(finalQbsMap.count(), 4); QCOMPARE(finalQbsMap.value(QLatin1String("toolchain")).toString(), QString::fromLatin1("clang")); QCOMPARE(finalQbsMap.value(QLatin1String("buildVariant")).toString(), QString::fromLatin1("debug")); QCOMPARE(finalQbsMap.value(QLatin1String("architecture")).toString(), QString::fromLatin1("Jean-Claude Pillemann")); QCOMPARE(finalQbsMap.value(QLatin1String("installRoot")).toString(), QLatin1String("/blubb")); const QVariantMap finalCppMap = finalMap.value(QLatin1String("cpp")).toMap(); QCOMPARE(finalCppMap.count(), 1); QCOMPARE(finalCppMap.value(QLatin1String("treatWarningsAsErrors")).toBool(), true); }
void IRunConfigurationAspect::fromMap(const QVariantMap &map) { m_projectSettings->fromMap(map); m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool(); }
bool ConfigureStep::fromMap(const QVariantMap &map) { m_additionalArguments = map.value(QLatin1String(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY)).toString(); return BuildStep::fromMap(map); }
void ClipboardMonitor::onClipboardChanged(ClipboardMode mode) { QVariantMap data = m_clipboard->data(mode, m_formats); auto clipboardData = mode == ClipboardMode::Clipboard ? &m_clipboardData : &m_selectionData; if ( hasSameData(data, *clipboardData) ) { COPYQ_LOG( QString("Ignoring unchanged %1") .arg(mode == ClipboardMode::Clipboard ? "clipboard" : "selection") ); return; } *clipboardData = data; COPYQ_LOG( QString("%1 changed, owner is \"%2\"") .arg(mode == ClipboardMode::Clipboard ? "Clipboard" : "Selection", getTextData(data, mimeOwner)) ); if (mode != ClipboardMode::Clipboard) { const QString modeName = mode == ClipboardMode::Selection ? "selection" : "find buffer"; data.insert(mimeClipboardMode, modeName); } // add window title of clipboard owner if ( !data.contains(mimeOwner) && !data.contains(mimeWindowTitle) ) { PlatformPtr platform = createPlatformNativeInterface(); PlatformWindowPtr currentWindow = platform->getCurrentWindow(); if (currentWindow) data.insert( mimeWindowTitle, currentWindow->getTitle().toUtf8() ); } #ifdef HAS_MOUSE_SELECTIONS if ( (mode == ClipboardMode::Clipboard ? m_clipboardToSelection : m_selectionToClipboard) && !data.contains(mimeOwner) ) { const auto text = getTextData(data); if ( !text.isEmpty() ) { const auto targetData = mode == ClipboardMode::Clipboard ? &m_selectionData : &m_clipboardData; const auto targetText = getTextData(*targetData); emit synchronizeSelection(mode, text, qHash(targetText)); } } #endif // run automatic commands if ( anySessionOwnsClipboardData(data) ) { emit clipboardChanged(data, ClipboardOwnership::Own); } else if ( isClipboardDataHidden(data) ) { emit clipboardChanged(data, ClipboardOwnership::Hidden); } else { const auto defaultTab = m_clipboardTab.isEmpty() ? defaultClipboardTabName() : m_clipboardTab; setTextData(&data, defaultTab, mimeCurrentTab); #ifdef HAS_MOUSE_SELECTIONS if (mode == ClipboardMode::Clipboard ? m_storeClipboard : m_storeSelection) { #else if (m_storeClipboard) { #endif setTextData(&data, m_clipboardTab, mimeOutputTab); } emit clipboardChanged(data, ClipboardOwnership::Foreign); } }
void CascadesCookbookApp::onTriggered(const QVariantList indexPath) { CustomControl *recipe = NULL; // Get the selected item title QVariantMap map = mRecipeModel.data(indexPath).toMap(); QString title = map.value("title").toString(); // Create a recipe based on the selected item title if (title.compare("Introduction") == 0) { recipe = new Intro(); } else if (title.compare("Image") == 0) { recipe = new ImageRecipe(); } else if (title.compare("Nine Slice") == 0) { recipe = new NineSliceRecipe(); } else if (title.compare("Button") == 0) { recipe = new ButtonRecipe(); } else if (title.compare("Slider") == 0) { recipe = new SliderRecipe(); } else if (title.compare("Selection") == 0) { recipe = new SelectionRecipe(); } else if (title.compare("Input") == 0) { recipe = new InputRecipe(); } else if (title.compare("Label") == 0) { recipe = new LabelRecipe(); } else if (title.compare("DockLayout") == 0) { recipe = new DockLayoutRecipe(); } else if (title.compare("Color") == 0) { recipe = new ColorRecipe(); } else if (title.compare("Orientation") == 0) { recipe = new OrientationRecipe(); } else if (title.compare("Animation") == 0) { recipe = new AnimationRecipe(); } else if (title.compare("Stock Curve") == 0) { recipe = new StockCurveRecipe(); } else if (title.compare("Picker") == 0) { recipe = new DateTimePickerRecipe(); } else if (title.compare("DropDown") == 0) { recipe = new DropDownRecipe(); } else if (title.compare("ActivityIndicator") == 0) { recipe = new ActivityIndicatorRecipe(); } else if (title.compare("ProgressIndicator") == 0) { recipe = new ProgressIndicatorRecipe(); } else if (title.compare("WebView") == 0) { recipe = new WebViewRecipe(); } else if (title.compare("Sheet") == 0) { recipe = new SheetRecipe(); } else if (title.compare("Dialog") == 0) { recipe = new CustomDialogRecipe(); } else if (title.compare("GestureHandler") == 0) { recipe = new GestureHandlerRecipe(); } else if (title.compare("ImagePaint") == 0) { recipe = new ImagePaintRecipe(); } else if (title.compare("PixelBuffer") == 0) { recipe = new PixelBufferRecipe(); } if (recipe) { // Get the content Container of the ContentPage, add the new recipe, it will be removed when // the popTransitionEnded signal is received in the onPopTransitionEnded function. Container *content = qobject_cast<Container *>(mContentPage->content()); if (content) { recipe->setHorizontalAlignment(HorizontalAlignment::Center); recipe->setVerticalAlignment(VerticalAlignment::Center); content->add(recipe); mContentPage->titleBar()->setTitle(title); mNavPane->push(mContentPage); } else { delete recipe; } } else { qDebug("No recipe created for this item yet."); } }
void SenderSequenceItem::doLoad(const QVariantMap& map) { m_dlg->load(map.value("form")); }
/* static Receipts::ReceiptsPlugin *receiptsPlugin() { qff::MainWindow *fwk = qff::MainWindow::frameWork(); auto *ret = qobject_cast<Receipts::ReceiptsPlugin *>(fwk->plugin("Receipts")); QF_ASSERT(ret != nullptr, "Bad plugin", return 0); return ret; } */ void ReceiptsPrinter::printReceipt(const QString &report_file_name, const QVariantMap &report_data) { qfLogFuncFrame(); QF_TIME_SCOPE("ReceiptsPrinter::printReceipt()"); const ReceiptsPrinterOptions &printer_opts = m_printerOptions; QPrinter *printer = nullptr; QPaintDevice *paint_device = nullptr; if(printer_opts.printerType() == (int)ReceiptsPrinterOptions::PrinterType::GraphicPrinter) { QF_TIME_SCOPE("init graphics printer"); QPrinterInfo pi = QPrinterInfo::printerInfo(printer_opts.graphicsPrinterName()); if(pi.isNull()) { for(auto s : QPrinterInfo::availablePrinterNames()) { qfInfo() << "available printer:" << s; } pi = QPrinterInfo::defaultPrinter(); } if(pi.isNull()) { qfWarning() << "Default printer not set"; return; } qfInfo() << "printing on:" << pi.printerName(); printer = new QPrinter(pi); paint_device = printer; } else { qfInfo() << "printing on:" << printer_opts.characterPrinterModel() << "at:" << printer_opts.characterPrinterDevice(); qff::MainWindow *fwk = qff::MainWindow::frameWork(); paint_device = fwk; } qf::qmlwidgets::reports::ReportProcessor rp(paint_device); { QF_TIME_SCOPE("setting report and data"); rp.setReport(report_file_name); for(auto key : report_data.keys()) { rp.setTableData(key, report_data.value(key)); } } if(printer_opts.printerType() == (int)ReceiptsPrinterOptions::PrinterType::GraphicPrinter) { QF_TIME_SCOPE("process graphics"); { QF_TIME_SCOPE("process report"); rp.process(); } qf::qmlwidgets::reports::ReportItemMetaPaintReport *doc; { QF_TIME_SCOPE("getting processor output"); doc = rp.processorOutput(); } qf::qmlwidgets::reports::ReportItemMetaPaint *it = doc->child(0); if(it) { QF_TIME_SCOPE("draw meta-paint"); qf::qmlwidgets::reports::ReportPainter painter(paint_device); painter.drawMetaPaint(it); } QF_SAFE_DELETE(printer); } else if(printer_opts.printerType() == (int)ReceiptsPrinterOptions::PrinterType::CharacterPrinter) { QDomDocument doc; doc.setContent(QLatin1String("<?xml version=\"1.0\"?><report><body/></report>")); QDomElement el_body = doc.documentElement().firstChildElement("body"); qf::qmlwidgets::reports::ReportProcessor::HtmlExportOptions opts; opts.setConvertBandsToTables(false); rp.processHtml(el_body, opts); //qfInfo() << doc.toString(); QList<QByteArray> data_lines = createPrinterData(el_body, printer_opts); auto save_file = [data_lines](const QString &fn) { QFile f(fn); if(f.open(QFile::WriteOnly)) { for(QByteArray ba : data_lines) { f.write(ba); f.write("\n"); } } else { qfError() << "Cannot open file" << f.fileName() << "for writing!"; } }; if(!printer_opts.characterPrinterDirectory().isEmpty()) { QString fn = printer_opts.characterPrinterDirectory(); qf::core::utils::FileUtils::ensurePath(fn); QCryptographicHash ch(QCryptographicHash::Sha1); for(QByteArray ba : data_lines) ch.addData(ba); fn += '/' + QString::fromLatin1(ch.result().toHex().mid(0, 8)) + ".txt"; save_file(fn); } else if (!printer_opts.characterPrinterDevice().isEmpty()) { save_file(printer_opts.characterPrinterDevice()); } } }
bool RmMerSdkOperation::test() const { QVariantMap map = AddMerSdkOperation::addSdk(AddMerSdkOperation::initializeSdks(), QLatin1String("testSdk"), true, QLatin1String("/test/sharedHomePath"), QLatin1String("/test/sharedTargetPath"), QLatin1String("/test/sharedSshPath"), QLatin1String("/test/sharedSrcPath"), QLatin1String("/test/sharedConfigPath"), QLatin1String("host"),QLatin1String("user"), QLatin1String("/test/privateKey"),22,80,false); map = AddMerSdkOperation::addSdk(map, QLatin1String("testSdk2"), true, QLatin1String("/test/sharedHomePath"), QLatin1String("/test/sharedTargetPath"), QLatin1String("/test/sharedSshPath"), QLatin1String("/test/sharedSrcPath"), QLatin1String("/test/sharedConfigPath"), QLatin1String("host"),QLatin1String("user"), QLatin1String("/test/privateKey"),22,80,false); const QString sdk1 = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); const QString sdk2 = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(1); if (map.count() != 4 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 2 || !map.contains(sdk1) || !map.contains(sdk2)) return false; QVariantMap result = removeSdk(map, QLatin1String("testSdk2")); if (result.count() != 3 || result.contains(sdk2) || !result.contains(sdk1) || !result.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 1 || !result.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2) return false; QString sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); QVariantMap sdkMap = result.value(sdk).toMap(); if (sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() == QLatin1String("testSdk2")) return false; result = removeSdk(map, QLatin1String("unknown")); if (result != map) return false; result = removeSdk(map, QLatin1String("testSdk")); if (result.count() != 3 || result.contains(sdk2) || !result.contains(sdk1) || !result.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 1 || !result.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2) return false; sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); sdkMap = result.value(sdk).toMap(); if (sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() == QLatin1String("testSdk")) return false; return true; }
void IRunConfigurationAspect::toMap(QVariantMap &map) const { m_projectSettings->toMap(map); map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings); }
void ServicesPanel::updateUserConfig(const QString & xuserid, const QVariantMap & datamap) { if (xuserid == m_xuserid) { QVariantMap deltaConfig = datamap["config"].toMap(); this->ui.call_filtering_checkbox->blockSignals(true); this->ui.dnd_checkbox->blockSignals(true); this->ui.nofwd_radiobutton->blockSignals(true); this->ui.fwdunc_radiobutton->blockSignals(true); this->ui.fwdsimple_radiobutton->blockSignals(true); this->ui.fwdna_checkbox->blockSignals(true); this->ui.fwdbusy_checkbox->blockSignals(true); if (deltaConfig.keys().contains("incallfilter")) { this->ui.call_filtering_checkbox->setChecked(m_ui->incallfilter()); } if (deltaConfig.keys().contains("enablednd")) { this->ui.dnd_checkbox->setChecked(m_ui->enablednd()); } CallForwardStruct call_fwdunc = {m_ui->enableunc(), m_ui->destunc()}; CallForwardStruct call_fwdna = {m_ui->enablerna(), m_ui->destrna()}; CallForwardStruct call_fwdbusy = {m_ui->enablebusy(), m_ui->destbusy()}; if (deltaConfig.keys().contains("enableunc") || deltaConfig.keys().contains("destunc")) { this->ui.fwdunc_input->setText(call_fwdunc.destination); } if (deltaConfig.keys().contains("enablerna") || deltaConfig.keys().contains("destrna")) { this->ui.fwdna_input->setText(call_fwdna.destination); this->ui.fwdna_checkbox->setChecked(call_fwdna.enabled); } if (deltaConfig.keys().contains("enablebusy") || deltaConfig.keys().contains("destbusy")) { this->ui.fwdbusy_input->setText(call_fwdbusy.destination); this->ui.fwdbusy_checkbox->setChecked(call_fwdbusy.enabled); } // Activate the right radiobutton if (m_nofwd_sent) { this->ui.nofwd_radiobutton->setChecked(true); } else if (call_fwdunc.enabled) { this->toggledSimpleFwd(false); this->ui.fwdunc_radiobutton->setChecked(true); } else if (call_fwdna.enabled || call_fwdbusy.enabled) { this->toggledSimpleFwd(true); } else if (this->ui.fwdunc_radiobutton->isChecked()) { this->ui.nofwd_radiobutton->setChecked(true); } if (m_nofwd_sent && ! call_fwdunc.enabled && ! call_fwdna.enabled && ! call_fwdbusy.enabled) { m_nofwd_sent = false; } this->ui.call_filtering_checkbox->blockSignals(false); this->ui.dnd_checkbox->blockSignals(false); this->ui.nofwd_radiobutton->blockSignals(false); this->ui.fwdunc_radiobutton->blockSignals(false); this->ui.fwdsimple_radiobutton->blockSignals(false); this->ui.fwdna_checkbox->blockSignals(false); this->ui.fwdbusy_checkbox->blockSignals(false); } }
void QPlaceMatchRequestPrivate::clear() { places.clear(); parameters.clear(); }
static void serializeEdge(QVariantMap & map, tikz::core::EdgePath * edge) { Q_ASSERT(edge != 0); map.insert("start", edge->startMetaPos().toString()); map.insert("end", edge->endMetaPos().toString()); }
void SlewDialog::loadPointsFromFile() { QVariantMap result; QString pointsJsonPath = StelFileMgr::findFile("modules/TelescopeControl", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/points.json"; if (pointsJsonPath.isEmpty()) { qWarning() << "SlewDialog: Error loading points"; return; } if(!QFileInfo(pointsJsonPath).exists()) { qWarning() << "SlewDialog::loadPointsFromFile(): No pointss loaded. File is missing:" << QDir::toNativeSeparators(pointsJsonPath); storedPointsDescriptions = result; return; } QFile pointsJsonFile(pointsJsonPath); QVariantMap map; if(!pointsJsonFile.open(QFile::ReadOnly)) { qWarning() << "SlewDialog: No points loaded. Can't open for reading" << QDir::toNativeSeparators(pointsJsonPath); storedPointsDescriptions = result; return; } else { map = StelJsonParser::parse(&pointsJsonFile).toMap(); pointsJsonFile.close(); } //File contains any points? if(map.isEmpty()) { storedPointsDescriptions = result; return; } QString version = map.value("version", "0.0.0").toString(); if(version < QString(TELESCOPE_CONTROL_VERSION)) { QString newName = pointsJsonPath + ".backup." + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss"); if(pointsJsonFile.rename(newName)) { qWarning() << "SlewDialog: The existing version of points.json is obsolete. Backing it up as " << QDir::toNativeSeparators(newName); qWarning() << "SlewDialog: A blank points.json file will have to be created."; storedPointsDescriptions = result; return; } else { qWarning() << "SlewDialog: The existing version of points.json is obsolete. Unable to rename."; storedPointsDescriptions = result; return; } } map.remove("version");//Otherwise it will try to read it as a point //Read pointss, if any QMapIterator<QString, QVariant> node(map); if(node.hasNext()) { ui->comboBoxStoredPoints->addItem(q_("Select one")); do { node.next(); QVariantMap point = node.value().toMap(); storedPoint sp; sp.name = point.value("name").toString(); sp.number = point.value("number").toInt(); sp.radiansRA = point.value("radiansRA").toDouble(); sp.radiansDec = point.value("radiansDec").toDouble(); QVariant var; var.setValue(sp); ui->comboBoxStoredPoints->addItem(sp.name,var); } while (node.hasNext()); } }
QVariantMap SerializeVisitor::serializeEdgeStyle(EdgeStyle * style) { QVariantMap map = serializeStyle(style); if (style->radiusXSet()) { map.insert("radius-x", style->radiusX().toString()); } if (style->radiusYSet()) { map.insert("radius-y", style->radiusY().toString()); } if (style->bendAngleSet()) { map.insert("bend-angle", style->bendAngle()); } if (style->loosenessSet()) { map.insert("looseness", style->looseness()); } if (style->outAngleSet()) { map.insert("out-angle", style->outAngle()); } if (style->inAngleSet()) { map.insert("in-angle", style->inAngle()); } if (style->arrowTailSet()) { map.insert("arrow-tail", toString(style->arrowTail())); } if (style->arrowHeadSet()) { map.insert("arrow-head", toString(style->arrowHead())); } if (style->shortenStartSet()) { map.insert("shorten-start", style->shortenStart().toString()); } if (style->shortenEndSet()) { map.insert("shorten-end", style->shortenEnd().toString()); } return map; }
AssignmentClient::AssignmentClient(int &argc, char **argv) : QCoreApplication(argc, argv), _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME) { setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("assignment-client"); QSettings::setDefaultFormat(QSettings::IniFormat); // set the logging target to the the CHILD_TARGET_NAME Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); const QVariantMap argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments()); const QString ASSIGNMENT_TYPE_OVERRIDE_OPTION = "t"; const QString ASSIGNMENT_POOL_OPTION = "pool"; const QString ASSIGNMENT_WALLET_DESTINATION_ID_OPTION = "wallet"; const QString CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION = "a"; Assignment::Type requestAssignmentType = Assignment::AllTypes; // check for an assignment type passed on the command line or in the config if (argumentVariantMap.contains(ASSIGNMENT_TYPE_OVERRIDE_OPTION)) { requestAssignmentType = (Assignment::Type) argumentVariantMap.value(ASSIGNMENT_TYPE_OVERRIDE_OPTION).toInt(); } QString assignmentPool; // check for an assignment pool passed on the command line or in the config if (argumentVariantMap.contains(ASSIGNMENT_POOL_OPTION)) { assignmentPool = argumentVariantMap.value(ASSIGNMENT_POOL_OPTION).toString(); } // setup our _requestAssignment member variable from the passed arguments _requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool); // check for a wallet UUID on the command line or in the config // this would represent where the user running AC wants funds sent to if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { QUuid walletUUID = argumentVariantMap.value(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION).toString(); qDebug() << "The destination wallet UUID for credits is" << uuidStringWithoutCurlyBraces(walletUUID); _requestAssignment.setWalletUUID(walletUUID); } // create a NodeList as an unassigned client NodeList* nodeList = NodeList::createInstance(NodeType::Unassigned); // check for an overriden assignment server hostname if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION)) { _assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString(); // set the custom assignment socket on our NodeList HifiSockAddr customAssignmentSocket = HifiSockAddr(_assignmentServerHostname, DEFAULT_DOMAIN_SERVER_PORT); nodeList->setAssignmentServerSocket(customAssignmentSocket); } // call a timer function every ASSIGNMENT_REQUEST_INTERVAL_MSECS to ask for assignment, if required qDebug() << "Waiting for assignment -" << _requestAssignment; QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(sendAssignmentRequest())); timer->start(ASSIGNMENT_REQUEST_INTERVAL_MSECS); // connect our readPendingDatagrams method to the readyRead() signal of the socket connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClient::readPendingDatagrams); // connections to AccountManager for authentication connect(&AccountManager::getInstance(), &AccountManager::authRequired, this, &AssignmentClient::handleAuthenticationRequest); NetworkAccessManager::getInstance(); }
void ToolChainFactory::idToMap(QVariantMap &data, const QString id) { data.insert(QLatin1String(ID_KEY), id); }
void SymbianQtVersion::fromMap(const QVariantMap &map) { BaseQtVersion::fromMap(map); setSbsV2Directory(QDir::fromNativeSeparators(map.value(QLatin1String("SBSv2Directory")).toString())); }
void Api_v1_5::playback( QxtWebRequestEvent* event, const QString& command ) { if ( command == "next") { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "next", Qt::QueuedConnection ) , "Skipping to the next track failed." ); } else if ( command == "previous" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "previous", Qt::QueuedConnection ), "Rewinding to the previous track failed." ); } else if ( command == "playpause" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "playPause", Qt::QueuedConnection ), "Play/Pause failed." ); } else if ( command == "play" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "play", Qt::QueuedConnection ), "Starting the playback failed." ); } else if ( command == "pause" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "pause", Qt::QueuedConnection ), "Pausing the current track failed." ); } else if ( command == "stop" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "stop", Qt::QueuedConnection ), "Stopping the current track failed." ); } else if ( command == "lowervolume" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "lowerVolume", Qt::QueuedConnection ), "Lowering volume failed." ); } else if ( command == "raisevolume" ) { JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "raiseVolume", Qt::QueuedConnection ), "Raising volume failed." ); } else if ( command == "currenttrack" ) { QByteArray json; Tomahawk::result_ptr currentTrack = AudioEngine::instance()->currentTrack(); if ( currentTrack.isNull() ) { json = "{ \"playing\": false }"; } else { QVariantMap trackInfo; trackInfo.insert( "playing", true ); trackInfo.insert( "bitrate", currentTrack->bitrate() ); if ( !currentTrack->resolvedBy().isNull() ) { QString resolverName = currentTrack->resolvedBy()->name(); trackInfo.insert( "resolvedBy", resolverName ); } else { trackInfo.insert( "resolvedBy", "<unknown resolver>" ); } trackInfo.insert( "score", currentTrack->score() ); trackInfo.insert( "album", currentTrack->track()->album() ); trackInfo.insert( "albumpos", currentTrack->track()->albumpos() ); trackInfo.insert( "artist", currentTrack->track()->artist() ); trackInfo.insert( "duration", currentTrack->track()->duration() ); trackInfo.insert( "track", currentTrack->track()->track() ); bool ok; json = TomahawkUtils::toJson( trackInfo, &ok ); Q_ASSERT( ok ); } QxtWebPageEvent * e = new QxtWebPageEvent( event->sessionID, event->requestID, json ); e->headers.insert( "Access-Control-Allow-Origin", "*" ); e->contentType = "application/json"; m_service->postEvent( e ); } else if ( command == "volume" ) { QByteArray json = QString( "{ \"result\": \"ok\", \"volume\": %1}" ).arg( AudioEngine::instance()->volume() ).toUtf8(); QxtWebPageEvent * e = new QxtWebPageEvent( event->sessionID, event->requestID, json ); e->headers.insert( "Access-Control-Allow-Origin", "*" ); e->contentType = "application/json"; m_service->postEvent( e ); } else { m_service->sendJsonError( event, "No such playback command." ); } }
QVariantMap SymbianQtVersion::toMap() const { QVariantMap result = BaseQtVersion::toMap(); result.insert(QLatin1String("SBSv2Directory"), sbsV2Directory()); return result; }
void Twitter::onDataReceived() { QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QString response; bool success = false; if (reply) { if (reply->error() == QNetworkReply::NoError) { int available = reply->bytesAvailable(); if (available > 0) { int bufSize = sizeof(char) * available + sizeof(char); QByteArray buffer(bufSize, 0); reply->read(buffer.data(), available); response = QString(buffer); success = true; } } else { response = QString("Error: ") + reply->errorString() + QString(" status:") + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString(); emit tweetParseComplete(false, "We can't connect to the internet"); } reply->deleteLater(); } if (success ) { if (response != "[]") { if (_refreshing) { _tweetList.clear(); emit itemsChanged(bb::cascades::DataModelChangeType::Init); } bb::data::JsonDataAccess jda; QVariant jsonva = jda.loadFromBuffer(response); QVariantMap map = jsonva.toMap(); QVariantList results = map.value("results").toList(); //okay let's get the news items int numTweets = 0; foreach (QVariant v, results) { QVariantMap map = v.toMap(); Tweet *tweet = new Tweet(); tweet->parse(v); QVariant q = QVariant::fromValue(tweet); _tweetList.append(q); //to go from a QVariant back to a Tweet* item: Tweet *Tweet = q.value<Tweet*>(); QVariantList path; path.append(_tweetList.indexOf(q)); emit itemAdded (path); numTweets++; } if (numTweets > 0) { emit tweetParseComplete(true, "Parsed successfully"); } else { if (_tweetList.count() == 0) { emit tweetParseComplete(false, "No Tweets yet"); } } } }
QVariant Result::toVariant() const { QVariantMap m; m.insert( "artist", m_track->artist() ); m.insert( "album", m_track->album() ); m.insert( "track", m_track->track() ); m.insert( "source", friendlySource() ); m.insert( "mimetype", mimetype() ); m.insert( "size", size() ); m.insert( "bitrate", bitrate() ); m.insert( "duration", m_track->duration() ); // m.insert( "score", score() ); m.insert( "sid", id() ); m.insert( "discnumber", m_track->discnumber() ); m.insert( "albumpos", m_track->albumpos() ); m.insert( "preview", isPreview() ); m.insert( "purchaseUrl", purchaseUrl() ); if ( !m_track->composer().isEmpty() ) m.insert( "composer", m_track->composer() ); return m; }
void InstrumentsForm::onGotInstrument(void* p) { auto item = (InstrumentField*)p; QVariantMap mdItem; mdItem.insert("InstrumentID", item->InstrumentID); mdItem.insert("ExchangeID", item->ExchangeID); mdItem.insert("InstrumentName", gbk2utf16(item->InstrumentName)); mdItem.insert("ExchangeInstID", item->ExchangeInstID); mdItem.insert("PriceTick", item->PriceTick); mdItem.insert("CreateDate", item->CreateDate); mdItem.insert("OpenDate", item->OpenDate); mdItem.insert("ExpireDate", item->ExpireDate); mdItem.insert("StartDelivDate", item->StartDelivDate); //根据id找到对应的行,然后用列的text来在map里面取值设置到item里面= int row = ui->tableWidget->rowCount(); ui->tableWidget->insertRow(row); for (int i = 0; i < instruments_col_.count(); i++) { QVariant raw_val = mdItem.value(instruments_col_.at(i)); QString str_val = raw_val.toString(); if (raw_val.type() == QMetaType::Double || raw_val.type() == QMetaType::Float) { str_val = QString().sprintf("%6.1f", raw_val.toDouble()); } QTableWidgetItem* item = new QTableWidgetItem(str_val); ui->tableWidget->setItem(row, i, item); } }
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(); }