File indexing completed on 2024-05-05 04:48:22

0001 /****************************************************************************************
0002  * Copyright (c) 2010 Ralf Engels <ralf-engels@gmx.de>                                  *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef AMAROK_SQLBATCH_IMPORTER_H
0018 #define AMAROK_SQLBATCH_IMPORTER_H
0019 
0020 #include <QObject>
0021 
0022 #include "core/meta/forward_declarations.h"
0023 
0024 class SqlBatchImporterConfig;
0025 
0026 /**
0027  * This importer will use the CollectionImportCapability to import a file.
0028  * Currently only used for the SqlCollection.
0029  */
0030 class SqlBatchImporter : public QObject
0031 {
0032     Q_OBJECT
0033 
0034     public:
0035         explicit SqlBatchImporter( QObject *parent );
0036         ~SqlBatchImporter() override;
0037 
0038         SqlBatchImporterConfig *configWidget( QWidget *parent );
0039 
0040         /**
0041          * @return whether the importer is running
0042          */
0043         bool importing() const;
0044 
0045         /**
0046          * Starts the importing process
0047          */
0048         void startImporting();
0049 
0050         /**
0051          * @returns the number of tracks imported
0052          */
0053         int importedCount() const;
0054 
0055     Q_SIGNALS:
0056         void importFailed();
0057         void importSucceeded();
0058         void importError( const QString& );
0059         void showMessage( const QString& );
0060         void trackAdded( Meta::TrackPtr );
0061         void trackDiscarded( const QString& );
0062         void trackMatchFound( Meta::TrackPtr, const QString& );
0063         void trackMatchMultiple( Meta::TrackList, const QString& );
0064 
0065     protected:
0066         void import();
0067 
0068     protected Q_SLOTS:
0069         void importingFinished();
0070         void trackImported( const Meta::TrackPtr &track );
0071         void trackMatched( const Meta::TrackPtr &track, const QString &oldUrl );
0072 
0073     private:
0074         SqlBatchImporterConfig *m_config;
0075         int m_count;
0076         bool m_importing;
0077 };
0078 
0079 #endif // multiple inclusion guard