[Bug 61591] "new file" relocation outside project tree fails

Alexander Dymo cloudtemple at mksat.net
Fri Jul 25 23:23:05 UTC 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=61591     
cloudtemple at mksat.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From cloudtemple at mksat.net  2003-07-25 23:22 -------
Subject: kdevelop/parts/filecreate

CVS commit by dymo: 

allow to create and open files not only in the project directory (if "Add to project" box is unchecked)
CCMAIL: 61591-done at bugs.kde.org


  M +61 -31    filecreate_part.cpp   1.34


--- kdevelop/parts/filecreate/filecreate_part.cpp  #1.33:1.34
@@ -437,5 +437,6 @@ KDevCreateFile::CreatedFile FileCreatePa
   }
 
-
+  if (dialog.addToProject())
+  {
   // work out the path relative to the project directory
   QString relToProj = URLUtil::relativePath(projectURL, selectedURL, URLUtil::SLASH_PREFIX );
@@ -462,14 +463,43 @@ KDevCreateFile::CreatedFile FileCreatePa
   }
 
-  if (result.addToProject)
     project()->addFile(relToProj.mid(1));
 
+    // tell the caller what we did
+    result.filename = filename;
+    result.dir = URLUtil::directory(relToProj);
+    result.status = KDevCreateFile::CreatedFile::STATUS_OK;
+  }
+  else //this is for non-project files
+  {
+    QString fullPath = selectedURL.path();
+    // add appropriate extension, if not already there
+    if (!ext.isNull() & ext!="" & !fullPath.endsWith("." + ext)) fullPath+="." + ext;
 
+    QString filename = URLUtil::filename(fullPath);
 
+    kdDebug(9034) << "full path = " << fullPath << endl;
+    kdDebug(9034) << "filename = " << filename << endl;
 
-  // tell the caller what we did
+    // add in subtype, if specified
+    if (!subtype.isEmpty())
+        ext += "-" + subtype;
+
+    // create file from template, and add it to the project
+    if (!FileTemplate::exists(this, ext) ||
+        !FileTemplate::copy(this, ext, fullPath) ) {
+        // no template, create a blank file instead
+        QFile f(fullPath);
+        f.open( IO_WriteOnly );
+        f.close();
+    }
+    KURL url;
+    url.setPath(fullPath);
+    qWarning("url: %s", url.url().latin1());
+    partController()->editDocument(url);
   result.filename = filename;
-  result.dir = URLUtil::directory(relToProj);
+    result.dir = URLUtil::directory(fullPath);
   result.status = KDevCreateFile::CreatedFile::STATUS_OK;
+  }
+
   return result;
 }




More information about the KDevelop-devel mailing list