| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #ifndef __FRMSCAN__H__ |
| 16 | #define __FRMSCAN__H__ |
| 17 | |
| 18 | #include "ui_frmscan.h" |
| 19 | |
| 20 | #include "config/scanconfig.h" |
| 21 | #include "config/staticconfig.h" |
| 22 | |
| 23 | #include "qnapiopendialog.h" |
| 24 | #include "qnapithread.h" |
| 25 | |
| 26 | #include "frmsummary.h" |
| 27 | |
| 28 | #include <QSet> |
| 29 | #include <QSharedPointer> |
| 30 | #include <QtWidgets> |
| 31 | |
| 32 | class ScanFilesThread : public QNapiThread { |
| 33 | Q_OBJECT |
| 34 | public: |
| 35 | ScanFilesThread(); |
| 36 | void run(); |
| 37 | void setSearchPath(const QString &path) { searchPath = path; } |
| 38 | void setFilters(const QString &filters) { scanFilters = filters.split(" "); } |
| 39 | void setSkipFilters(const QString &filters) { |
| 40 | skipFilters = filters.split(" "); |
| 41 | } |
| 42 | void setSkipIfSubtitlesExists(bool skip) { skipIfSubtitlesExists = skip; } |
| 43 | void setFollowSymLinks(bool follow) { followSymLinks = follow; } |
| 44 | |
| 45 | QStringList fileList; |
| 46 | |
| 47 | signals: |
| 48 | void addFile(const QString &fileName); |
| 49 | void scanFinished(bool result); |
| 50 | void folderChange(const QString &folder); |
| 51 | |
| 52 | private: |
| 53 | bool doScan(const QString &path, QDir::Filters filters); |
| 54 | |
| 55 | QSharedPointer<const StaticConfig> staticConfig; |
| 56 | QString searchPath; |
| 57 | QStringList scanFilters, skipFilters; |
| 58 | bool skipIfSubtitlesExists, followSymLinks; |
| 59 | QSet<QString> visited; |
| 60 | }; |
| 61 | |
| 62 | class frmScan : public QDialog { |
| 63 | Q_OBJECT |
| 64 | |
| 65 | public: |
| 66 | frmScan(QWidget *parent = 0, Qt::WindowFlags f = 0); |
| 67 | ~frmScan(); |
| 68 | |
| 69 | void setInitDir(const QString &dir); |
| 70 | |
| 71 | QStringList getSelectedFiles() { return selectedFiles; } |
| 72 | |
| 73 | public slots: |
| 74 | |
| 75 | void accept(); |
| 76 | |
| 77 | private: |
| 78 | void closeEvent(QCloseEvent *event); |
| 79 | void keyPressEvent(QKeyEvent *event); |
| 80 | |
| 81 | Ui::frmScan ui; |
| 82 | const ScanConfig scanConfig; |
| 83 | ScanFilesThread scanThread; |
| 84 | |
| 85 | QIcon iconFilm; |
| 86 | QStringList selectedFiles; |
| 87 | |
| 88 | private slots: |
| 89 | |
| 90 | void selectDirectory(); |
| 91 | void leDirectoryTextChanged(); |
| 92 | void pbScanClicked(); |
| 93 | void addFile(const QString &fileName); |
| 94 | void folderChange(const QString &dirName); |
| 95 | void scanFinished(); |
| 96 | void enableControlWidgets(bool enable); |
| 97 | void enableFilesWidgets(bool enable); |
| 98 | void lwMoviesClicked(QListWidgetItem *item); |
| 99 | void pbSelectAllClicked(); |
| 100 | void pbUnselectAllClicked(); |
| 101 | void pbInvertSelectionClicked(); |
| 102 | void checkPbGetEnabled(); |
| 103 | }; |
| 104 | |
| 105 | #endif |