diff --git a/src/libtomahawk/utils/dropjobnotifier.cpp b/src/libtomahawk/utils/dropjobnotifier.cpp new file mode 100644 index 000000000..2bd1dca56 --- /dev/null +++ b/src/libtomahawk/utils/dropjobnotifier.cpp @@ -0,0 +1,92 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Leo Franchi + * Copyright 2010-2011, Hugo Lindström + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "dropjobnotifier.h" + +#include "utils/logger.h" +#include "utils/tomahawkutils.h" +#include "query.h" +#include "sourcelist.h" +#include "jobview/JobStatusView.h" +#include "jobview/JobStatusModel.h" +#include "dropjob.h" +#include +#include "dropjobnotifier.h" +#include +#include + +class QNetworkReply; + +using namespace Tomahawk; + +DropJobNotifier::DropJobNotifier( QPixmap servicePixmap, QString service, DropJob::DropType type, QNetworkReply* job ) + : JobStatusItem() + , m_type( "unknown" ) + , m_job( 0 ) + , m_service ( service ) + , m_pixmap ( servicePixmap ) +{ + + if( type == DropJob::Playlist ) + m_type = "playlist"; + + if( type == DropJob::Artist ) + m_type = "artist"; + + if( type == DropJob::Track ) + m_type = "track"; + + if( type == DropJob::Album ) + m_type = "album"; + + if( m_service.isEmpty() ) + m_service = "DropJob"; + + connect( job, SIGNAL( finished() ), this, SLOT( setFinished() ) ); +} + + +DropJobNotifier::~DropJobNotifier() +{} + +QString +DropJobNotifier::rightColumnText() const +{ + return QString(); +} + +QPixmap +DropJobNotifier::icon() const +{ + return m_pixmap; +} + + +QString +DropJobNotifier::mainText() const +{ + return tr( "Parsing %1 %2" ).arg( m_service ) + .arg( m_type ); +} + +void +DropJobNotifier::setFinished() +{ + emit finished(); +} + diff --git a/src/libtomahawk/utils/dropjobnotifier.h b/src/libtomahawk/utils/dropjobnotifier.h new file mode 100644 index 000000000..3d5aa9e3d --- /dev/null +++ b/src/libtomahawk/utils/dropjobnotifier.h @@ -0,0 +1,62 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Leo Franchi + * Copyright 2010-2011, Hugo Lindström + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef DROPJOBNOTIFIER_H +#define DROPJOBNOTIFIER_H + +#include "dllmacro.h" +#include "dropjob.h" +#include "typedefs.h" +#include "query.h" +#include "jobview/JobStatusItem.h" + +#include +#include +#include + +class QNetworkReply; +namespace Tomahawk +{ + +class DLLEXPORT DropJobNotifier : public JobStatusItem +{ + Q_OBJECT +public: + + DropJobNotifier( QPixmap pixmap, QString service, DropJob::DropType type, QNetworkReply* job ); + virtual ~DropJobNotifier(); + + virtual QString rightColumnText() const; + virtual QString mainText() const; + virtual QPixmap icon() const; + virtual QString type() const { return m_type; } + virtual bool collapseItem() const { return true; } + +public slots: + void setFinished(); + +private: + QString m_type; + QNetworkReply* m_job; + QPixmap m_pixmap; + QString m_service; +}; + +} + +#endif // DROPJOBNOTIFIER_H