Revert the multiple playlist commits until they can be cleaned up a bit. These are: r324, r326, r327, r328, r335, r336, r337, r338, and r339.
This commit is contained in:
parent
5294ea1276
commit
aee1cbb4fd
|
@ -53,7 +53,6 @@ set(CLEMENTINE-SOURCES
|
||||||
albumcovermanager.cpp
|
albumcovermanager.cpp
|
||||||
albumcoverloader.cpp
|
albumcoverloader.cpp
|
||||||
m3uparser.cpp
|
m3uparser.cpp
|
||||||
playlistmanager.cpp
|
|
||||||
playlistsequence.cpp
|
playlistsequence.cpp
|
||||||
xspfparser.cpp
|
xspfparser.cpp
|
||||||
)
|
)
|
||||||
|
@ -103,7 +102,6 @@ set(CLEMENTINE-MOC-HEADERS
|
||||||
albumcovermanager.h
|
albumcovermanager.h
|
||||||
albumcoverloader.h
|
albumcoverloader.h
|
||||||
m3uparser.h
|
m3uparser.h
|
||||||
playlistmanager.h
|
|
||||||
playlistsequence.h
|
playlistsequence.h
|
||||||
xspfparser.h
|
xspfparser.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playlistview.h"
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "libraryconfig.h"
|
#include "libraryconfig.h"
|
||||||
|
@ -21,7 +20,6 @@
|
||||||
#include "stylesheetloader.h"
|
#include "stylesheetloader.h"
|
||||||
#include "albumcovermanager.h"
|
#include "albumcovermanager.h"
|
||||||
#include "m3uparser.h"
|
#include "m3uparser.h"
|
||||||
#include "playlistmanager.h"
|
|
||||||
#include "playlistsequence.h"
|
#include "playlistsequence.h"
|
||||||
|
|
||||||
#include "qxtglobalshortcut.h"
|
#include "qxtglobalshortcut.h"
|
||||||
|
@ -40,7 +38,6 @@
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
const int MainWindow::kStateVersion = 1;
|
const int MainWindow::kStateVersion = 1;
|
||||||
const char* MainWindow::kSettingsGroup = "MainWindow";
|
const char* MainWindow::kSettingsGroup = "MainWindow";
|
||||||
const char* MainWindow::kMediaFilterSpec =
|
const char* MainWindow::kMediaFilterSpec =
|
||||||
|
@ -57,9 +54,8 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
library_config_dialog_(new LibraryConfigDialog(this)),
|
library_config_dialog_(new LibraryConfigDialog(this)),
|
||||||
about_dialog_(new About(this)),
|
about_dialog_(new About(this)),
|
||||||
radio_model_(new RadioModel(this)),
|
radio_model_(new RadioModel(this)),
|
||||||
current_playlist_(NULL),
|
playlist_(new Playlist(this)),
|
||||||
current_playlist_view_(NULL),
|
player_(new Player(playlist_, radio_model_->GetLastFMService(), this)),
|
||||||
player_(new Player(current_playlist_, radio_model_->GetLastFMService(), this)),
|
|
||||||
library_(new Library(player_->GetEngine(), this)),
|
library_(new Library(player_->GetEngine(), this)),
|
||||||
settings_dialog_(new SettingsDialog(this)),
|
settings_dialog_(new SettingsDialog(this)),
|
||||||
add_stream_dialog_(new AddStreamDialog(this)),
|
add_stream_dialog_(new AddStreamDialog(this)),
|
||||||
|
@ -67,9 +63,7 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
cover_manager_(new AlbumCoverManager(network, this)),
|
cover_manager_(new AlbumCoverManager(network, this)),
|
||||||
playlist_menu_(new QMenu(this)),
|
playlist_menu_(new QMenu(this)),
|
||||||
library_sort_model_(new QSortFilterProxyModel(this)),
|
library_sort_model_(new QSortFilterProxyModel(this)),
|
||||||
track_position_timer_(new QTimer(this)),
|
track_position_timer_(new QTimer(this))
|
||||||
next_playlist_number_(1),
|
|
||||||
playlistManager_( new PlaylistManager(this) )
|
|
||||||
{
|
{
|
||||||
ui_.setupUi(this);
|
ui_.setupUi(this);
|
||||||
tray_icon_->setIcon(windowIcon());
|
tray_icon_->setIcon(windowIcon());
|
||||||
|
@ -90,6 +84,12 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
library_sort_model_->setDynamicSortFilter(true);
|
library_sort_model_->setDynamicSortFilter(true);
|
||||||
library_sort_model_->sort(0);
|
library_sort_model_->sort(0);
|
||||||
|
|
||||||
|
playlist_->Restore();
|
||||||
|
|
||||||
|
playlist_->IgnoreSorting(true);
|
||||||
|
ui_.playlist->setModel(playlist_);
|
||||||
|
playlist_->IgnoreSorting(false);
|
||||||
|
|
||||||
ui_.library_view->setModel(library_sort_model_);
|
ui_.library_view->setModel(library_sort_model_);
|
||||||
ui_.library_view->SetLibrary(library_);
|
ui_.library_view->SetLibrary(library_);
|
||||||
library_config_dialog_->SetModel(library_->GetDirectoryModel());
|
library_config_dialog_->SetModel(library_->GetDirectoryModel());
|
||||||
|
@ -111,15 +111,14 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
connect(ui_.library_filter, SIGNAL(textChanged(QString)), library_, SLOT(SetFilterText(QString)));
|
connect(ui_.library_filter, SIGNAL(textChanged(QString)), library_, SLOT(SetFilterText(QString)));
|
||||||
connect(ui_.action_ban, SIGNAL(triggered()), radio_model_->GetLastFMService(), SLOT(Ban()));
|
connect(ui_.action_ban, SIGNAL(triggered()), radio_model_->GetLastFMService(), SLOT(Ban()));
|
||||||
connect(ui_.action_love, SIGNAL(triggered()), SLOT(Love()));
|
connect(ui_.action_love, SIGNAL(triggered()), SLOT(Love()));
|
||||||
|
connect(ui_.action_clear_playlist, SIGNAL(triggered()), playlist_, SLOT(Clear()));
|
||||||
connect(ui_.action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
|
connect(ui_.action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
|
||||||
connect(ui_.action_configure, SIGNAL(triggered()), settings_dialog_, SLOT(show()));
|
connect(ui_.action_configure, SIGNAL(triggered()), settings_dialog_, SLOT(show()));
|
||||||
connect(ui_.action_about, SIGNAL(triggered()), about_dialog_, SLOT(show()));
|
connect(ui_.action_about, SIGNAL(triggered()), about_dialog_, SLOT(show()));
|
||||||
|
connect(ui_.action_shuffle, SIGNAL(triggered()), playlist_, SLOT(Shuffle()));
|
||||||
connect(ui_.action_open_media, SIGNAL(triggered()), SLOT(AddMedia()));
|
connect(ui_.action_open_media, SIGNAL(triggered()), SLOT(AddMedia()));
|
||||||
connect(ui_.action_add_media, SIGNAL(triggered()), SLOT(AddMedia()));
|
connect(ui_.action_add_media, SIGNAL(triggered()), SLOT(AddMedia()));
|
||||||
connect(ui_.action_add_stream, SIGNAL(triggered()), SLOT(AddStream()));
|
connect(ui_.action_add_stream, SIGNAL(triggered()), SLOT(AddStream()));
|
||||||
connect(ui_.action_new_playlist, SIGNAL(triggered()), SLOT(NewPlaylist()));
|
|
||||||
connect(ui_.action_hide_tray_icon, SIGNAL(triggered()), SLOT(HideShowTrayIcon()));
|
connect(ui_.action_hide_tray_icon, SIGNAL(triggered()), SLOT(HideShowTrayIcon()));
|
||||||
connect(ui_.action_global_shortcuts, SIGNAL(triggered()), shortcuts_dialog_, SLOT(show()));
|
connect(ui_.action_global_shortcuts, SIGNAL(triggered()), shortcuts_dialog_, SLOT(show()));
|
||||||
connect(ui_.action_cover_manager, SIGNAL(triggered()), cover_manager_, SLOT(show()));
|
connect(ui_.action_cover_manager, SIGNAL(triggered()), cover_manager_, SLOT(show()));
|
||||||
|
@ -148,18 +147,25 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
connect(player_, SIGNAL(Playing()), SLOT(MediaPlaying()));
|
connect(player_, SIGNAL(Playing()), SLOT(MediaPlaying()));
|
||||||
connect(player_, SIGNAL(Stopped()), SLOT(MediaStopped()));
|
connect(player_, SIGNAL(Stopped()), SLOT(MediaStopped()));
|
||||||
|
|
||||||
|
connect(player_, SIGNAL(Paused()), playlist_, SLOT(Paused()));
|
||||||
|
connect(player_, SIGNAL(Playing()), playlist_, SLOT(Playing()));
|
||||||
|
connect(player_, SIGNAL(Stopped()), playlist_, SLOT(Stopped()));
|
||||||
|
|
||||||
|
connect(player_, SIGNAL(Paused()), ui_.playlist, SLOT(StopGlowing()));
|
||||||
|
connect(player_, SIGNAL(Playing()), ui_.playlist, SLOT(StartGlowing()));
|
||||||
|
connect(player_, SIGNAL(Stopped()), ui_.playlist, SLOT(StopGlowing()));
|
||||||
|
|
||||||
connect(player_, SIGNAL(Paused()), osd_, SLOT(Paused()));
|
connect(player_, SIGNAL(Paused()), osd_, SLOT(Paused()));
|
||||||
connect(player_, SIGNAL(Stopped()), osd_, SLOT(Stopped()));
|
connect(player_, SIGNAL(Stopped()), osd_, SLOT(Stopped()));
|
||||||
connect(player_, SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int)));
|
connect(player_, SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int)));
|
||||||
|
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song)));
|
||||||
// PlaylistManager connections
|
|
||||||
connect (playlistManager_, SIGNAL(CurrentPlaylistChanged(Playlist*)), this, SLOT(CurrentPlaylistChanged(Playlist*)));
|
connect(ui_.playlist, SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
||||||
|
connect(ui_.playlist, SIGNAL(PlayPauseItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
||||||
|
connect(ui_.playlist, SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
||||||
|
|
||||||
connect(track_slider_, SIGNAL(ValueChanged(int)), player_, SLOT(Seek(int)));
|
connect(track_slider_, SIGNAL(ValueChanged(int)), player_, SLOT(Seek(int)));
|
||||||
|
|
||||||
// Tab connections
|
|
||||||
connect (ui_.tab_widget, SIGNAL(currentChanged(int)), SLOT(CurrentTabChanged(int)));
|
|
||||||
|
|
||||||
// Library connections
|
// Library connections
|
||||||
connect(library_, SIGNAL(Error(QString)), SLOT(ReportError(QString)));
|
connect(library_, SIGNAL(Error(QString)), SLOT(ReportError(QString)));
|
||||||
connect(ui_.library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryDoubleClick(QModelIndex)));
|
connect(ui_.library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryDoubleClick(QModelIndex)));
|
||||||
|
@ -219,7 +225,7 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
connect(radio_model_, SIGNAL(StreamError(QString)), SLOT(ReportError(QString)));
|
connect(radio_model_, SIGNAL(StreamError(QString)), SLOT(ReportError(QString)));
|
||||||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(NextItem()));
|
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(NextItem()));
|
||||||
connect(radio_model_, SIGNAL(StreamReady(QUrl,QUrl)), player_, SLOT(StreamReady(QUrl,QUrl)));
|
connect(radio_model_, SIGNAL(StreamReady(QUrl,QUrl)), player_, SLOT(StreamReady(QUrl,QUrl)));
|
||||||
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), current_playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
||||||
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
|
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
|
||||||
connect(radio_model_->GetLastFMService(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool)));
|
connect(radio_model_->GetLastFMService(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool)));
|
||||||
connect(ui_.radio_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(RadioDoubleClick(QModelIndex)));
|
connect(ui_.radio_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(RadioDoubleClick(QModelIndex)));
|
||||||
|
@ -305,17 +311,10 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
library_->StartThreads();
|
library_->StartThreads();
|
||||||
|
|
||||||
playlistManager_->SetTabWidget(ui_.tab_widget);
|
|
||||||
|
|
||||||
QTimer::singleShot(500,this,SLOT(InitPlaylists())) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
SaveGeometry();
|
SaveGeometry();
|
||||||
playlistManager_->Save() ;
|
|
||||||
|
|
||||||
delete player_ ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::HideShowTrayIcon() {
|
void MainWindow::HideShowTrayIcon() {
|
||||||
|
@ -332,7 +331,7 @@ void MainWindow::HideShowTrayIcon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::QueueFiles(const QList<QUrl>& urls) {
|
void MainWindow::QueueFiles(const QList<QUrl>& urls) {
|
||||||
QModelIndex playlist_index = current_playlist_->InsertPaths(urls);
|
QModelIndex playlist_index = playlist_->InsertPaths(urls);
|
||||||
|
|
||||||
if (playlist_index.isValid() && player_->GetState() != Engine::Playing)
|
if (playlist_index.isValid() && player_->GetState() != Engine::Playing)
|
||||||
player_->PlayAt(playlist_index.row());
|
player_->PlayAt(playlist_index.row());
|
||||||
|
@ -417,7 +416,7 @@ void MainWindow::PlayIndex(const QModelIndex& index) {
|
||||||
|
|
||||||
void MainWindow::LibraryDoubleClick(const QModelIndex& index) {
|
void MainWindow::LibraryDoubleClick(const QModelIndex& index) {
|
||||||
QModelIndex first_song =
|
QModelIndex first_song =
|
||||||
current_playlist_->InsertSongs(library_->GetChildSongs(
|
playlist_->InsertSongs(library_->GetChildSongs(
|
||||||
library_sort_model_->mapToSource(index)));
|
library_sort_model_->mapToSource(index)));
|
||||||
|
|
||||||
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
||||||
|
@ -445,7 +444,7 @@ void MainWindow::TrayClicked(QSystemTrayIcon::ActivationReason reason) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::StopAfterCurrent() {
|
void MainWindow::StopAfterCurrent() {
|
||||||
current_playlist_->StopAfter(current_playlist_->current_index());
|
playlist_->StopAfter(playlist_->current_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -498,10 +497,10 @@ void MainWindow::UpdateTrackPosition() {
|
||||||
// Time to scrobble?
|
// Time to scrobble?
|
||||||
LastFMService* lastfm = radio_model_->GetLastFMService();
|
LastFMService* lastfm = radio_model_->GetLastFMService();
|
||||||
|
|
||||||
if (!current_playlist_->has_scrobbled() &&
|
if (!playlist_->has_scrobbled() &&
|
||||||
position >= current_playlist_->scrobble_point()) {
|
position >= playlist_->scrobble_point()) {
|
||||||
lastfm->Scrobble();
|
lastfm->Scrobble();
|
||||||
current_playlist_->set_scrobbled(true);
|
playlist_->set_scrobbled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the slider
|
// Update the slider
|
||||||
|
@ -523,7 +522,7 @@ void MainWindow::RadioDoubleClick(const QModelIndex& index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::InsertRadioItem(RadioItem* item) {
|
void MainWindow::InsertRadioItem(RadioItem* item) {
|
||||||
QModelIndex first_song = current_playlist_->InsertRadioStations(
|
QModelIndex first_song = playlist_->InsertRadioStations(
|
||||||
QList<RadioItem*>() << item);
|
QList<RadioItem*>() << item);
|
||||||
|
|
||||||
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
||||||
|
@ -533,9 +532,7 @@ void MainWindow::InsertRadioItem(RadioItem* item) {
|
||||||
void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index) {
|
void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index) {
|
||||||
playlist_menu_index_ = index;
|
playlist_menu_index_ = index;
|
||||||
|
|
||||||
if ( current_playlist_ == NULL )
|
if (playlist_->current_index() == index.row() && player_->GetState() == Engine::Playing) {
|
||||||
return ; // we don't have any playlist created.
|
|
||||||
if (current_playlist_->current_index() == index.row() && player_->GetState() == Engine::Playing) {
|
|
||||||
playlist_play_pause_->setText(tr("Pause"));
|
playlist_play_pause_->setText(tr("Pause"));
|
||||||
playlist_play_pause_->setIcon(QIcon(":media-playback-pause.png"));
|
playlist_play_pause_->setIcon(QIcon(":media-playback-pause.png"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -545,8 +542,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
|
||||||
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
playlist_play_pause_->setEnabled(
|
playlist_play_pause_->setEnabled(
|
||||||
current_playlist_->current_index() != index.row() ||
|
playlist_->current_index() != index.row() ||
|
||||||
! (current_playlist_->item_at(index.row())->options() & PlaylistItem::PauseDisabled));
|
! (playlist_->item_at(index.row())->options() & PlaylistItem::PauseDisabled));
|
||||||
} else {
|
} else {
|
||||||
playlist_play_pause_->setEnabled(false);
|
playlist_play_pause_->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -556,10 +553,10 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
|
||||||
// Are any of the selected songs editable?
|
// Are any of the selected songs editable?
|
||||||
bool editable = false;
|
bool editable = false;
|
||||||
foreach (const QModelIndex& index,
|
foreach (const QModelIndex& index,
|
||||||
current_playlist_view_->selectionModel()->selection().indexes()) {
|
ui_.playlist->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0)
|
if (index.column() != 0)
|
||||||
continue;
|
continue;
|
||||||
if (current_playlist_->item_at(index.row())->Metadata().IsEditable()) {
|
if (playlist_->item_at(index.row())->Metadata().IsEditable()) {
|
||||||
editable = true;
|
editable = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +567,7 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistPlay() {
|
void MainWindow::PlaylistPlay() {
|
||||||
if (current_playlist_->current_index() == playlist_menu_index_.row()) {
|
if (playlist_->current_index() == playlist_menu_index_.row()) {
|
||||||
player_->PlayPause();
|
player_->PlayPause();
|
||||||
} else {
|
} else {
|
||||||
player_->PlayAt(playlist_menu_index_.row());
|
player_->PlayAt(playlist_menu_index_.row());
|
||||||
|
@ -578,7 +575,7 @@ void MainWindow::PlaylistPlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistStopAfter() {
|
void MainWindow::PlaylistStopAfter() {
|
||||||
current_playlist_->StopAfter(playlist_menu_index_.row());
|
playlist_->StopAfter(playlist_menu_index_.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditTracks() {
|
void MainWindow::EditTracks() {
|
||||||
|
@ -586,10 +583,10 @@ void MainWindow::EditTracks() {
|
||||||
QList<int> rows;
|
QList<int> rows;
|
||||||
|
|
||||||
foreach (const QModelIndex& index,
|
foreach (const QModelIndex& index,
|
||||||
current_playlist_view_->selectionModel()->selection().indexes()) {
|
ui_.playlist->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0)
|
if (index.column() != 0)
|
||||||
continue;
|
continue;
|
||||||
Song song = current_playlist_->item_at(index.row())->Metadata();
|
Song song = playlist_->item_at(index.row())->Metadata();
|
||||||
|
|
||||||
if (song.IsEditable()) {
|
if (song.IsEditable()) {
|
||||||
songs << song;
|
songs << song;
|
||||||
|
@ -601,7 +598,7 @@ void MainWindow::EditTracks() {
|
||||||
if (edit_tag_dialog_->exec() == QDialog::Rejected)
|
if (edit_tag_dialog_->exec() == QDialog::Rejected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
current_playlist_->ReloadItems(rows);
|
playlist_->ReloadItems(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::LibraryScanStarted() {
|
void MainWindow::LibraryScanStarted() {
|
||||||
|
@ -638,7 +635,7 @@ void MainWindow::AddMedia() {
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
M3UParser parser(&file, info.dir());
|
M3UParser parser(&file, info.dir());
|
||||||
const SongList& songs = parser.Parse();
|
const SongList& songs = parser.Parse();
|
||||||
current_playlist_->InsertSongs(songs);
|
playlist_->InsertSongs(songs);
|
||||||
} else {
|
} else {
|
||||||
QUrl url(path);
|
QUrl url(path);
|
||||||
if (url.scheme().isEmpty())
|
if (url.scheme().isEmpty())
|
||||||
|
@ -646,7 +643,7 @@ void MainWindow::AddMedia() {
|
||||||
urls << url;
|
urls << url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current_playlist_->InsertPaths(urls);
|
playlist_->InsertPaths(urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddStream() {
|
void MainWindow::AddStream() {
|
||||||
|
@ -657,70 +654,5 @@ void MainWindow::AddStreamAccepted() {
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
urls << add_stream_dialog_->url();
|
urls << add_stream_dialog_->url();
|
||||||
|
|
||||||
current_playlist_->InsertStreamUrls(urls);
|
playlist_->InsertStreamUrls(urls);
|
||||||
}
|
|
||||||
void MainWindow::NewPlaylist(){
|
|
||||||
playlistManager_->addPlaylist();
|
|
||||||
}
|
|
||||||
void MainWindow::SetCurrentPlaylist(PlaylistView* pCurrent){
|
|
||||||
// tab widget ;
|
|
||||||
//disconnects!!
|
|
||||||
if ( current_playlist_ != NULL && current_playlist_view_ != NULL ) {
|
|
||||||
disconnect(current_playlist_, SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song)));
|
|
||||||
disconnect(current_playlist_view_, SIGNAL(doubleClicked(QModelIndex)),this, SLOT(PlayIndex(QModelIndex)));
|
|
||||||
disconnect(current_playlist_view_, SIGNAL(PlayPauseItem(QModelIndex)),this, SLOT(PlayIndex(QModelIndex)));
|
|
||||||
disconnect(current_playlist_view_, SIGNAL(RightClicked(QPoint,QModelIndex)),this, SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
|
||||||
disconnect(ui_.action_clear_playlist, SIGNAL(triggered()), current_playlist_, SLOT(Clear()));
|
|
||||||
disconnect(ui_.action_shuffle, SIGNAL(triggered()), current_playlist_, SLOT(Shuffle()));
|
|
||||||
disconnect(player_, SIGNAL(Paused()), current_playlist_, SLOT(Paused()));
|
|
||||||
disconnect(player_, SIGNAL(Playing()), current_playlist_, SLOT(Playing()));
|
|
||||||
disconnect(player_, SIGNAL(Stopped()), current_playlist_, SLOT(Stopped()));
|
|
||||||
|
|
||||||
disconnect(player_, SIGNAL(Paused()), current_playlist_view_, SLOT(StopGlowing()));
|
|
||||||
disconnect(player_, SIGNAL(Playing()), current_playlist_view_, SLOT(StartGlowing()));
|
|
||||||
disconnect(player_, SIGNAL(Stopped()), current_playlist_view_, SLOT(StopGlowing()));
|
|
||||||
|
|
||||||
disconnect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), current_playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// repin pointers
|
|
||||||
|
|
||||||
ui_.tab_widget->setCurrentWidget(pCurrent);
|
|
||||||
current_playlist_view_ = pCurrent ;
|
|
||||||
current_playlist_ = qobject_cast< Playlist* >( pCurrent->model() );
|
|
||||||
player_->SetCurrentPlaylist(current_playlist_);
|
|
||||||
|
|
||||||
current_playlist_->set_sequence(playlist_sequence_);
|
|
||||||
|
|
||||||
// connects !! :)
|
|
||||||
|
|
||||||
connect(current_playlist_, SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song)));
|
|
||||||
connect(current_playlist_, SIGNAL(CurrentSongChanged(Song)), player_, SLOT(CurrentMetadataChanged(Song)));
|
|
||||||
connect(current_playlist_view_, SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
|
||||||
connect(current_playlist_view_, SIGNAL(PlayPauseItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
|
||||||
connect(current_playlist_view_, SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
|
||||||
connect(ui_.action_clear_playlist, SIGNAL(triggered()), current_playlist_, SLOT(Clear()));
|
|
||||||
connect(ui_.action_shuffle, SIGNAL(triggered()), current_playlist_, SLOT(Shuffle()));
|
|
||||||
connect(player_, SIGNAL(Paused()), current_playlist_, SLOT(Paused()));
|
|
||||||
connect(player_, SIGNAL(Playing()), current_playlist_, SLOT(Playing()));
|
|
||||||
connect(player_, SIGNAL(Stopped()), current_playlist_, SLOT(Stopped()));
|
|
||||||
|
|
||||||
connect(player_, SIGNAL(Paused()), current_playlist_view_, SLOT(StopGlowing()));
|
|
||||||
connect(player_, SIGNAL(Playing()), current_playlist_view_, SLOT(StartGlowing()));
|
|
||||||
connect(player_, SIGNAL(Stopped()), current_playlist_view_, SLOT(StopGlowing()));
|
|
||||||
|
|
||||||
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), current_playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::CurrentTabChanged(int index ){
|
|
||||||
PlaylistView *pCurrent = qobject_cast< PlaylistView* >( ui_.tab_widget->currentWidget() );
|
|
||||||
SetCurrentPlaylist(pCurrent);
|
|
||||||
}
|
|
||||||
void MainWindow::CurrentPlaylistChanged(Playlist* pPlaylist){
|
|
||||||
|
|
||||||
}
|
|
||||||
void MainWindow::InitPlaylists(){
|
|
||||||
bool bRestored = playlistManager_->Restore() ;
|
|
||||||
if ( !bRestored )
|
|
||||||
playlistManager_->addPlaylist();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
class PlaylistManager;
|
|
||||||
class Playlist;
|
class Playlist;
|
||||||
class PlaylistView;
|
|
||||||
class Player;
|
class Player;
|
||||||
class Library;
|
class Library;
|
||||||
class LibraryConfigDialog;
|
class LibraryConfigDialog;
|
||||||
|
@ -85,20 +83,10 @@ class MainWindow : public QMainWindow {
|
||||||
void AddMedia();
|
void AddMedia();
|
||||||
void AddStream();
|
void AddStream();
|
||||||
void AddStreamAccepted();
|
void AddStreamAccepted();
|
||||||
|
|
||||||
void NewPlaylist() ;
|
|
||||||
|
|
||||||
void CurrentTabChanged ( int ) ;
|
|
||||||
|
|
||||||
void CurrentPlaylistChanged( Playlist * pPlaylist ) ;
|
|
||||||
|
|
||||||
void InitPlaylists() ;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
|
|
||||||
void SetCurrentPlaylist(PlaylistView* current);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kStateVersion;
|
static const int kStateVersion;
|
||||||
static const char* kSettingsGroup;
|
static const char* kSettingsGroup;
|
||||||
|
@ -115,10 +103,7 @@ class MainWindow : public QMainWindow {
|
||||||
About* about_dialog_;
|
About* about_dialog_;
|
||||||
|
|
||||||
RadioModel* radio_model_;
|
RadioModel* radio_model_;
|
||||||
QList<Playlist*> playlists_;
|
Playlist* playlist_;
|
||||||
Playlist* current_playlist_;
|
|
||||||
PlaylistView* current_playlist_view_;
|
|
||||||
|
|
||||||
Player* player_;
|
Player* player_;
|
||||||
Library* library_;
|
Library* library_;
|
||||||
|
|
||||||
|
@ -136,8 +121,6 @@ class MainWindow : public QMainWindow {
|
||||||
|
|
||||||
QTimer* track_position_timer_;
|
QTimer* track_position_timer_;
|
||||||
QSettings settings_;
|
QSettings settings_;
|
||||||
PlaylistManager * playlistManager_ ;
|
|
||||||
int next_playlist_number_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -36,11 +36,32 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tab_widget">
|
<widget class="PlaylistView" name="playlist">
|
||||||
<property name="tabsClosable">
|
<property name="acceptDrops">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="movable">
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="rootIsDecorated">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="uniformRowHeights">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="itemsExpandable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="allColumnsShowFocus">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -417,7 +438,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>804</width>
|
<width>804</width>
|
||||||
<height>19</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuMusic">
|
<widget class="QMenu" name="menuMusic">
|
||||||
|
@ -445,8 +466,6 @@
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_clear_playlist"/>
|
<addaction name="action_clear_playlist"/>
|
||||||
<addaction name="action_shuffle"/>
|
<addaction name="action_shuffle"/>
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="action_new_playlist"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuSettings">
|
<widget class="QMenu" name="menuSettings">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -707,11 +726,6 @@
|
||||||
<string>Cover Manager</string>
|
<string>Cover Manager</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_new_playlist">
|
|
||||||
<property name="text">
|
|
||||||
<string>New playlist</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -731,6 +745,11 @@
|
||||||
<extends>QSlider</extends>
|
<extends>QSlider</extends>
|
||||||
<header>sliderwidget.h</header>
|
<header>sliderwidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PlaylistView</class>
|
||||||
|
<extends>QTreeView</extends>
|
||||||
|
<header>playlistview.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>LibraryView</class>
|
<class>LibraryView</class>
|
||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
|
||||||
const char* OSD::kSettingsGroup = "OSD";
|
const char* OSD::kSettingsGroup = "OSD";
|
||||||
|
|
||||||
OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent)
|
OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent)
|
||||||
|
@ -34,7 +33,7 @@ void OSD::ReloadSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSD::SongChanged(const Song &song) {
|
void OSD::SongChanged(const Song &song) {
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << __PRETTY_FUNCTION__;
|
||||||
QString summary(song.PrettyTitle());
|
QString summary(song.PrettyTitle());
|
||||||
if (!song.artist().isEmpty())
|
if (!song.artist().isEmpty())
|
||||||
summary = QString("%1 - %2").arg(song.artist(), summary);
|
summary = QString("%1 - %2").arg(song.artist(), summary);
|
||||||
|
|
|
@ -63,7 +63,6 @@ void Player::ReloadSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Next() {
|
void Player::Next() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
if (playlist_->current_item_options() & PlaylistItem::ContainsMultipleTracks) {
|
if (playlist_->current_item_options() & PlaylistItem::ContainsMultipleTracks) {
|
||||||
playlist_->current_item()->LoadNext();
|
playlist_->current_item()->LoadNext();
|
||||||
return;
|
return;
|
||||||
|
@ -73,7 +72,6 @@ void Player::Next() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::NextItem() {
|
void Player::NextItem() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
int i = playlist_->next_index();
|
int i = playlist_->next_index();
|
||||||
playlist_->set_current_index(i);
|
playlist_->set_current_index(i);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
|
@ -85,7 +83,6 @@ void Player::NextItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::TrackEnded() {
|
void Player::TrackEnded() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
int i = playlist_->current_index();
|
int i = playlist_->current_index();
|
||||||
if (i == -1 || playlist_->stop_after_current()) {
|
if (i == -1 || playlist_->stop_after_current()) {
|
||||||
Stop();
|
Stop();
|
||||||
|
@ -96,7 +93,6 @@ void Player::TrackEnded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::PlayPause() {
|
void Player::PlayPause() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
if (!init_engine_.isFinished())
|
if (!init_engine_.isFinished())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -130,7 +126,6 @@ void Player::PlayPause() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Stop() {
|
void Player::Stop() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
if (!init_engine_.isFinished())
|
if (!init_engine_.isFinished())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -140,7 +135,6 @@ void Player::Stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Previous() {
|
void Player::Previous() {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
int i = playlist_->previous_index();
|
int i = playlist_->previous_index();
|
||||||
playlist_->set_current_index(i);
|
playlist_->set_current_index(i);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
|
@ -175,7 +169,6 @@ Engine::State Player::GetState() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::PlayAt(int index) {
|
void Player::PlayAt(int index) {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
if (!init_engine_.isFinished())
|
if (!init_engine_.isFinished())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -196,7 +189,6 @@ void Player::PlayAt(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::StreamReady(const QUrl& original_url, const QUrl& media_url) {
|
void Player::StreamReady(const QUrl& original_url, const QUrl& media_url) {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
if (!init_engine_.isFinished())
|
if (!init_engine_.isFinished())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -227,7 +219,6 @@ void Player::Seek(int seconds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) {
|
void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) {
|
||||||
Q_ASSERT(playlist_ != NULL ) ;
|
|
||||||
PlaylistItem* item = playlist_->current_item();
|
PlaylistItem* item = playlist_->current_item();
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -29,9 +29,6 @@ class Player : public QObject {
|
||||||
PlaylistItem::Options GetCurrentItemOptions() const { return current_item_options_; }
|
PlaylistItem::Options GetCurrentItemOptions() const { return current_item_options_; }
|
||||||
Song GetCurrentItem() const { return current_item_; }
|
Song GetCurrentItem() const { return current_item_; }
|
||||||
|
|
||||||
Playlist* CurrentPlaylist() const { return playlist_; }
|
|
||||||
void SetCurrentPlaylist(Playlist* current) { playlist_ = current; }
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,8 @@ Playlist::Playlist(QObject *parent) :
|
||||||
is_shuffled_(false),
|
is_shuffled_(false),
|
||||||
scrobble_point_(-1),
|
scrobble_point_(-1),
|
||||||
has_scrobbled_(false),
|
has_scrobbled_(false),
|
||||||
ignore_sorting_(false),
|
playlist_sequence_(NULL),
|
||||||
title_(""),
|
ignore_sorting_(false)
|
||||||
index_(-1),
|
|
||||||
playlist_sequence_(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +291,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutChanged();
|
layoutChanged();
|
||||||
// Save();
|
Save();
|
||||||
|
|
||||||
} else if (data->hasUrls()) {
|
} else if (data->hasUrls()) {
|
||||||
// URL list dragged from the file list or some other app
|
// URL list dragged from the file list or some other app
|
||||||
|
@ -356,7 +354,7 @@ QModelIndex Playlist::InsertItems(const QList<PlaylistItem*>& items, int after)
|
||||||
}
|
}
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
// Save();
|
Save();
|
||||||
ReshuffleIndices();
|
ReshuffleIndices();
|
||||||
|
|
||||||
return index(start, 0);
|
return index(start, 0);
|
||||||
|
@ -457,7 +455,7 @@ void Playlist::sort(int column, Qt::SortOrder order) {
|
||||||
|
|
||||||
layoutChanged();
|
layoutChanged();
|
||||||
|
|
||||||
// Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::Playing() {
|
void Playlist::Playing() {
|
||||||
|
@ -483,11 +481,10 @@ void Playlist::SetCurrentIsPaused(bool paused) {
|
||||||
index(current_item_.row(), ColumnCount));
|
index(current_item_.row(), ColumnCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::SaveR() const {
|
void Playlist::Save() const {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
Q_ASSERT(index_ != -1 ) ;
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.beginGroup(title_);
|
|
||||||
s.beginWriteArray("items", items_.count());
|
s.beginWriteArray("items", items_.count());
|
||||||
for (int i=0 ; i<items_.count() ; ++i) {
|
for (int i=0 ; i<items_.count() ; ++i) {
|
||||||
s.setArrayIndex(i);
|
s.setArrayIndex(i);
|
||||||
|
@ -495,19 +492,15 @@ void Playlist::SaveR() const {
|
||||||
items_.at(i)->Save(s);
|
items_.at(i)->Save(s);
|
||||||
}
|
}
|
||||||
s.endArray();
|
s.endArray();
|
||||||
s.setValue("title",title_);
|
|
||||||
s.endGroup();
|
|
||||||
s.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::RestoreR() {
|
void Playlist::Restore() {
|
||||||
qDeleteAll(items_);
|
qDeleteAll(items_);
|
||||||
items_.clear();
|
items_.clear();
|
||||||
virtual_items_.clear();
|
virtual_items_.clear();
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.beginGroup(title_);
|
|
||||||
|
|
||||||
int count = s.beginReadArray("items");
|
int count = s.beginReadArray("items");
|
||||||
for (int i=0 ; i<count ; ++i) {
|
for (int i=0 ; i<count ; ++i) {
|
||||||
|
@ -523,8 +516,7 @@ void Playlist::RestoreR() {
|
||||||
virtual_items_ << virtual_items_.count();
|
virtual_items_ << virtual_items_.count();
|
||||||
}
|
}
|
||||||
s.endArray();
|
s.endArray();
|
||||||
s.endGroup();
|
|
||||||
s.endGroup();
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +543,7 @@ bool Playlist::removeRows(int row, int count, const QModelIndex& parent) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save();
|
Save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +634,7 @@ void Playlist::Clear() {
|
||||||
items_.clear();
|
items_.clear();
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
// Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::ReloadItems(const QList<int>& rows) {
|
void Playlist::ReloadItems(const QList<int>& rows) {
|
||||||
|
@ -671,7 +663,7 @@ void Playlist::Shuffle() {
|
||||||
|
|
||||||
layoutChanged();
|
layoutChanged();
|
||||||
|
|
||||||
// Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::ReshuffleIndices() {
|
void Playlist::ReshuffleIndices() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ class RadioService;
|
||||||
class Playlist : public QAbstractListModel {
|
class Playlist : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class PlaylistManager ;
|
|
||||||
public:
|
public:
|
||||||
Playlist(QObject* parent = 0);
|
Playlist(QObject* parent = 0);
|
||||||
~Playlist();
|
~Playlist();
|
||||||
|
@ -55,7 +54,9 @@ class Playlist : public QAbstractListModel {
|
||||||
static bool CompareItems(int column, Qt::SortOrder order,
|
static bool CompareItems(int column, Qt::SortOrder order,
|
||||||
const PlaylistItem* a, const PlaylistItem* b);
|
const PlaylistItem* a, const PlaylistItem* b);
|
||||||
|
|
||||||
|
// Persistence
|
||||||
|
void Save() const;
|
||||||
|
void Restore();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
int current_index() const;
|
int current_index() const;
|
||||||
|
@ -69,12 +70,6 @@ class Playlist : public QAbstractListModel {
|
||||||
PlaylistItem::Options current_item_options() const;
|
PlaylistItem::Options current_item_options() const;
|
||||||
Song current_item_metadata() const;
|
Song current_item_metadata() const;
|
||||||
|
|
||||||
const QString & GetTitle() const { return title_ ; }
|
|
||||||
void SetTitle(const QString& title) { title_ = title; }
|
|
||||||
|
|
||||||
void SetPlaylistIndex( int ipos ) { index_ = ipos ; }
|
|
||||||
int GetPlaylistIndex() const { return index_ ; }
|
|
||||||
|
|
||||||
void set_sequence(PlaylistSequence* v);
|
void set_sequence(PlaylistSequence* v);
|
||||||
PlaylistSequence* sequence() const { return playlist_sequence_; }
|
PlaylistSequence* sequence() const { return playlist_sequence_; }
|
||||||
|
|
||||||
|
@ -129,10 +124,6 @@ class Playlist : public QAbstractListModel {
|
||||||
void ReshuffleIndices();
|
void ReshuffleIndices();
|
||||||
int NextVirtualIndex(int i) const;
|
int NextVirtualIndex(int i) const;
|
||||||
|
|
||||||
// Persistence
|
|
||||||
void SaveR() const;
|
|
||||||
void RestoreR();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<PlaylistItem*> items_;
|
QList<PlaylistItem*> items_;
|
||||||
QList<int> virtual_items_; // Contains the indices into items_ in the order
|
QList<int> virtual_items_; // Contains the indices into items_ in the order
|
||||||
|
@ -149,8 +140,6 @@ class Playlist : public QAbstractListModel {
|
||||||
|
|
||||||
// Hack to stop QTreeView::setModel sorting the playlist
|
// Hack to stop QTreeView::setModel sorting the playlist
|
||||||
bool ignore_sorting_;
|
bool ignore_sorting_;
|
||||||
QString title_;
|
|
||||||
int index_ ;
|
|
||||||
|
|
||||||
PlaylistSequence* playlist_sequence_;
|
PlaylistSequence* playlist_sequence_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
#include "playlistmanager.h"
|
|
||||||
#include "playlistview.h"
|
|
||||||
#include "playlist.h"
|
|
||||||
|
|
||||||
#include <QAbstractItemView>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
PlaylistManager::PlaylistManager(QObject* parent): QObject(parent),
|
|
||||||
pTabWidget_( NULL ),
|
|
||||||
pCurrentPlaylist_(NULL),
|
|
||||||
pCurrentPlaylistView_(NULL),
|
|
||||||
playlistCount_(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void PlaylistManager::addPlaylist(const QString & playlistName /*= QString()*/){
|
|
||||||
Q_ASSERT ( pTabWidget_ ) ;
|
|
||||||
PlaylistView * playListView = new PlaylistView(pTabWidget_);
|
|
||||||
|
|
||||||
playListView->setObjectName(QString::fromUtf8("playlist"));
|
|
||||||
playListView->setAcceptDrops(true);
|
|
||||||
playListView->setDragEnabled(true);
|
|
||||||
playListView->setDragDropMode(QAbstractItemView::DragDrop);
|
|
||||||
playListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
||||||
playListView->setRootIsDecorated(false);
|
|
||||||
playListView->setUniformRowHeights(true);
|
|
||||||
playListView->setItemsExpandable(false);
|
|
||||||
playListView->setSortingEnabled(true);
|
|
||||||
playListView->setAllColumnsShowFocus(true);
|
|
||||||
|
|
||||||
Playlist* playList = new Playlist(playListView) ;
|
|
||||||
|
|
||||||
playList->IgnoreSorting(true);
|
|
||||||
playListView->setModel(playList);
|
|
||||||
playList->IgnoreSorting(false);
|
|
||||||
|
|
||||||
QString title = playList->GetTitle();
|
|
||||||
playlistCount_++ ;
|
|
||||||
if ( title.isEmpty() )
|
|
||||||
title = tr("New playlist") + QString::number(playlistCount_) ;
|
|
||||||
playList->SetPlaylistIndex( playlistCount_) ;
|
|
||||||
playList->SetTitle(title);
|
|
||||||
pTabWidget_->addTab(playListView, title);
|
|
||||||
|
|
||||||
SetCurrentPlaylist(playList);
|
|
||||||
pCurrentPlaylistView_ = playListView ;
|
|
||||||
|
|
||||||
playlists_ << playList ;
|
|
||||||
}
|
|
||||||
void PlaylistManager::SetCurrentPlaylist(Playlist* pPlaylist){
|
|
||||||
pCurrentPlaylist_ = pPlaylist ;
|
|
||||||
|
|
||||||
emit CurrentPlaylistChanged( pCurrentPlaylist_ ) ;
|
|
||||||
}
|
|
||||||
void PlaylistManager::Save() const{
|
|
||||||
QSettings s ;
|
|
||||||
Q_FOREACH ( Playlist* p, playlists_ ) {
|
|
||||||
qDebug() << "Saving" << p->GetTitle() ;
|
|
||||||
p->SaveR() ;
|
|
||||||
}
|
|
||||||
s.setValue("numberofplaylists", playlistCount_ ) ;
|
|
||||||
s.setValue("currentplaylistindex",pTabWidget_->currentIndex());
|
|
||||||
}
|
|
||||||
bool PlaylistManager::Restore(){
|
|
||||||
Q_ASSERT ( pTabWidget_ ) ;
|
|
||||||
QSettings s ;
|
|
||||||
bool bOk ;
|
|
||||||
int nOfPlaylist = s.value("numberofplaylists").toInt(&bOk) ;
|
|
||||||
playlistCount_ = nOfPlaylist ;
|
|
||||||
s.beginGroup(Playlist::kSettingsGroup);
|
|
||||||
QStringList childs = s.childGroups() ;
|
|
||||||
if ( bOk == false || nOfPlaylist == 0 ) {
|
|
||||||
qDebug()<< "No reading from settings";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int index = 0;
|
|
||||||
foreach ( QString title, childs ) {
|
|
||||||
PlaylistView* playListView = new PlaylistView(pTabWidget_);
|
|
||||||
|
|
||||||
playListView->setObjectName(QString::fromUtf8("playlist"));
|
|
||||||
playListView->setAcceptDrops(true);
|
|
||||||
playListView->setDragEnabled(true);
|
|
||||||
playListView->setDragDropMode(QAbstractItemView::DragDrop);
|
|
||||||
playListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
||||||
playListView->setRootIsDecorated(false);
|
|
||||||
playListView->setUniformRowHeights(true);
|
|
||||||
playListView->setItemsExpandable(false);
|
|
||||||
playListView->setSortingEnabled(true);
|
|
||||||
playListView->setAllColumnsShowFocus(true);
|
|
||||||
|
|
||||||
Playlist* playList = new Playlist(playListView) ;
|
|
||||||
|
|
||||||
playList->IgnoreSorting(true);
|
|
||||||
playListView->setModel(playList);
|
|
||||||
playList->IgnoreSorting(false);
|
|
||||||
|
|
||||||
playList->SetPlaylistIndex( index+1 ) ;
|
|
||||||
playList->SetTitle(title);
|
|
||||||
playList->RestoreR() ;
|
|
||||||
|
|
||||||
pTabWidget_->addTab( playListView, playList->GetTitle() );
|
|
||||||
|
|
||||||
SetCurrentPlaylist(playList);
|
|
||||||
pCurrentPlaylistView_ = playListView ;
|
|
||||||
playlists_ << playList ;
|
|
||||||
}
|
|
||||||
int nCurrentIndex = -1 ;
|
|
||||||
int currentIndex = s.value("currentplaylistindex").toInt(&bOk);
|
|
||||||
if(bOk)
|
|
||||||
pTabWidget_->setCurrentIndex(currentIndex);
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
void PlaylistManager::TabCloseRequest(int index){
|
|
||||||
const PlaylistView* playListView = qobject_cast<const PlaylistView*> (pTabWidget_->widget(index)) ;
|
|
||||||
Playlist* playlist = qobject_cast<Playlist*>( playListView->model() ) ;
|
|
||||||
playlists_.removeAll(playlist);
|
|
||||||
pTabWidget_->removeTab(index);
|
|
||||||
|
|
||||||
QSettings s ;
|
|
||||||
s.beginGroup(Playlist::kSettingsGroup);
|
|
||||||
s.remove(playlist->GetTitle());
|
|
||||||
}
|
|
||||||
void PlaylistManager::SetTabWidget(QTabWidget* pWidget) {
|
|
||||||
if ( pTabWidget_ )
|
|
||||||
disconnect ( pTabWidget_, SIGNAL(tabCloseRequested(int)),this, SLOT(TabCloseRequest(int)));
|
|
||||||
pTabWidget_ = pWidget ;
|
|
||||||
connect ( pTabWidget_, SIGNAL(tabCloseRequested(int)),this, SLOT(TabCloseRequest(int)));
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
#ifndef PLAYLISTMANAGER_H
|
|
||||||
#define PLAYLISTMANAGER_H
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
|
|
||||||
class PlaylistView;
|
|
||||||
class QTabWidget;
|
|
||||||
class Playlist;
|
|
||||||
|
|
||||||
class PlaylistManager : public QObject{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
PlaylistManager(QObject* parent = 0);
|
|
||||||
void addPlaylist( const QString& playlistName = QString() ) ;
|
|
||||||
|
|
||||||
// accessors
|
|
||||||
void SetTabWidget( QTabWidget * pWidget ) ;
|
|
||||||
QTabWidget* GetTabWidget() const {return pTabWidget_; }
|
|
||||||
|
|
||||||
void SetCurrentPlaylist ( Playlist * pPlaylist ) ;
|
|
||||||
|
|
||||||
void Save() const ;
|
|
||||||
bool Restore() ;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<Playlist*> playlists_ ;
|
|
||||||
QTabWidget* pTabWidget_ ;
|
|
||||||
QList<QString> playlistNames_ ;
|
|
||||||
Playlist* pCurrentPlaylist_ ;
|
|
||||||
PlaylistView* pCurrentPlaylistView_ ;
|
|
||||||
|
|
||||||
int playlistCount_ ;
|
|
||||||
signals:
|
|
||||||
void CurrentPlaylistChanged( Playlist* pPlaylist ) ;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void TabCloseRequest( int index ) ;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PLAYLISTMANAGER_H
|
|
Loading…
Reference in New Issue