• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • TDevelop Interfaces Library
 

TDevelop Interfaces Library

  • lib
  • interfaces
kdevproject.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
3 Copyright (C) 2002-2003 Roberto Raggi <roberto@kdevelop.org>
4 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
5 Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
6 Copyright (C) 2003 Mario Scalas <mario.scalas@libero.it>
7 Copyright (C) 2003-2004 Alexander Dymo <adymo@kdevelop.org>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.
23*/
24
25#include <kdebug.h>
26
27#include "kdevproject.h"
28#include <urlutil.h>
29#include <tqfileinfo.h>
30#include <tqtimer.h>
31#include "kdevprojectiface.h"
32
33struct KDevProject::Private {
34 TQMap<TQString, TQString> m_absToRel;
35 TQStringList m_symlinkList;
36 TQTimer *m_timer;
37 KDevProjectIface *m_iface;
38};
39
40KDevProject::KDevProject(const KDevPluginInfo *info, TQObject *parent, const char *name)
41 : KDevPlugin(info, parent, name), d(new KDevProject::Private())
42{
43 connect( this, TQ_SIGNAL(addedFilesToProject(const TQStringList& )), this, TQ_SLOT(buildFileMap()) );
44 connect( this, TQ_SIGNAL(removedFilesFromProject(const TQStringList& )), this, TQ_SLOT(buildFileMap()) );
45
46 connect( this, TQ_SIGNAL(addedFilesToProject(const TQStringList& )), this, TQ_SLOT(slotAddFilesToFileMap(const TQStringList& )) );
47 connect( this, TQ_SIGNAL(removedFilesFromProject(const TQStringList& )), this, TQ_SLOT(slotRemoveFilesFromFileMap(const TQStringList& )) );
48
49 d->m_timer = new TQTimer(this);
50 connect(d->m_timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotBuildFileMap()));
51 d->m_iface = new KDevProjectIface(this);
52}
53
54KDevProject::~KDevProject()
55{
56 d->m_timer->stop();
57 delete d->m_iface;
58 delete d->m_timer;
59 delete d;
60}
61
62void KDevProject::changedFile( const TQString & fileName )
63{
64 TQStringList fileList;
65 fileList.append ( fileName );
66
67 emit changedFilesInProject( fileList );
68
69}
70
71void KDevProject::changedFiles( const TQStringList & fileList )
72{
73 emit changedFilesInProject( fileList );
74}
75
76KDevProject::Options KDevProject::options() const
77{
78 return (KDevProject::Options)0;
79}
80
81bool KDevProject::isProjectFile( const TQString & absFileName )
82{
83 return d->m_absToRel.contains( absFileName );
84}
85
86TQString KDevProject::relativeProjectFile( const TQString & absFileName )
87{
88 if( isProjectFile(absFileName) )
89 return d->m_absToRel[ absFileName ];
90 return TQString();
91}
92
93void KDevProject::buildFileMap()
94{
95 d->m_timer->stop();
96 d->m_timer->start(0, true);
97}
98
99void KDevProject::slotBuildFileMap()
100{
101 kdDebug(9000) << k_funcinfo << endl;
102
103 d->m_absToRel.clear();
104 d->m_symlinkList.clear();
105 const TQStringList fileList = allFiles();
106 for( TQStringList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
107 {
108 TQFileInfo fileInfo( projectDirectory() + "/" + *it );
109 d->m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
110
111 if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
112 {
113 d->m_symlinkList << *it;
114 }
115 }
116}
117
118void KDevProject::openProject( const TQString & /*dirName*/, const TQString & /*projectName*/ )
119{
120 buildFileMap();
121}
122
123TQStringList KDevProject::symlinkProjectFiles( )
124{
125 return d->m_symlinkList;
126}
127
128TQString KDevProject::defaultRunDirectory(const TQString& projectPluginName) const
129{
130 return DomUtil::readEntry(*projectDom(), "/" + projectPluginName + "/run/globalcwd");
131}
132
133void KDevProject::slotAddFilesToFileMap( const TQStringList & fileList )
134{
135 TQStringList::ConstIterator it = fileList.begin();
136 while( it != fileList.end() )
137 {
138 TQFileInfo fileInfo( projectDirectory() + "/" + *it );
139 d->m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
140
141 if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
142 {
143 d->m_symlinkList << *it;
144 }
145
146 ++it;
147 }
148}
149
150void KDevProject::slotRemoveFilesFromFileMap( const TQStringList & fileList )
151{
152 TQStringList::ConstIterator it = fileList.begin();
153 while( it != fileList.end() )
154 {
155 TQFileInfo fileInfo( projectDirectory() + "/" + *it );
156 d->m_absToRel.remove( URLUtil::canonicalPath(fileInfo.absFilePath()) );
157
158 d->m_symlinkList.remove( *it );
159
160 ++it;
161 }
162}
163
164#include "kdevproject.moc"
KDevPluginInfo
Information about TDevelop plugin.
Definition kdevplugininfo.h:40
KDevPlugin
The base class for all TDevelop plugins.
Definition kdevplugin.h:108
KDevPlugin::projectDom
TQDomDocument * projectDom() const
Definition kdevplugin.cpp:94
KDevProjectIface
DCOP Interface for the KDevProject object.
Definition kdevprojectiface.h:35
KDevProject
KDevelop project interface.
Definition kdevproject.h:49
KDevProject::~KDevProject
virtual ~KDevProject()
Destructor.
Definition kdevproject.cpp:54
KDevProject::relativeProjectFile
virtual TQString relativeProjectFile(const TQString &absFileName)
Definition kdevproject.cpp:86
KDevProject::options
virtual Options options() const
Reimplement this method to set project plugin options.
Definition kdevproject.cpp:76
KDevProject::addedFilesToProject
void addedFilesToProject(const TQStringList &fileList)
Emitted when a new list of files has been added to the project.
KDevProject::KDevProject
KDevProject(const KDevPluginInfo *info, TQObject *parent=0, const char *name=0)
Constructs a project plugin.
Definition kdevproject.cpp:40
KDevProject::projectDirectory
virtual TQString projectDirectory() const =0
KDevProject::removedFilesFromProject
void removedFilesFromProject(const TQStringList &fileList)
Emitted when a list of files has been removed from the project.
KDevProject::defaultRunDirectory
TQString defaultRunDirectory(const TQString &projectPluginName) const
Default implementation of runDirectory method.
Definition kdevproject.cpp:128
KDevProject::symlinkProjectFiles
virtual TQStringList symlinkProjectFiles()
Definition kdevproject.cpp:123
KDevProject::changedFiles
virtual void changedFiles(const TQStringList &fileList)
Notifies the project about changes to the files.
Definition kdevproject.cpp:71
KDevProject::changedFilesInProject
void changedFilesInProject(const TQStringList &fileList)
Emitted when a list of files has changed in the project.
KDevProject::openProject
virtual void openProject(const TQString &dirName, const TQString &projectName)
This method is invoked when the project is opened (i.e.
Definition kdevproject.cpp:118
KDevProject::isProjectFile
virtual bool isProjectFile(const TQString &absFileName)
Definition kdevproject.cpp:81
KDevProject::changedFile
virtual void changedFile(const TQString &fileName)
Notifies the project of a change to one of the files.
Definition kdevproject.cpp:62
KDevProject::allFiles
virtual TQStringList allFiles() const =0
KDevProject::Options
Options
Options of the project plugin.
Definition kdevproject.h:67
kdevproject.h
KDevelop project interface.

TDevelop Interfaces Library

Skip menu "TDevelop Interfaces Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

TDevelop Interfaces Library

Skip menu "TDevelop Interfaces Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for TDevelop Interfaces Library by doxygen 1.9.8
This website is maintained by Timothy Pearson.