Debian Codegraph @

src/album/fileinotify.h

raw
1 /*
2 * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
3 *
4 * Author: ZhangYong <[email protected]>
5 *
6 * Maintainer: ZhangYong <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef FILEINOTIFY_H
22 #define FILEINOTIFY_H
23
24 #include <QThread>
25 #include <QObject>
26 #include <QMutex>
27 #include <QMap>
28 #include <QTimer>
29
30 class FileInotify : public QThread
31 {
32 Q_OBJECT
33 public:
34 explicit FileInotify(QObject *parent = nullptr);
35 ~FileInotify() override;
36
37 bool isVaild();
38 //添加和删除监控
39 void addWather(const QString &path);
40 // void removeWatcher(const QString &path);
41
42 void clear();
43 //获取监控目录所有照片
44 void getAllPicture(bool isFirst);
45 //文件数量改变
46 // void fileNumChange(); //预留,暂未使用
47 //启动时加载一次
48 void pathLoadOnce();
49
50 public slots:
51 //发送插入
52 void onNeedSendPictures();
53
54 protected:
55 void run() override;
56
57 private:
58 int m_handleId = -1;
59 int m_wd = -1;
60 bool m_running = false;
61 QMutex m_mutex;
62 QMap<QString, int> watchedDirId;
63 QStringList m_allPic; //目前所有照片
64 QStringList m_newFile; //当前新添加的
65 QString m_currentDir; //给定的当前监控路径
66 QStringList m_Supported; //支持的格式
67 QTimer *m_timer;
68 };
69
70 #endif // FILEINOTIFY_H