-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
89 lines (71 loc) · 2.11 KB
/
mainwindow.cpp
File metadata and controls
89 lines (71 loc) · 2.11 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "wrapper.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
previousSelectedPlaylist = 0; //what if already playing? fix this
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addPlaylistItem(QString artist, QString title) {
int newRow = ui->playlistTableWidget->rowCount();
//artist
QTableWidgetItem *artistItem = new QTableWidgetItem;
artistItem->setText(artist);
//title
QTableWidgetItem *titleItem = new QTableWidgetItem;
titleItem->setText(title);
titleItem->setTextAlignment(Qt::AlignRight);
ui->playlistTableWidget->insertRow(newRow);
ui->playlistTableWidget->setItem(newRow, 0 , artistItem);
ui->playlistTableWidget->setItem(newRow, 1 , titleItem);
}
void MainWindow::on_toolButton_clicked()
{
Mpd.Play();
}
void MainWindow::on_toolButton_2_clicked()
{
Mpd.Pause(1);
}
void MainWindow::on_toolButton_3_clicked()
{
Mpd.Prev();
}
void MainWindow::on_toolButton_4_clicked()
{
Mpd.Next();
}
void MainWindow::deleteItem() {
/* // Delete from mpd queue
QModelIndexList indexes = ui->playlistTableWidget->selectionModel()->selectedIndexes();
foreach(QModelIndex index, indexes)
{
Mpd.Delete(index.row());
ui->playlistTableWidget->takeItem(index.row());
}
// Delete from UI
QList<QListWidgetItem *> itemList = ui->playlistTableWidget->selectedItems();
foreach(QListWidgetItem *item, itemList) {
delete item;
}
// TODO: Delete from songlist
*/
}
void MainWindow::on_playlistTableWidget_doubleClicked(const QModelIndex &index)
{
QFont font;
font.setBold(false);
ui->playlistTableWidget->item(getPreviousSelectedPlaylist(), 0)->setFont(font);
ui->playlistTableWidget->item(getPreviousSelectedPlaylist(), 1)->setFont(font);
font.setBold(true);
ui->playlistTableWidget->item(index.row(), 0)->setFont(font);
ui->playlistTableWidget->item(index.row(), 1)->setFont(font);
setPreviousSelectedPlaylist(index.row());
Mpd.Play(index.row());
}