Summary: | "new file" relocation outside project tree fails | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Daniel Franke <franke.daniel> |
Component: | file create | Assignee: | KDevelop Developers <kdevelop-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | git master | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Solaris | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Daniel Franke
2003-07-23 21:42:02 UTC
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@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; } |