File indexing completed on 2024-05-05 04:53:18

0001 /*
0002     SPDX-FileCopyrightText: 2023 Julius Künzel <jk.kdedev@smartlab.uber.space>
0003     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #pragma once
0007 
0008 #include "abstractmodel/abstracttreemodel.hpp"
0009 
0010 #include "doc/documentchecker.h"
0011 
0012 #include <vector>
0013 
0014 class DocumentCheckerTreeModel : public AbstractTreeModel
0015 {
0016     Q_OBJECT
0017 
0018 protected:
0019     explicit DocumentCheckerTreeModel(QObject *parent = nullptr);
0020 
0021 public:
0022     static std::shared_ptr<DocumentCheckerTreeModel> construct(const std::vector<DocumentChecker::DocumentResource> &items, QObject *parent = nullptr);
0023 
0024     void removeItem(const QModelIndex &ix);
0025     void slotSearchRecursively(const QString &newpath);
0026     void usePlaceholdersForMissing();
0027     void setItemsNewFilePath(const QModelIndex &ix, const QString &url, DocumentChecker::MissingStatus status, bool refresh = true);
0028     void setItemsFileHash(const QModelIndex &index, const QString &hash);
0029 
0030     QVariant data(const QModelIndex &index, int role) const override;
0031 
0032     QList<DocumentChecker::DocumentResource> getDocumentResources() { return m_resourceItems.values(); }
0033     DocumentChecker::DocumentResource getDocumentResource(const QModelIndex &index);
0034     // This is reimplemented to allow selection of the categories
0035     Qt::ItemFlags flags(const QModelIndex &index) const override;
0036 
0037     bool isEmpty() { return m_resourceItems.isEmpty(); }
0038 
0039 private:
0040     QMap<int, DocumentChecker::DocumentResource> m_resourceItems;
0041 
0042 Q_SIGNALS:
0043     void searchProgress(int current, int total);
0044     void searchDone();
0045 };