kdevproject.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00035
00036
00037
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 & , const QString & )
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"
This file is part of the documentation for KDevelop Version 3.1.2.