KDevelop API Documentation

kdevproject.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
00003    Copyright (C) 2002-2003 Roberto Raggi <roberto@kdevelop.org>
00004    Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
00005    Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
00006    Copyright (C) 2003 Mario Scalas <mario.scalas@libero.it>
00007    Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net>
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #include <kdebug.h>
00026 
00027 #include "kdevproject.h"
00028 #include <urlutil.h>
00029 #include <qfileinfo.h>
00030 
00031 KDevProject::KDevProject( const QString& pluginName, const QString& icon, QObject *parent, const char *name)
00032     : KDevPlugin( pluginName, icon, parent, name)
00033 {
00034 //    connect( this, SIGNAL(addedFilesToProject(const QStringList& )), this, SLOT(slotBuildFileMap()) ); // too expensive
00035 //    connect( this, SIGNAL(removedFilesFromProject(const QStringList& )), this, SLOT(slotBuildFileMap()) ); // too expensive
00036 
00037 //    connect( this, SIGNAL(changedFilesInProject(const QStringList& )), this, SLOT(slotBuildFileMap()) ); // no reason for this one
00038 
00039     connect( this, SIGNAL(addedFilesToProject(const QStringList& )), this, SLOT(slotAddFilesToFileMap(const QStringList& )) ); 
00040     connect( this, SIGNAL(removedFilesFromProject(const QStringList& )), this, SLOT(slotRemoveFilesFromFileMap(const QStringList& )) ); 
00041 }
00042 
00043 KDevProject::~KDevProject()
00044 {
00045 }
00046 
00047 void KDevProject::changedFile( const QString & fileName )
00048 {
00049     QStringList fileList;
00050     fileList.append ( fileName );
00051 
00052     emit changedFilesInProject( fileList );
00053 
00054 }
00055 
00056 void KDevProject::changedFiles( const QStringList & fileList )
00057 {
00058     emit changedFilesInProject( fileList );
00059 }
00060 
00061 KDevProject::Options KDevProject::options() const
00062 {
00063     return (KDevProject::Options)0;
00064 }
00065 
00066 bool KDevProject::isProjectFile( const QString & absFileName )
00067 {
00068     return m_absToRel.contains( absFileName );
00069 }
00070 
00071 QString KDevProject::relativeProjectFile( const QString & absFileName )
00072 {
00073     if( isProjectFile(absFileName) )
00074     return m_absToRel[ absFileName ];
00075     return QString::null;
00076 }
00077 
00078 void KDevProject::slotBuildFileMap( )
00079 {
00080     kdDebug(9000) << k_funcinfo << endl;
00081 
00082     m_absToRel.clear();
00083     m_symlinkList.clear();
00084     const QStringList fileList = allFiles();
00085     for( QStringList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
00086     {
00087     QFileInfo fileInfo( projectDirectory() + "/" + *it );
00088     m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
00089     
00090         if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
00091         {
00092             m_symlinkList << *it;
00093         }
00094     }
00095 }
00096 
00097 void KDevProject::openProject( const QString & /*dirName*/, const QString & /*projectName*/ )
00098 {
00099     slotBuildFileMap();
00100 }
00101 
00102 QStringList KDevProject::symlinkProjectFiles( )
00103 {
00104     return m_symlinkList;
00105 }
00106 
00107 void KDevProject::slotAddFilesToFileMap( const QStringList & fileList )
00108 {
00109     QStringList::ConstIterator it = fileList.begin();
00110     while( it != fileList.end() )
00111     {
00112         QFileInfo fileInfo( projectDirectory() + "/" + *it );
00113         m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
00114         
00115         if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
00116         {
00117             m_symlinkList << *it;
00118         }
00119 
00120         ++it;
00121     }
00122 }
00123 
00124 void KDevProject::slotRemoveFilesFromFileMap( const QStringList & fileList )
00125 {
00126     QStringList::ConstIterator it = fileList.begin();
00127     while( it != fileList.end() )
00128     {
00129         QFileInfo fileInfo( projectDirectory() + "/" + *it );
00130         m_absToRel.remove( URLUtil::canonicalPath(fileInfo.absFilePath()) );
00131         
00132         m_symlinkList.remove( *it );
00133 
00134         ++it;
00135     }
00136 }
00137 
00138 #include "kdevproject.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:36 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003