Commit 111c18e3 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Fix Wizard page not offering the right project to add to.

Symptom of file name slashification breakage.

Reviewed-by: dt
Task-number: QTCREATORBUG-2535
parent 5e59605c
......@@ -72,7 +72,7 @@ public:
};
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
path(p),
path(QDir::cleanPath(p)),
binary(false),
attributes(0)
{
......@@ -111,7 +111,7 @@ QString GeneratedFile::path() const
void GeneratedFile::setPath(const QString &p)
{
m_d->path = p;
m_d->path = QDir::cleanPath(p);
}
QString GeneratedFile::contents() const
......@@ -628,7 +628,7 @@ bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *e
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
if (!em->openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) {
if (errorMessage)
*errorMessage = tr("Failed to open an editor for '%1'.").arg(file.path());
*errorMessage = tr("Failed to open an editor for '%1'.").arg(QDir::toNativeSeparators(file.path()));
return false;
}
}
......@@ -663,7 +663,7 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QStringLis
if (fi.exists()) {
if (!fileNamesMsgPart.isEmpty())
fileNamesMsgPart += QLatin1String(", ");
fileNamesMsgPart += fileName.mid(commonExistingPath.size() + 1);
fileNamesMsgPart += QDir::toNativeSeparators(fileName.mid(commonExistingPath.size() + 1));
do {
if (fi.isDir()) {
oddStuffFound = true;
......@@ -687,13 +687,14 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QStringLis
return OverwriteOk;
if (oddStuffFound) {
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.").arg(commonExistingPath).arg(fileNamesMsgPart);
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.")
.arg(QDir::toNativeSeparators(commonExistingPath)).arg(fileNamesMsgPart);
return OverwriteError;
}
const QString messageFormat = tr("The following files already exist in the directory %1:\n"
"%2.\nWould you like to overwrite them?");
const QString message = messageFormat.arg(commonExistingPath).arg(fileNamesMsgPart);
const QString message = messageFormat.arg(QDir::toNativeSeparators(commonExistingPath)).arg(fileNamesMsgPart);
const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
tr("Existing files"), message,
QMessageBox::Yes | QMessageBox::No,
......
......@@ -78,7 +78,7 @@ void AttachGdbAdapter::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk();
m_engine->continueInferiorInternal();
//m_engine->continueInferiorInternal();
m_engine->showStatusMessage(tr("Attached to process %1.")
.arg(m_engine->inferiorPid()));
}
......
......@@ -148,7 +148,7 @@ static inline bool createFile(Internal::CustomWizardFile cwFile,
const QString sourcePath = sourceDirectory + slash + cwFile.source;
// Field replacement on target path
Internal::CustomWizardContext::replaceFields(fm, &cwFile.target);
const QString targetPath = QDir::toNativeSeparators(targetDirectory + slash + cwFile.target);
const QString targetPath = targetDirectory + slash + cwFile.target;
if (CustomWizardPrivate::verbose)
qDebug() << "generating " << targetPath << sourcePath << fm;
......@@ -533,7 +533,8 @@ bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QStrin
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) {
if (errorMessage)
*errorMessage = tr("The project %1 could not be opened.").arg(file.path());
*errorMessage = tr("The project %1 could not be opened.").
arg(QDir::toNativeSeparators(file.path()));
return false;
}
}
......
......@@ -184,7 +184,7 @@ Core::GeneratedFiles
fileInfo.isAbsolute() ?
token :
(targetPath + QLatin1Char('/') + token);
file.setPath(QDir::toNativeSeparators(fullPath));
file.setPath(fullPath);
}
}
file.setAttributes(attributes);
......
......@@ -101,7 +101,7 @@ struct ProjectEntry {
int compare(const ProjectEntry &rhs) const;
ProjectNode *node;
QString nativeDirectory; // For matching against wizards' files, which are native.
QString directory; // For matching against wizards' files, which are native.
QString fileName;
QString baseName;
Type type;
......@@ -116,13 +116,13 @@ ProjectEntry::ProjectEntry(ProjectNode *n) :
baseName = fi.baseName();
if (fi.suffix() != QLatin1String("pro"))
type = PriFile;
nativeDirectory = QDir::toNativeSeparators(fi.absolutePath());
directory = fi.absolutePath();
}
// Sort helper that sorts by base name and puts '*.pro' before '*.pri'
int ProjectEntry::compare(const ProjectEntry &rhs) const
{
if (const int drc = nativeDirectory.compare(rhs.nativeDirectory))
if (const int drc = directory.compare(rhs.directory))
return drc;
if (const int brc = baseName.compare(rhs.baseName))
return brc;
......@@ -140,7 +140,7 @@ inline bool operator<(const ProjectEntry &pe1, const ProjectEntry &pe2)
QDebug operator<<(QDebug d, const ProjectEntry &e)
{
d.nospace() << e.nativeDirectory << ' ' << e.fileName << ' ' << e.type;
d.nospace() << e.directory << ' ' << e.fileName << ' ' << e.type;
return d;
}
......@@ -212,7 +212,7 @@ static int findMatchingProject(const QList<ProjectEntry> &projects,
const int count = projects.size();
for (int p = 0; p < count; p++) {
// Direct match or better match? (note that the wizards' files are native).
const QString &projectDirectory = projects.at(p).nativeDirectory;
const QString &projectDirectory = projects.at(p).directory;
if (projectDirectory == commonPath)
return p;
if (projectDirectory.size() > bestMatchLength
......@@ -357,7 +357,7 @@ void ProjectFileWizardExtension::initProjectChoices(const QString &generatedProj
for (ProjectEntryMap::const_iterator it = entryMap.constBegin(); it != cend; ++it) {
m_context->projects.push_back(it.key());
projectChoices.push_back(it.key().fileName);
projectToolTips.push_back(it.key().nativeDirectory);
projectToolTips.push_back(QDir::toNativeSeparators(it.key().directory));
}
m_context->page->setProjects(projectChoices);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment