Bug 63787

Summary: trollproject: Relative url's to files subdirs are handled wrong.
Product: [Applications] kdevelop Reporter: Stephan Heigl <steve>
Component: Build tools: QMakeAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Stephan Heigl 2003-09-06 09:50:32 UTC
Version:            (using KDE KDE 3.1.1)
Installed from:    Compiled From Sources
Compiler:          gcc 3.3.1 
OS:          Linux

When maintaining one .pro file for the whole project and not having a separate .pro for each subdir KDevelop/Gideon (latest CVS) just links to the file as if it was in the projects root dir when creating a new file (header/source doesn't matter). The file is created in the right directory, but the link in the header/source listbox discharges the path.

example:

/ project root (there's the .pro file)

Insert new File -> subdir/File.h
Then we get a new entry in the listbox linking to
/ File.h instead of subdir/File.h
Comment 1 Amilcar do Carmo Lucas 2003-09-06 13:02:34 UTC
Please specify your version. Are you using CVS HEAD? If not, please update. 
Comment 2 Stephan Heigl 2003-09-06 13:19:13 UTC
It's CVS HEAD (from 01-sept-2003). 
Comment 3 Alexander Dymo 2003-11-18 20:31:18 UTC
Subject: kdevelop/buildtools/qmake

CVS commit by dymo: 

Allow to use relative paths with "new file" wizard.
CCMAIL: 63787-done@bugs.kde.org


  M +25 -0     trollprojectwidget.cpp   1.141


--- kdevelop/buildtools/qmake/trollprojectwidget.cpp  #1.140:1.141
@@ -1632,4 +1632,29 @@ void TrollProjectWidget::addFiles( QStri
         noPathFileName = info.fileName();
 
+    GroupItem *gitem = 0;
+    QPtrListIterator<GroupItem> it(m_shownSubproject->groups);
+    for (; it.current(); ++it)
+    {
+        if ((*it)->groupType == GroupItem::groupTypeForExtension(ext))
+        {
+            gitem = *it;
+            break;
+        }
+    }
+    if (gitem && !noPathTruncate)
+    {
+        QString addName;
+        if (fileName.startsWith("/"))
+            addName = URLUtil::relativePath(gitem->owner->path, fileName);
+        else
+            addName = URLUtil::relativePath(gitem->owner->relpath, "/" + fileName);
+        if (!addName.isEmpty())
+        {
+            if (addName[0] == '/')
+                addName = addName.mid(1);
+            noPathFileName = addName;
+        }
+    }
+
     addFileToCurrentSubProject(GroupItem::groupTypeForExtension(ext), noPathFileName);
     updateProjectFile(m_shownSubproject);