QVariant RKObjectListModel::data (const QModelIndex& index, int role) const { RK_TRACE (OBJECTS); int col = index.column (); RObject *object = static_cast<RObject*> (index.internalPointer ()); if ((!object) || (col >= ColumnCount)) { RK_ASSERT (false); return QVariant (); } if (role == Qt::DisplayRole) { if (col == NameColumn) return object->getShortName (); if (col == LabelColumn) return object->getLabel (); if (col == TypeColumn) { if (object->isVariable ()) return RObject::typeToText (object->getDataType ()); return QVariant (); } if ((col == ClassColumn) && (!object->isPseudoObject ())) return object->makeClassString ("; "); } else if (role == Qt::FontRole) { if (col == NameColumn && object->isPseudoObject ()) { QFont font; font.setItalic (true); return (font); } } else if (role == Qt::DecorationRole) { if (col == NameColumn) return RKStandardIcons::iconForObject (object); } else if (role == Qt::ToolTipRole) { return object->getObjectDescription (); } return QVariant (); }
bool RKObjectListViewSettings::acceptRow (int source_row, const QModelIndex& source_parent) const { // RK_TRACE (APP); // always show the root item if (!source_parent.isValid ()) return true; RObject* object = static_cast<RObject*> (source_parent.internalPointer ()); // always show global env and search path if (!object) return true; if (!object->findChildByObjectModelIndex (source_row)) { return true; } object = object->findChildByObjectModelIndex (source_row); RK_ASSERT (object); if (!persistent_settings[ShowObjectsHidden]) { if (object->getShortName ().startsWith ('.')) return false; if (object == reinterpret_cast<RObject*> (RObjectList::getObjectList ()->orphanNamespacesObject ())) return false; } if (hide_functions && object->isType (RObject::Function)) return false; if (hide_non_functions && !object->isType (RObject::Function)) return false; if (filterRegExp ().isEmpty ()) return true; if (filter_on_name && object->getShortName ().contains (filterRegExp ())) return true; if (filter_on_label && object->getLabel ().contains (filterRegExp ())) return true; if (filter_on_class) { QStringList cnames = object->classNames (); for (int i = cnames.length () - 1; i >= 0; --i) { if (cnames[i].contains (filterRegExp ())) return true; } } return false; }