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