forked from mpc-qt/mpc-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrarywindow.cpp
More file actions
65 lines (54 loc) · 1.9 KB
/
librarywindow.cpp
File metadata and controls
65 lines (54 loc) · 1.9 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
#include <QCloseEvent>
#include "playlist.h"
#include "widgets/drawncollection.h"
#include "widgets/drawnplaylist.h"
#include "librarywindow.h"
#include "ui_librarywindow.h"
LibraryWindow::LibraryWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::LibraryWindow)
{
ui->setupUi(this);
collectionWidget = new DrawnCollection(PlaylistCollection::getBackup());
ui->collectionLayout->addWidget(collectionWidget);
playlistWidget = new DrawnPlaylist(PlaylistCollection::getBackup());
ui->playlistLayout->addWidget(playlistWidget);
connect(collectionWidget, &DrawnCollection::playlistSelected,
playlistWidget, &DrawnPlaylist::setUuid);
}
LibraryWindow::~LibraryWindow()
{
delete ui;
}
void LibraryWindow::refreshLibrary()
{
collectionWidget->repopulatePlaylists();
}
void LibraryWindow::closeEvent(QCloseEvent *event)
{
event->accept();
emit windowClosed();
}
void LibraryWindow::on_restorePlaylist_clicked()
{
int currentRow = collectionWidget->currentRow();
if (currentRow == -1)
return;
auto collectionItem = reinterpret_cast<CollectionItem*>(collectionWidget->currentItem());
auto playlistCollection = PlaylistCollection::getSingleton();
auto backupCollection = PlaylistCollection::getBackup();
auto playlistTaken = backupCollection->takePlaylist(collectionItem->uuid());
playlistCollection->addPlaylist(playlistTaken);
emit playlistRestored(playlistTaken->uuid());
delete collectionWidget->takeItem(currentRow);
}
void LibraryWindow::on_removePlaylist_clicked()
{
int currentRow = collectionWidget->currentRow();
if (currentRow == -1)
return;
auto backupCollection = PlaylistCollection::getBackup();
auto collectionItem = reinterpret_cast<CollectionItem*>(collectionWidget->currentItem());
backupCollection->removePlaylist(collectionItem->uuid());
delete collectionWidget->takeItem(currentRow);
}