Changeset - 3455b67378d9
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 9 years ago 2017-01-01 05:05:51
hy@ozderya.net
added color column
1 file changed with 16 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/channelinfomodel.cpp
Show inline comments
 
@@ -23,12 +23,13 @@
 
#include <QtDebug>
 

	
 
enum ChannelInfoColumn
 
{
 
    COLUMN_NAME = 0,
 
    COLUMN_VISIBILITY,
 
    COLUMN_COLOR,
 
    COLUMN_COUNT
 
};
 

	
 
const QColor colors[8] =
 
{
 
    QColor(237,97,68),
 
@@ -65,12 +66,16 @@ Qt::ItemFlags ChannelInfoModel::flags(co
 
        return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 
    else if (index.column() == COLUMN_VISIBILITY)
 
    {
 
        return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 
    else if (index.column() == COLUMN_COLOR)
 
    {
 
        return Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 

	
 
    return Qt::NoItemFlags;
 
}
 

	
 
QVariant ChannelInfoModel::data(const QModelIndex &index, int role) const
 
{
 
@@ -96,12 +101,19 @@ QVariant ChannelInfoModel::data(const QM
 
        if (role == Qt::CheckStateRole)
 
        {
 
            bool visible = infos[index.row()].visibility;
 
            return visible ? Qt::Checked : Qt::Unchecked;
 
        }
 
    }
 
    else if (index.column() == COLUMN_COLOR)
 
    {
 
        if (role == Qt::ForegroundRole || role == Qt::BackgroundRole)
 
        {
 
            return colors[index.row() % 8];
 
        }
 
    }
 

	
 
    return QVariant();
 
}
 

	
 
QVariant ChannelInfoModel::headerData(int section, Qt::Orientation orientation, int role) const
 
{
 
@@ -114,12 +126,16 @@ QVariant ChannelInfoModel::headerData(in
 
                return tr("Channel");
 
            }
 
            else if (section == COLUMN_VISIBILITY)
 
            {
 
                return tr("Visible");
 
            }
 
            else if (section == COLUMN_COLOR)
 
            {
 
                return tr("Color");
 
            }
 
        }
 
    }
 
    else                        // vertical
 
    {
 
        if (section < (int) _numOfChannels && role == Qt::DisplayRole)
 
        {
0 comments (0 inline, 0 general)