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