本文整理汇总了C++中QVariantMap类的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap类的具体用法?C++ QVariantMap怎么用?C++ QVariantMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QVariantMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QRectF
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());
}
}
示例2: on_arguments_updated
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);
}
});
示例3: commentLessThan
static bool commentLessThan(const QVariantMap &a, const QVariantMap &b)
{
return a.value("cid").toInt() < b.value("cid").toInt();
}
示例4: idFromMap
QString ToolChainFactory::idFromMap(const QVariantMap &data)
{
return data.value(QLatin1String(ID_KEY)).toString();
}
示例5: autoDetectionToMap
void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected)
{
data.insert(QLatin1String(AUTODETECT_KEY), detected);
}
示例6: handle
void ProtoSlaveCurrentBuilds::handle(QVariantMap jsonObject, Management *management, QTcpSocket *masterSocket){
if(!jsonObject.value("subHandler").toString().compare("Rechecker"))
Rechecker(management, masterSocket);
}
示例7: serializeEdge
static void serializeEdge(QVariantMap & map, tikz::core::EllipsePath * ellipse)
{
Q_ASSERT(ellipse != 0);
map.insert("center", ellipse->metaPos().toString());
}
示例8: settings
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);
}
示例9: fromMap
void IRunConfigurationAspect::fromMap(const QVariantMap &map)
{
m_projectSettings->fromMap(map);
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
}
示例10: fromMap
bool ConfigureStep::fromMap(const QVariantMap &map)
{
m_additionalArguments = map.value(QLatin1String(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY)).toString();
return BuildStep::fromMap(map);
}
示例11: onClipboardChanged
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);
}
}
示例12: onTriggered
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.");
}
}
示例13: doLoad
void SenderSequenceItem::doLoad(const QVariantMap& map)
{
m_dlg->load(map.value("form"));
}
示例14: QF_ASSERT
/*
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());
}
}
}
示例15: QLatin1String
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;
}