QVariantList AppEntry::actions() const { QVariantList actionList; actionList << Kicker::jumpListActions(m_service); if (!actionList.isEmpty()) { actionList << Kicker::createSeparatorActionItem(); } QObject *appletInterface = m_owner->rootModel()->property("appletInterface").value<QObject *>(); const bool systemImmutable = appletInterface->property("immutability").toInt() == Plasma::Types::SystemImmutable; const QVariantList &addLauncherActions = Kicker::createAddLauncherActionList(appletInterface, m_service); if (!systemImmutable && !addLauncherActions.isEmpty()) { actionList << addLauncherActions << Kicker::createSeparatorActionItem(); } const QVariantList &recentDocuments = Kicker::recentDocumentActions(m_service); if (!recentDocuments.isEmpty()) { actionList << recentDocuments << Kicker::createSeparatorActionItem(); } // Don't allow adding launchers, editing, hiding, or uninstalling applications // when system is immutable. if (systemImmutable) { return actionList; } if (m_menuEntryEditor->canEdit(m_service->entryPath())) { actionList << Kicker::createSeparatorActionItem(); QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), "editApplication"); editAction["icon"] = "kmenuedit"; // TODO: Using the KMenuEdit icon might be misleading. actionList << editAction; } #ifdef HAVE_APPSTREAMQT if (m_service->isApplication()) { actionList << appstreamActions(m_service); } #endif QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>()); if (appletConfig && appletConfig->contains("hiddenApplications") && qobject_cast<AppsModel *>(m_owner)) { const QStringList &hiddenApps = appletConfig->value("hiddenApplications").toStringList(); if (!hiddenApps.contains(m_service->menuId())) { actionList << Kicker::createActionItem(i18n("Hide Application"), "hideApplication"); } } return actionList; }
void tst_QQmlPropertyMap::clear() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); QVERIFY(map.keys().count() == 1); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); map.clear(QLatin1String("key1")); QVERIFY(map.keys().count() == 1); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant()); }
void tst_QQmlPropertyMap::operatorValue() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); QVERIFY(map.count() == 2); QVERIFY(map.contains(QLatin1String("key1"))); const QQmlPropertyMap &constMap = map; QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100)); QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200)); QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1"))); QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2"))); }
void tst_QQmlPropertyMap::insert() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); QVERIFY(map.keys().count() == 2); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); QCOMPARE(map.value(QLatin1String("key2")), QVariant(200)); map.insert(QLatin1String("key1"),"Hello World"); QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World")); //inserting property names same with existing method(signal, slot, method) names is not allowed //QQmlPropertyMap has an invokable keys() method QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. "); map.insert(QLatin1String("keys"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("keys"))); QVERIFY(map.value(QLatin1String("keys")).isNull()); //QQmlPropertyMap has a deleteLater() slot QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. "); map.insert(QLatin1String("deleteLater"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("deleteLater"))); QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); //QQmlPropertyMap has an valueChanged() signal QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. "); map.insert(QLatin1String("valueChanged"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("valueChanged"))); QVERIFY(map.value(QLatin1String("valueChanged")).isNull()); //but 'valueChange' should be ok map.insert(QLatin1String("valueChange"), 1); QVERIFY(map.keys().count() == 3); QVERIFY(map.contains(QLatin1String("valueChange"))); QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1)); //'valueCHANGED' should be ok, too map.insert(QLatin1String("valueCHANGED"), 1); QVERIFY(map.keys().count() == 4); QVERIFY(map.contains(QLatin1String("valueCHANGED"))); QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1)); }
void MarSystemView::createItem( MarSystem *system, QQmlComponent * delegate, QQuickItem * parent ) { int level = -1; MarSystem *s = system; while(s) { s = s->getParent(); ++level; } QQmlPropertyMap *data = new QQmlPropertyMap; data->insert("level", level); // Get controls QQmlPropertyMap *defaultControls = new QQmlPropertyMap; defaultControls->insert("inSamples", variantFromControl(system->getControl("mrs_natural/inSamples"))); defaultControls->insert("onSamples", variantFromControl(system->getControl("mrs_natural/onSamples"))); defaultControls->insert("inObservations", variantFromControl(system->getControl("mrs_natural/inObservations"))); defaultControls->insert("onObservations", variantFromControl(system->getControl("mrs_natural/onObservations"))); defaultControls->insert("israte", variantFromControl(system->getControl("mrs_real/israte"))); defaultControls->insert("osrate", variantFromControl(system->getControl("mrs_real/osrate"))); defaultControls->insert("inStabilizingDelay", variantFromControl(system->getControl("mrs_natural/inStabilizingDelay"))); defaultControls->insert("onStabilizingDelay", variantFromControl(system->getControl("mrs_natural/onStabilizingDelay"))); defaultControls->insert("inObsNames", variantFromControl(system->getControl("mrs_string/inObsNames"))); defaultControls->insert("onObsNames", variantFromControl(system->getControl("mrs_string/onObsNames"))); defaultControls->insert("active", variantFromControl(system->getControl("mrs_bool/active"))); defaultControls->insert("mute", variantFromControl(system->getControl("mrs_bool/mute"))); defaultControls->insert("debug", variantFromControl(system->getControl("mrs_bool/debug"))); defaultControls->insert("verbose", variantFromControl(system->getControl("mrs_bool/verbose"))); defaultControls->insert("processedData", variantFromControl(system->getControl("mrs_realvec/processedData"))); QQmlPropertyMap *customControls = new QQmlPropertyMap; control_map_t controls = system->controls(); control_map_t::iterator it; for (it = controls.begin(); it != controls.end(); ++it) { const MarControlPtr & control = it->second; QString name = QString::fromStdString( control->getName() ); name = name.split('/').last(); if (defaultControls->contains(name)) continue; customControls->insert(name, variantFromControl(control)); } data->insert("defaultControls", QVariant::fromValue<QObject*>(defaultControls)); data->insert("controls", QVariant::fromValue<QObject*>(customControls)); data->insert("absolutePath", QString::fromStdString(system->getAbsPath())); data->insert("path", QString::fromStdString(system->getPrefix())); // Set context QQmlContext *context = new QQmlContext( delegate->creationContext() ); context->setContextProperty("system", data); QObject *object = delegate->create(context); object->setParent(parent); m_items.append(object); QQuickItem *item = qobject_cast<QQuickItem*>(object); if (!item) return; QString path = QString::fromStdString(system->getPrefix()); std::vector<MarSystem*> children = system->getChildren(); int children_count = children.size(); bool has_children = children_count > 0; bool create_if_not_existent = true; MarSystemViewAttached *attached = qobject_cast<MarSystemViewAttached*>(qmlAttachedPropertiesObject<MarSystemView>(item, create_if_not_existent) ); Q_ASSERT(attached); attached->setPath(path); attached->setHasChildren(has_children); attached->setSystem(system); QQuickItem *children_area = attached->childrenArea(); if (!children_area) children_area = item; for (int child_idx = 0; child_idx < children_count; ++child_idx) { MarSystem *child_system = children[child_idx]; createItem(child_system, delegate, children_area); } item->setParentItem(parent); }