~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/app_templates/kdevlang/kdevlang_part.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{CPP_TEMPLATE}
 
2
 
 
3
#include <qwhatsthis.h>
 
4
#include <qtimer.h>
 
5
 
 
6
#include <kiconloader.h>
 
7
#include <klocale.h>
 
8
#include <kgenericfactory.h>
 
9
#include <kdevcore.h>
 
10
#include <kdevpartcontroller.h>
 
11
#include <kdevplugininfo.h>
 
12
#include <kdevproject.h>
 
13
#include <kaction.h>
 
14
#include <kdebug.h>
 
15
#include <kapplication.h>
 
16
 
 
17
//#include "%{APPNAMELC}_widget.h"
 
18
#include "%{APPNAMELC}_part.h"
 
19
 
 
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}");
 
23
 
 
24
%{APPNAME}Part::%{APPNAME}Part(QObject *parent, const char *name, const QStringList& )
 
25
: KDevLanguageSupport(&data, parent, name ? name : "%{APPNAME}Part" )
 
26
{
 
27
        setInstance(%{APPNAME}Factory::instance());
 
28
        setXMLFile("kdevlang_%{APPNAMELC}.rc");
 
29
 
 
30
 
 
31
        m_build = new KAction( i18n("&Run"), "exec",Key_F9,this, SLOT(slotRun()),actionCollection(), "build_execute" );
 
32
 
 
33
        kdDebug() << "Creating %{APPNAMELC} Part" << endl;
 
34
 
 
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 *)));
 
42
}
 
43
 
 
44
 
 
45
%{APPNAME}Part::~%{APPNAME}Part()
 
46
{
 
47
        delete m_build;
 
48
}
 
49
 
 
50
KDevLanguageSupport::Features %{APPNAME}Part::features()
 
51
{
 
52
        return Features(Variables | Functions);
 
53
}
 
54
KMimeType::List %{APPNAME}Part::mimeTypes()
 
55
{
 
56
    KMimeType::List list;
 
57
 
 
58
    KMimeType::Ptr mime = KMimeType::mimeType( "application/x-shellscript" );
 
59
    if( mime )
 
60
        list << mime;
 
61
 
 
62
    return list;
 
63
}
 
64
void %{APPNAME}Part::slotRun()
 
65
{
 
66
        // Execute the application here.
 
67
}
 
68
void %{APPNAME}Part::projectConfigWidget(KDialogBase *dlg)
 
69
{
 
70
        Q_UNUSED( dlg );
 
71
        // Create your config dialog here.
 
72
}
 
73
void %{APPNAME}Part::projectOpened()
 
74
{
 
75
        kdDebug(9014) << "projectOpened()" << endl;
 
76
 
 
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 &)) );
 
81
 
 
82
        // We want to parse only after all components have been
 
83
        // properly initialized
 
84
        QTimer::singleShot(0, this, SLOT(parse()));
 
85
}
 
86
void %{APPNAME}Part::projectClosed()
 
87
{
 
88
 
 
89
}
 
90
void %{APPNAME}Part::savedFile(const KURL &fileName)
 
91
{
 
92
 
 
93
 
 
94
        if (project()->allFiles().contains(fileName.path().mid ( project()->projectDirectory().length() + 1 )))
 
95
        {
 
96
                kdDebug(9014) << "parse file " << fileName.path() << endl;
 
97
                emit addedSourceInfo( fileName.path() );
 
98
        }
 
99
}
 
100
void %{APPNAME}Part::addedFilesToProject(const QStringList &fileList)
 
101
{
 
102
        kdDebug(9014) << "addedFilesToProject()" << endl;
 
103
 
 
104
        QStringList::ConstIterator it;
 
105
 
 
106
        for ( it = fileList.begin(); it != fileList.end(); ++it )
 
107
        {
 
108
                kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + ( *it ) << endl;
 
109
        }
 
110
 
 
111
        emit updatedSourceInfo();
 
112
}
 
113
void %{APPNAME}Part::removedFilesFromProject(const QStringList &fileList)
 
114
{
 
115
 
 
116
 
 
117
        QStringList::ConstIterator it;
 
118
 
 
119
        for ( it = fileList.begin(); it != fileList.end(); ++it )
 
120
        {
 
121
                QString fileName = project()->projectDirectory() + "/" + ( *it );
 
122
                if( codeModel()->hasFile(fileName) )
 
123
                {
 
124
                        kdDebug(9014) << "removed " << fileName << endl;
 
125
                        emit aboutToRemoveSourceInfo( fileName );
 
126
                        codeModel()->removeFile( codeModel()->fileByName(fileName) );
 
127
                }
 
128
        }
 
129
 
 
130
}
 
131
void %{APPNAME}Part::parse()
 
132
{
 
133
        kdDebug(9014) << "initialParse()" << endl;
 
134
 
 
135
        if (project())
 
136
        {
 
137
                kapp->setOverrideCursor(waitCursor);
 
138
                QStringList files = project()->allFiles();
 
139
                for (QStringList::Iterator it = files.begin(); it != files.end() ;++it)
 
140
                {
 
141
                        kdDebug(9014) << "maybe parse " << project()->projectDirectory() + "/" + (*it) << endl;
 
142
                }
 
143
                emit updatedSourceInfo();
 
144
                kapp->restoreOverrideCursor();
 
145
        } else {
 
146
                kdDebug(9014) << "No project" << endl;
 
147
        }
 
148
}
 
149
void %{APPNAME}Part::slotActivePartChanged(KParts::Part *part)
 
150
{
 
151
        kdDebug() << "Changeing active part..." << endl;
 
152
}
 
153
 
 
154
#include "%{APPNAMELC}_part.moc"