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


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

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


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

示例1:

void Qtilities::CoreGui::ObjectScopeWidget::refreshActions() {
    if (ui->observerTable->selectedItems().count() > 0) {
        int id = ui->observerTable->currentItem()->type();
        Observer* observer = OBJECT_MANAGER->observerReference(id);
        if (observer) {
            if (observer->displayHints()) {
                if (ui->observerTable->rowCount() > 1)
                    d->actionDetachToSelection->setEnabled(true);
                else
                    d->actionDetachToSelection->setEnabled(false);

                if (observer->displayHints()->actionHints() & ObserverHints::ActionRemoveItem)
                    d->actionRemoveContext->setEnabled(true);
                else
                    d->actionRemoveContext->setEnabled(false);
            }
        } else {
            d->actionDetachToSelection->setEnabled(false);
            d->actionRemoveContext->setEnabled(false);
        }
    } else {
        d->actionDetachToSelection->setEnabled(false);
        d->actionRemoveContext->setEnabled(false);
    }

    // Check if the observer limit is reached, if so disable the add context action.
    if (!d->obj) {
        d->actionDetachToSelection->setEnabled(false);
        d->actionRemoveContext->setEnabled(false);
    }
}
开发者ID:austinsc,项目名称:Qtilities,代码行数:31,代码来源:ObjectScopeWidget.cpp

示例2: switch

void Qtilities::CoreGui::ObjectScopeWidget::handle_actionDetachToSelection_triggered() {
    // Get the ids of all unselected items
    QList<int> other_ids;
    int selected_id = ui->observerTable->currentItem()->type();
    for (int i = 0; i < ui->observerTable->rowCount(); i++) {
        if (selected_id != ui->observerTable->item(i,0)->type())
            other_ids << ui->observerTable->item(i,0)->type();
    }

    QStringList unsupported_items;
    for (int i = 0; i < other_ids.count(); i++) {
        Observer* observer = OBJECT_MANAGER->observerReference(other_ids.at(i));
        if (!observer)
            break;

        if (observer->displayHints()) {
            if (!(observer->displayHints()->actionHints() & ObserverHints::ActionRemoveItem)) {
                unsupported_items << observer->observerName();
            }
        } else {
            unsupported_items << observer->observerName();
        }
    }

    if (unsupported_items.count() > 0)  {
        QMessageBox msgBox;
        msgBox.setText(tr("All other contexts does not support removing of child items."));
        msgBox.setInformativeText(tr("Do you want to continue and remove the contexts which does support this?"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::Yes);
        int ret = msgBox.exec();

        switch (ret) {
           case QMessageBox::No:
               return;
           default:
               break;
        }
    }

    for (int i = 0; i < other_ids.count(); i++) {
        Observer* observer = OBJECT_MANAGER->observerReference(other_ids.at(i));
        if (!observer)
            break;

        if (observer->displayHints()) {
            if (observer->displayHints()->actionHints() & ObserverHints::ActionRemoveItem) {
                observer->detachSubject(d->obj);
            }
        }
    }
}
开发者ID:austinsc,项目名称:Qtilities,代码行数:52,代码来源:ObjectScopeWidget.cpp

示例3: shortened_category

void Qtilities::CoreGui::ObserverTreeModelBuilder::buildRecursive(ObserverTreeItem* item, QList<QPointer<QObject> > category_objects) {
     // In here we build the complete structure of all the children below item.
    Observer* observer = qobject_cast<Observer*> (item->getObject());
    ObserverTreeItem* new_item;

    if (!observer && item->getObject()) {
        // Handle cases where the item is a category item
        if (item->itemType() == ObserverTreeItem::CategoryItem) {
            // Get the observer from the parent of item
            if (item->parentItem()) {
                Observer* parent_observer = item->containedObserver();
                if (parent_observer) {
                    // Now add all items belonging to this category
                    int cat_count = category_objects.count();
                    for (int i = 0; i < cat_count; ++i) {
                        //QApplication::processEvents();
                        // Storing all information in the data vector here can improve performance
                        QPointer<QObject> object = category_objects.at(i);
                        if (object) {
                            QPointer<Observer> obs = qobject_cast<Observer*> (object);
                            QVector<QVariant> column_data;
                            column_data << QVariant(parent_observer->subjectNameInContext(object));
                            if (obs) {
                                new_item = new ObserverTreeItem(object,item,column_data,ObserverTreeItem::TreeNode);
                            } else {
                                new_item = new ObserverTreeItem(object,item,column_data,ObserverTreeItem::TreeItem);
                            }
                            item->appendChild(new_item);

                            if (obs)
                                buildRecursive(new_item);
                        }
                    }
                }
            }
        }
    }

    if (observer) {
        // If this observer is locked we don't show its children:
        if (observer->accessMode() != Observer::LockedAccess) {
            // Check the HierarchicalDisplay hint of the observer:
            // Remember this is an recursive function, we can't use hints directly since thats linked to the selection parent.
            bool use_categorized;
            ObserverHints* hints_to_use = 0;
            if (d->use_hints) {
                if (observer->displayHints()) {
                    use_categorized = (observer->displayHints()->hierarchicalDisplayHint() == ObserverHints::CategorizedHierarchy);
                    hints_to_use = observer->displayHints();
                } else
                    use_categorized = false;
            } else {
                use_categorized = (d->hints->hierarchicalDisplayHint() == ObserverHints::CategorizedHierarchy);
                hints_to_use = d->hints;
            }

            if (use_categorized) {
                // Get the object / category hash:
                QMap<QPointer<QObject>, QString> category_map = observer->subjectReferenceCategoryMap();
                QSet<QString> categories = category_map.values().toSet();

                foreach (const QString& category_string, categories) {
                    //QApplication::processEvents();
                    QtilitiesCategory category = QtilitiesCategory(category_string,"::");
                    // Check the category against the displayed category list:
                    bool valid_category = true;
                    if (hints_to_use) {
                        QList<QtilitiesCategory> displayed_categories = hints_to_use->displayedCategories();
                        if (hints_to_use->categoryFilterEnabled()) {
                            if (hints_to_use->hasInversedCategoryDisplay()) {
                                if (!displayed_categories.contains(category))
                                    valid_category = true;
                                else
                                    valid_category = false;
                            } else {
                                if (displayed_categories.contains(category))
                                    valid_category = true;
                                else
                                    valid_category = false;
                            }
                        }
                    }

                    // Only add valid categories:
                    if (valid_category) {
                        // Ok here we need to create items for each category level and add the items underneath it.
                        int level_counter = 0;
                        QList<ObserverTreeItem*> tree_item_list;
                        while (level_counter < category.categoryDepth()) {
                            QStringList category_levels = category.toStringList(level_counter+1);

                            // Get the correct parent:
                            ObserverTreeItem* correct_parent;
                            if (tree_item_list.count() == 0)
                                correct_parent = item;
                            else
                                correct_parent = tree_item_list.last();

                            // Check if the parent item already has a category for this level:
                            ObserverTreeItem* existing_item = correct_parent->childWithName(category_levels.last());
//.........这里部分代码省略.........
开发者ID:JPNaude,项目名称:Qtilities,代码行数:101,代码来源:ObserverTreeModelBuilder.cpp


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