Parent: [6ad7c7] (diff)

Download this file

playlist.h    143 lines (117 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* Copyright (C) 2011 Lucio Carreras
*
* This file is part of sayonara player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAYLIST_H_
#define PLAYLIST_H_
#include <iostream>
#include <QObject>
#include <QList>
#include <QMap>
#include <QStringList>
#include "HelperStructs/MetaData.h"
#include "HelperStructs/PlaylistMode.h"
#include "HelperStructs/globals.h"
#include "HelperStructs/CSettingsStorage.h"
class Playlist : public QObject {
Q_OBJECT
public:
Playlist(QObject * parent=0);
virtual ~Playlist() {}
virtual uint get_num_tracks() {
return m_meta.size();
}
virtual void get_metadata(MetaDataList&);
virtual Playlist_Mode mode();
virtual void update_state() {}
signals:
// New playlist (for displaying in ui_playlist)
void sig_playlist_updated(MetaDataList&, int playidx, int/*unused*/);
// Inform the ui_playlist about what row to highlight
void sig_playing_track_changed(int row);
// Current track info for displaying in the control area
void sig_track_metadata(const MetaData&);
// Make sure we have the latest state of the world
void sig_sync();
// Stopped at end of Playlist
void sig_playlist_done();
// These request action from the audio part
void sig_stop();
void sig_pause();
void sig_resume_play();
void sig_forward();
void sig_backward();
// Only connect in OHPlaylist mode
void sig_mode_changed(Playlist_Mode);
// These report a state transition of the audio part
void sig_stopped();
void sig_paused();
void sig_playing();
// Done inserting tracks in the playlist
void sig_insert_done();
void connectionLost();
// Only ever emitted by the openhome variant
void playlistModeChanged(Playlist_Mode);
public slots:
virtual void psl_insert_tracks(const MetaDataList&, int afteridx) = 0;
virtual void psl_add_tracks(const MetaDataList&);
virtual void psl_sort_by_tno();
virtual void psl_load_playlist();
virtual void psl_save_playlist();
virtual void psl_change_track(int num) final;
virtual void psl_change_track_impl(int) = 0;
virtual void psl_seek(int secs) = 0;
// Information from the remote end
virtual void onRemoteTpState(int, const char *) final;
// Maybe also tell the subclass about these
virtual void onRemoteTpState_impl(int, const char *) {}
virtual void onRemoteSecsInSong(quint32 s) final;
virtual void onRemoteSecsInSong_impl(quint32) {}
// Mode change requested by UI
virtual void psl_change_mode(const Playlist_Mode&);
virtual void psl_clear_playlist();
virtual void psl_clear_playlist_impl() = 0;
virtual void psl_play() = 0;
virtual void psl_pause() final;
virtual void psl_pause_impl() = 0;
virtual void psl_stop() = 0;
virtual void psl_forward() = 0;
virtual void psl_backward() = 0;
// Note: in openhome mode, drag-dropping a selection containing
// the currently playing track results in a track change because
// this is seen as 2 separate remove/insert operations. After the
// remove, the playing track has changed, and there is no way to
// restore it when the insert occurs. We would need additional
// input from the playlist ui which is the only code with the info
// to link the remove/insert ops. Even then, it would be
// complicated to restore the right playing track because we'd
// have to wait for the playlist update from the remote player to
// do it. Even them this would cause the sound to flicker. It
// seems that the only option is to acknowledge the issue. We now stop
// playing in this situation (when removing the currently playing track)
virtual void psl_remove_rows(const QList<int> &, bool select_next=true)
= 0;
virtual void psl_selection_min_row(int);
protected:
MetaDataList m_meta;
int m_play_idx;
int m_selection_min_row;
int m_insertion_point;
int m_tpstate;
virtual void remove_row(int row);
virtual bool valid_row(int row) {
return row >= 0 && row < int(m_meta.size());
}
};
#endif /* PLAYLIST_H_ */