MissingFilesModel.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. Copyright (C) 2019 by Dillon Pentz <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <QAbstractTableModel>
  16. #include <QIcon>
  17. // TODO: Fix redefinition error of due to clash with enums defined in importer code.
  18. enum MissingFilesRole { EntryStateRole = Qt::UserRole, NewPathsToProcessRole };
  19. // TODO: Fix redefinition error of due to clash with enums defined in importer code.
  20. enum MissingFilesColumn { Source, OriginalPath, NewPath, State, Count };
  21. enum MissingFilesState { Missing, Found, Replaced, Cleared };
  22. Q_DECLARE_METATYPE(MissingFilesState);
  23. class MissingFilesModel : public QAbstractTableModel {
  24. Q_OBJECT
  25. friend class OBSMissingFiles;
  26. public:
  27. explicit MissingFilesModel(QObject *parent = 0);
  28. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  29. int columnCount(const QModelIndex &parent = QModelIndex()) const;
  30. int found() const;
  31. QVariant data(const QModelIndex &index, int role) const;
  32. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
  33. Qt::ItemFlags flags(const QModelIndex &index) const;
  34. bool setData(const QModelIndex &index, const QVariant &value, int role);
  35. bool allFilesFound = false;
  36. int recursionLevel = 0;
  37. QIcon warningIcon;
  38. private:
  39. struct MissingFileEntry {
  40. MissingFilesState state = MissingFilesState::Missing;
  41. QString source;
  42. QString originalPath;
  43. QString newPath;
  44. };
  45. QList<MissingFileEntry> files;
  46. void findAllFilesInPath(const QString &path, bool skipPrompt);
  47. void fileCheckLoop(const QString &path, bool skipPrompt, int depth);
  48. };