mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Show job status for indexing
This commit is contained in:
parent
0d9e248dac
commit
6b68598d1d
@ -39,6 +39,7 @@ set( libGuiSources
|
||||
jobview/TransferStatusItem.cpp
|
||||
jobview/LatchedStatusItem.cpp
|
||||
jobview/ErrorStatusMessage.cpp
|
||||
jobview/IndexingJobItem.cpp
|
||||
|
||||
infobar/infobar.cpp
|
||||
|
||||
@ -278,6 +279,7 @@ set( libGuiHeaders
|
||||
jobview/TransferStatusItem.h
|
||||
jobview/LatchedStatusItem.h
|
||||
jobview/ErrorStatusMessage.h
|
||||
jobview/IndexingJobItem.h
|
||||
|
||||
thirdparty/Qocoa/qsearchfield.h
|
||||
)
|
||||
|
@ -21,14 +21,26 @@
|
||||
#include "databaseimpl.h"
|
||||
#include "tomahawksqlquery.h"
|
||||
#include "utils/logger.h"
|
||||
#include "jobview/IndexingJobItem.h"
|
||||
#include "jobview/JobStatusView.h"
|
||||
#include "jobview/JobStatusModel.h"
|
||||
|
||||
#include <QSqlRecord>
|
||||
|
||||
|
||||
DatabaseCommand_UpdateSearchIndex::DatabaseCommand_UpdateSearchIndex()
|
||||
: DatabaseCommand()
|
||||
, m_statusJob( new IndexingJobItem )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Updating index.";
|
||||
|
||||
JobStatusView::instance()->model()->addJob( m_statusJob );
|
||||
}
|
||||
|
||||
|
||||
DatabaseCommand_UpdateSearchIndex::~DatabaseCommand_UpdateSearchIndex()
|
||||
{
|
||||
m_statusJob->done();
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +60,7 @@ DatabaseCommand_UpdateSearchIndex::indexTable( DatabaseImpl* db, const QString&
|
||||
value = "";
|
||||
for ( int v = 1; v < q.record().count(); v++ )
|
||||
value += q.value( v ).toString() + " ";
|
||||
|
||||
|
||||
fields.insert( q.value( 0 ).toUInt(), value.trimmed() );
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,14 @@
|
||||
#include "databasecommand.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
class IndexingJobItem;
|
||||
|
||||
class DLLEXPORT DatabaseCommand_UpdateSearchIndex : public DatabaseCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DatabaseCommand_UpdateSearchIndex();
|
||||
virtual ~DatabaseCommand_UpdateSearchIndex();
|
||||
|
||||
virtual QString commandname() const { return "updatesearchindex"; }
|
||||
virtual bool doesMutates() const { return true; }
|
||||
@ -39,6 +42,7 @@ private:
|
||||
void indexTable( DatabaseImpl* db, const QString& table, const QString& query );
|
||||
|
||||
QString table;
|
||||
IndexingJobItem* m_statusJob;
|
||||
};
|
||||
|
||||
#endif // DATABASECOMMAND_UPDATESEARCHINDEX_H
|
||||
|
47
src/libtomahawk/jobview/IndexingJobItem.cpp
Normal file
47
src/libtomahawk/jobview/IndexingJobItem.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "IndexingJobItem.h"
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
static QPixmap* s_indexIcon = 0;
|
||||
|
||||
|
||||
QString
|
||||
IndexingJobItem::mainText() const
|
||||
{
|
||||
return tr( "Indexing database" );
|
||||
}
|
||||
|
||||
QPixmap
|
||||
IndexingJobItem::icon() const
|
||||
{
|
||||
if ( s_indexIcon == 0 )
|
||||
s_indexIcon = new QPixmap( RESPATH "images/view-refresh.png" );
|
||||
|
||||
return *s_indexIcon;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IndexingJobItem::done()
|
||||
{
|
||||
emit finished();
|
||||
}
|
||||
|
39
src/libtomahawk/jobview/IndexingJobItem.h
Normal file
39
src/libtomahawk/jobview/IndexingJobItem.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INDEXINGJOBITEM_H
|
||||
#define INDEXINGJOBITEM_H
|
||||
|
||||
#include <jobview/JobStatusItem.h>
|
||||
|
||||
|
||||
class IndexingJobItem : public JobStatusItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IndexingJobItem() {}
|
||||
|
||||
void done();
|
||||
|
||||
virtual QString rightColumnText() const { return QString(); }
|
||||
virtual QString mainText() const;
|
||||
virtual QPixmap icon() const;
|
||||
virtual QString type() const { return "indexerjob"; }
|
||||
};
|
||||
|
||||
#endif // INDEXINGJOBITEM_H
|
Loading…
x
Reference in New Issue
Block a user