summaryrefslogtreecommitdiffstats
path: root/languages/cpp/app_templates/kdevlang/kdevlang_part.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/app_templates/kdevlang/kdevlang_part.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/app_templates/kdevlang/kdevlang_part.cpp')
-rw-r--r--languages/cpp/app_templates/kdevlang/kdevlang_part.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/kdevlang/kdevlang_part.cpp b/languages/cpp/app_templates/kdevlang/kdevlang_part.cpp
new file mode 100644
index 00000000..9d5cadcf
--- /dev/null
+++ b/languages/cpp/app_templates/kdevlang/kdevlang_part.cpp
@@ -0,0 +1,154 @@
+%{CPP_TEMPLATE}
+
+#include <qwhatsthis.h>
+#include <qtimer.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(QObject *parent, const char *name, const QStringList& )
+: 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, 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"