Sayonara Player
FileOperations.h
1 /* FileOperations.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef FILEOPERATIONS_H
24 #define FILEOPERATIONS_H
25 
26 #include "Utils/Pimpl.h"
27 
28 #include <QThread>
29 
30 class QString;
31 class QStringList;
32 
33 class DirectoryCopyThread : public QThread
34 {
35  Q_OBJECT
36  PIMPL(DirectoryCopyThread)
37 
38 public:
39  DirectoryCopyThread(QObject* parent, LibraryId target_library_id, const QStringList& source_dirs, const QString& target_dir);
41 
42  LibraryId target_library() const;
43 
44 protected:
45  void run() override;
46 };
47 
48 class FileCopyThread : public QThread
49 {
50  Q_OBJECT
51  PIMPL(FileCopyThread)
52 
53 public:
54  FileCopyThread(QObject* parent, LibraryId target_library_id, const QStringList& source_files, const QString& target_dir);
55  ~FileCopyThread();
56 
57  LibraryId target_library() const;
58 
59 protected:
60  void run() override;
61 };
62 
63 
64 class FileOperations : public QObject
65 {
66  Q_OBJECT
67 
68 signals:
69  void sig_copy_finished();
70  void sig_copy_started();
71 
72 public:
73  explicit FileOperations(QObject *parent = 0);
74  ~FileOperations();
75 
76  bool move_dirs(const QStringList& source_dirs, const QString& target_dir);
77  bool copy_dirs(const QStringList& source_dirs, const QString& target_dir);
78  bool rename_dir(const QString& source_dir, const QString& target_dir);
79 
80  bool move_files(const QStringList& files, const QString& target_dir);
81  bool copy_files(const QStringList& files, const QString& target_dir);
82 
83  bool rename_file(const QString& old_name, const QString& new_name);
84 
85 private slots:
86  void copy_dir_thread_finished();
87  void copy_file_thread_finished();
88 
89 };
90 
91 #endif // FILEOPERATIONS_H
Definition: FileOperations.h:64
Definition: FileOperations.h:33
Definition: FileOperations.h:48