kateprojectworker.h 3.2 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 31
 * 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
32
 */
33
class KateProjectWorker : public QObject
Christoph Cullmann's avatar
Christoph Cullmann committed
34 35 36 37
{
  Q_OBJECT

  public:
Christoph Cullmann's avatar
Christoph Cullmann committed
38 39 40
    /**
     * Type for QueuedConnection
     */
41
    typedef QMap<QString, KateProjectItem *> MapString2Item;
Christoph Cullmann's avatar
Christoph Cullmann committed
42
    
Christoph Cullmann's avatar
Christoph Cullmann committed
43
    /**
44
     * construct project worker for given project
Christoph Cullmann's avatar
Christoph Cullmann committed
45 46
     * @param project our project
     */
Christoph Cullmann's avatar
Christoph Cullmann committed
47
    KateProjectWorker (QObject *project);
Christoph Cullmann's avatar
Christoph Cullmann committed
48 49

    /**
50
     * deconstruct worker
Christoph Cullmann's avatar
Christoph Cullmann committed
51
     */
52
    ~KateProjectWorker ();
Christoph Cullmann's avatar
Christoph Cullmann committed
53
    
Christoph Cullmann's avatar
Christoph Cullmann committed
54 55 56 57 58
  private Q_SLOTS:
    /**
     * 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!
59
     * @param baseDir project file name, should stay the same after initial setup
Christoph Cullmann's avatar
Christoph Cullmann committed
60 61
     * @param projectMap full map containing the whole project as copy to work on
     */
62
    void loadProject (QString baseDir, QVariantMap projectMap);
Christoph Cullmann's avatar
Christoph Cullmann committed
63 64 65 66 67 68 69 70 71
    
  private:
    /**
     * 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
     */
72
    void loadProject (QStandardItem *parent, const QVariantMap &project, QMap<QString, KateProjectItem *> *file2Item);
Christoph Cullmann's avatar
Christoph Cullmann committed
73 74 75 76 77 78 79

    /**
     * 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
     */
80
    void loadFilesEntry (QStandardItem *parent, const QVariantMap &filesEntry, QMap<QString, KateProjectItem *> *file2Item);
Christoph Cullmann's avatar
Christoph Cullmann committed
81
    
82
    /**
83 84
     * Load index for whole project.
     * @param files list of all project files to index
85
     */
86
    void loadIndex (const QStringList &files);
87
    
Christoph Cullmann's avatar
Christoph Cullmann committed
88 89
  private:
    /**
Christoph Cullmann's avatar
Christoph Cullmann committed
90 91 92 93 94
     * our project, only as QObject, we only send messages back and forth!
     */
    QObject *m_project;
    
    /**
95
     * project base directory name
Christoph Cullmann's avatar
Christoph Cullmann committed
96
     */
97
    QString m_baseDir;
Christoph Cullmann's avatar
Christoph Cullmann committed
98 99 100 101 102
};

#endif

// kate: space-indent on; indent-width 2; replace-tabs on;