Qt
::ItemFlags WTrackTableModel
::flags(const QModelIndex &index
) const{
if (!index.isValid())
return Qt::ItemIsEnabled;
switch(index.column())
{
}
return Qt::ItemIsEnabled;
}
Qt::ItemFlags WTrackTableModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
switch(index.column())
{
case 7: return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
return Qt::ItemIsEnabled;
}
To copy to clipboard, switch view to plain text mode
void WTrackTableView
::setup(QDomNode node
) {
// Position
if (!WWidget::selectNode(node, "Pos").isNull())
{
QString pos
= WWidget
::selectNodeQString(node,
"Pos");
int x = pos.left(pos.find(",")).toInt();
int y = pos.mid(pos.find(",")+1).toInt();
move(x,y);
}
// Size
if (!WWidget::selectNode(node, "Size").isNull())
{
QString size
= WWidget
::selectNodeQString(node,
"Size");
int x = size.left(size.find(",")).toInt();
int y = size.mid(size.find(",")+1).toInt();
setFixedSize(x,y);
}
// Foreground color
if (!WWidget::selectNode(node, "FgColor").isNull())
{
fgc.setNamedColor(WWidget::selectNodeQString(node, "FgColor"));
}
m_pTable->setForegroundColor(fgc);
// Row colors
if (!WWidget::selectNode(node, "BgColorRowEven").isNull())
{
r1.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowEven"));
r2.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowUneven"));
setAlternatingRowColors ( true );
m_pTable->setRowColor(r1, r2);
Rowpalette.
setColor(QPalette::Base, r1
);
Rowpalette.
setColor(QPalette::AlternateBase, r2
);
setPalette(Rowpalette);
}
/*
// BPM confidence colors
if (!WWidget::selectNode(node, "BgColorBpmNoConfirm").isNull())
{
QColor c1;
c1.setNamedColor(WWidget::selectNodeQString(node, "BgColorBpmNoConfirm"));
QColor c2;
c2.setNamedColor(WWidget::selectNodeQString(node, "BgColorBpmConfirm"));
}
*/
}
void WTrackTableView::setup(QDomNode node)
{
// Position
if (!WWidget::selectNode(node, "Pos").isNull())
{
QString pos = WWidget::selectNodeQString(node, "Pos");
int x = pos.left(pos.find(",")).toInt();
int y = pos.mid(pos.find(",")+1).toInt();
move(x,y);
}
// Size
if (!WWidget::selectNode(node, "Size").isNull())
{
QString size = WWidget::selectNodeQString(node, "Size");
int x = size.left(size.find(",")).toInt();
int y = size.mid(size.find(",")+1).toInt();
setFixedSize(x,y);
}
// Foreground color
QColor fgc(0,0,0);
if (!WWidget::selectNode(node, "FgColor").isNull())
{
fgc.setNamedColor(WWidget::selectNodeQString(node, "FgColor"));
}
m_pTable->setForegroundColor(fgc);
// Row colors
if (!WWidget::selectNode(node, "BgColorRowEven").isNull())
{
QColor r1;
r1.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowEven"));
QColor r2;
r2.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowUneven"));
setAlternatingRowColors ( true );
m_pTable->setRowColor(r1, r2);
QPalette Rowpalette = palette();
Rowpalette.setColor(QPalette::Base, r1);
Rowpalette.setColor(QPalette::AlternateBase, r2);
setPalette(Rowpalette);
}
/*
// BPM confidence colors
if (!WWidget::selectNode(node, "BgColorBpmNoConfirm").isNull())
{
QColor c1;
c1.setNamedColor(WWidget::selectNodeQString(node, "BgColorBpmNoConfirm"));
QColor c2;
c2.setNamedColor(WWidget::selectNodeQString(node, "BgColorBpmConfirm"));
}
*/
}
To copy to clipboard, switch view to plain text mode
in the QTableView on lines 28-41. Now what I would like to do is use the colors found in the BPM if statement on items in one single column. Say I have a function [bool bpmConfirm()] that returns true if the BPM is confirmed, I would then like to use r2, and r1 is the BPM is not confirmed. How would I go about doing this?
{
TrackInfoObject *m_pTrackInfo = m_pTrackPlaylist->getTrackAt(index.row());
if (!index.isValid())
if (index.row() >= m_pTrackPlaylist->getSongNum())
if (role == Qt::ForegroundRole )
{
return foregroundColor;
}
else if (role == Qt::DisplayRole )
{
switch(index.column())
{
case 0: return m_pTrackInfo->getScoreStr();
case 1: return m_pTrackInfo->getTitle();
case 2: return m_pTrackInfo->getArtist();
case 3: return m_pTrackInfo->getType();
case 4: return m_pTrackInfo->getDurationStr();
case 5: return m_pTrackInfo->getBitrateStr();
case 6: return m_pTrackInfo->getBpmStr();
case 7: return m_pTrackInfo->getComment();
}
}
else
}
QVariant WTrackTableModel :: data(const QModelIndex &index, int role) const
{
TrackInfoObject *m_pTrackInfo = m_pTrackPlaylist->getTrackAt(index.row());
if (!index.isValid())
return QVariant();
if (index.row() >= m_pTrackPlaylist->getSongNum())
return QVariant();
if (role == Qt::ForegroundRole )
{
return foregroundColor;
}
else if (role == Qt::DisplayRole )
{
switch(index.column())
{
case 0: return m_pTrackInfo->getScoreStr();
case 1: return m_pTrackInfo->getTitle();
case 2: return m_pTrackInfo->getArtist();
case 3: return m_pTrackInfo->getType();
case 4: return m_pTrackInfo->getDurationStr();
case 5: return m_pTrackInfo->getBitrateStr();
case 6: return m_pTrackInfo->getBpmStr();
case 7: return m_pTrackInfo->getComment();
}
}
else
return QVariant();
}
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks