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 DirectoryCopyThread : public QThread
31 {
32  Q_OBJECT
33  PIMPL(DirectoryCopyThread)
34 
35 public:
36  DirectoryCopyThread(QObject* parent, LibraryId target_library_id, const QStringList& source_dirs, const QString& target_dir);
38 
39  LibraryId target_library() const;
40 
41 protected:
42  void run() override;
43 };
44 
45 class FileCopyThread : public QThread
46 {
47  Q_OBJECT
48  PIMPL(FileCopyThread)
49 
50 public:
51  FileCopyThread(QObject* parent, LibraryId target_library_id, const QStringList& source_files, const QString& target_dir);
52  ~FileCopyThread();
53 
54  LibraryId target_library() const;
55 
56 protected:
57  void run() override;
58 };
59 
60 
61 class FileOperations : public QObject
62 {
63  Q_OBJECT
64 
65 signals:
66  void sig_copy_finished();
67  void sig_copy_started();
68 
69 public:
70  explicit FileOperations(QObject *parent = 0);
71  ~FileOperations();
72 
73  bool move_dirs(const QStringList& source_dirs, const QString& target_dir);
74  bool copy_dirs(const QStringList& source_dirs, const QString& target_dir);
75  bool rename_dir(const QString& source_dir, const QString& target_dir);
76 
77  bool move_files(const QStringList& files, const QString& target_dir);
78  bool copy_files(const QStringList& files, const QString& target_dir);
79 
80  bool rename_file(const QString& old_name, const QString& new_name);
81 
82 private slots:
83  void copy_dir_thread_finished();
84  void copy_file_thread_finished();
85 
86 };
87 
88 #endif // FILEOPERATIONS_H
Definition: FileOperations.h:61
Definition: FileOperations.h:30
Definition: FileOperations.h:45