本文整理汇总了C++中WModelIndex::internalId方法的典型用法代码示例。如果您正苦于以下问题:C++ WModelIndex::internalId方法的具体用法?C++ WModelIndex::internalId怎么用?C++ WModelIndex::internalId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WModelIndex
的用法示例。
在下文中一共展示了WModelIndex::internalId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parent
virtual WModelIndex parent(const WModelIndex& index) const {
if (!index.isValid() || index.internalId() == 0) {
return WModelIndex(); // treeData_[0] is the tree root
} else {
const Tree& item = treeData_[index.internalId()];
return createIndex(item.index(), 0, item.parentId());
}
}
示例2: parent
WModelIndex GitModel::parent(const WModelIndex& index) const
{
// treeData_[0] indicates the top-level parent.
if (!index.isValid() || index.internalId() == 0)
return WModelIndex();
else {
// get the item that corresponds to the parent ...
const Tree& item = treeData_[index.internalId()];
// ... and construct that identifies the parent:
// row = child index in the grand parent
// internalId = id of the grand parent
return createIndex(item.index(), 0, item.parentId());
}
}
示例3: rowCount
int GitModel::rowCount(const WModelIndex& index) const
{
// we are looking for the git SHA1 id of a tree object (since only folders
// may contain children).
Git::ObjectId objectId;
int treeId;
if (index.isValid()) {
// only column 0 items may contain children
if (index.column() != 0)
return 0;
Git::Object o = getObject(index);
if (o.type == Git::Tree) {
objectId = o.id;
treeId = getTreeId(index.internalId(), index.row());
} else
// not a folder: no children
return 0;
} else {
treeId = 0;
// the index corresponds to the root object
if (treeData_.empty())
// model not yet loaded !
return 0;
else
objectId = treeData_[0].treeObject();
}
return treeData_[treeId].rowCount();
}
示例4: index
virtual WModelIndex index(int row, int column,
const WModelIndex& parent = WModelIndex()) const {
int parentId;
if (!parent.isValid())
parentId = 0;
else {
int grandParentId = parent.internalId();
parentId = getTreeId(grandParentId, parent.row());
}
return createIndex(row, column, parentId);
}
示例5: rowCount
virtual int rowCount(const WModelIndex& parent = WModelIndex()) const {
int treeId;
if (parent.isValid()) {
if (parent.column() != 0)
return 0;
Git::Object o = getObject(parent);
if (o.type == Git::Tree) { // is a folder
treeId = getTreeId(parent.internalId(), parent.row());
} else // is a file
return 0;
} else {
treeId = 0;
}
return treeData_[treeId].rowCount();
}
示例6: index
WModelIndex GitModel::index(int row, int column,
const WModelIndex& parent) const
{
int parentId;
// the top-level parent has id=0.
if (!parent.isValid())
parentId = 0;
else {
// the internal id of the parent identifies the grand parent
int grandParentId = parent.internalId();
// lookup the parent id for the parent himself, based on grand parent
// and child-index (=row) within the grand parent
parentId = getTreeId(grandParentId, parent.row());
}
return createIndex(row, column, parentId);
}
示例7: getObject
/*
* Gets the Git::Object that corresponds to an index.
*/
Git::Object getObject(const WModelIndex& index) const {
int parentId = index.internalId();
const Tree& parentItem = treeData_[parentId];
return git_.treeGetObject(parentItem.treeObject(), index.row());
}