Add moodbar

This commit is contained in:
Jonas Kvinge
2019-04-18 15:03:01 +02:00
parent 37b923bea3
commit 907d18a83a
49 changed files with 3347 additions and 5 deletions

View File

@@ -365,6 +365,12 @@ QVariant Playlist::data(const QModelIndex &index, int role) const {
}
#ifdef HAVE_MOODBAR
void Playlist::MoodbarUpdated(const QModelIndex& index) {
emit dataChanged(index.sibling(index.row(), Column_Mood), index.sibling(index.row(), Column_Mood));
}
#endif
bool Playlist::setData(const QModelIndex &index, const QVariant &value, int role) {
int row = index.row();
@@ -1183,6 +1189,7 @@ QString Playlist::column_name(Column column) {
case Column_Comment: return tr("Comment");
case Column_Source: return tr("Source");
case Column_Mood: return tr("Mood");
default: qLog(Error) << "No such column" << column;;
}
return "";

View File

@@ -124,6 +124,7 @@ class Playlist : public QAbstractListModel {
Column_Comment,
Column_Grouping,
Column_Source,
Column_Mood,
ColumnCount
};
@@ -251,6 +252,11 @@ class Playlist : public QAbstractListModel {
// Unregisters a SongInsertVetoListener object.
void RemoveSongInsertVetoListener(SongInsertVetoListener *listener);
// Just emits the dataChanged() signal so the mood column is repainted.
#ifdef HAVE_MOODBAR
void MoodbarUpdated(const QModelIndex& index);
#endif
// QAbstractListModel
int rowCount(const QModelIndex& = QModelIndex()) const { return items_.count(); }
int columnCount(const QModelIndex& = QModelIndex()) const { return ColumnCount; }

View File

@@ -104,6 +104,12 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent *e) {
void PlaylistHeader::AddColumnAction(int index) {
#ifndef HAVE_MOODBAR
if (index == Playlist::Column_Mood) {
return;
}
#endif
QString title(model()->headerData(index, Qt::Horizontal).toString());
QAction *action = menu_->addAction(title, show_mapper_, SLOT(map()));

View File

@@ -77,6 +77,10 @@
#include "settings/appearancesettingspage.h"
#include "settings/playlistsettingspage.h"
#ifdef HAVE_MOODBAR
# include "moodbar/moodbaritemdelegate.h"
#endif
using std::sort;
const int PlaylistView::kGlowIntensitySteps = 24;
@@ -244,6 +248,10 @@ void PlaylistView::SetItemDelegates(CollectionBackend *backend) {
setItemDelegateForColumn(Playlist::Column_Source, new SongSourceDelegate(this));
#ifdef HAVE_MOODBAR
setItemDelegateForColumn(Playlist::Column_Mood, new MoodbarItemDelegate(app_, this, this));
#endif
}
void PlaylistView::SetPlaylist(Playlist *playlist) {
@@ -310,6 +318,7 @@ void PlaylistView::LoadGeometry() {
header_->HideSection(Playlist::Column_LastPlayed);
header_->HideSection(Playlist::Column_Comment);
header_->HideSection(Playlist::Column_Grouping);
header_->HideSection(Playlist::Column_Mood);
header_->moveSection(header_->visualIndex(Playlist::Column_Track), 0);
setting_initial_header_layout_ = true;