/***************************************************************************
 *   Copyright (C) 2007-2011 by Vegeta                                     *
 *                                                                         *
 *   This program 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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef RENAMEFILES_H
#define RENAMEFILES_H

#include <QWidget>
#include <QHash>

class QProcess;
class CoverDownload;

class folderRenamingClass{
public:
    QString currentPath;
    QHash <QString, QString> renameFolderList; // Oldname -> Newname
};

class renameFiles : public QWidget
{
    Q_OBJECT
public:
    explicit renameFiles(QWidget *parent = 0);
    ~renameFiles();

    void startRenaming(QList<QString> &Files, bool isRenameFiles, bool isRenameFolders, bool isDownload, QString renamePatternFolders, QString renamePatternFiles, int SearchEngine);
    void cancelAllOperations();

private:
    CoverDownload *CoverDownloader;
    folderRenamingClass folderRenamingInfo;
    QProcess *ID3Process;
    QList<QString> allFiles;
    QString currentFileName;
    QString folderTemplate;
    QString fileTemplate;
    bool isAutorenameFiles;
    bool isAutorenameFolders;
    bool isDownloadCovers;
    bool isCancelAllJobs;
    int searchEngine;
    int Counter;
    int Skipped;

    void readID3Tags();
    void executeRenameFolders();
    QString searchRegExp(QString searchValue, QString &Buffer);


public slots:
    void processID3Tags();
    void updateDownloadInfos();
    void allDownloadsFinished();

signals:
    void signal_addToErrorlog(QString Error);
    void signal_allJobsFinished();
    void signal_updateDownloadInfos(QString Statustext,
                                    QString Foldertext,
                                    QString Filetext,
                                    int ToDo,
                                    int Error,
                                    int Skipped,
                                    int Gained,
                                    int progressBarValue,
                                    int progressBarMax,
                                    bool setDownloadIcon);

};

#endif // RENAMEFILES_H
