コード例 #1
0
Qt::ItemFlags QmlConsoleItemModel::flags(const QModelIndex &index) const
{
    if (!index.isValid())
        return 0;

    ConsoleItem *item = getItem(index);
    if (m_hasEditableRow && item->parent() == m_rootItem
            && index.row() == m_rootItem->childCount() - 1)
        return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
    return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
コード例 #2
0
QModelIndex QmlConsoleItemModel::parent(const QModelIndex &index) const
{
    if (!index.isValid())
        return QModelIndex();

    ConsoleItem *childItem = getItem(index);
    ConsoleItem *parentItem = childItem->parent();

    if (parentItem == m_rootItem)
        return QModelIndex();

    if (!parentItem)
        return QModelIndex();
    return createIndex(parentItem->childNumber(), 0, parentItem);
}