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
|
%{CPP_TEMPLATE}
#include <tqwhatsthis.h>
#include <tqtimer.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kgenericfactory.h>
#include <kdevcore.h>
#include <kdevpartcontroller.h>
#include <kdevplugininfo.h>
#include <kdevproject.h>
#include <kaction.h>
#include <kdebug.h>
#include <kapplication.h>
//#include "%{APPNAMELC}_widget.h"
#include "%{APPNAMELC}_part.h"
typedef KGenericFactory<%{APPNAME}Part> %{APPNAME}Factory;
K_EXPORT_COMPONENT_FACTORY( libkdev%{APPNAMELC}, %{APPNAME}Factory( "kdev%{APPNAMELC}" ) );
static const KDevPluginInfo data("kdev%{APPNAMELC}");
%{APPNAME}Part::%{APPNAME}Part(TQObject *parent, const char *name, const TQStringList& )
: KDevLanguageSupport(&data, parent, name ? name : "%{APPNAME}Part" )
{
setInstance(%{APPNAME}Factory::instance());
setXMLFile("kdevlang_%{APPNAMELC}.rc");
m_build = new KAction( i18n("&Run"), "exec",Key_F9,this, TQT_SLOT(slotRun()),actionCollection(), "build_execute" );
kdDebug() << "Creating %{APPNAMELC} Part" << endl;
connect( core(), TQT_SIGNAL(projectConfigWidget(KDialogBase*)),
this, TQT_SLOT(projectConfigWidget(KDialogBase*)) );
connect( core(), TQT_SIGNAL(projectOpened()), this, TQT_SLOT(projectOpened()) );
connect( core(), TQT_SIGNAL(projectClosed()), this, TQT_SLOT(projectClosed()) );
connect( partController(), TQT_SIGNAL(savedFile(const KURL&)), this, TQT_SLOT(savedFile(const KURL&)) );
connect(partController(), TQT_SIGNAL(activePartChanged(KParts::Part*)),
this, TQT_SLOT(slotActivePartChanged(KParts::Part *)));
}
%{APPNAME}Part::~%{APPNAME}Part()
{
delete m_build;
}
KDevLanguageSupport::Features %{APPNAME}Part::features()
{
return Features(Variables | Functions);
}
KMimeType::List %{APPNAME}Part::mimeTypes()
{
KMimeType::List list;
KMimeType::Ptr mime = KMimeType::mimeType( "application/x-shellscript" );
if( mime )
list << mime;
return list;
}
void %{APPNAME}Part::slotRun()
{
// Execute the application here.
}
void %{APPNAME}Part::projectConfigWidget(KDialogBase *dlg)
{
Q_UNUSED( dlg );
// Create your config dialog here.
}
void %{APPNAME}Part::projectOpened()
{
kdDebug(9014) << "projectOpened()" << endl;
connect( project(), TQT_SIGNAL(addedFilesToProject(const TQStringList &)),
this, TQT_SLOT(addedFilesToProject(const TQStringList &)) );
connect( project(), TQT_SIGNAL(removedFilesFromProject(const TQStringList &)),
this, TQT_SLOT(removedFilesFromProject(const TQStringList &)) );
// We want to parse only after all components have been
// properly initialized
TQTimer::singleShot(0, this, TQT_SLOT(parse()));
}
void %{APPNAME}Part::projectClosed()
{
}
void %{APPNAME}Part::savedFile(const KURL &fileName)
{
if (project()->allFiles().contains(fileName.path().mid ( project()->projectDirectory().length() + 1 )))
{
kdDebug(9014) << "parse file " << fileName.path() << endl;
emit addedSourceInfo( fileName.path() );
}
}
void %{APPNAME}Part::addedFilesToProject(const TQStringList &fileList)
{
kdDebug(9014) << "addedFilesToProject()" << endl;
TQStringList::ConstIterator it;
for ( it = fileList.begin(); it != fileList.end(); ++it )
{
kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + ( *it ) << endl;
}
emit updatedSourceInfo();
}
void %{APPNAME}Part::removedFilesFromProject(const TQStringList &fileList)
{
TQStringList::ConstIterator it;
for ( it = fileList.begin(); it != fileList.end(); ++it )
{
TQString fileName = project()->projectDirectory() + "/" + ( *it );
if( codeModel()->hasFile(fileName) )
{
kdDebug(9014) << "removed " << fileName << endl;
emit aboutToRemoveSourceInfo( fileName );
codeModel()->removeFile( codeModel()->fileByName(fileName) );
}
}
}
void %{APPNAME}Part::parse()
{
kdDebug(9014) << "initialParse()" << endl;
if (project())
{
kapp->setOverrideCursor(waitCursor);
TQStringList files = project()->allFiles();
for (TQStringList::Iterator it = files.begin(); it != files.end() ;++it)
{
kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + (*it) << endl;
}
emit updatedSourceInfo();
kapp->restoreOverrideCursor();
} else {
kdDebug(9014) << "No project" << endl;
}
}
void %{APPNAME}Part::slotActivePartChanged(KParts::Part *part)
{
kdDebug() << "Changeing active part..." << endl;
}
#include "%{APPNAMELC}_part.moc"
|