File indexing completed on 2024-04-28 05:49:10
0001 /* This file is part of the Kate project. 0002 * 0003 * SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "kateproject.h" 0011 0012 #include <QHash> 0013 #include <QRunnable> 0014 0015 class QDir; 0016 class KateProjectItem; 0017 0018 /** 0019 * Class representing a project background worker. 0020 * This worker will build up the model for the project on load and do other stuff in the background. 0021 */ 0022 class KateProjectWorker : public QObject, public QRunnable 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** 0028 * Type for QueuedConnection 0029 */ 0030 typedef QHash<QString, KateProjectItem *> MapString2Item; 0031 0032 explicit KateProjectWorker(const QString &baseDir, const QString &indexDir, const QVariantMap &projectMap, bool force); 0033 0034 void run() override; 0035 0036 static QStandardItem *directoryParent(const QDir &base, QHash<QString, QStandardItem *> &dir2Item, QString path); 0037 0038 Q_SIGNALS: 0039 void loadDone(KateProjectSharedQStandardItem topLevel, KateProjectSharedQHashStringItem file2Item); 0040 void loadIndexDone(KateProjectSharedProjectIndex index); 0041 0042 private: 0043 /** 0044 * Load one project inside the project tree. 0045 * Fill data from JSON storage to model and recurse to sub-projects. 0046 * @param parent parent standard item in the model 0047 * @param project variant map for this group 0048 * @param file2Item mapping file => item, will be filled 0049 */ 0050 void loadProject(QStandardItem *parent, const QVariantMap &project, QHash<QString, KateProjectItem *> *file2Item, const QString &baseDir); 0051 0052 /** 0053 * Load one files entry in the current parent item. 0054 * @param parent parent standard item in the model 0055 * @param filesEntry one files entry specification to load 0056 * @param file2Item mapping file => item, will be filled 0057 */ 0058 void loadFilesEntry(QStandardItem *parent, const QVariantMap &filesEntry, QHash<QString, KateProjectItem *> *file2Item, const QString &baseDir); 0059 0060 static QList<QString> findFiles(const QDir &dir, const QVariantMap &filesEntry); 0061 0062 static QList<QString> filesFromGit(const QDir &dir, bool recursive); 0063 static QList<QString> filesFromMercurial(const QDir &dir, bool recursive); 0064 static QList<QString> filesFromSubversion(const QDir &dir, bool recursive); 0065 static QList<QString> filesFromDarcs(const QDir &dir, bool recursive); 0066 static QList<QString> filesFromFossil(const QDir &dir, bool recursive); 0067 static QList<QString> filesFromDirectory(QDir dir, bool recursive, bool hidden, const QStringList &filters); 0068 0069 static QList<QString> gitFiles(const QDir &dir, bool recursive, const QStringList &args); 0070 0071 private: 0072 /** 0073 * project base directory name 0074 */ 0075 const QString m_baseDir; 0076 0077 /** 0078 * index directory 0079 */ 0080 const QString m_indexDir; 0081 0082 const QVariantMap m_projectMap; 0083 const bool m_force; 0084 };