/src/libtomahawk/utils/DropJobNotifier.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 120 lines · 75 code · 26 blank · 19 comment · 10 complexity · e390ed8b8034e2db285e7c5b14bf2633 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4. * Copyright 2010-2011, Hugo Lindström <hugolm84@gmail.com>
  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. #include "DropJobNotifier.h"
  21. #include <QtNetwork/QNetworkAccessManager>
  22. #include <QtNetwork/QNetworkReply>
  23. #include "Query.h"
  24. #include "SourceList.h"
  25. #include "DropJob.h"
  26. #include "DropJobNotifier.h"
  27. #include "jobview/JobStatusView.h"
  28. #include "jobview/JobStatusModel.h"
  29. #include "utils/NetworkReply.h"
  30. #include "utils/TomahawkUtils.h"
  31. #include "utils/Logger.h"
  32. using namespace Tomahawk;
  33. DropJobNotifier::DropJobNotifier( QPixmap servicePixmap, QString service, DropJob::DropType type, NetworkReply* job )
  34. : JobStatusItem()
  35. , m_type( "unknown" )
  36. , m_job( 0 )
  37. , m_pixmap( servicePixmap )
  38. , m_service( service )
  39. {
  40. init( type );
  41. if ( m_service.isEmpty() )
  42. m_service = "DropJob";
  43. connect( job, SIGNAL( finished() ), this, SLOT( setFinished() ) );
  44. }
  45. DropJobNotifier::DropJobNotifier( QPixmap pixmap, DropJob::DropType type )
  46. : JobStatusItem()
  47. , m_job( 0 )
  48. , m_pixmap( pixmap )
  49. {
  50. init( type );
  51. }
  52. DropJobNotifier::~DropJobNotifier()
  53. {
  54. }
  55. void
  56. DropJobNotifier::init( DropJob::DropType type )
  57. {
  58. if ( type == DropJob::Playlist )
  59. m_type = tr( "playlist" );
  60. if ( type == DropJob::Artist )
  61. m_type = tr( "artist" );
  62. if ( type == DropJob::Track )
  63. m_type = tr( "track" );
  64. if ( type == DropJob::Album )
  65. m_type = tr( "album" );
  66. }
  67. QString
  68. DropJobNotifier::rightColumnText() const
  69. {
  70. return QString();
  71. }
  72. QPixmap
  73. DropJobNotifier::icon() const
  74. {
  75. return m_pixmap;
  76. }
  77. QString
  78. DropJobNotifier::mainText() const
  79. {
  80. if ( m_service.isEmpty() )
  81. {
  82. return tr( "Fetching %1 from database" ).arg( m_type );
  83. }
  84. else
  85. {
  86. return tr( "Parsing %1 %2" ).arg( m_service )
  87. .arg( m_type );
  88. }
  89. }
  90. void
  91. DropJobNotifier::setFinished()
  92. {
  93. emit finished();
  94. }