当前位置: 首页>>代码示例>>C++>>正文


C++ Observer::getMultiContextPropertyValue方法代码示例

本文整理汇总了C++中Observer::getMultiContextPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Observer::getMultiContextPropertyValue方法的具体用法?C++ Observer::getMultiContextPropertyValue怎么用?C++ Observer::getMultiContextPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Observer的用法示例。


在下文中一共展示了Observer::getMultiContextPropertyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QtilitiesCategory

Qtilities::Core::QtilitiesCategory Qtilities::CoreGui::Command::category() const {
    Observer* obs = OBJECT_MANAGER->observerReference(d_category_context);
    if (obs) {
        QVariant category_variant = obs->getMultiContextPropertyValue(this,qti_prop_CATEGORY_MAP);
        if (category_variant.isValid()) {
            return category_variant.value<QtilitiesCategory>();
        }
    }
    return QtilitiesCategory();
}
开发者ID:CJCombrink,项目名称:Qtilities,代码行数:10,代码来源:Command.cpp

示例2: if

void Qtilities::CoreGui::ObjectScopeWidget::updateContents() {
    if (!d->obj)
        return;

    int observer_count = -1;
    int observer_limit = -2;
    int ownership = -1;
    ui->txtName->setText(d->obj->objectName());

    // Observer Count
    MultiContextProperty context_map_prop = ObjectManager::getMultiContextProperty(d->obj,qti_prop_OBSERVER_MAP);
    if (context_map_prop.isValid())
        observer_count = context_map_prop.contextMap().count();

    // Observer Limit
    SharedProperty shared_property = ObjectManager::getSharedProperty(d->obj,qti_prop_OBSERVER_LIMIT);
    if (shared_property.isValid())
        observer_limit = shared_property.value().toInt();

    if (observer_limit == -1)
        ui->txtObserverLimit->setText(tr("Unlimited"));
    else if (observer_limit == -2)
        ui->txtObserverLimit->setText(tr("Unlimited"));
    else
        ui->txtObserverLimit->setText(QString("%1").arg(observer_limit));

    // Ownership
    shared_property = ObjectManager::getSharedProperty(d->obj,qti_prop_OWNERSHIP);
    if (shared_property.isValid())
        ownership = shared_property.value().toInt();

    if (ownership == -1)
        ui->txtOwnership->setText(tr("Manual Ownership"));
    else if (ownership == Observer::ManualOwnership)
        ui->txtOwnership->setText(tr("Manual Ownership"));
    else if (ownership == Observer::SpecificObserverOwnership)
        ui->txtOwnership->setText(tr("Specific Observer Ownership"));
    else if (ownership == Observer::ObserverScopeOwnership)
        ui->txtOwnership->setText(tr("Observer Scope Ownership"));

    ui->observerTable->clearContents();
    ui->observerTable->setRowCount(observer_count);
    QString tooltip_string;
    bool has_instance_names = false;

    for (int i = 0; i < observer_count; i++) {
        int id = context_map_prop.contextMap().keys().at(i);
        Observer* observer = OBJECT_MANAGER->observerReference(id);
        if (!observer)  {
            LOG_ERROR("Object scope widget: Found invalid observer ID on object: " + d->obj->objectName());
            continue;
        }

        // Observer Name
        QTableWidgetItem *nameItem = new QTableWidgetItem(observer->observerName(), id);
        ui->observerTable->setItem(i, 0, nameItem);
        if (ownership == Observer::SpecificObserverOwnership) {
            QVariant observer_parent = observer->getMultiContextPropertyValue(d->obj,qti_prop_PARENT_ID);
            if (observer_parent.isValid() && (observer_parent.toInt() == id)) {
                QTableWidgetItem *ownerItem = new QTableWidgetItem("", id);
                ownerItem->setIcon(QIcon(qti_icon_SUCCESS_16x16));
                ownerItem->setToolTip(tr("This context owns the selected object (Manages its lifetime)."));
                ui->observerTable->setItem(i, OwnerColumn, ownerItem);
            }
        }
        tooltip_string.append(QString(tr("<b>Context Name</b>: %1")).arg(observer->observerName()));
        // Context Description
        tooltip_string.append(QString(tr("<br><b>Context Description</b>: %1")).arg(observer->observerDescription()));
        // Context ID
        tooltip_string.append(QString(tr("<br><b>Context ID</b>: %1")).arg(observer->observerID()));
        // Context Category
        MultiContextProperty category_prop = ObjectManager::getMultiContextProperty(d->obj,qti_prop_CATEGORY_MAP);
        QString category_string;
        if (category_prop.isValid()) {
            if (category_prop.contextMap().keys().contains(observer->observerID()))
                category_string = category_prop.value(observer->observerID()).toString();
            else
                category_string = tr("None");
        } else {
            category_string = tr("None");
        }
        tooltip_string.append(QString(tr("<br><b>Context Category</b>: %1")).arg(category_string));

        // Attributes
        tooltip_string.append(tr("<br><br><b>Attributes: </b> "));
        // Attribute: Activity
        QVariant activity = observer->getMultiContextPropertyValue(d->obj,qti_prop_ACTIVITY_MAP);
        if (activity.isValid() && activity.toBool())
            tooltip_string.append(tr("Active, "));

        // Attribute: Object Name Controller
        QVariant name_manager_id = observer->getMultiContextPropertyValue(d->obj,qti_prop_NAME_MANAGER_ID);
        if (name_manager_id.isValid() && (name_manager_id.toInt() == observer->observerID()))
            tooltip_string.append(tr("Manages Name, "));

        // Attribute: Uses Instance Name
        MultiContextProperty instance_names = ObjectManager::getMultiContextProperty(d->obj,qti_prop_ALIAS_MAP);
        if (instance_names.isValid() && instance_names.hasContext(observer->observerID())) {
            tooltip_string.append(QString(tr("Uses Instance Name (\"%1\"), ").arg(instance_names.value(observer->observerID()).toString())));
            has_instance_names = true;
//.........这里部分代码省略.........
开发者ID:austinsc,项目名称:Qtilities,代码行数:101,代码来源:ObjectScopeWidget.cpp


注:本文中的Observer::getMultiContextPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。