/src/libtomahawk/context/pages/WikipediaContext.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 91 lines · 52 code · 22 blank · 17 comment · 12 complexity · 5cc4c6679799416a44a2ce2d2e1fdbe7 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. *
  5. * Tomahawk is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "WikipediaContext.h"
  19. #include "Source.h"
  20. using namespace Tomahawk;
  21. void
  22. WikipediaContext::setArtist( const Tomahawk::artist_ptr& artist )
  23. {
  24. if ( artist.isNull() )
  25. return;
  26. if ( !m_artist.isNull() && m_artist->name() == artist->name() )
  27. return;
  28. m_artist = artist;
  29. QString lang = QLocale::system().name().split("_").first();
  30. webView()->load( QString( "http://%1.wikipedia.org/w/index.php?useformat=mobile&title=%2" ).arg( lang ).arg( m_artist->name() ) );
  31. }
  32. void
  33. WikipediaContext::setAlbum( const Tomahawk::album_ptr& album )
  34. {
  35. if ( album.isNull() )
  36. return;
  37. setArtist( album->artist() );
  38. }
  39. void
  40. WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
  41. {
  42. if ( query.isNull() )
  43. return;
  44. setArtist( Artist::get( query->artist(), false ) );
  45. }
  46. void
  47. LastfmContext::setArtist( const Tomahawk::artist_ptr& artist )
  48. {
  49. if ( artist.isNull() )
  50. return;
  51. if ( !m_artist.isNull() && m_artist->name() == artist->name() )
  52. return;
  53. m_artist = artist;
  54. webView()->load( QString( "http://last.fm/music/%1" ).arg( m_artist->name() ) );
  55. }
  56. void
  57. LastfmContext::setAlbum( const Tomahawk::album_ptr& album )
  58. {
  59. if ( album.isNull() )
  60. return;
  61. setArtist( album->artist() );
  62. }
  63. void
  64. LastfmContext::setQuery( const Tomahawk::query_ptr& query )
  65. {
  66. if ( query.isNull() )
  67. return;
  68. setArtist( Artist::get( query->artist(), false ) );
  69. }