kateprojectitem.h 2.18 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*  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.
 */

#ifndef KATE_PROJECT_ITEM_H
#define KATE_PROJECT_ITEM_H

24
#include <KTextEditor/ModificationInterface>
25
#include <QStandardItem>
26

27
28
29
30
namespace KTextEditor
{
class Document;

31
}
32
33
34
35
36
37
38

/**
 * Class representing a item inside a project.
 * Items can be: projects, directories, files
 */
class KateProjectItem : public QStandardItem
{
39
public:
40
41
42
    /**
     * Possible Types
     */
43
    enum Type { Project, Directory, File };
44

45
46
47
48
49
    /**
     * construct new item with given text
     * @param type type for this item
     * @param text text for this item
     */
50
    KateProjectItem(Type type, const QString &text);
51
52
53
54

    /**
     * deconstruct project
     */
Kevin Funk's avatar
Kevin Funk committed
55
    ~KateProjectItem() override;
56

57
    /**
Yuri Chornoivan's avatar
Yuri Chornoivan committed
58
     * Overwritten data method for on-demand icon creation and co.
59
60
61
     * @param role role to get data for
     * @return data for role
     */
Kevin Funk's avatar
Kevin Funk committed
62
    QVariant data(int role = Qt::UserRole + 1) const override;
63

Michal Humpula's avatar
Michal Humpula committed
64
65
public:
    void slotModifiedChanged(KTextEditor::Document *);
66
    void slotModifiedOnDisk(KTextEditor::Document *document, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
Michal Humpula's avatar
Michal Humpula committed
67
68
69
70

private:
    QIcon *icon() const;

71
private:
72
73
74
75
    /**
     * type
     */
    const Type m_type;
76

77
78
79
    /**
     * cached icon
     */
80
    mutable QIcon *m_icon;
Dominik Haumann's avatar
Dominik Haumann committed
81

82
83
84
    /**
     * for document icons
     */
Michal Humpula's avatar
Michal Humpula committed
85
    QString m_emblem;
86
87
88
};

#endif