summaryrefslogtreecommitdiffstats
path: root/buildtools/qmake/trollprojectwidget.h
blob: 7821d075cad6fd657dadc1cc3a30a12320d2b9ee (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
/***************************************************************************
*   Copyright (C) 2001 by Bernd Gehrmann                                  *
*   [email protected]                                                    *
*   Copyright (C) 2002 by Jakob Simon-Gaarde                              *
*   [email protected]                                                          *
*   Copyright (C) 2002-2003 by Alexander Dymo                             *
*   [email protected]                                                 *
*   Copyright (C) 2003 by Thomas Hasart                                   *
*   [email protected]                                                        *
*   Copyright (C) 2006 by Andreas Pakulat                                 *
*   [email protected]                                                          *
*                                                                         *
*   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 <tqdict.h>
#include <tqlistview.h>
#include <tqmap.h>
#include <tqstrlist.h>
#include <tqvbox.h>
#include <tqtoolbutton.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdeversion.h>
#include <tqbutton.h>
#include <tqfileinfo.h>
#include <tqptrlist.h>
#include "choosesubprojectdlg.h"
#include "newwidgetdlg.h"
#include "domutil.h"
#include "qmakescopeitem.h"

class TrollProjectPart;
class TDEListView;
class ProjectConfigurationDlg;

class TrollProjectWidget : public TQVBox
{
    TQ_OBJECT
  

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

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

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

    TQString getCurrentDestDir();

    TQString getCurrentOutputFilename();

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

    TQString getUiFileLink( const TQString &path, const TQString& 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( TQFocusEvent *e );

private slots:
    void slotOverviewSelectionChanged( TQListViewItem *item );
    void slotOverviewContextMenu( TDEListView *, TQListViewItem *item, const TQPoint &p );
    void slotDetailsSelectionChanged( TQListViewItem* );
    void slotDetailsExecuted( TQListViewItem *item );
    void slotDetailsContextMenu( TDEListView *, TQListViewItem *item, const TQPoint &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 TQString& );

    void createQMakeScopeItems();

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

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

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

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

    TrollProjectWidget::SaveType dialogSaveBehaviour() const;

    QMakeScopeItem *findSubprojectForScope( QMakeScopeItem *scope );

    void reloadProjectFromFile( QMakeScopeItem* item );
    TQMap<TQString,TQString> qmakeEnvironment() const;

    TQVBox *overviewContainer;
    TDEListView *overview;
    TQHBox *projectTools;
    TQToolButton *addSubdirButton;
    TQToolButton *createScopeButton;

    TQToolButton *buildProjectButton;
    TQToolButton *rebuildProjectButton;
    TQToolButton *executeProjectButton;

    TQToolButton *buildTargetButton;
    TQToolButton *rebuildTargetButton;
    TQToolButton *executeTargetButton;

    TQToolButton *buildFileButton;
    TQToolButton *projectconfButton;

    TQVBox *detailContainer;
    TDEListView *details;
    TQHBox *fileTools;
    TQToolButton *addfilesButton;
    TQToolButton *newfileButton;
    TQToolButton *removefileButton;
    TQToolButton *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;
    TQStringList m_allFilesCache;

    friend class ChooseSubprojectDlg;
    friend class ProjectConfigurationDlg;
};

#endif