3
#include <qwhatsthis.h>
6
#include <kiconloader.h>
8
#include <kgenericfactory.h>
10
#include <kdevpartcontroller.h>
11
#include <kdevplugininfo.h>
12
#include <kdevproject.h>
15
#include <kapplication.h>
17
//#include "%{APPNAMELC}_widget.h"
18
#include "%{APPNAMELC}_part.h"
20
typedef KGenericFactory<%{APPNAME}Part> %{APPNAME}Factory;
21
K_EXPORT_COMPONENT_FACTORY( libkdev%{APPNAMELC}, %{APPNAME}Factory( "kdev%{APPNAMELC}" ) );
22
static const KDevPluginInfo data("kdev%{APPNAMELC}");
24
%{APPNAME}Part::%{APPNAME}Part(QObject *parent, const char *name, const QStringList& )
25
: KDevLanguageSupport(&data, parent, name ? name : "%{APPNAME}Part" )
27
setInstance(%{APPNAME}Factory::instance());
28
setXMLFile("kdevlang_%{APPNAMELC}.rc");
31
m_build = new KAction( i18n("&Run"), "exec",Key_F9,this, SLOT(slotRun()),actionCollection(), "build_execute" );
33
kdDebug() << "Creating %{APPNAMELC} Part" << endl;
35
connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)),
36
this, SLOT(projectConfigWidget(KDialogBase*)) );
37
connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) );
38
connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) );
39
connect( partController(), SIGNAL(savedFile(const KURL&)), this, SLOT(savedFile(const KURL&)) );
40
connect(partController(), SIGNAL(activePartChanged(KParts::Part*)),
41
this, SLOT(slotActivePartChanged(KParts::Part *)));
45
%{APPNAME}Part::~%{APPNAME}Part()
50
KDevLanguageSupport::Features %{APPNAME}Part::features()
52
return Features(Variables | Functions);
54
KMimeType::List %{APPNAME}Part::mimeTypes()
58
KMimeType::Ptr mime = KMimeType::mimeType( "application/x-shellscript" );
64
void %{APPNAME}Part::slotRun()
66
// Execute the application here.
68
void %{APPNAME}Part::projectConfigWidget(KDialogBase *dlg)
71
// Create your config dialog here.
73
void %{APPNAME}Part::projectOpened()
75
kdDebug(9014) << "projectOpened()" << endl;
77
connect( project(), SIGNAL(addedFilesToProject(const QStringList &)),
78
this, SLOT(addedFilesToProject(const QStringList &)) );
79
connect( project(), SIGNAL(removedFilesFromProject(const QStringList &)),
80
this, SLOT(removedFilesFromProject(const QStringList &)) );
82
// We want to parse only after all components have been
83
// properly initialized
84
QTimer::singleShot(0, this, SLOT(parse()));
86
void %{APPNAME}Part::projectClosed()
90
void %{APPNAME}Part::savedFile(const KURL &fileName)
94
if (project()->allFiles().contains(fileName.path().mid ( project()->projectDirectory().length() + 1 )))
96
kdDebug(9014) << "parse file " << fileName.path() << endl;
97
emit addedSourceInfo( fileName.path() );
100
void %{APPNAME}Part::addedFilesToProject(const QStringList &fileList)
102
kdDebug(9014) << "addedFilesToProject()" << endl;
104
QStringList::ConstIterator it;
106
for ( it = fileList.begin(); it != fileList.end(); ++it )
108
kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + ( *it ) << endl;
111
emit updatedSourceInfo();
113
void %{APPNAME}Part::removedFilesFromProject(const QStringList &fileList)
117
QStringList::ConstIterator it;
119
for ( it = fileList.begin(); it != fileList.end(); ++it )
121
QString fileName = project()->projectDirectory() + "/" + ( *it );
122
if( codeModel()->hasFile(fileName) )
124
kdDebug(9014) << "removed " << fileName << endl;
125
emit aboutToRemoveSourceInfo( fileName );
126
codeModel()->removeFile( codeModel()->fileByName(fileName) );
131
void %{APPNAME}Part::parse()
133
kdDebug(9014) << "initialParse()" << endl;
137
kapp->setOverrideCursor(waitCursor);
138
QStringList files = project()->allFiles();
139
for (QStringList::Iterator it = files.begin(); it != files.end() ;++it)
141
kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + (*it) << endl;
143
emit updatedSourceInfo();
144
kapp->restoreOverrideCursor();
146
kdDebug(9014) << "No project" << endl;
149
void %{APPNAME}Part::slotActivePartChanged(KParts::Part *part)
151
kdDebug() << "Changeing active part..." << endl;
154
#include "%{APPNAMELC}_part.moc"