summaryrefslogtreecommitdiffstats
path: root/buildtools/autotools/autoprojectwidget.h
blob: ff79ce71ad0a64eca1592f6d87b7d6455250bfc2 (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
219
220
221
222
223
224
225
226
227
228
229
/*
  KDevelop Autotools Support
  Copyright (c) 2001-2002 by Bernd Gehrmann <[email protected]>
  Copyright (c) 2002 by Victor Roeder <[email protected]>
  Copyright (c) 2005 by Matt Rogers <[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 _AUTOPROJECTWIDGET_H_
#define _AUTOPROJECTWIDGET_H_

#include <tqdict.h>
#include <tqlistview.h>
#include <tqmap.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqlayout.h>
#include <tqtoolbutton.h>
#include <kiconloader.h>
#include <klocale.h>

#include "domutil.h"
#include "makefilehandler.h"

class AutoProjectPart;
class AutoSubprojectView;
class AutoDetailsView;
class SubprojectItem;
class TargetItem;
class FileItem;
class KAction;
class TQDomElement;
class TQToolButton;
class TQStringList;
class TQFocusEvent;
class KListViewItem;
class TQListViewItem;
class MakefileHandler;

class AutoProjectWidget : public QVBox
{
	Q_OBJECT
	friend class RemoveFileDialog;
	friend class TargetOptionsDialog;  // to access projectDom() via m_part->projectDom()
public:
	AutoProjectWidget( AutoProjectPart *part, bool kde );
	~AutoProjectWidget();

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

	/**
	* A list of the (relative) names of all subprojects (== subdirectories)
	*/
	TQStringList allSubprojects();
	/**
	 * A list of all Subproject items in the overview KListView
	 */
	TQPtrList <SubprojectItem> allSubprojectItems();
	/**
	* 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() const;
	/**
	* The directory of the currently shown subproject.
	*/
	TQString subprojectDirectory();
	/**
	* Are we in KDE mode?
	*/
	bool kdeMode() const
	{
		return m_kdeMode;
	}

	/**
	* Sets the given target active. The argument is given
	* relative to the project directory.
	*/
	void setActiveTarget( const TQString &targetPath );
	/**
	* Returns the active target as path relative to
	* the project directory.
	*/
	TQString activeDirectory();

	/**
	* Adds a file to the active target.
	* If the file does not contain a "/" character, it is added
	* to the active target.
	* If it does contain "/" character(s), ... @todo .. add to appropriate target
	*/
	void addFiles( const TQStringList &list );
	/**
	* Removes the file fileName from the directory directory.
	* (not implemented currently)
	*/
	void removeFiles( const TQStringList &list );

	/**
	* Returns the currently selected target. Returns 0 if
	* no target is selected.
	*/
	TargetItem *selectedTarget();

	/**
	* Returns the currently selected file. Returns 0 if
	* no file is selected.
	*/
	FileItem *selectedFile();

	/**
	* Returns the currently selected subproject (directory with Makefile.am). Returns 0 if
	* no subproject is selected.
	*/
	SubprojectItem* selectedSubproject();

	/**
	* Creates a TargetItem instance without a parent item.
	*/
	TargetItem *createTargetItem( const TQString &name,
	                              const TQString &prefix, const TQString &primary,
	                              bool take = true );
	/**
	* Creates a FileItem instance without a parent item.
	*/
	FileItem *createFileItem( const TQString &name, SubprojectItem *subproject );

	/**
	 * Returns the Subproject that contains the Active Target. The Active Target is a special target
	 * to which e.g. all files are added to.
	 */
	SubprojectItem* activeSubproject ();
	void setActiveSubproject( SubprojectItem* spitem );

	/**
	 * Returns the Active Target. The Active Target is a special target
	 * to which e.g. all files are added to.
	 */
	TargetItem* activeTarget();

	/**
	 * Returns the sub project item, if any, for a given path. The path supplied can be either
	 * absolute, or relative to the project directory. If no subproject item is found for the
	 * path, null is returned.
	 */
	SubprojectItem* subprojectItemForPath( const TQString & path, bool pathIsAbsolute = false );

	/**
	 * Returns the projectdir-relative path for a target item
	 */
	TQString pathForTarget( const TargetItem *item ) const;

	/**
	 * Adds file fileName to target titem in subproject spitem
	 */
	void addToTarget( const TQString & fileName, SubprojectItem* spitem, TargetItem* titem );

	/**
	* Restores the last settings of the AutoProjectWidget
	*/
	void restoreSession ( const TQDomElement* el );

	/**
	 * Saves the latest changes of the AutoProjectWidget to the session file.
	 */
	void saveSession ( TQDomElement* el );

	AutoSubprojectView* getSubprojectView ();
	AutoDetailsView* getDetailsView ();


	void emitAddedFile ( const TQString& name );
	void emitAddedFiles( const TQStringList &fileList );
	void emitRemovedFile ( const TQString& name );
	void emitRemovedFiles( const TQStringList &fileList );

	void parse( SubprojectItem *item );

	enum AutoProjectView { SubprojectView, DetailsView };
	void setLastFocusedView( AutoProjectView view );

	MakefileHandler* makefileHandler();

public slots:
	void slotOverviewSelectionChanged( TQListViewItem *item );

protected:
	void initOverview ( TQWidget* parent );
	void initDetailview ( TQWidget* parent );
	void initActions ();

	virtual void focusInEvent( TQFocusEvent *e );

private:

	AutoSubprojectView* m_subprojectView;
	AutoDetailsView* m_detailView;

	bool m_kdeMode;
	AutoProjectPart *m_part;
	SubprojectItem *m_activeSubproject;
	TargetItem *m_activeTarget;
	TargetItem *m_choosenTarget;
	SubprojectItem *m_shownSubproject;

	AutoProjectView m_lastFocusedView;

	MakefileHandler *m_makefileHandler;
};

#endif
// kate: indent-mode csands; tab-width 4;