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
|
%{CPP_TEMPLATE}
#include <qwhatsthis.h>
#include <qtimer.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kgenericfactory.h>
#include <kdevelop/kdevcore.h>
#include <kdevelop/kdevpartcontroller.h>
#include <kdevelop/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}" ) );
%{APPNAME}Part::%{APPNAME}Part(QObject *parent, const char *name, const QStringList& )
: KDevLanguageSupport("KDevPart", "kdevpart", parent, name ? name : "%{APPNAME}Part" )
{
setInstance(%{APPNAME}Factory::instance());
setXMLFile("kdevlang_%{APPNAMELC}.rc");
m_build = new KAction( i18n("&Run"), "exec",Key_F9,this, SLOT(slotRun()),actionCollection(), "build_execute" );
kdDebug() << "Creating %{APPNAMELC} Part" << endl;
connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)),
this, SLOT(projectConfigWidget(KDialogBase*)) );
connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) );
connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) );
connect( partController(), SIGNAL(savedFile(const KURL&)), this, SLOT(savedFile(const KURL&)) );
connect(partController(), SIGNAL(activePartChanged(KParts::Part*)),
this, 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(), SIGNAL(addedFilesToProject(const QStringList &)),
this, SLOT(addedFilesToProject(const QStringList &)) );
connect( project(), SIGNAL(removedFilesFromProject(const QStringList &)),
this, SLOT(removedFilesFromProject(const QStringList &)) );
// We want to parse only after all components have been
// properly initialized
QTimer::singleShot(0, this, 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 QStringList &fileList)
{
kdDebug(9014) << "addedFilesToProject()" << endl;
QStringList::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 QStringList &fileList)
{
QStringList::ConstIterator it;
for ( it = fileList.begin(); it != fileList.end(); ++it )
{
QString 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);
QStringList files = project()->allFiles();
for (QStringList::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"
|