4f8e25b4686d181732f87b9ab17daad45fe3c4b8
[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 #include "toolswidget.h"
31
32 namespace Ui {
33     class LibraryForm;
34 }
35
36 using SomePlayer::DataObjects::Library;
37 using SomePlayer::DataObjects::Track;
38 using SomePlayer::DataObjects::Playlist;
39
40 enum LibraryFormListState {STATE_NONE, STATE_ARTIST, STATE_ALBUM, STATE_TRACK, STATE_PLAYLIST, STATE_PLAYLIST_TRACK, STATE_DYNAMIC};
41
42 class LibraryForm : public QWidget
43 {
44     Q_OBJECT
45
46 public:
47         explicit LibraryForm(Library *lib, QWidget *parent = 0);
48     ~LibraryForm();
49 signals:
50         void player(bool);
51         void busy(QString);
52         void done();
53         void fullscreen(bool);
54 public slots:
55         void search(QString);
56         void nextItem();
57         void prevItem();
58         void cancelSearch();
59         void refresh();
60         void landscapeMode();
61         void portraitMode();
62 private slots:
63         void _player();
64         void _view_button();
65         void _dynamic_button();
66         void _playlists_button();
67         void _toggle_select_all_button();
68         void _add_button();
69         void _delete_button();
70         void _back_button();
71         void _use_button();
72         void _process_list_click(QModelIndex);
73         void _more_button();
74
75 private:
76         Ui::LibraryForm *ui;
77         Library *_lib;
78         QStandardItemModel *_model;
79         LibraryFormListState _state;
80         QString _current_artist;
81         QString _current_album;
82         Playlist _current_playlist;
83         QList<Track> _current_tracks;
84         QString _search_pattern;
85         int _search_current_id;
86         bool _current_playlist_changed;
87         ToolsWidget *_tools_widget;
88
89         void _add_artist(QString artist);
90         void _add_album(QString artist, QString album);
91         void _add_track(Track track);
92         void _add_playlist(QString name);
93         void _delete_track(Track track);
94 };
95
96 #endif // LIBRARYFORM_H