summaryrefslogtreecommitdiffstats
path: root/buildtools/qmake/qmakescopeitem.h
blob: b2c84345b3c6d2c2eb2898170b6df5eff23146fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
*   Copyright (C) 2006 by Andreas Pakulat                                 *
*   apaku@gmx.de                                                          *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/

#ifndef _QMAKESCOPEITEM_H_
#define _QMAKESCOPEITEM_H_

#include <qlistview.h>
#include <qstring.h>

class Scope;
class QMakeScopeItem;
class FileItem;
class TrollProjectWidget;

/**
 * Base class for all items appearing in ProjectOverview and ProjectDetails.
 */
class qProjectItem : public QListViewItem
{
public:
    enum Type { Subproject, Group, File };

    qProjectItem( Type type, QListView *parent, const QString &text );
    qProjectItem( Type type, qProjectItem *parent, const QString &text );

    QString scopeString;
    Type type()
    { return typ; }

private:
    Type typ;
    void init();

};


class GroupItem : public qProjectItem
{
public:
    enum GroupType {NoType, Sources, Headers, Forms, Distfiles, Images, Resources, Lexsources, Yaccsources, Translations, IDLs, InstallRoot, InstallObject, MaxTypeEnum };

    static GroupType groupTypeForExtension( const QString &ext );
    static void groupTypeMeanings( GroupItem::GroupType type, QString& title, QString& ext );

    GroupItem( QListView *lv, GroupType type, const QString &text, QMakeScopeItem* spitem );

    void removeFileFromScope( const QString& filename);
    void addFileToScope( const QString& filename);
    void addInstallObject( const QString& objectname);
    void removeInstallObject( GroupItem* item );

    // qmake INSTALLS support
    QPtrList<GroupItem> installs;
    QPtrList<FileItem> files;

//     QStringList str_files;
//     QStringList str_files_exclude;
    // end qmake INSTALLS support
    GroupType groupType;
    QMakeScopeItem* owner;

protected:
    void paintCell( QPainter* p, const QColorGroup& cg, int column, int width, int align );
};


// Not sure if this complexity is really necessary...
class FileItem : public qProjectItem
{
public:
    FileItem( QListView *lv, const QString &text );

    QString uiFileLink;
    QString localFilePath;
};

/**
 * Stores one Scope
 */
class QMakeScopeItem : public qProjectItem
{
public:
    QMakeScopeItem( QListView *parent, const QString &text, Scope *s, TrollProjectWidget* widget );
    QMakeScopeItem( QMakeScopeItem *parent, const QString &text, Scope* );
    void updateValues( const QString& var, const QStringList& values );
    void addValue( const QString& var, const QString& value );
    void removeValue( const QString& var, const QString& value );
    void addValues( const QString& var, const QStringList& values );
    void removeValues( const QString& var, const QStringList& values );
    void disableSubprojects( const QStringList& );
    void reloadProject();
    int compare( QListViewItem* i, int col, bool ascending ) const;
    ~QMakeScopeItem();

    QMap<GroupItem::GroupType, GroupItem*> groups;

    Scope* scope;
    QString relativePath();
    QString getLibAddPath( QString );
    QString getLibAddObject( QString );
    QString getSharedLibAddObject( QString );
    QString getApplicationObject( QString );
    QString getIncAddPath( QString downDirs );
    FileItem* createFileItem(const QString& file);
    GroupItem* createGroupItem(GroupItem::GroupType type, const QString& name, QMakeScopeItem* scopeitem);
    QMap<QString, QString> getLibInfos( QString );

    QMakeScopeItem* projectFileItem();

    TrollProjectWidget* m_widget;
private:
    void init();
    void buildSubTree();
    void buildGroups();
};


#endif

// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on