PageRenderTime 107ms CodeModel.GetById 40ms app.highlight 22ms RepoModel.GetById 38ms app.codeStats 0ms

/src/libtomahawk/widgets/searchwidget.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 91 lines | 50 code | 22 blank | 19 comment | 0 complexity | 21d2c3cb80aab7c39b7737cabe8f2adf MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright 2012       Leo Franchi            <lfranchi@kde.org>
 5 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
 6 *
 7 *   Tomahawk is free software: you can redistribute it and/or modify
 8 *   it under the terms of the GNU General Public License as published by
 9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   Tomahawk is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SEARCHWIDGET_H
22#define SEARCHWIDGET_H
23
24#include <QWidget>
25#include <QTimer>
26
27#include "Result.h"
28#include "PlaylistInterface.h"
29#include "ViewPage.h"
30
31#include "DllMacro.h"
32
33class QPushButton;
34class PlayableModel;
35class PlaylistModel;
36
37namespace Ui
38{
39    class SearchWidget;
40}
41
42class DLLEXPORT SearchWidget : public QWidget, public Tomahawk::ViewPage
43{
44Q_OBJECT
45
46public:
47    SearchWidget( const QString& search, QWidget* parent = 0 );
48    ~SearchWidget();
49
50    virtual QWidget* widget() { return this; }
51    virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
52
53    virtual QString title() const { return QString( tr( "Search: %1" ) ).arg( m_search ); }
54    virtual QString description() const { return tr( "Results for '%1'" ).arg( m_search ); }
55    virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/search-icon.png" ); }
56
57    virtual bool isTemporaryPage() const { return true; }
58
59    virtual bool jumpToCurrentTrack();
60
61protected:
62    void changeEvent( QEvent* e );
63
64signals:
65    void destroyed( QWidget* widget );
66
67private slots:
68    void onResultsFound( const QList<Tomahawk::result_ptr>& results );
69    void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums );
70    void onArtistsFound( const QList<Tomahawk::artist_ptr>& artists );
71
72    void onQueryFinished();
73
74private:
75    void sortArtists();
76    void sortAlbums();
77
78    Ui::SearchWidget *ui;
79
80    QString m_search;
81
82    PlayableModel* m_artistsModel;
83    PlayableModel* m_albumsModel;
84    PlaylistModel* m_resultsModel;
85
86    QList< Tomahawk::query_ptr > m_queries;
87    QList< Tomahawk::artist_ptr > m_artists;
88    QList< Tomahawk::album_ptr > m_albums;
89};
90
91#endif // NEWPLAYLISTWIDGET_H