almost got color indicators working in table view cells

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@659 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2007-11-04 22:11:37 +00:00
parent dfdf34d45b
commit b5babdfe4b
5 changed files with 26 additions and 8 deletions

View File

@ -824,14 +824,12 @@ void projectM::destroyPresetTools()
/// @slow might not be necessary
m_presetPos = 0;
if ( m_presetQueuePos )
delete ( m_presetQueuePos );
/// @slow might not be necessary
m_presetQueuePos = 0;
if ( m_presetChooser )
delete ( m_presetChooser );
@ -944,8 +942,12 @@ bool projectM::isPresetQueued() const {
return (*m_presetQueuePos != m_presetChooser->end());
}
unsigned int projectM::selectedPresetIndex() const {
return **m_presetPos;
}
unsigned int projectM::getPlaylistSize() const
{
return m_presetLoader->getNumPresets();
}

View File

@ -150,7 +150,10 @@ public:
/// Returns true if the active preset is locked
bool isPresetLocked() const;
/// Add a preset url to the play list. Appended to bottom
/// Returns index of currently active preset
unsigned int selectedPresetIndex() const;
/// Add a preset url to the play list. Appended to bottom
unsigned int addPresetURL(const std::string & presetURL, const std::string & presetName);
/// Returns the url associated with a preset index

View File

@ -60,6 +60,15 @@ QVariant QPlaylistModel::data ( const QModelIndex & index, int role = Qt::Displa
case QPlaylistModel::RatingRole:
return QVariant(m_ratings[index.row()]);
case Qt::BackgroundRole:
if (m_projectM.isPresetLocked() && (index.row() == m_projectM.selectedPresetIndex()))
return Qt::red;
if (!m_projectM.isPresetLocked() && (index.row() == m_projectM.selectedPresetIndex()))
return Qt::green;
return Qt::white;
case QPlaylistModel::URLInfoRole:
return QVariant(QString(m_projectM.getPresetURL(index.row()).c_str()));
default:

View File

@ -45,6 +45,7 @@ QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::D
void clear();
QVariant data ( const QModelIndex & index, int role) const;
int rowCount ( const QModelIndex & parent = QModelIndex()) const ;
int columnCount ( const QModelIndex & parent) const ;

View File

@ -92,8 +92,8 @@ void QProjectM_MainWindow::updatePlaylistSelection(bool hardCut, int index) {
if (oldPresetIndex > 0)
playlistModel->setData(playlistModel->index(oldPresetIndex, 0), Qt::white, Qt::BackgroundRole);
playlistModel->setData(playlistModel->index(index, 0), Qt::green, Qt::BackgroundRole);
oldPresetIndex = index;
//playlistModel->setData(playlistModel->index(index, 0), Qt::green, Qt::BackgroundRole);
//oldPresetIndex = index;
}
@ -138,11 +138,14 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e ) {
if (ui.presetSearchBarLineEdit->hasFocus())
return;
if (ui.lockPresetCheckBox->checkState() == Qt::Checked)
if (ui.lockPresetCheckBox->checkState() == Qt::Checked) {
ui.lockPresetCheckBox->setCheckState(Qt::Unchecked);
else
ui.lockPresetCheckBox->setCheckState(Qt::Checked);
}
else {
ui.lockPresetCheckBox->setCheckState(Qt::Checked);
}
// the projectM widget handles the actual lock
//e->ignore();
//m_QProjectMWidget->keyReleaseEvent(e);