[companion] Adjust GVAR not possible in global functions (fix #5425)
[opentx.git] / companion / src / process_sync.h
blob636b3b9b8e2d48be075cf2691fe4f8dedc8e9e81
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _PROCESS_SYNC_H_
22 #define _PROCESS_SYNC_H_
24 #include <QObject>
25 #include <QDir>
26 #include <QMutex>
27 #include <QString>
29 class SyncProcess : public QObject
31 Q_OBJECT
33 public:
34 enum SyncDirection {
35 SYNC_A2B_B2A,
36 SYNC_B2A_A2B,
37 SYNC_A2B,
38 SYNC_B2A
41 enum SyncCompareType {
42 OVERWR_NEWER_IF_DIFF,
43 OVERWR_NEWER_ALWAYS,
44 OVERWR_IF_DIFF,
45 OVERWR_ALWAYS
48 SyncProcess(const QString & folderA,
49 const QString & folderB,
50 const int & syncDirection = SYNC_A2B_B2A,
51 const int & compareType = OVERWR_NEWER_IF_DIFF,
52 const qint64 & maxFileSize = 5*1024*1024,
53 const bool dryRun = false);
55 public slots:
56 void run();
57 void stop();
59 signals:
60 void started();
61 void finished();
62 void fileCountChanged(int count);
63 void progressStep(int step);
64 void progressMessage(const QString & text, const int & type);
65 void statusMessage(const QString & text);
67 protected:
68 bool isStopRequsted();
69 void finish();
70 int getFilesCount(const QString & directory);
71 void updateDir(const QString & source, const QString & destination);
72 bool updateEntry(const QString & entry, const QDir & source, const QDir & destination);
74 QString folder1;
75 QString folder2;
76 SyncDirection direction;
77 SyncCompareType ctype;
78 qint64 maxFileSize; // Bytes
79 QDir::Filters dirFilters;
80 QMutex stopReqMutex;
81 QString reportTemplate;
82 QString testRunStr;
83 int index;
84 int count;
85 int created;
86 int updated;
87 int skipped;
88 int errored;
89 bool dryRun;
90 bool stopping;
93 #endif // _PROCESS_SYNC_H_