Exemple #1
0
QVariant LocalBranchModel::data(const QModelIndex &index, int role) const
{
    if (isNewBranchRow(index)) {
        switch (role) {
        case Qt::DisplayRole:
            return m_typeHere;
        case Qt::ToolTipRole:
            return m_typeHereToolTip;
        case Qt::CheckStateRole:
            return QVariant(false);
        }
        return QVariant();
    }

    if (role == Qt::CheckStateRole)
        return index.row() == m_currentBranch ? Qt::Checked : Qt::Unchecked;
    return RemoteBranchModel::data(index, role);
}
QVariant LocalBranchModel::data(const QModelIndex &index, int role) const
{
    if (isNewBranchRow(index)) {
        switch (role) {
        case Qt::DisplayRole:
            return m_typeHere;
        case Qt::ToolTipRole:
            return m_typeHereToolTip;
        }
        return QVariant();
    }

    if (role == Qt::FontRole && index.row() == m_currentBranch) {
        QFont font = RemoteBranchModel::data(index, role).value<QFont>();
        font.setBold(true);
        font.setUnderline(true);
        return font;
    }
    return RemoteBranchModel::data(index, role);
}
Exemple #3
0
Qt::ItemFlags LocalBranchModel::flags(const QModelIndex & index) const
{
    if (isNewBranchRow(index))
        return Qt::ItemIsEditable|Qt::ItemIsSelectable|Qt::ItemIsEnabled| Qt::ItemIsUserCheckable;
    return RemoteBranchModel::flags(index) | Qt::ItemIsUserCheckable;
}