-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusermode.cpp
115 lines (88 loc) · 2.65 KB
/
usermode.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "usermode.h"
#include "ui_usermode.h"
#include "MovieTableModel.h"
void userMode::updateTable()
{ MovieTableModel *mymodel = new MovieTableModel(wlist); ui->tableView->setModel(mymodel); }
userMode::userMode(Controller ctrl, WatchList *wlist, QWidget *parent) :
QDialog(parent),
ui(new Ui::userMode)
{
ui->setupUi(this);
this->ctrl = ctrl;
this->wlist = wlist;
ui->liked->addItem("Liked it");
ui->liked->addItem("Disliked it");
this->updateTable();
//ui->listView = new MovieTableModel(wlist);
//ui->items = new MovieTableModel(wlist);
}
userMode::~userMode()
{
delete ui;
}
void userMode::on_suggestionButton_clicked()
{
string needle = ui->genreEdit->toPlainText().toStdString();
this->wlist->getSuggestions(this->ctrl.getItems(), needle);
if (wlist->getMaximumPos() == 0)
ui->movieLabel->setText("No suggestions for this genre!");
else
{
Movie mov = wlist->getCurrentMovie();
ui->movieLabel->setText(QString::fromStdString(mov.getTitle()));
// else if (option == 2)
// this->wlist->add();
// else if (option == 3)
// continue;
// else if (option == 0)
// break;
}
// if (suggestions.size() == 0)
// ui->movieLabel->setText("That's all for now!\n");
}
void userMode::on_trailerButton_clicked()
{
Movie mov = wlist->getCurrentMovie();
string url = "open ";
url += mov.getTrailer();
system(url.c_str());
wlist->setCurrentPos(-1);
}
void userMode::on_addButton_clicked()
{
this->wlist->add();
ui->items->clear();
for (Movie mov: wlist->getArray())
ui->items->addItem(QString::fromStdString(mov.toStr()));
this->updateTable();
on_nextButton_clicked();
}
void userMode::on_nextButton_clicked()
{
Movie mov = wlist->getCurrentMovie();
ui->movieLabel->setText(QString::fromStdString(mov.getTitle()));
}
void userMode::on_openButton_clicked()
{
this->wlist->saveToFile();
this->wlist->openInApp();
}
void userMode::on_deleteButton_clicked()
{
string title = ui->watchedEdit->toPlainText().toStdString();
this->wlist->del(title);
if (ui->liked->currentIndex() == 0)
this->ctrl.incLikes(title);
ui->items->clear();
for (Movie mov: wlist->getArray())
ui->items->addItem(QString::fromStdString(mov.toStr()));
this->updateTable();
}
void userMode::on_undoButton_clicked()
{
this->wlist->undo();
ui->items->clear();
for (Movie mov: wlist->getArray())
ui->items->addItem(QString::fromStdString(mov.toStr()));
this->updateTable();
}