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
|
/***************************************************************************
* Copyright (C) 1998 by Sandy Meier *
* [email protected] *
* Copyright (C) 2002 by Bernd Gehrmann *
* [email protected] *
* Copyright (C) 2003 by Alexander Dymo *
* [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 _CPPNEWCLASSDLG_H_
#define _CPPNEWCLASSDLG_H_
#include <qlineedit.h>
#include <qlistview.h>
#include <qwidgetstack.h>
#include "codemodel.h"
#include "cppnewclassdlgbase.h"
class CppSupportPart;
class KDevProject;
class QPopupMenu;
class KCompletion;
class CodeModel;
template <class T>
class PCheckListItem: public QCheckListItem
{
public:
PCheckListItem ( T item, QCheckListItem * parent, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QCheckListItem * parent, QListViewItem * after, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, after, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QListViewItem * parent, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QListViewItem * parent, QListViewItem * after, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, after, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QListView * parent, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QListView * parent, QListViewItem * after, const QString & text, Type tt = Controller ) :
QCheckListItem ( parent, after, text, tt ), m_item( item )
{}
PCheckListItem ( T item, QListViewItem * parent, const QString & text, const QPixmap & p ) :
QCheckListItem ( parent, text, p ), m_item( item )
{}
PCheckListItem ( T item, QListView * parent, const QString & text, const QPixmap & p ) :
QCheckListItem ( parent, text, p ), m_item( item )
{}
T item()
{
return m_item;
}
QString templateAddition;
private:
T m_item;
};
template <class T>
class PListViewItem: public QListViewItem
{
public:
PListViewItem ( T item, QListViewItem * parent, QListViewItem * after, const QString & text ) :
QListViewItem ( parent, after, text ), m_item( item )
{}
PListViewItem ( T item, QListViewItem * parent, const QString & text ) :
QListViewItem ( parent, text ), m_item( item )
{}
PListViewItem ( T item, QListView * parent, const QString & text ) :
QListViewItem ( parent, text ), m_item( item )
{}
PListViewItem ( T item, QListView * parent, QListViewItem * after, const QString & text ) :
QListViewItem ( parent, after, text ), m_item( item )
{}
T item()
{
return m_item;
}
QString templateAddition;
private:
T m_item;
};
class CppNewClassDialog : public CppNewClassDialogBase
{
Q_OBJECT
public:
CppNewClassDialog( CppSupportPart *part, QWidget *parent = 0, const char *name = 0 );
~CppNewClassDialog();
protected:
virtual void accept();
virtual void classNameChanged( const QString &text );
virtual void classNamespaceChanged( const QString &text );
virtual void headerChanged();
virtual void implementationChanged();
virtual void nameHandlerChanged( const QString &text );
virtual void baseclassname_changed( const QString &text );
virtual void baseIncludeChanged( const QString &text );
virtual void addBaseClass();
virtual void remBaseClass();
virtual void remBaseClassOnly();
virtual void currBaseNameChanged( const QString &text );
virtual void currBasePrivateSet();
virtual void currBaseProtectedSet();
virtual void currBasePublicSet();
virtual void currBaseVirtualChanged( int val );
virtual void currBaseSelected( QListViewItem *it );
virtual void scopeboxActivated( int value );
virtual void checkObjCInheritance( int val );
virtual void checkQWidgetInheritance( int val );
virtual void upbaseclass_button_clicked();
virtual void downbaseclass_button_clicked();
virtual void baseclasses_view_selectionChanged();
virtual void newTabSelected( const QString &text );
virtual void newTabSelected( QWidget *w );
virtual void access_view_mouseButtonPressed( int button, QListViewItem * item, const QPoint &p, int c );
virtual void changeToPrivate();
virtual void changeToProtected();
virtual void changeToPublic();
virtual void changeToInherited();
virtual void methods_view_mouseButtonPressed( int button , QListViewItem * item, const QPoint&p , int c );
virtual void extendFunctionality();
virtual void replaceFunctionality();
virtual void to_constructors_list_clicked();
virtual void clear_selection_button_clicked();
virtual void selectall_button_clicked();
virtual void gtk_box_stateChanged( int val );
virtual void qobject_box_stateChanged( int val );
virtual void headeronly_box_stateChanged(int val);
void reloadAdvancedInheritance( bool clean = false );
void parseClass( QString clName, QString inheritance );
void parsePCSClass( QString clName, QString inheritance );
void addToConstructorsList( QCheckListItem *myClass, FunctionDom method );
void addToMethodsList( QListViewItem *parent, FunctionDom method );
void addToUpgradeList( QListViewItem *parent, FunctionDom method, QString modifier );
void addToUpgradeList( QListViewItem *parent, VariableDom attr, QString modifier );
void clearConstructorsList( bool clean = false );
void clearMethodsList( bool clean = false );
void clearUpgradeList( bool clean = false );
bool isConstructor( QString className, const FunctionDom &method );
bool isDestructor( QString className, const FunctionDom &method );
private:
bool headerModified;
bool baseincludeModified;
bool implementationModified;
QString m_parse;
QPopupMenu *accessMenu;
QPopupMenu *overMenu;
CppSupportPart *m_part;
CodeModel *myModel;
// configuration variables
QString interface_url;
QString implementation_url;
QString interface_suffix;
QString implementation_suffix;
QStringList currNamespace;
bool lowercase_filenames;
QStringList currBaseClasses;
KCompletion * compBasename;
KCompletion * compNamespace;
void setCompletionBasename( CodeModel *model );
void addCompletionBasenameNamespacesRecursive( const NamespaceDom & namespaceDom, const QString & namespaceParent = "" );
void setCompletionNamespaceRecursive( const NamespaceDom & namespaceDom, const QString & namespaceParent = "" );
void setStateOfInheritanceEditors( bool state, bool hideList = true );
void setAccessForBase( QString baseclass, QString newAccess );
void setAccessForItem( QListViewItem *curr, QString newAccess, bool isPublic );
void remClassFromAdv( QString text );
void checkUpButtonState();
void checkDownButtonState();
void updateConstructorsOrder();
QString classNameFormatted();
QString templateStrFormatted();
QString templateParamsFormatted();
QString classNameFormatted( const QString & );
QString templateStrFormatted( const QString & );
QString templateParamsFormatted( const QString & );
QString templateActualParamsFormatted( const QString & );
void removeTemplateParams( QString & );
friend class ClassGenerator;
//! The class that translates UI input to a class
class ClassGenerator
{
public:
ClassGenerator( CppNewClassDialog& _dlg ) : dlg( _dlg )
{}
bool generate();
private:
bool validateInput();
void common_text();
void gen_implementation();
void gen_interface();
void genMethodDeclaration( FunctionDom method, QString className, QString templateStr,
QString *adv_h, QString *adv_cpp, bool extend, QString baseClassName );
void beautifyHeader( QString &templ, QString &headerGuard,
QString &includeBaseHeader, QString &author, QString &doc, QString &className, QString &templateStr,
QString &baseclass, QString &inheritance, QString &qobjectStr, QString &args,
QString &header, QString &namespaceBeg, QString &constructors, QString &advH_public,
QString &advH_public_slots,
QString &advH_protected, QString &advH_protected_slots, QString &advH_private, QString &advH_private_slots,
QString &namespaceEnd );
void beautifySource( QString &templ, QString &header, QString &className, QString &namespaceBeg,
QString &constructors, QString &advCpp, QString &namespaceEnd, QString &implementation );
QString className;
QString templateStr;
QString templateParams;
QString header;
QString implementation;
QString advConstructorsHeader;
QString advConstructorsSource;
KDevProject *project;
QString subDir, headerPath, implementationPath;
QString doc;
QString namespaceStr;
bool childClass;
bool objc;
bool qobject;
bool gtk;
bool headeronly;
QStringList namespaces;
QString namespaceBeg, namespaceEnd;
QString argsH;
QString argsCpp;
QString advH_public;
QString advH_public_slots;
QString advH_protected;
QString advH_protected_slots;
QString advH_private;
QString advH_private_slots;
QString advCpp;
CppNewClassDialog& dlg;
};
//! workaround to make gcc 2.95.x happy
friend class CppNewClassDialog::ClassGenerator;
};
#endif
// kate: indent-mode csands; tab-width 4;
|