summaryrefslogtreecommitdiffstats
path: root/kdevdesigner/designer/project.h
blob: 350fd6f04cbd6b69cab424a7981900a13067afad (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
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
/**********************************************************************
** Copyright (C) 2000 Trolltech AS.  All rights reserved.
**
** This file is part of TQt Designer.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
** licenses may use this file in accordance with the TQt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
** See http://www.trolltech.com/pricing.html or email [email protected] for
**   information about TQt Commercial License Agreements.
**
** Contact [email protected] if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef PROJECT_H
#define PROJECT_H

#include <tqfeatures.h>

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqptrlist.h>
#include <tqmap.h>
#include <private/tqpluginmanager_p.h>
#include "../interfaces/projectsettingsiface.h"
#include "sourcefile.h"
#include "formfile.h"
#include <tqobjectlist.h>
#include <tqptrdict.h>
#include "formfile.h"

class TQObjectList;
struct DesignerProject;
struct DesignerDatabase;
class PixmapCollection;
class Project;

#ifndef TQT_NO_SQL
class TQSqlDatabase;

class DatabaseConnection
{
public:
    DatabaseConnection( Project *p ) :
#ifndef TQT_NO_SQL
	conn( 0 ),
#endif
	project( p ), loaded( FALSE ), iface( 0 ) {}
    ~DatabaseConnection();

    bool refreshCatalog();
    bool open( bool suppressDialog = TRUE );
    void close();
    DesignerDatabase *iFace();

    bool isLoaded() const { return loaded; }
    void setName( const TQString& n ) { nm = n; }
    TQString name() const { return nm; }
    void setDriver( const TQString& d ) { drv = d; }
    TQString driver() const { return drv; }
    void setDatabase( const TQString& db ) { dbName = db; }
    TQString database() const { return dbName; }
    void setUsername( const TQString& u ) { uname = u; }
    TQString username() const { return uname; }
    void setPassword( const TQString& p ) { pword = p; }
    TQString password() const { return pword; }
    void setHostname( const TQString& h ) { hname = h; }
    TQString hostname() const { return hname; }
    void setPort( int p ) { prt = p; }
    int port() const { return prt; }
    TQString lastError() const { return dbErr; }
    void addTable( const TQString& t ) { tbls.append(t); }
    void setFields( const TQString& t, const TQStringList& f ) { flds[t] = f; }
    TQStringList tables() const { return tbls; }
    TQStringList fields( const TQString& t ) { return flds[t]; }
    TQMap<TQString, TQStringList> fields() { return flds; }
#ifndef TQT_NO_SQL
    TQSqlDatabase* connection() const { return conn; }
    void remove();
#endif

private:
    TQString nm;
    TQString drv, dbName, uname, pword, hname;
    TQString dbErr;
    int prt;
    TQStringList tbls;
    TQMap<TQString, TQStringList> flds;
#ifndef TQT_NO_SQL
    TQSqlDatabase *conn;
#endif
    Project *project;
    bool loaded;
    DesignerDatabase *iface;
};

#endif

class Project : public TQObject
{
    Q_OBJECT
  TQ_OBJECT
    friend class DatabaseConnection;

public:
    Project( const TQString &fn, const TQString &pName = TQString(),
	     TQPluginManager<ProjectSettingsInterface> *pm = 0, bool isDummy = FALSE,
	     const TQString &l = "C++" );
    ~Project();

    void setFileName( const TQString &fn, bool doClear = TRUE );
    TQString fileName( bool singlePro = FALSE ) const;
    TQString projectName() const;

    void setDatabaseDescription( const TQString &db );
    TQString databaseDescription() const;

    void setDescription( const TQString &s );
    TQString description() const;

    void setLanguage( const TQString &l );
    TQString language() const;


    bool isValid() const;

    // returns TRUE if this project is the <No Project> project
    bool isDummy() const;

    TQString makeAbsolute( const TQString &f );
    TQString makeRelative( const TQString &f );

    void save( bool onlyProjectFile = FALSE );

#ifndef TQT_NO_SQL
    TQPtrList<DatabaseConnection> databaseConnections() const;
    void setDatabaseConnections( const TQPtrList<DatabaseConnection> &lst );
    void addDatabaseConnection( DatabaseConnection *conn );
    void removeDatabaseConnection( const TQString &conn );
    DatabaseConnection *databaseConnection( const TQString &name );
    TQStringList databaseConnectionList();
    TQStringList databaseTableList( const TQString &connection );
    TQStringList databaseFieldList( const TQString &connection, const TQString &table );
#endif
    void saveConnections();
    void loadConnections();

    bool openDatabase( const TQString &connection, bool suppressDialog = TRUE );
    void closeDatabase( const TQString &connection );

    TQObjectList *formList( bool resolveFakeObjects = FALSE ) const;

    DesignerProject *iFace();

    void setCustomSetting( const TQString &key, const TQString &value );
    TQString customSetting( const TQString &key ) const;

    PixmapCollection *pixmapCollection() const { return pixCollection; }

    void setActive( bool b );

    TQPtrListIterator<SourceFile> sourceFiles() const { return TQPtrListIterator<SourceFile>(sourcefiles); }
    void addSourceFile( SourceFile *sf );
    bool removeSourceFile( SourceFile *sf );
    SourceFile* findSourceFile( const TQString& filename, SourceFile *ignore = 0 ) const;

    TQPtrListIterator<FormFile> formFiles() const { return TQPtrListIterator<FormFile>(formfiles); }
    void addFormFile( FormFile *ff );
    bool removeFormFile( FormFile *ff );
    FormFile* findFormFile( const TQString& filename, FormFile *ignore = 0 ) const;

    void setIncludePath( const TQString &platform, const TQString &path );
    void setLibs( const TQString &platform, const TQString &path );
    void setDefines( const TQString &platform, const TQString &path );
    void setConfig( const TQString &platform, const TQString &config );
    void setTemplate( const TQString &t );

    TQString config( const TQString &platform ) const;
    TQString libs( const TQString &platform ) const;
    TQString defines( const TQString &platform ) const;
    TQString includePath( const TQString &platform ) const;
    TQString templte() const;

    bool isModified() const { return !isDummy() && modified; }
    void setModified( bool b );

    void addObject( TQObject *o );
    void setObjects( const TQObjectList &ol );
    void removeObject( TQObject *o );
    TQObjectList objects() const;
    FormFile *fakeFormFileFor( TQObject *o ) const;
    TQObject *objectForFakeForm( FormWindow *fw ) const;
    TQObject *objectForFakeFormFile( FormFile *ff ) const;

    void addAndEditFunction( const TQString &functionName, const TQString &functionBody,
			     bool openDeveloper );

    void removeTempProject();
    bool hasParentObject( TQObject *o );
    TQString qualifiedName( TQObject *o );

    bool isCpp() const { return is_cpp; }

    void designerCreated();

    void formOpened( FormWindow *fw );

    TQString locationOfObject( TQObject *o );

    bool hasGUI() const;

signals:
    void projectModified();
    void sourceFileAdded( SourceFile* );
    void sourceFileRemoved( SourceFile* );
    void formFileAdded( FormFile* );
    void formFileRemoved( FormFile* );
    void objectAdded( TQObject * );
    void objectRemoved( TQObject * );
    void newFormOpened( FormWindow *fw );

private:
    void parse();
    void clear();
    void updateCustomSettings();
    void readPlatformSettings( const TQString &contents,
			       const TQString &setting,
			       TQMap<TQString, TQString> &res );
    void removePlatformSettings( TQString &contents, const TQString &setting );
    void writePlatformSettings( TQString &contents, const TQString &setting,
				const TQMap<TQString, TQString> &input );
    bool singleProjectMode() const;
    TQWidget *messageBoxParent() const;

private:
    TQString filename;
    TQString proName;
    TQString desc;
    TQString dbFile;
#ifndef TQT_NO_SQL
    TQPtrList<DatabaseConnection> dbConnections;
#endif
    TQString lang;
    DesignerProject *iface;
    TQMap<TQString, TQString> customSettings;
    TQStringList csList;
    TQPluginManager<ProjectSettingsInterface> *projectSettingsPluginManager;
    PixmapCollection *pixCollection;
    TQPtrList<SourceFile> sourcefiles;
    TQPtrList<FormFile> formfiles;
    TQMap<TQString, TQString> inclPath, defs, lbs, cfg, sources, headers;
    TQString templ;
    bool isDummyProject;
    bool modified;
    TQObjectList objs;
    TQPtrDict<FormFile> fakeFormFiles;
    TQString singleProFileName;
    bool is_cpp;

};

#endif