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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
/***************************************************************************
* Copyright (C) 2003-2005 by David Saxton *
* david@bluehaze.org *
* *
* 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 PROJECTMANAGER_H
#define PROJECTMANAGER_H
#include "itemselector.h"
#include <kurl.h>
#include <tqguardedptr.h>
#include <tqvaluelist.h>
class Document;
class ILVItem;
class KTechlab;
class ProcessOptions;
class ProjectInfo;
class ProjectItem;
class ProjectManager;
class TQDomDocument;
class TQDomElement;
class TQStringList;
namespace KateMDI { class ToolView; }
typedef TQValueList<ProcessOptions> ProcessOptionsList;
typedef TQValueList< TQGuardedPtr<ProjectItem> > ProjectItemList;
class LinkerOptions
{
public:
LinkerOptions();
class HexFormat
{
public:
enum type { inhx32, inhx8m, inhx8s, inhx16 };
};
HexFormat::type hexFormat() const { return m_hexFormat; }
void setHexFormat( HexFormat::type hexFormat ) { m_hexFormat = hexFormat; }
bool outputMapFile() const { return m_bOutputMapFile; }
void setOutputMapFile( bool outputMapFile ) { m_bOutputMapFile = outputMapFile; }
TQString libraryDir() const { return m_libraryDir; }
void setLibraryDir( const TQString & libraryDir ) { m_libraryDir = libraryDir; }
TQString linkerScript() const { return m_linkerScript; }
void setLinkerScript( const TQString & linkerScript ) { m_linkerScript = linkerScript; }
TQString linkerOther() const { return m_other; }
void setLinkerOther( const TQString & other ) { m_other = other; }
/**
* Used for linkable ProjectItems. Returns a list of urls of files
* inside the project to link against. Each url is relative to the
* project directory.
*/
TQStringList linkedInternal() const { return m_linkedInternal; }
void setLinkedInternal( const TQStringList & linkedInternal ) { m_linkedInternal = linkedInternal; }
/**
* Used for linkable ProjectItems. Returns a list of urls of files
* outside the project to link against. Each url is absolute.
*/
TQStringList linkedExternal() const { return m_linkedExternal; }
void setLinkedExternal( const TQStringList & linkedExternal ) { m_linkedExternal = linkedExternal; }
TQDomElement toDomElement( TQDomDocument & doc, const KURL & baseURL ) const;
static TQString hexFormatToString( HexFormat::type format );
static HexFormat::type stringToHexFormat( const TQString & hexFormat );
protected:
void domElementToLinkerOptions( const TQDomElement & element, const KURL & baseURL );
TQStringList m_linkedInternal;
TQStringList m_linkedExternal;
HexFormat::type m_hexFormat;
bool m_bOutputMapFile;
TQString m_libraryDir;
TQString m_linkerScript;
TQString m_other;
};
class ProcessingOptions
{
public:
ProcessingOptions();
virtual ~ProcessingOptions();
/**
* Sets the output url that this item will be built into (if this is a
* buildable item).
*/
void setOutputURL( const KURL & url ) { m_outputURL = url; }
KURL outputURL() const { return m_outputURL; }
/**
* Set the microprocessor id that this project item is being built for
* (when applicable).
*/
virtual void setMicroID( const TQString & id ) { m_microID = id; }
virtual TQString microID() const { return m_microID; }
TQDomElement toDomElement( TQDomDocument & doc, const KURL & baseURL ) const;
void setUseParentMicroID( bool useParentMicroID ) { m_bUseParentMicroID = useParentMicroID; }
bool useParentMicroID() const { return m_bUseParentMicroID; }
protected:
void domElementToProcessingOptions( const TQDomElement & element, const KURL & baseURL );
KURL m_outputURL;
TQString m_microID;
bool m_bUseParentMicroID;
};
/**
@author David Saxton
*/
class ProjectItem : public TQObject, public LinkerOptions, public ProcessingOptions
{
public:
enum Type
{
ProjectType = 1 << 0,
FileType = 1 << 1,
ProgramType = 1 << 2,
LibraryType = 1 << 3
};
enum { AllTypes = ProjectType | FileType | ProgramType | LibraryType };
enum OutputType
{
ProgramOutput = 1 << 0,
ObjectOutput = 1 << 1,
LibraryOutput = 1 << 2,
UnknownOutput = 1 << 3
};
enum { AllOutputs = ProgramOutput | ObjectOutput | LibraryOutput | UnknownOutput };
ProjectItem( ProjectItem * parent, Type type, ProjectManager * projectManager, KTechlab * ktechlab );
virtual ~ProjectItem();
Type type() const { return m_type; }
TQString typeToString() const;
static Type stringToType( const TQString & type );
void setILVItem( ILVItem * ilvItem );
/**
* Adds the child to the list of tqchildren, and creates an ILVItem for it
* in the project tree view.
*/
void addChild( ProjectItem * child );
ProjectItemList tqchildren() const { return m_tqchildren; }
void setName( const TQString & name );
TQString name() const { return m_name; }
/**
* Sets the (input) url that this project item refers to. If the output
* url has not yet been set, then this project item will set the output
* url based on this (input) url.
*/
void setURL( const KURL & url );
KURL url() const { return m_url; }
OutputType outputType() const;
/**
* Returns a list of output urls of the tqchildren and their recursively
* contained tqchildren (does not include the url for this project item).
* @param types An OR'ed list of ProjectItem::Type values for the
* tqchildren.
* @param outputTypes An OR'ed list of ProjectItem::OutputType values
* for the tqchildren.
*/
KURL::List childOutputURLs( unsigned types = AllTypes, unsigned outputTypes = AllOutputs ) const;
/**
* Creates a new ProjectItem for the given url and adds it as a child.
*/
void addFile( const KURL & url );
/**
* Queries the user for a list of urls to add, and then calls addFile
* for each url.
*/
void addFiles();
void addCurrentFile();
bool closeOpenFiles();
TQDomElement toDomElement( TQDomDocument & doc, const KURL & baseURL ) const;
bool build( ProcessOptionsList * pol );
void upload( ProcessOptionsList * pol );
virtual void setMicroID( const TQString & id );
virtual TQString microID() const;
/**
* Searches this item and the tqchildren for an item for the given url,
* return null if no such item could be found.
*/
ProjectItem * findItem( const KURL & url );
protected:
void domElementToItem( const TQDomElement & element, const KURL & baseURL );
void updateILVItemPixmap();
void updateControlChildMicroIDs();
KURL m_url;
TQString m_name;
ProjectItemList m_tqchildren;
Type m_type;
KTechlab * p_ktechlab;
TQGuardedPtr<ILVItem> m_pILVItem;
ProjectManager * m_pProjectManager;
ProjectItem * m_pParent;
};
/**
@author David Saxton
*/
class ProjectInfo : public ProjectItem
{
Q_OBJECT
TQ_OBJECT
public:
ProjectInfo( ProjectManager * projectManager, KTechlab * ktechlab );
~ProjectInfo();
/**
* Returns the directory that the project is saved in
*/
TQString directory() const { return m_url.directory(false); }
/**
* Saves the project information to file, and attempts to close all
* open project files.
* @return true iff succesful
*/
bool saveAndClose();
bool save();
bool open( const KURL & url );
};
/**
@short Project Management
@author David Saxton
*/
class ProjectManager : public ItemSelector
{
Q_OBJECT
TQ_OBJECT
public:
~ProjectManager();
static ProjectManager * self( KTechlab * ktl = 0l, KateMDI::ToolView * parent = 0l );
static TQString toolViewIdentifier() { return "ProjectManager"; }
/**
* @return the currently open project, or NULL if no project is open.
*/
ProjectInfo * currentProject() const { return m_pCurrentProject; }
void updateActions();
signals:
/**
* Emitted when an existing project is opened.
*/
void projectOpened();
/**
* Emitted when the current project is closed.
*/
void projectClosed();
/**
* Emitted when a new project is created.
*/
void projectCreated();
/**
* Emitted when a subproject is created.
*/
void subprojectCreated();
/**
* Emitted when file(s) are added to the project or a subproject.
*/
void filesAdded();
/**
* Emitted when file(s) are removed from the project or a subproject.
*/
void filesRemoved();
public slots:
void slotNewProject();
void slotOpenProject();
void slotOpenProject( const KURL &url );
bool slotCloseProject();
void slotCreateSubproject();
void slotAddFile();
void slotAddCurrentFile();
void slotSubprojectAddExistingFile();
void slotSubprojectAddCurrentFile();
void slotItemBuild();
void slotItemUpload();
void slotItemProcessingOptions();
void slotRemoveSelected();
void slotExportToMakefile();
void slotSubprojectLinkerOptions();
/**
* Pops ups a project configuration dialog
*/
void slotProjectOptions();
private slots:
void slotContextMenuRequested( TQListViewItem *item, const TQPoint &pos, int col );
/**
* Called when a user clicks on any item in the project view
*/
void slotItemClicked( TQListViewItem * item );
protected:
ProjectInfo * m_pCurrentProject;
KTechlab * const p_ktechlab;
private:
ProjectManager( KTechlab * ktl, KateMDI::ToolView * parent );
static ProjectManager * m_pSelf;
};
#endif
|