1
/***************************************************************************
2
* Copyright (C) 2005 - 2007 by *
3
* Christian Muehlhaeuser, Last.fm Ltd <chris@last.fm> *
4
* Max Howell, Last.fm Ltd <max@last.fm> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
20
***************************************************************************/
23
#ifndef SIDE_BAR_MODEL_H
24
#define SIDE_BAR_MODEL_H
26
#include <QAbstractItemModel>
27
#include <QStringList>
32
#include "RadioEnums.h"
33
#include "WeightedStringList.h"
76
StationUrlRole = Qt::UserRole,
92
class SideBarModel : public QAbstractItemModel
99
void addRecentlyPlayedTrack( Track );
101
/** Reimplimentations */
102
QVariant data(const QModelIndex &index, int role) const;
103
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
104
QModelIndex parent(const QModelIndex &index) const;
105
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
106
Qt::ItemFlags flags( const QModelIndex& ) const;
107
QMimeData *mimeData( const QModelIndexList& indexes ) const;
108
QStringList mimeTypes() const;
110
/** no header, one column always */
111
QVariant headerData( int, Qt::Orientation, int ) const { return QVariant(); }
112
int columnCount( const QModelIndex& ) const { return 1; }
114
void sortTags( WeightedStringList tagsToSort, SideBar::SortOrder sortOrder );
115
void sortTags( SideBar::SortOrder sortOrder );
116
void sortNeighbours( QStringList neighboursToSort, SideBar::SortOrder );
117
void sortNeighbours( SideBar::SortOrder sortOrder );
120
void onResult( Request* );
121
void onAvatarDownloaded( QByteArray );
122
void onAppEvent( int, const QVariant& );
123
void updateHistory();
126
QStringList m_friends;
127
QStringList m_neighbours;
128
QStringList m_neighboursBySimilarity;
130
QList<Track> m_banned;
131
QList<Track> m_loved;
132
QList<Track> m_played;
133
WeightedStringList m_tags;
134
QList<Station> m_history;
136
void queueAvatarsDownload( const QMap<QString, QString>& urls );
137
void downloadAvatar( const QString& user, const QUrl& url );
138
void emitRowChanged( int parent_row, int child_row = -1 );
140
template <class T> void changeData( int row, T& old_data, const T& new_data );
144
bool m_track_is_playing;
146
QString m_change_station_text;
147
QMap<QString, QString> m_avatarQueue;
148
QHash<QString, QIcon> m_avatars;
155
SideBarItem( const QModelIndex& );
166
SideBar::Type type() const { return m_type; }
167
Classification classification() const { return m_classification; }
169
::Track track() const;
170
::Station station() const;
173
Classification m_classification;
174
SideBar::Type m_type;