[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdevelop/3.4/buildtools/custommakefiles
From: Andreas Pakulat <apaku () gmx ! de>
Date: 2007-03-06 22:21:43
Message-ID: 1173219703.979706.8083.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 640121 by apaku:
Fix switching the blacklist entry
make it more clear wether the context menu entry adds or removes and item to the \
blacklist Implement finding of new files on project open
make populate clear blacklist and sourceslist
M +82 -85 customprojectpart.cpp
M +1 -0 customprojectpart.h
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.cpp \
#640120:640121 @@ -246,13 +246,25 @@
popup->insertSeparator();
m_contextDirName = fcontext->urls().first().path();
m_contextDirName = m_contextDirName.mid( \
project()->projectDirectory().length() + 1 );
- int id = popup->insertItem( i18n( "Add/Remove to/from blacklist" ),
- this, SLOT( slotChangeBlacklist() ) );
- popup->setWhatsThis( id, i18n( "<b>Add/Remove to/from blacklist</b><p>"
- "Adds the given file or directory to the \
blacklist, or removes it from the "
- "blacklist if its already in it.<br>The \
blacklist contains files and"
- " directories that should be ignored even if \
they match a project filetype "
- "pattern" ) );
+ int id;
+ if( isInBlacklist( m_contextDirName ) )
+ {
+ id = popup->insertItem( i18n( "Remove from blacklist" ),
+ this, SLOT( slotChangeBlacklist() ) );
+ popup->setWhatsThis( id, i18n( "<b>Remove from blacklist</b><p>"
+ "Removes the given file or directory from \
the " + "blacklist if its already in \
it.<br>The blacklist contains files and" + " \
directories that should be ignored even if they match a project filetype " + \
"pattern" ) ); + }else
+ {
+ id = popup->insertItem( i18n( "Add to blacklist" ),
+ this, SLOT( slotChangeBlacklist() ) );
+ popup->setWhatsThis( id, i18n( "<b>Add to blacklist</b><p>"
+ "Adds the given file or directory to the \
blacklist.<br>The blacklist contains files and" + \
" directories that should be ignored even if they match a project filetype " + \
"pattern" ) ); + }
}
const KURL::List urls = fcontext->urls();
@@ -436,6 +448,15 @@
populateProject();
}
+ QStringList newfiles;
+ findNewFiles(dirName, newfiles);
+
+ if( newfiles.count() > 0 )
+ {
+ m_autoAddFiles = newfiles;
+ addNewFilesToProject();
+ }
+
// check if there is an old envvars entry (from old project file with single \
make environment)
QString buildtool = DomUtil::readEntry(dom , \
"/kdevcustomproject/build/buildtool" ); QDomElement el =
@@ -453,81 +474,56 @@
dirwatch->blockSignals( false );
}
-void CustomProjectPart::addDirWatches( const QString& absPath )
+void CustomProjectPart::findNewFiles( const QString& dir, QStringList& filelist ) \
const {
-
- dirwatch->addDir( absPath );
- QStringList entries = QDir( absPath ).entryList( QDir::Dirs );
+ if( dir.isEmpty() )
+ return;
+ QStringList entries = QDir(dir).entryList();
+ QString relpath = relativeToProject( dir );
+ entries.remove(".");
+ entries.remove("..");
for( QStringList::const_iterator it = entries.begin(); it != entries.end(); ++it \
) {
- if( *it != "." && *it != ".." )
- addDirWatches( absPath + "/" + *it );
+ if( m_sourceFiles.find( relpath + "/" + *it ) == m_sourceFiles.end() )
+ {
+ if( QFileInfo( dir+"/"+*it ).isFile() )
+ {
+ filelist << relpath+"/"+*it;
+ }else if( QFileInfo( dir+"/"+*it ).isDir() )
+ {
+ findNewFiles( dir+"/"+*it, filelist );
+ }
+ }
}
}
-void CustomProjectPart::cleanFileList()
+void CustomProjectPart::addDirWatches( const QString& absPath )
{
- QStringList temp;
- QFileInfo fi;
- for( QStringList::const_iterator it = m_sourceFiles.begin(); it != \
m_sourceFiles.end(); ++it ) + dirwatch->addDir( absPath );
+ QStringList entries = QDir( absPath ).entryList( QDir::Dirs );
+ entries.remove(".");
+ entries.remove("..");
+ for( QStringList::const_iterator it = entries.begin(); it != entries.end(); ++it \
) {
- fi.setFile( projectDirectory()+"/"+*it );
- if( !fi.exists() || ( fi.isFile() && !this->isProjectFile( fi.fileName() ) ) \
)
- temp << *it;
+ addDirWatches( absPath + "/" + *it );
}
- removeFiles( temp );
}
+
void CustomProjectPart::populateProject()
{
QApplication::setOverrideCursor( Qt::waitCursor );
- cleanFileList();
+ removeFiles( m_sourceFiles );
+ updateBlacklist( QStringList() );
QStringList newlist;
- QValueStack<QString> s;
- int prefixlen = m_projectDirectory.length() + 1;
- s.push( m_projectDirectory );
+ findNewFiles( projectDirectory(), newlist );
- QDir dir;
- do
- {
- dir.setPath( s.pop() );
- kdDebug( 9025 ) << "Examining: " << dir.path() << endl;
- const QFileInfoList *dirEntries = dir.entryInfoList();
- if ( dirEntries )
- {
- QPtrListIterator<QFileInfo> it( *dirEntries );
- for ( ; it.current(); ++it )
- {
- QString fileName = it.current()->fileName();
- QString path = it.current()->absFilePath();
- if ( fileName == "." || fileName == ".." )
- continue;
- if( isInBlacklist( fileName ) )
- continue;
- if ( it.current()->isDir() && m_sourceFiles.find( path.mid( \
prefixlen ) ) == m_sourceFiles.end())
- {
- kdDebug( 9025 ) << "Pushing: " << path << endl;
- newlist.append( path );
- s.push( path );
- continue;
- }
- if (( !fileName.endsWith( "~" ) )
- && isProjectFileType( fileName )
- && m_sourceFiles.find( path.mid( prefixlen ) ) == \
m_sourceFiles.end() )
- {
- kdDebug( 9025 ) << "Adding: " << path << endl;
- newlist.append( path.mid( prefixlen ) );
- }
- }
- }
- }
- while ( !s.isEmpty() );
+ m_autoAddFiles = newlist;
+ addNewFilesToProject();
- addFiles( newlist );
-
QApplication::restoreOverrideCursor();
}
@@ -675,11 +671,12 @@
{
QStringList::ConstIterator it;
QStringList addedFiles;
- kdDebug(9025) << "Adding files: " << fileList << endl;
- for ( it = fileList.begin(); it != fileList.end(); ++it )
+ QStringList myfileList = fileList;
+ kdDebug(9025) << "Adding files: " << myfileList << endl;
+ myfileList.remove(".");
+ myfileList.remove("..");
+ for ( it = myfileList.begin(); it != myfileList.end(); ++it )
{
- if ( *it == "." || *it == ".." )
- continue;
if ( isInBlacklist( *it ) )
continue;
kdDebug( 9025 ) << "Add file: " << *it << endl;
@@ -750,13 +747,13 @@
{
kdDebug( 9025 ) << "Emitting removedFilesFromProject" << endl;
QStringList removedFiles;
-
+ QStringList myfileList = fileList;
QStringList::ConstIterator it;
+ myfileList.remove(".");
+ myfileList.remove("..");
- for ( it = fileList.begin(); it != fileList.end(); ++it )
+ for ( it = myfileList.begin(); it != myfileList.end(); ++it )
{
- if ( *it == "." || *it == ".." )
- continue;
QString relpath;
if ( QDir::isRelativePath( *it ) )
relpath = *it;
@@ -1365,10 +1362,10 @@
if( isInBlacklist( dir ) )
return false;
QStringList subentries = QDir( dir ).entryList();
+ subentries.remove(".");
+ subentries.remove("..");
for ( QStringList::const_iterator it = subentries.begin(); it != \
subentries.end(); ++it ) {
- if ( *it == "." || *it == ".." )
- continue;
if( isInBlacklist( *it ) )
continue;
if ( QFileInfo( dir + "/" + *it ).isDir() && !isInBlacklist( *it ) )
@@ -1396,10 +1393,10 @@
if( isInBlacklist( dir ) )
return false;
QStringList subentries = QDir( dir ).entryList();
+ subentries.remove(".");
+ subentries.remove("..");
for ( QStringList::const_iterator it = subentries.begin(); it != \
subentries.end(); ++it ) {
- if ( *it == "." || *it == ".." )
- continue;
if( isInBlacklist( *it ) )
continue;
@@ -1422,14 +1419,13 @@
{
QStringList result;
QStringList subentries = QDir( projectDirectory()+"/"+dir ).entryList();
+ subentries.remove(".");
+ subentries.remove("..");
for ( QStringList::const_iterator it = subentries.begin(); it != \
subentries.end(); ++it ) {
- if ( *it != "." && *it != ".." )
+ if ( m_sourceFiles.find( dir + "/" + *it ) != m_sourceFiles.end() )
{
- if ( m_sourceFiles.find( dir + "/" + *it ) != m_sourceFiles.end() )
- {
- result << (*it);
- }
+ result << (*it);
}
}
return result;
@@ -1487,11 +1483,10 @@
removeFiles(remove);
QStringList files = QDir(dir).entryList();
+ files.remove(".");
+ files.remove("..");
for( QStringList::const_iterator it = files.begin(); it != files.end(); ++it )
{
- if( *it == "." || *it == ".." )
- continue;
-
kdDebug(9025) << "Checking " << reldir+*it << " against sources list: " << \
m_sourceFiles << endl;
if( m_sourceFiles.find( reldir+*it ) == m_sourceFiles.end() && \
isProjectFileType( *it ) && !isInBlacklist( reldir+*it ) ) {
@@ -1504,8 +1499,10 @@
void CustomProjectPart::switchBlacklistEntry( const QString& path)
{
QStringList blacklist = this->blacklist();
- if( isInBlacklist( path ) )
+ kdDebug(9025) << "Switching path " << path << endl;
+ if( !isInBlacklist( path ) )
{
+ kdDebug(9025) << "Path in blacklist" << endl;
blacklist << path;
m_recursive = true;
removeFile(path);
@@ -1528,10 +1525,10 @@
bool CustomProjectPart::isInBlacklist( const QString& path ) const
{
QString relpath = path;
+ QStringList blacklist = this->blacklist();
if( !QFileInfo( relpath ).isRelative() )
relpath = relativeToProject( path );
- kdDebug(9025) << "Checking " << relpath << " if it is in blacklist" << endl;
- QStringList blacklist = this->blacklist();
+ kdDebug(9025) << "Checking " << relpath << " if it is in blacklist " << \
blacklist << endl; if( blacklist.find( relpath ) != blacklist.end() )
return true;
QStringList paths = QStringList::split("/", relpath);
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.h \
#640120:640121 @@ -101,6 +101,7 @@
void cleanFileList();
QString relativeToProject( const QString& ) const;
void addDirWatches( const QString& );
+ void findNewFiles( const QString& dir, QStringList& list) const;
QStringList filetypes() const;
QStringList blacklist() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic