Fix for opening mixed-case projects

Andreas Pakulat apaku at gmx.de
Thu Jan 11 19:57:17 UTC 2007


On 11.01.07 20:51:03, Andreas Pakulat wrote:
> I'd like to apply the attached patch before KDevelop3.4.0. It fixes the
> few reports we had about kdevelop not opening the .filelist or .pcs
> files from existing projects that were imported into kdevelop. Problem
> is that I hardcoded the parts to use lowercase, which seemed fine back
> then. 

As always I forgot the patch...

Andreas

-- 
Beware of low-flying butterflies.
-------------- next part --------------
Index: buildtools/custommakefiles/customprojectpart.cpp
===================================================================
--- buildtools/custommakefiles/customprojectpart.cpp	(Revision 620964)
+++ buildtools/custommakefiles/customprojectpart.cpp	(Arbeitskopie)
@@ -302,7 +302,11 @@ void CustomProjectPart::openProject(cons
     if (m_filelistDir.isEmpty())
        m_filelistDir=dirName;
 
-    QFile f(m_filelistDir + "/" + projectName.lower() + ".kdevelop.filelist");
+    if( QFileInfo(m_filelistDir + "/" + projectName.lower() + ".kdevelop.filelist").exists() )
+    {
+        QDir( m_filelistDir ).rename(projectName.lower()+".kdevelop.filelist", projectName+".kdevelop.filelist");
+    }
+    QFile f( m_filelistDir + "/" + projectName + ".kdevelop.filelist" );
     if (f.open(IO_ReadOnly)) {
         QTextStream stream(&f);
         while (!stream.atEnd()) {
Index: parts/doxygen/doxygenpart.cpp
===================================================================
--- parts/doxygen/doxygenpart.cpp	(Revision 620906)
+++ parts/doxygen/doxygenpart.cpp	(Arbeitskopie)
@@ -195,7 +195,7 @@ void DoxygenPart::adjustDoxyfile()
   ConfigString *gen_tag = dynamic_cast<ConfigString*>(Config::instance()->get("GENERATE_TAGFILE"));
   if (gen_tag)
   {
-    gen_tag->setDefaultValue(QString(project()->projectName().lower().remove(".kdevelop")+".tag").latin1());
+    gen_tag->setDefaultValue(QString(project()->projectName()+".tag").latin1());
     gen_tag->init();
   }
 
Index: languages/java/javasupportpart.cpp
===================================================================
--- languages/java/javasupportpart.cpp	(Revision 620906)
+++ languages/java/javasupportpart.cpp	(Arbeitskopie)
@@ -528,7 +528,11 @@ JavaSupportPart::parseProject( )
     QDataStream stream;
     QMap< QString, QPair<uint, Q_LONG> > pcs;
 
-    QFile f( project()->projectDirectory() + "/" + project()->projectName().lower() + ".kdevelop" + ".pcs" );
+    if( QFileInfo( project()->projectDirectory() + "/" + project()->projectName().lower() + ".kdevelop.pcs" ).exists() )
+    {
+        QDir(project()->projectDirectory()).rename( project()->projectName().lower() + ".kdevelop.pcs",  project()->projectName() + ".kdevelop.pcs");
+    }
+    QFile f(project()->projectDirectory() + "/" + project()->projectName() + ".kdevelop.pcs");
     if( f.open(IO_ReadOnly) ){
 	stream.setDevice( &f );
 
@@ -864,7 +868,7 @@ void JavaSupportPart::saveProjectSourceI
     if( !project() || fileList.isEmpty() )
 	return;
 
-    QFile f( project()->projectDirectory() + "/" + project()->projectName().lower() + ".kdevelop" + ".pcs" );
+    QFile f( project()->projectDirectory() + "/" + project()->projectName() + ".kdevelop.pcs" );
     if( !f.open( IO_WriteOnly ) )
 	return;
 
Index: languages/cpp/cppsupportpart.cpp
===================================================================
--- languages/cpp/cppsupportpart.cpp	(Revision 620906)
+++ languages/cpp/cppsupportpart.cpp	(Arbeitskopie)
@@ -1349,11 +1349,16 @@ bool CppSupportPart::parseProject( bool 
 	kapp->setOverrideCursor( waitCursor );
 
 	_jd = new JobData;
-	_jd->file.setName( project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".pcs" );
+	if( QFileInfo( project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop.pcs" ).exists())
+	{
+		QDir d(project()->projectDirectory()).rename(project()->projectName().lower() + ".kdevelop.pcs", project()->projectName() +".kdevelop.pcs");
+	}
+	_jd->file.setName( project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.pcs" );
 
-	QString skip_file_name = project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".ignore_pcs";
+	QString skip_file_name = project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.ignore_pcs";
+	QString skip_lower_file_name = project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop.ignore_pcs";
 
-	if ( !force && !QFile::exists( skip_file_name ) && _jd->file.open( IO_ReadOnly ) )
+	if ( !force && !QFile::exists( skip_file_name ) && !QFile::exists( skip_lower_file_name ) && _jd->file.open( IO_ReadOnly ) )
 	{
 		_jd->stream.setDevice( &( _jd->file ) );
 
@@ -1495,7 +1500,10 @@ void CppSupportPart::slotParseFiles()
 				emit updatedSourceInfo();
 				mainWindow( ) ->statusBar( ) ->message( i18n( "Done" ), 2000 );
 				QFile::remove
-					( project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".ignore_pcs" );
+					( project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.ignore_pcs" );
+				QFile::remove
+					( project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop.ignore_pcs" );
+
 			}
 			else
 			{
@@ -2030,7 +2038,7 @@ void CppSupportPart::saveProjectSourceIn
 	if ( !project() || fileList.isEmpty() )
 		return ;
 
-	QFile f( project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".pcs" );
+	QFile f( project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.pcs" );
 	if ( !f.open( IO_WriteOnly ) )
 		return ;
 
@@ -2070,9 +2078,8 @@ void CppSupportPart::saveProjectSourceIn
 		stream.device() ->at( end );
 	}
 
-	QString skip_file_name = project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".ignore_pcs";
-	QFile::remove
-		( skip_file_name );
+	QFile::remove(  project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.ignore_pcs" );
+	QFile::remove(  project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop.ignore_pcs" );
 
 	m_backgroundParser->unlock();
 }
@@ -2553,7 +2560,7 @@ void CppSupportPart::createIgnorePCSFile
 {
 	static QCString skip_me( "ignore me\n" );
 
-	QString skip_file_name = project() ->projectDirectory() + "/" + project() ->projectName().lower() + ".kdevelop" + ".ignore_pcs";
+	QString skip_file_name = project() ->projectDirectory() + "/" + project() ->projectName() + ".kdevelop.ignore_pcs";
 	QFile skip_pcs_file( skip_file_name );
 	if ( skip_pcs_file.open( IO_WriteOnly ) )
 	{


More information about the KDevelop-devel mailing list