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