[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-05 2:01:36
Message-ID: 1173060096.912992.16898.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 639386 by apaku:
Add a FilesDialog that allows the user to choose among files that should be added to \
the project This doesn't work yet, the files don't get added/blacklisted and for some \
reason the initial list isn't generated properly.
M +6 -5 Makefile.am
A addfilesdialog.cpp [License: GPL (v2+)]
A addfilesdialog.h [License: GPL (v2+)]
A addfilesdialogbase.ui
M +1 -1 custommanagerwidget.cpp
M +109 -37 customprojectpart.cpp
M +4 -0 customprojectpart.h
M +2 -1 kdevcustomproject.rc
--- branches/kdevelop/3.4/buildtools/custommakefiles/Makefile.am #639385:639386
@@ -10,10 +10,10 @@
libkdevcustomproject_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
$(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la \
$(top_builddir)/buildtools/lib/base/libkdevbuildbase.la
-libkdevcustomproject_la_SOURCES = custombuildoptionswidget.cpp \
- custombuildoptionswidgetbase.ui custommakeconfigwidget.cpp \
custommakeconfigwidgetbase.ui \
- custommanagerwidget.cpp custommanagerwidgetbase.ui customotherconfigwidget.cpp \
- customotherconfigwidgetbase.ui customprojectpart.cpp
+libkdevcustomproject_la_SOURCES = addfilesdialog.cpp addfilesdialogbase.ui \
+ custombuildoptionswidget.cpp custombuildoptionswidgetbase.ui \
custommakeconfigwidget.cpp \ + custommakeconfigwidgetbase.ui custommanagerwidget.cpp \
custommanagerwidgetbase.ui \ + customotherconfigwidget.cpp \
customotherconfigwidgetbase.ui customprojectpart.cpp
METASOURCES = AUTO
@@ -22,4 +22,5 @@
rcdir = $(kde_datadir)/kdevcustomproject
rc_DATA = kdevcustomproject.rc
-noinst_HEADERS = custommanagerwidget.h customotherconfigwidget.h
+noinst_HEADERS = addfilesdialog.h custommanagerwidget.h \
+ customotherconfigwidget.h
--- branches/kdevelop/3.4/buildtools/custommakefiles/custommanagerwidget.cpp \
#639385:639386 @@ -29,7 +29,7 @@
{
m_filetypes->insertStringList( DomUtil::readListEntry( m_dom, \
"kdevcustomproject/filetypes", "filetype" ) ); KURLRequester* urlselector = new \
KURLRequester( );
- urlselector->setMode( KFile::Files | KFile::ExistingOnly | KFile::LocalOnly );
+ urlselector->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
urlselector->setURL( QString::null );
urlselector->completionObject() ->setDir( part->projectDirectory() );
urlselector->fileDialog() ->setURL( KURL( part->projectDirectory() ) );
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.cpp \
#639385:639386 @@ -55,6 +55,8 @@
#include "envvartools.h"
#include "urlutil.h"
+#include "addfilesdialog.h"
+
#include <kdevplugininfo.h>
typedef KDevGenericFactory<CustomProjectPart> CustomProjectFactory;
@@ -76,6 +78,10 @@
action->setToolTip( i18n( "Re-Populate Project" ) );
action->setWhatsThis( i18n( "<b>Re-Populate Project</b><p>Re-Populate's the \
project, searches through the project directory and adds all files that match one of \
the wildcards set in the custom manager options to the project filelist." ) );
+ action = new KAction( i18n( "Add New Files To Project" ), 0, this, SLOT( \
addNewFilesToProject() ), actionCollection(), "addnewfiles_project" ); + \
action->setToolTip( i18n( "Add New Files To Project" ) ); + action->setWhatsThis( \
i18n( "<b>Add New Files To Project</b><p>Adds files created outside of kdevelop to \
the project." ) ); +
action = new KAction( i18n( "&Build Project" ), "make_kdevelop", Key_F8,
this, SLOT( slotBuild() ),
actionCollection(), "build_build" );
@@ -256,7 +262,7 @@
for ( KURL::List::ConstIterator it = urls.begin(); it != urls.end(); ++it )
{
QString canPath( URLUtil::canonicalPath(( *it ).path() ) );
- QString relPath = URLUtil::extractPathNameRelative( URLUtil::canonicalPath( \
project()->projectDirectory() ), canPath ); + QString relPath = \
relativeToProject( canPath ); if( isInBlacklist( relPath ) )
continue;
if ((( *it ).isLocalFile() && isProjectFileType(( *it ).fileName() ) ) )
@@ -365,9 +371,15 @@
void CustomProjectPart::openProject( const QString &dirName, const QString \
&projectName ) {
+ dirwatch->blockSignals( true );
+ dirwatch->stopScan();
+
m_projectDirectory = dirName;
m_projectName = projectName;
+
+ m_autoAddFiles.clear();
+
QDomDocument &dom = *projectDom();
// Set the default directory radio to "executable"
if ( DomUtil::readEntry( dom, "/kdevcustomproject/run/directoryradio" ) == "" )
@@ -398,6 +410,7 @@
projectName.lower() + ".kdevelop.filelist",
projectName + ".kdevelop.filelist" );
}
+
QFile f( m_filelistDir + "/" + projectName + ".kdevelop.filelist" );
if ( f.open( IO_ReadOnly ) )
{
@@ -407,24 +420,8 @@
QString s = stream.readLine();
if ( !s.startsWith( "#" ) && QFileInfo( projectDirectory() + "/" + s \
).exists() && m_sourceFiles.find(s) == m_sourceFiles.end() ) {
-
if( isInBlacklist(s) )
continue;
- QStringList paths = QStringList::split("/", s);
- paths.pop_back();
- QString path;
- for( QStringList::const_iterator it = paths.begin(); it != \
paths.end(); ++it)
- {
- path += *it;
- if( m_sourceFiles.find( path ) == m_sourceFiles.end() )
- {
- dirwatch->addDir( projectDirectory() + "/"+ path );
- m_sourceFiles << path;
- }
- path += "/";
- }
- if( QFileInfo( projectDirectory() + "/" +s ).isDir() )
- dirwatch->addDir( projectDirectory() + "/"+ s );
m_sourceFiles << s;
}
}
@@ -450,10 +447,24 @@
el.setTagName( "default" );
envs.appendChild( el );
}
-
+ addDirWatches( dirName );
KDevProject::openProject( dirName, projectName );
+ dirwatch->startScan();
+ dirwatch->blockSignals( false );
}
+void CustomProjectPart::addDirWatches( const QString& absPath )
+{
+
+ dirwatch->addDir( absPath );
+ QStringList entries = QDir( absPath ).entryList( QDir::Dirs );
+ for( QStringList::const_iterator it = entries.begin(); it != entries.end(); ++it \
) + {
+ if( *it != "." && *it != ".." )
+ addDirWatches( absPath + "/" + *it );
+ }
+}
+
void CustomProjectPart::cleanFileList()
{
QStringList temp;
@@ -492,10 +503,10 @@
{
QString fileName = it.current()->fileName();
QString path = it.current()->absFilePath();
- if ( fileName == "." || fileName == ".." || isInBlacklist( fileName \
) )
- {
+ 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;
@@ -539,6 +550,7 @@
for ( it = m_sourceFiles.begin(); it != m_sourceFiles.end(); ++it )
stream << ( *it ) << endl;
f.close();
+ m_autoAddFiles.clear();
}
@@ -665,8 +677,10 @@
QStringList addedFiles;
for ( it = fileList.begin(); it != fileList.end(); ++it )
{
- if ( *it == "." || *it == ".." || isInBlacklist( *it ) )
+ if ( *it == "." || *it == ".." )
continue;
+ if ( isInBlacklist( *it ) )
+ continue;
kdDebug( 9025 ) << "Add file: " << *it << endl;
QString relpath;
if( QDir::isRelativePath( *it ) )
@@ -674,7 +688,7 @@
relpath = *it;
}else
{
- relpath = URLUtil::relativePathToFile( projectDirectory(), *it );
+ relpath = relativeToProject( *it );
}
if ( QFileInfo( projectDirectory() + "/" + relpath ).isDir() && ( \
m_recursive || m_first_recursive ) ) @@ -683,11 +697,10 @@
QStringList subentries = QDir( projectDirectory() + "/" + relpath \
).entryList();
for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit ) if ( *subit != "." && *subit != ".." )
- *subit = QDir::cleanDirPath(( relpath ) + "/" + ( *subit ) );
- dirwatch->addDir( projectDirectory()+"/"+relpath );
+ *subit = relpath + "/" + ( *subit );
addFiles( subentries );
- addedFiles << QDir::cleanDirPath( relpath );
- m_sourceFiles.append( QDir::cleanDirPath( relpath ) );
+ addedFiles << relpath;
+ m_sourceFiles.append( relpath );
m_first_recursive = true;
}
else if ( isProjectFileType( QFileInfo( relpath ).fileName() ) && \
m_sourceFiles.find( relpath ) == m_sourceFiles.end() ) @@ -700,7 +713,6 @@
path += *it;
if( m_sourceFiles.find( path ) == m_sourceFiles.end() )
{
- dirwatch->addDir( projectDirectory() + "/" + path );
addedFiles << path;
m_sourceFiles << path;
}
@@ -745,7 +757,7 @@
if ( QDir::isRelativePath( *it ) )
relpath = *it;
else
- relpath = URLUtil::relativePathToFile( projectDirectory(), *it );
+ relpath = relativeToProject( *it );
if ( QFileInfo( projectDirectory() + "/" + relpath ).isDir() && ( \
m_recursive || m_first_recursive ) ) {
@@ -753,12 +765,12 @@
QStringList subentries = QDir( projectDirectory() + "/" + relpath \
).entryList();
for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit ) if ( *subit != "." && *subit != ".." )
- *subit = QDir::cleanDirPath(( relpath ) + "/" + ( *subit ) );
+ *subit = relpath + "/" + ( *subit );
removeFiles( subentries );
if ( !containsProjectFiles( relpath ) )
{
- removedFiles << QDir::cleanDirPath( relpath );
- m_sourceFiles.remove( QDir::cleanDirPath( relpath ) );
+ removedFiles << relpath;
+ m_sourceFiles.remove( relpath );
}
m_first_recursive = true;
}
@@ -1353,8 +1365,10 @@
QStringList subentries = QDir( dir ).entryList();
for ( QStringList::const_iterator it = subentries.begin(); it != \
subentries.end(); ++it ) {
- if ( *it == "." || *it == ".." || isInBlacklist( *it ) )
+ if ( *it == "." || *it == ".." )
continue;
+ if( isInBlacklist( *it ) )
+ continue;
if ( QFileInfo( dir + "/" + *it ).isDir() && !isInBlacklist( *it ) )
{
kdDebug( 9025 ) << dir + "/" + *it << " checking for contained \
non-proj-files" << endl; @@ -1382,8 +1396,11 @@
QStringList subentries = QDir( dir ).entryList();
for ( QStringList::const_iterator it = subentries.begin(); it != \
subentries.end(); ++it ) {
- if ( *it == "." || *it == ".." || isInBlacklist( *it ) )
+ if ( *it == "." || *it == ".." )
continue;
+ if( isInBlacklist( *it ) )
+ continue;
+
if ( QFileInfo( dir + "/" + *it ).isDir() && !isInBlacklist( *it ) )
{
if ( containsProjectFiles( dir + "/" + *it ) )
@@ -1428,8 +1445,12 @@
for( QStringList::const_iterator it = types.begin(); it != types.end(); ++it )
{
re.setPattern( *it );
- if( re.search( filename ) != -1 )
+ if ( ( (*it).find("*") != -1 || (*it).find("?") != -1 ) && re.search( \
filename ) != -1 ) return true;
+ else if( filename.find( "/" ) != -1 && filename.find( *it ) != -1 )
+ return true;
+ else if( filename.find( "/" ) == -1 && filename == *it)
+ return true;
}
return false;
}
@@ -1437,7 +1458,11 @@
void CustomProjectPart::slotDirDirty( const QString& dir )
{
QStringList remove;
- QString reldir = URLUtil::relativePathToFile( projectDirectory(), dir);
+ QString reldir = relativeToProject( dir );
+ if( !reldir.isEmpty() )
+ reldir += "/";
+ kdDebug(9025) << "dir: " << dir <<" reldir:" << reldir << endl;
+
QStringList blacklist = this->blacklist();
for( QStringList::const_iterator it = m_sourceFiles.begin(); it !=
m_sourceFiles.end(); ++it)
@@ -1458,6 +1483,20 @@
}
updateBlacklist( blacklist );
removeFiles(remove);
+
+ QStringList files = QDir(dir).entryList();
+ 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 ) ) + \
{ + kdDebug(9025) << "Adding " << reldir+*it << " to autolist" << endl;
+ m_autoAddFiles.append( reldir+*it );
+ }
+ }
}
void CustomProjectPart::switchBlacklistEntry( const QString& path)
@@ -1476,11 +1515,19 @@
updateBlacklist( blacklist );
}
+QString CustomProjectPart::relativeToProject( const QString& abspath ) const
+{
+ QString path = abspath.mid( projectDirectory().length()+1 );
+ if( path.endsWith("/") )
+ path = path.mid( 0, path.length()-1 );
+ return path;
+}
+
bool CustomProjectPart::isInBlacklist( const QString& path ) const
{
QString relpath = path;
if( !QFileInfo( relpath ).isRelative() )
- relpath = URLUtil::relativePathToFile( projectDirectory(), path );
+ relpath = relativeToProject( path );
kdDebug(9025) << "Checking " << relpath << " if it is in blacklist" << endl;
QStringList blacklist = this->blacklist();
if( blacklist.find( relpath ) != blacklist.end() )
@@ -1507,6 +1554,31 @@
return DomUtil::readListEntry( *projectDom(), "kdevcustomproject/blacklist", \
"path"); }
+void CustomProjectPart::addNewFilesToProject()
+{
+ QStringList addfiles;
+ for( QStringList::const_iterator it = m_autoAddFiles.begin(); it != \
m_autoAddFiles.end(); ++it ) + {
+ if( m_sourceFiles.find( *it ) == m_sourceFiles.end() && isProjectFileType( \
*it ) && !isInBlacklist( *it ) ) + {
+ addfiles << *it;
+ }
+ }
+
+ kdDebug(9025) << "Took " << addfiles << " from " << m_autoAddFiles << endl;
+
+ AddFilesDialog *dlg = new AddFilesDialog( addfiles, this->mainWindow()->main() \
); + if( dlg->exec() == KDialog::Accepted )
+ {
+ kdDebug(9025) << "Dialog was accepted" << endl;
+ m_autoAddFiles.clear();
+ QStringList blacklist = this->blacklist();
+ blacklist += dlg->excludedPaths();
+ updateBlacklist( blacklist );
+ addFiles( dlg->includedPaths() );
+ }
+}
+
#include "customprojectpart.moc"
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.h \
#639385:639386 @@ -73,6 +73,7 @@
void slotRemoveFromProject();
void slotAddToProjectRecursive();
void slotRemoveFromProjectRecursive();
+ void addNewFilesToProject();
void slotChangeBlacklist();
void slotChooseActiveDirectory();
void slotBuild();
@@ -98,6 +99,8 @@
bool isProjectFileType( const QString& absFile ) const;
bool isInBlacklist( const QString& ) const;
void cleanFileList();
+ QString relativeToProject( const QString& ) const;
+ void addDirWatches( const QString& );
QStringList filetypes() const;
QStringList blacklist() const;
@@ -113,6 +116,7 @@
QString m_projectName;
QString m_filelistDir;
QStringList m_sourceFiles;
+ QStringList m_autoAddFiles;
QPopupMenu *m_targetMenu;
QPopupMenu *m_targetObjectFilesMenu;
QPopupMenu *m_targetOtherFilesMenu;
--- branches/kdevelop/3.4/buildtools/custommakefiles/kdevcustomproject.rc \
#639385:639386 @@ -1,8 +1,9 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="KDevCustomProject" version="5">
+<kpartgui name="KDevCustomProject" version="6">
<MenuBar>
<Menu name="project" >
<Action name="repopulate_project" />
+ <Action name="addnewfiles_project" />
</Menu>
<Menu name="build" >
<Action name="build_build" />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic