You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
4.8 KiB
165 lines
4.8 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2001 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
|
||
11 years ago
|
Copyright (C) 2002-2003 Roberto Raggi <roberto@kdevelop.org>
|
||
15 years ago
|
Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
|
||
|
Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
|
||
|
Copyright (C) 2003 Mario Scalas <mario.scalas@libero.it>
|
||
11 years ago
|
Copyright (C) 2003-2004 Alexander Dymo <adymo@kdevelop.org>
|
||
15 years ago
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
15 years ago
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
15 years ago
|
*/
|
||
|
|
||
|
#include <kdebug.h>
|
||
|
|
||
11 years ago
|
#include "tdevproject.h"
|
||
15 years ago
|
#include <urlutil.h>
|
||
15 years ago
|
#include <tqfileinfo.h>
|
||
|
#include <tqtimer.h>
|
||
11 years ago
|
#include "tdevprojectiface.h"
|
||
15 years ago
|
|
||
11 years ago
|
struct TDevProject::Private {
|
||
15 years ago
|
TQMap<TQString, TQString> m_absToRel;
|
||
|
TQStringList m_symlinkList;
|
||
|
TQTimer *m_timer;
|
||
11 years ago
|
TDevProjectIface *m_iface;
|
||
15 years ago
|
};
|
||
|
|
||
11 years ago
|
TDevProject::TDevProject(const TDevPluginInfo *info, TQObject *parent, const char *name)
|
||
|
: TDevPlugin(info, parent, name), d(new TDevProject::Private())
|
||
15 years ago
|
{
|
||
15 years ago
|
connect( this, TQT_SIGNAL(addedFilesToProject(const TQStringList& )), this, TQT_SLOT(buildFileMap()) );
|
||
|
connect( this, TQT_SIGNAL(removedFilesFromProject(const TQStringList& )), this, TQT_SLOT(buildFileMap()) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( this, TQT_SIGNAL(addedFilesToProject(const TQStringList& )), this, TQT_SLOT(slotAddFilesToFileMap(const TQStringList& )) );
|
||
|
connect( this, TQT_SIGNAL(removedFilesFromProject(const TQStringList& )), this, TQT_SLOT(slotRemoveFilesFromFileMap(const TQStringList& )) );
|
||
15 years ago
|
|
||
15 years ago
|
d->m_timer = new TQTimer(this);
|
||
|
connect(d->m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotBuildFileMap()));
|
||
11 years ago
|
d->m_iface = new TDevProjectIface(this);
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
TDevProject::~TDevProject()
|
||
15 years ago
|
{
|
||
|
d->m_timer->stop();
|
||
|
delete d->m_iface;
|
||
|
delete d->m_timer;
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::changedFile( const TQString & fileName )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList fileList;
|
||
15 years ago
|
fileList.append ( fileName );
|
||
|
|
||
|
emit changedFilesInProject( fileList );
|
||
|
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::changedFiles( const TQStringList & fileList )
|
||
15 years ago
|
{
|
||
|
emit changedFilesInProject( fileList );
|
||
|
}
|
||
|
|
||
11 years ago
|
TDevProject::Options TDevProject::options() const
|
||
15 years ago
|
{
|
||
11 years ago
|
return (TDevProject::Options)0;
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
bool TDevProject::isProjectFile( const TQString & absFileName )
|
||
15 years ago
|
{
|
||
14 years ago
|
return d->m_absToRel.contains( absFileName );
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
TQString TDevProject::relativeProjectFile( const TQString & absFileName )
|
||
15 years ago
|
{
|
||
|
if( isProjectFile(absFileName) )
|
||
|
return d->m_absToRel[ absFileName ];
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::buildFileMap()
|
||
15 years ago
|
{
|
||
|
d->m_timer->stop();
|
||
|
d->m_timer->start(0, true);
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::slotBuildFileMap()
|
||
15 years ago
|
{
|
||
|
kdDebug(9000) << k_funcinfo << endl;
|
||
|
|
||
|
d->m_absToRel.clear();
|
||
|
d->m_symlinkList.clear();
|
||
15 years ago
|
const TQStringList fileList = allFiles();
|
||
|
for( TQStringList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQFileInfo fileInfo( projectDirectory() + "/" + *it );
|
||
15 years ago
|
d->m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
|
||
|
|
||
|
if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
|
||
|
{
|
||
|
d->m_symlinkList << *it;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::openProject( const TQString & /*dirName*/, const TQString & /*projectName*/ )
|
||
15 years ago
|
{
|
||
|
buildFileMap();
|
||
|
}
|
||
|
|
||
11 years ago
|
TQStringList TDevProject::symlinkProjectFiles( )
|
||
15 years ago
|
{
|
||
|
return d->m_symlinkList;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevProject::defaultRunDirectory(const TQString& projectPluginName) const
|
||
15 years ago
|
{
|
||
|
return DomUtil::readEntry(*projectDom(), "/" + projectPluginName + "/run/globalcwd");
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::slotAddFilesToFileMap( const TQStringList & fileList )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList::ConstIterator it = fileList.begin();
|
||
15 years ago
|
while( it != fileList.end() )
|
||
|
{
|
||
15 years ago
|
TQFileInfo fileInfo( projectDirectory() + "/" + *it );
|
||
15 years ago
|
d->m_absToRel[ URLUtil::canonicalPath(fileInfo.absFilePath()) ] = *it;
|
||
|
|
||
|
if ( URLUtil::canonicalPath( fileInfo.absFilePath() ) != fileInfo.absFilePath() )
|
||
|
{
|
||
|
d->m_symlinkList << *it;
|
||
|
}
|
||
|
|
||
|
++it;
|
||
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
void TDevProject::slotRemoveFilesFromFileMap( const TQStringList & fileList )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList::ConstIterator it = fileList.begin();
|
||
15 years ago
|
while( it != fileList.end() )
|
||
|
{
|
||
15 years ago
|
TQFileInfo fileInfo( projectDirectory() + "/" + *it );
|
||
15 years ago
|
d->m_absToRel.remove( URLUtil::canonicalPath(fileInfo.absFilePath()) );
|
||
|
|
||
|
d->m_symlinkList.remove( *it );
|
||
|
|
||
|
++it;
|
||
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
#include "tdevproject.moc"
|