本文整理汇总了C++中Observer::accessMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Observer::accessMode方法的具体用法?C++ Observer::accessMode怎么用?C++ Observer::accessMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Observer
的用法示例。
在下文中一共展示了Observer::accessMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
void Qtilities::CoreGui::ObjectHierarchyNavigator::refreshHierarchy() {
// For this version, we make it simple. Just display the hierarchy.
QString label_text = QString("");
Observer* observer = 0;
bool read_only = false;
for (int i = d_navigation_stack.count()-1; i >= 0; i--) {
observer = OBJECT_MANAGER->observerReference(d_navigation_stack.at(i));
if (!observer)
return;
Q_ASSERT(observer);
if (observer) {
if (observer->accessMode() == Observer::ReadOnlyAccess)
read_only = true;
}
if (i > 0) {
if (read_only)
label_text.prepend(QString("<font color = 'red'>%1</color> :: ").arg(observer->observerName(d_navigation_stack.at(i-1))));
else {
// TODO: This is a bug, the navigation stack is not used correctly, since observer is not contained in the ID used.
label_text.prepend(QString("%1 :: ").arg(observer->observerName(d_navigation_stack.at(i-1))));
}
} else {
if (read_only)
label_text.prepend(QString("<font color = 'red'>%1</color> :: ").arg(observer->observerName()));
else
label_text.prepend(QString("%1 :: ").arg(observer->observerName()));
}
}
if (d_current_obj) {
// Get the object name for the current parent context
if (d_navigation_stack.count() > 0) {
observer = qobject_cast<Observer*> (d_current_obj);
if (observer) {
if (observer->accessMode() == Observer::ReadOnlyAccess)
read_only = true;
}
observer = OBJECT_MANAGER->observerReference(d_navigation_stack.at(d_navigation_stack.count()-1));
if (read_only)
label_text.append(QString("<font color = 'red'>%1</color>").arg(observer->subjectDisplayedNameInContext(d_current_obj)));
else
label_text.append(QString("%1").arg(observer->subjectDisplayedNameInContext(d_current_obj)));
} else {
observer = qobject_cast<Observer*> (d_current_obj);
if (observer) {
if (observer->accessMode() == Observer::ReadOnlyAccess)
read_only = true;
}
if (read_only)
label_text.append(QString("<font color = 'red'>%1</color>").arg(d_current_obj->objectName()));
else
label_text.append(QString("%1").arg(d_current_obj->objectName()));
}
} else
label_text.append(tr("Current Object"));
if (label_text.length() == 0)
label_text = tr("Invalid observer name received.");
ui->lblHierarchy->setText(label_text);
}
示例2: 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());
//.........这里部分代码省略.........