You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
4.2 KiB
155 lines
4.2 KiB
%{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 <tdeaction.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 TDEAction( 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"
|