Renaming skip properties, strike out track when it is to be skipped

This commit is contained in:
asiviero 2014-01-27 00:26:00 -02:00
parent c817431593
commit c0132b2ed3
4 changed files with 24 additions and 24 deletions

View File

@ -342,6 +342,14 @@ QVariant Playlist::data(const QModelIndex& index, int role) const {
}
return QVariant();
case Qt::FontRole:
if (items_[index.row()]->GetShouldSkip()) {
QFont track_font;
track_font.setStrikeOut(true);
return track_font;
}
return QVariant();
default:
return QVariant();
}
@ -443,8 +451,9 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
// Advance i until we find any track that is in the filter, skipping
// the selected to be skipped
while (i < virtual_items_.count() && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetToSkip())) {
++i;
while (i < virtual_items_.count() &&
(!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip())) {
++i;
}
return i;
}
@ -452,7 +461,7 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
// We need to advance i until we get something else on the same album
Song last_song = current_item_metadata();
for (int j=i+1 ; j<virtual_items_.count(); ++j) {
if (item_at(virtual_items_[j])->GetToSkip()) {
if (item_at(virtual_items_[j])->GetShouldSkip()) {
continue;
}
Song this_song = item_at(virtual_items_[j])->Metadata();
@ -487,7 +496,7 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
--i;
// Decrement i until we find any track that is in the filter
while (i>=0 && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetToSkip()))
while (i>=0 && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip()))
--i;
return i;
}
@ -495,7 +504,7 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
// We need to decrement i until we get something else on the same album
Song last_song = current_item_metadata();
for (int j=i-1 ; j>=0; --j) {
if (item_at(virtual_items_[j])->GetToSkip()) {
if (item_at(virtual_items_[j])->GetShouldSkip()) {
continue;
}
Song this_song = item_at(virtual_items_[j])->Metadata();
@ -2028,13 +2037,6 @@ void Playlist::SetColumnAlignment(const ColumnAlignmentMap& 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()));
// gray out the song if it's now to be skipped;
// otherwise undo the gray color
if (track_to_skip->GetToSkip()) {
track_to_skip->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
} else {
track_to_skip->RemoveForegroundColor(kInvalidSongPriority);
}
track_to_skip->SetShouldSkip(!((track_to_skip)->GetShouldSkip()));
}
}

View File

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

View File

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

View File

@ -1335,7 +1335,7 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
else
in_queue ++;
if(item->GetToSkip()) {
if(item->GetShouldSkip()) {
in_skipped++;
} else {
not_in_skipped++;
@ -1390,8 +1390,6 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
else if (in_skipped == 0 && not_in_skipped > 1)
playlist_skip_->setText(tr("Skip selected tracks"));
if (not_in_queue == 0)
playlist_queue_->setIcon(IconLoader::Load("go-previous"));
else