Fixed bug with removing tracks from another playlist. Implemented adding track to...
[someplayer] / src / libraryform.h
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef LIBRARYFORM_H
21 #define LIBRARYFORM_H
22
23 #include <QWidget>
24 #include "someplayer.h"
25
26 #include <QStandardItemModel>
27 #include <QStandardItem>
28 #include <QModelIndex>
29 #include "playlist.h"
30
31 namespace Ui {
32     class LibraryForm;
33 }
34
35 using SomePlayer::DataObjects::Library;
36 using SomePlayer::DataObjects::Track;
37 using SomePlayer::DataObjects::Playlist;
38
39 enum LibraryFormListState {STATE_NONE, STATE_ARTIST, STATE_ALBUM, STATE_TRACK, STATE_PLAYLIST, STATE_PLAYLIST_TRACK, STATE_DYNAMIC};
40
41 class LibraryForm : public QWidget
42 {
43     Q_OBJECT
44
45 public:
46         explicit LibraryForm(Library *lib, QWidget *parent = 0);
47     ~LibraryForm();
48 signals:
49         void player();
50         void busy(QString);
51         void done();
52 public slots:
53         void search(QString &);
54         void nextItem();
55         void prevItem();
56         void cancelSearch();
57 private slots:
58         void _player();
59         void _view_button();
60         void _dynamic_button();
61         void _playlists_button();
62         void _add_button();
63         void _delete_button();
64         void _back_button();
65         void _use_button();
66         void _process_list_click(QModelIndex);
67
68 private:
69     Ui::LibraryForm *ui;
70         Library *_lib;
71         QStandardItemModel *_model;
72         LibraryFormListState _state;
73         QString _current_artist;
74         QString _current_album;
75         Playlist _current_playlist;
76         QList<Track> _current_tracks;
77         QString _search_pattern;
78         int _search_current_id;
79
80         void _add_artist(QString artist);
81         void _add_album(QString artist, QString album);
82         void _add_track(Track track);
83         void _add_playlist(QString name);
84         void _delete_track(Track track);
85 };
86
87 #endif // LIBRARYFORM_H