kateprojectworker.h 3.48 KB
Newer Older
Christoph Cullmann's avatar
Christoph Cullmann committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*  This file is part of the Kate project.
 *
 *  Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 */

21 22
#ifndef KATE_PROJECT_WORKER_H
#define KATE_PROJECT_WORKER_H
Christoph Cullmann's avatar
Christoph Cullmann committed
23

Christoph Cullmann's avatar
Christoph Cullmann committed
24 25
#include <QStandardItemModel>
#include <QMap>
Christoph Cullmann's avatar
Christoph Cullmann committed
26

Christoph Cullmann's avatar
Christoph Cullmann committed
27
#include "kateprojectitem.h"
Christoph Cullmann's avatar
Christoph Cullmann committed
28

29 30
class QDir;

Christoph Cullmann's avatar
Christoph Cullmann committed
31
/**
32 33
 * Class representing a project background worker.
 * This worker will build up the model for the project on load and do other stuff in the background.
Christoph Cullmann's avatar
Christoph Cullmann committed
34
 */
35
class KateProjectWorker : public QObject
Christoph Cullmann's avatar
Christoph Cullmann committed
36
{
37
    Q_OBJECT
Christoph Cullmann's avatar
Christoph Cullmann committed
38

39
public:
Christoph Cullmann's avatar
Christoph Cullmann committed
40 41 42
    /**
     * Type for QueuedConnection
     */
43
    typedef QMap<QString, KateProjectItem *> MapString2Item;
44

Christoph Cullmann's avatar
Christoph Cullmann committed
45
    /**
46
     * construct project worker for given project
Christoph Cullmann's avatar
Christoph Cullmann committed
47 48
     * @param project our project
     */
49
    KateProjectWorker(QObject *project);
Christoph Cullmann's avatar
Christoph Cullmann committed
50 51

    /**
52
     * deconstruct worker
Christoph Cullmann's avatar
Christoph Cullmann committed
53
     */
54 55 56
    ~KateProjectWorker();

private Q_SLOTS:
Christoph Cullmann's avatar
Christoph Cullmann committed
57 58 59 60
    /**
     * Load the project.
     * Will be used to load project in background.
     * Will inform the project after loading was done and pass over all needed data!
61
     * @param baseDir project file name, should stay the same after initial setup
Christoph Cullmann's avatar
Christoph Cullmann committed
62 63
     * @param projectMap full map containing the whole project as copy to work on
     */
64 65 66
    void loadProject(QString baseDir, QVariantMap projectMap);

private:
Christoph Cullmann's avatar
Christoph Cullmann committed
67 68 69 70 71 72 73
    /**
     * Load one project inside the project tree.
     * Fill data from JSON storage to model and recurse to sub-projects.
     * @param parent parent standard item in the model
     * @param project variant map for this group
     * @param file2Item mapping file => item, will be filled
     */
74
    void loadProject(QStandardItem *parent, const QVariantMap &project, QMap<QString, KateProjectItem *> *file2Item);
Christoph Cullmann's avatar
Christoph Cullmann committed
75 76 77 78 79 80 81

    /**
     * Load one files entry in the current parent item.
     * @param parent parent standard item in the model
     * @param filesEntry one files entry specification to load
     * @param file2Item mapping file => item, will be filled
     */
82 83
    void loadFilesEntry(QStandardItem *parent, const QVariantMap &filesEntry, QMap<QString, KateProjectItem *> *file2Item);

84
    /**
85 86
     * Load index for whole project.
     * @param files list of all project files to index
87
     */
88 89
    void loadIndex(const QStringList &files);

90 91 92 93 94 95 96
    QStringList findFiles(const QDir &dir, const QVariantMap &filesEntry);

    QStringList filesFromGit(const QDir &dir, bool recursive);
    QStringList filesFromMercurial(const QDir &dir, bool recursive);
    QStringList filesFromSubversion(const QDir &dir, bool recursive);
    QStringList filesFromDirectory(const QDir &dir, bool recursive, const QStringList &filters);

97
private:
Christoph Cullmann's avatar
Christoph Cullmann committed
98
    /**
Christoph Cullmann's avatar
Christoph Cullmann committed
99 100 101
     * our project, only as QObject, we only send messages back and forth!
     */
    QObject *m_project;
102

Christoph Cullmann's avatar
Christoph Cullmann committed
103
    /**
104
     * project base directory name
Christoph Cullmann's avatar
Christoph Cullmann committed
105
     */
106
    QString m_baseDir;
Christoph Cullmann's avatar
Christoph Cullmann committed
107 108 109 110
};

#endif