Changeset - efe60c271bd1
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-12-31 10:06:16
hy@ozderya.net
fixed visibility column display
1 file changed with 15 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/channelinfomodel.cpp
Show inline comments
 
@@ -50,11 +50,11 @@ Qt::ItemFlags ChannelInfoModel::flags(co
 
{
 
    if (index.column() == COLUMN_NAME)
 
    {
 
        return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
 
        return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 
    else if (index.column() == COLUMN_VISIBILITY)
 
    {
 
        return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
 
        return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 

	
 
    return Qt::NoItemFlags;
 
@@ -62,8 +62,6 @@ Qt::ItemFlags ChannelInfoModel::flags(co
 

	
 
QVariant ChannelInfoModel::data(const QModelIndex &index, int role) const
 
{
 
    // TODO: check role parameter
 

	
 
    if (index.row() >= (int) _numOfChannels)
 
    {
 
        return QVariant();
 
@@ -78,15 +76,11 @@ QVariant ChannelInfoModel::data(const QM
 
    }
 
    else if (index.column() == COLUMN_VISIBILITY)
 
    {
 
        if (Qt::CheckStateRole)
 
        if (role == Qt::CheckStateRole)
 
        {
 
            bool visible = infos[index.row()].visibility;
 
            return visible ? Qt::Checked : Qt::Unchecked;
 
        }
 
        else if (role == Qt::DisplayRole || role == Qt::EditRole)
 
        {
 
            return QString("");
 
        }
 
    }
 

	
 
    return QVariant();
 
@@ -94,23 +88,30 @@ QVariant ChannelInfoModel::data(const QM
 

	
 
bool ChannelInfoModel::setData(const QModelIndex &index, const QVariant &value, int role)
 
{
 
    // TODO: check role
 
    if (index.row() >= (int) _numOfChannels)
 
    {
 
        return false;
 
    }
 

	
 
    if (index.row() < (int) _numOfChannels)
 
    if (index.column() == COLUMN_NAME)
 
    {
 
        if (index.column() == COLUMN_NAME)
 
        if (role == Qt::DisplayRole || role == Qt::EditRole)
 
        {
 
            infos[index.row()].name = value.toString();
 
            return true;
 
        }
 
    }
 
        else if (index.column() == COLUMN_VISIBILITY)
 
        {
 
            infos[index.row()].visibility = value.toBool();
 
        if (role == Qt::CheckStateRole)
 
        {
 
            bool checked = value.toInt() == Qt::Checked;
 
            infos[index.row()].visibility = checked;
 
            return true;
 
        }
 
    }
 

	
 
    // invalid index
 
    // invalid index/role
 
    return false;
 
}
 

	
0 comments (0 inline, 0 general)