mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Added IndexStatusManager, which observes indexing progress and creates a job-item accordingly.
This commit is contained in:
@@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
#include "IndexingJobItem.h"
|
#include "IndexingJobItem.h"
|
||||||
|
|
||||||
|
#include "JobStatusModel.h"
|
||||||
|
#include "JobStatusView.h"
|
||||||
|
#include "database/Database.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
@@ -29,16 +33,40 @@ IndexingJobItem::mainText() const
|
|||||||
return tr( "Indexing Music Library" );
|
return tr( "Indexing Music Library" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
IndexingJobItem::icon() const
|
IndexingJobItem::icon() const
|
||||||
{
|
{
|
||||||
return TomahawkUtils::defaultPixmap( TomahawkUtils::ViewRefresh, TomahawkUtils::Original, QSize( 128, 128 ) );
|
return TomahawkUtils::defaultPixmap( TomahawkUtils::ViewRefresh, TomahawkUtils::Original, QSize( 128, 128 ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IndexingJobItem::done()
|
void
|
||||||
|
IndexingJobItem::done()
|
||||||
{
|
{
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IndexStatusManager::IndexStatusManager( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
connect( Tomahawk::Database::instance(), SIGNAL( indexStarted() ), SLOT( started() ) );
|
||||||
|
connect( Tomahawk::Database::instance(), SIGNAL( indexReady() ), SLOT( finished() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
IndexStatusManager::started()
|
||||||
|
{
|
||||||
|
m_curItem = new IndexingJobItem;
|
||||||
|
JobStatusView::instance()->model()->addJob( m_curItem.data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
IndexStatusManager::finished()
|
||||||
|
{
|
||||||
|
if ( m_curItem )
|
||||||
|
m_curItem->done();
|
||||||
|
}
|
||||||
|
@@ -19,8 +19,9 @@
|
|||||||
#ifndef INDEXINGJOBITEM_H
|
#ifndef INDEXINGJOBITEM_H
|
||||||
#define INDEXINGJOBITEM_H
|
#define INDEXINGJOBITEM_H
|
||||||
|
|
||||||
#include <jobview/JobStatusItem.h>
|
#include "JobStatusItem.h"
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
class IndexingJobItem : public JobStatusItem
|
class IndexingJobItem : public JobStatusItem
|
||||||
{
|
{
|
||||||
@@ -37,4 +38,19 @@ public:
|
|||||||
virtual QString type() const { return "indexerjob"; }
|
virtual QString type() const { return "indexerjob"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class IndexStatusManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit IndexStatusManager( QObject* parent = 0 );
|
||||||
|
virtual ~IndexStatusManager() {}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void started();
|
||||||
|
void finished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<IndexingJobItem> m_curItem;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // INDEXINGJOBITEM_H
|
#endif // INDEXINGJOBITEM_H
|
||||||
|
Reference in New Issue
Block a user