summaryrefslogtreecommitdiffstats
path: root/buildtools/qmake/trollprojectwidget.h
blob: 19595f7895d44b1d0ffb653d441dcea1cb3830db (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/***************************************************************************
*   Copyright (C) 2001 by Bernd Gehrmann                                  *
*   bernd@kdevelop.org                                                    *
*   Copyright (C) 2002 by Jakob Simon-Gaarde                              *
*   jakob@jsg.dk                                                          *
*   Copyright (C) 2002-2003 by Alexander Dymo                             *
*   cloudtemple@mksat.net                                                 *
*   Copyright (C) 2003 by Thomas Hasart                                   *
*   thasart@gmx.de                                                        *
*   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 _TROLLPROJECTWIDGET_H_
#define _TROLLPROJECTWIDGET_H_

#include <qdict.h>
#include <qlistview.h>
#include <qmap.h>
#include <qstrlist.h>
#include <qvbox.h>
#include <qtoolbutton.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kdeversion.h>
#include <qbutton.h>
#include <qfileinfo.h>
#include <qptrlist.h>
#include "choosesubprojectdlg.h"
#include "newwidgetdlg.h"
#include "domutil.h"
#include "qmakescopeitem.h"

class TrollProjectPart;
class KListView;
class ProjectConfigurationDlg;

class TrollProjectWidget : public QVBox
{
    Q_OBJECT

public:
    TrollProjectWidget( TrollProjectPart *part );
    ~TrollProjectWidget();

    void openProject( const QString &dirName );
    void closeProject();

    /**
     * A list of the (relative) names of all subprojects (== subdirectories).
     */
    //QStringList allSubprojects();
    /**
     * A list of the (relative) names of all libraries.
     */
    QStringList allLibraries();
    /**
     * A list of all files that belong to the project.
     **/
    QStringList allFiles();
    /**
     * The top level directory of the project.
     **/
    QString projectDirectory();
    /**
     * The directory of the currently active subproject.
     */
    QString subprojectDirectory();
    /**
     * The directory of the currently active subproject.
     */
    QString getCurrentTarget();

    QString getCurrentDestDir();

    QString getCurrentOutputFilename();

    void addFileToCurrentSubProject( GroupItem *titem, const QString &filename );
    void addFileToCurrentSubProject( GroupItem::GroupType gtype, const QString &filename );
    void addFiles( QStringList &files, bool relativeToProjectRoot = true );
    void emitAddedFile( const QString &name );
    void emitRemovedFile( const QString &name );

    QString getUiFileLink( const QString &path, const QString& filename );
    bool isTMakeProject();

    enum TrollProjectView { SubprojectView, DetailsView };
    void setLastFocusedView( TrollProjectView view );
    enum SaveType { AlwaysSave, NeverSave, Ask };
    QMakeScopeItem* currentSubproject();

    bool showFilenamesOnly() const;
    bool showVariablesInTree() const;

public slots:
    void slotBuildTarget();
    void slotInstallTarget();
    void slotRebuildTarget();
    void slotCleanTarget();
    void slotDistCleanTarget();
    void slotExecuteTarget();

    void slotBuildProject();
    void slotInstallProject();
    void slotRebuildProject();
    void slotCleanProject();
    void slotDistCleanProject();
    void slotExecuteProject();

    void slotBuildOpenFile();
    void slotBuildSelectedFile();

    void slotConfigureProject();
    void slotAddFiles();
    void slotNewFile();
    void slotRemoveFile();

protected:
    virtual void focusInEvent( QFocusEvent *e );

private slots:
    void slotOverviewSelectionChanged( QListViewItem *item );
    void slotOverviewContextMenu( KListView *, QListViewItem *item, const QPoint &p );
    void slotDetailsSelectionChanged( QListViewItem* );
    void slotDetailsExecuted( QListViewItem *item );
    void slotDetailsContextMenu( KListView *, QListViewItem *item, const QPoint &p );
    void slotExcludeFileFromScopeButton();
    void slotAddSubproject( QMakeScopeItem *spitem = 0 );
    void slotRemoveSubproject( QMakeScopeItem *spitem = 0 );
    void slotCreateScope( QMakeScopeItem *spitem = 0 );
    void slotRemoveScope( QMakeScopeItem *spitem = 0 );
    void slotDisableSubproject( QMakeScopeItem* spitem = 0 );
    void slotProjectDirty( const QString& );

    void createQMakeScopeItems();

private:
    void cleanDetailView( QMakeScopeItem *item );
    void runClean( QMakeScopeItem*, const QString& );
    void buildProjectDetailTree( QMakeScopeItem *item, KListView *listviewControl );
    void removeFile( QMakeScopeItem *spitem, FileItem *fitem );
    void addSubprojectToItem( QMakeScopeItem*, const QString& );
    void setupContext();
    //     void parseScope(QMakeScopeItem *item,QString scopeString, Scope *scope);
    GroupItem* getInstallRoot( QMakeScopeItem *item );
    GroupItem* getInstallObject( QMakeScopeItem *item, const QString& objectname );
    QString constructMakeCommandLine( Scope* s = 0 );

    void createMakefileIfMissing( const QString &dir, QMakeScopeItem *item );

    void runQMakeRecursive( QMakeScopeItem* proj);
    void buildFile( QMakeScopeItem* spitem, FileItem* fitem);

    /*fileName: full base file name like QFileInfo::baseName ( true )*/
    QPtrList<QMakeScopeItem> findSubprojectForFile( QFileInfo fi );
    void findSubprojectForFile( QPtrList<QMakeScopeItem> &list, QMakeScopeItem * item, QString absFilePath );
    QMakeScopeItem* findSubprojectForPath( const QString& );
    //    QString makeEnvironment();

    TrollProjectWidget::SaveType dialogSaveBehaviour() const;

    QMakeScopeItem *findSubprojectForScope( QMakeScopeItem *scope );

    void reloadProjectFromFile( QMakeScopeItem* item );
    QMap<QString,QString> qmakeEnvironment() const;

    QVBox *overviewContainer;
    KListView *overview;
    QHBox *projectTools;
    QToolButton *addSubdirButton;
    QToolButton *createScopeButton;

    QToolButton *buildProjectButton;
    QToolButton *rebuildProjectButton;
    QToolButton *executeProjectButton;

    QToolButton *buildTargetButton;
    QToolButton *rebuildTargetButton;
    QToolButton *executeTargetButton;

    QToolButton *buildFileButton;
    QToolButton *projectconfButton;

    QVBox *detailContainer;
    KListView *details;
    QHBox *fileTools;
    QToolButton *addfilesButton;
    QToolButton *newfileButton;
    QToolButton *removefileButton;
    QToolButton *excludeFileFromScopeButton;

    DomUtil::PairList m_subclasslist;
    QMakeScopeItem *m_shownSubproject;
    QMakeScopeItem *m_rootSubproject;
    Scope* m_rootScope;
    TrollProjectPart *m_part;
    ProjectConfigurationDlg* m_configDlg;

    TrollProjectView m_lastFocusedView;

    bool m_filesCached;
    bool m_showFilenamesOnly;
    bool m_showVariablesInTree;
    QStringList m_allFilesCache;

    friend class ChooseSubprojectDlg;
    friend class ProjectConfigurationDlg;
};

#endif

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