Added skip track feature

This commit is contained in:
asiviero 2014-01-17 04:01:31 -02:00
parent 048c2d9b9c
commit 1c0a221563
5 changed files with 40 additions and 5 deletions

View File

@ -441,8 +441,9 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
if (!album_only) { if (!album_only) {
++i; ++i;
// Advance i until we find any track that is in the filter // Advance i until we find any track that is in the filter, skipping
while ((i < virtual_items_.count() && !FilterContainsVirtualIndex(i)) || queue_->SkipSourceRow(i)) { // the selected to be skipped
while ((i < virtual_items_.count() && !FilterContainsVirtualIndex(i)) || items_[virtual_items_[i]]->GetToSkip()) {
++i; ++i;
} }
return i; return i;
@ -2017,3 +2018,10 @@ bool Playlist::ApplyValidityOnCurrentSong(const QUrl& url, bool valid) {
void Playlist::SetColumnAlignment(const ColumnAlignmentMap& alignment) { void Playlist::SetColumnAlignment(const ColumnAlignmentMap& alignment) {
column_alignments_ = alignment; column_alignments_ = alignment;
} }
void Playlist::SkipTracks(const QModelIndexList &source_indexes) {
foreach (const QModelIndex& source_index, source_indexes) {
PlaylistItemPtr track_to_skip = item_at(source_index.row());
track_to_skip->SetToSkip(!((track_to_skip)->GetToSkip()));
}
}

View File

@ -84,6 +84,8 @@ class Playlist : public QAbstractListModel {
QObject* parent = 0); QObject* parent = 0);
~Playlist(); ~Playlist();
void SkipTracks(const QModelIndexList &source_indexes);
// Always add new columns to the end of this enum - the values are persisted // Always add new columns to the end of this enum - the values are persisted
enum Column { enum Column {
Column_Title = 0, Column_Title = 0,
@ -354,7 +356,6 @@ class Playlist : public QAbstractListModel {
void ItemReloadComplete(); void ItemReloadComplete();
void ItemsLoaded(); void ItemsLoaded();
void SongInsertVetoListenerDestroyed(); void SongInsertVetoListenerDestroyed();
private: private:
bool is_loading_; bool is_loading_;
PlaylistFilter* proxy_; PlaylistFilter* proxy_;

View File

@ -123,3 +123,9 @@ QColor PlaylistItem::GetCurrentForegroundColor() const {
bool PlaylistItem::HasCurrentForegroundColor() const { bool PlaylistItem::HasCurrentForegroundColor() const {
return !foreground_colors_.isEmpty(); return !foreground_colors_.isEmpty();
} }
void PlaylistItem::SetToSkip(bool val) {
to_skip_ = val;
}
bool PlaylistItem::GetToSkip() const {
return to_skip_;
}

View File

@ -33,7 +33,7 @@ class SqlRow;
class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> { class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
public: public:
PlaylistItem(const QString& type) PlaylistItem(const QString& type)
: type_(type) {} : to_skip_(false), type_(type) {}
virtual ~PlaylistItem(); virtual ~PlaylistItem();
static PlaylistItem* NewFromType(const QString& type); static PlaylistItem* NewFromType(const QString& type);
@ -91,8 +91,12 @@ class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
// invalid so you might want to check that its id is not equal to -1 // invalid so you might want to check that its id is not equal to -1
// before actually using it. // before actually using it.
virtual bool IsLocalLibraryItem() const { return false; } virtual bool IsLocalLibraryItem() const { return false; }
void SetToSkip(bool val);
bool GetToSkip() const;
protected: protected:
bool to_skip_;
enum DatabaseColumn { enum DatabaseColumn {
Column_LibraryId, Column_LibraryId,
Column_InternetService, Column_InternetService,

View File

@ -1313,6 +1313,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
int streams = 0; int streams = 0;
int in_queue = 0; int in_queue = 0;
int not_in_queue = 0; int not_in_queue = 0;
int in_skipped = 0;
int not_in_skipped = 0;
foreach (const QModelIndex& index, selection) { foreach (const QModelIndex& index, selection) {
if (index.column() != 0) if (index.column() != 0)
continue; continue;
@ -1332,6 +1334,12 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
not_in_queue ++; not_in_queue ++;
else else
in_queue ++; in_queue ++;
if(item->GetToSkip()) {
in_skipped++;
} else {
not_in_skipped++;
}
} }
int all = not_in_queue + in_queue; int all = not_in_queue + in_queue;
@ -1366,10 +1374,18 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
playlist_queue_->setText(tr("Dequeue track")); playlist_queue_->setText(tr("Dequeue track"));
else if (in_queue > 1 && not_in_queue == 0) else if (in_queue > 1 && not_in_queue == 0)
playlist_queue_->setText(tr("Dequeue selected tracks")); playlist_queue_->setText(tr("Dequeue selected tracks"));
else if (in_skipped == 1 && not_in_skipped == 0)
playlist_skip_->setText(tr("Unskip track"));
else if (in_skipped > 1 && not_in_skipped == 0)
playlist_skip_->setText(tr("Unskip selected tracks"));
else if (in_queue == 0 && not_in_queue == 1) else if (in_queue == 0 && not_in_queue == 1)
playlist_queue_->setText(tr("Queue track")); playlist_queue_->setText(tr("Queue track"));
else if (in_queue == 0 && not_in_queue > 1) else if (in_queue == 0 && not_in_queue > 1)
playlist_queue_->setText(tr("Queue selected tracks")); playlist_queue_->setText(tr("Queue selected tracks"));
else if (in_skipped == 0 && not_in_skipped == 1)
playlist_skip_->setText(tr("Skip track"));
else if (in_skipped == 0 && not_in_skipped > 1)
playlist_skip_->setText(tr("Skip selected tracks"));
else else
playlist_queue_->setText(tr("Toggle queue status")); playlist_queue_->setText(tr("Toggle queue status"));
@ -1967,7 +1983,7 @@ void MainWindow::PlaylistSkip() {
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
} }
app_->playlist_manager()->current()->queue()->SkipTracks(indexes); app_->playlist_manager()->current()->SkipTracks(indexes);
} }
void MainWindow::PlaylistCopyToDevice() { void MainWindow::PlaylistCopyToDevice() {