/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. #ifndef SEARCHWIDGET_H
  21. #define SEARCHWIDGET_H
  22. #include <QWidget>
  23. #include <QTimer>
  24. #include "Result.h"
  25. #include "PlaylistInterface.h"
  26. #include "ViewPage.h"
  27. #include "DllMacro.h"
  28. class QPushButton;
  29. class PlayableModel;
  30. class PlaylistModel;
  31. namespace Ui
  32. {
  33. class SearchWidget;
  34. }
  35. class DLLEXPORT SearchWidget : public QWidget, public Tomahawk::ViewPage
  36. {
  37. Q_OBJECT
  38. public:
  39. SearchWidget( const QString& search, QWidget* parent = 0 );
  40. ~SearchWidget();
  41. virtual QWidget* widget() { return this; }
  42. virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
  43. virtual QString title() const { return QString( tr( "Search: %1" ) ).arg( m_search ); }
  44. virtual QString description() const { return tr( "Results for '%1'" ).arg( m_search ); }
  45. virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/search-icon.png" ); }
  46. virtual bool isTemporaryPage() const { return true; }
  47. virtual bool jumpToCurrentTrack();
  48. protected:
  49. void changeEvent( QEvent* e );
  50. signals:
  51. void destroyed( QWidget* widget );
  52. private slots:
  53. void onResultsFound( const QList<Tomahawk::result_ptr>& results );
  54. void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums );
  55. void onArtistsFound( const QList<Tomahawk::artist_ptr>& artists );
  56. void onQueryFinished();
  57. private:
  58. void sortArtists();
  59. void sortAlbums();
  60. Ui::SearchWidget *ui;
  61. QString m_search;
  62. PlayableModel* m_artistsModel;
  63. PlayableModel* m_albumsModel;
  64. PlaylistModel* m_resultsModel;
  65. QList< Tomahawk::query_ptr > m_queries;
  66. QList< Tomahawk::artist_ptr > m_artists;
  67. QList< Tomahawk::album_ptr > m_albums;
  68. };
  69. #endif // NEWPLAYLISTWIDGET_H