Commit 71aeac59 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Use completeBaseName instead of baseName where appropriate

Fixes issues with handling additional dots in the filename in many
places.

Task: 246390
parent 937010f5
......@@ -84,7 +84,7 @@ void CMakeProject::parseCMakeLists()
{
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration()));
m_rootNode->setFolderName(QFileInfo(cbpFile).baseName());
m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName());
CMakeCbpParser cbpparser;
qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
......
......@@ -67,7 +67,7 @@ Core::GeneratedFiles CppFileWizard::generateFilesFromPath(const QString &path,
QString CppFileWizard::fileContents(FileType type, const QString &fileName) const
{
const QString baseName = QFileInfo(fileName).baseName();
const QString baseName = QFileInfo(fileName).completeBaseName();
QString contents;
QTextStream str(&contents);
switch (type) {
......@@ -79,7 +79,9 @@ QString CppFileWizard::fileContents(FileType type, const QString &fileName) cons
}
break;
case Source:
str << QLatin1String("#include \"") << baseName << '.' << preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE)) << QLatin1String("\"\n\n");
str << QLatin1String("#include \"") << baseName
<< '.' << preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE))
<< QLatin1String("\"\n\n");
break;
}
return contents;
......
......@@ -76,7 +76,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
const QString guard = Core::Utils::headerGuard(headerFile);
QString uiInclude = QLatin1String("ui_");
uiInclude += QFileInfo(uiFile).baseName();
uiInclude += QFileInfo(uiFile).completeBaseName();
uiInclude += QLatin1String(".h");
// 1) Header file
......
......@@ -448,7 +448,7 @@ static Document::Ptr addDefinition(const CPlusPlus::Snapshot &docTable,
return Document::Ptr();
QFileInfo headerFI(headerFileName);
const QString headerBaseName = headerFI.baseName();
const QString headerBaseName = headerFI.completeBaseName();
const QString headerAbsolutePath = headerFI.absolutePath();
foreach (const Document::Ptr &doc, docList) {
const QFileInfo sourceFI(doc->fileName());
......@@ -562,7 +562,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
// be generating the ui_<>.h file for it, and the .pro file knows what the generated file's name and its absolute path will be.
// So we should somehow get that info from project manager (?)
const QFileInfo fi(currentUiFile);
const QString uicedName = QLatin1String("ui_") + fi.baseName() + QLatin1String(".h");
const QString uicedName = QLatin1String("ui_") + fi.completeBaseName() + QLatin1String(".h");
// take all docs, find the ones that include the ui_xx.h.
......
......@@ -115,7 +115,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
QFileInfo fileInfo(m_fileName);
QDir dir = fileInfo.dir();
m_projectName = fileInfo.baseName();
m_projectName = fileInfo.completeBaseName();
m_filesFileName = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath();
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
......
......@@ -43,7 +43,7 @@ GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *pro
m_project(project),
m_projectFile(projectFile)
{
setFolderName(QFileInfo(projectFile->fileName()).baseName());
setFolderName(QFileInfo(projectFile->fileName()).completeBaseName());
}
GenericProjectNode::~GenericProjectNode()
......
......@@ -824,7 +824,7 @@ void GitPlugin::updateActions()
if (m_projectExplorer) {
if (Node *node = m_projectExplorer->currentNode())
if (Node *projectNode = node->projectNode())
project = '"' + QFileInfo(projectNode->path()).baseName() + '"';
project = '"' + QFileInfo(projectNode->path()).completeBaseName() + '"';
}
enabled = !project.isEmpty();
......
......@@ -1106,7 +1106,7 @@ QString SessionManager::lastSession() const
{
QSettings *settings = m_core->settings();
QString fileName = settings->value("ProjectExplorer/StartupSession").toString();
return QFileInfo(fileName).baseName();
return QFileInfo(fileName).completeBaseName();
}
SessionNode *SessionManager::sessionNode() const
......
......@@ -30,29 +30,14 @@
#include "projectloadwizard.h"
#include "qt4project.h"
#include "qtversionmanager.h"
#include "qt4projectmanager.h"
#include "qmakestep.h"
#include "makestep.h"
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QFileDialog>
#include <QtGui/QFormLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QListWidget>
#include <QtGui/QRadioButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWizard>
#include <QtGui/QWizardPage>
using namespace Qt4ProjectManager;
......
......@@ -30,34 +30,27 @@
#ifndef PROJECTLOADWIZARD_H
#define PROJECTLOADWIZARD_H
#include "qt4project.h"
#include "qtversionmanager.h"
#include <QtGui/QWizard>
QT_BEGIN_NAMESPACE
class QWizardPage;
class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QCheckBox;
class QRadioButton;
class QListWidget;
class QLineEdit;
class QToolButton;
class QSpacerItem;
class QFormLayout;
class QComboBox;
QT_END_NAMESPACE
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class ProjectLoadWizard : public QWizard
{
Q_OBJECT
public:
ProjectLoadWizard(Qt4ProjectManager::Qt4Project *project, QWidget * parent = 0, Qt::WindowFlags flags = 0);
ProjectLoadWizard(Qt4Project *project, QWidget * parent = 0, Qt::WindowFlags flags = 0);
virtual ~ProjectLoadWizard();
virtual int nextId() const;
virtual void done(int result);
......
......@@ -91,7 +91,7 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo
m_fileWatcher(new FileWatcher(this))
{
Q_ASSERT(project);
setFolderName(QFileInfo(filePath).baseName());
setFolderName(QFileInfo(filePath).completeBaseName());
static QIcon dirIcon;
if (dirIcon.isNull()) {
......@@ -771,7 +771,7 @@ void Qt4ProFileNode::updateUiFiles(const QString &buildDirectory)
QStringList newFilePaths;
foreach (FileNode *uiFile, uiFiles) {
const QString uiHeaderFilePath
= QString("%1/ui_%2.h").arg(uiDir, QFileInfo(uiFile->path()).baseName());
= QString("%1/ui_%2.h").arg(uiDir, QFileInfo(uiFile->path()).completeBaseName());
if (QFileInfo(uiHeaderFilePath).exists())
newFilePaths << uiHeaderFilePath;
}
......
......@@ -51,7 +51,7 @@ using ProjectExplorer::ApplicationRunConfiguration;
using ProjectExplorer::PersistentSettingsReader;
using ProjectExplorer::PersistentSettingsWriter;
Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, QString proFilePath)
Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath)
: ApplicationRunConfiguration(pro),
m_proFilePath(proFilePath),
m_runMode(Gui),
......@@ -61,10 +61,10 @@ Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, QString proFilePath)
m_workingDirectoryLabel(0),
m_cachedTargetInformationValid(false)
{
setName(tr("Qt4RunConfiguration"));
if (!m_proFilePath.isEmpty()) {
setName(QFileInfo(m_proFilePath).baseName());
}
if (!m_proFilePath.isEmpty())
setName(QFileInfo(m_proFilePath).completeBaseName());
else
setName(tr("Qt4RunConfiguration"));
connect(pro, SIGNAL(activeBuildConfigurationChanged()),
this, SLOT(invalidateCachedTargetInformation()));
......@@ -72,7 +72,6 @@ Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, QString proFilePath)
Qt4RunConfiguration::~Qt4RunConfiguration()
{
}
QString Qt4RunConfiguration::type() const
......@@ -217,7 +216,7 @@ void Qt4RunConfiguration::restore(const PersistentSettingsReader &reader)
if (!m_proFilePath.isEmpty()) {
m_cachedTargetInformationValid = false;
if (!m_userSetName)
setName(QFileInfo(m_proFilePath).baseName());
setName(QFileInfo(m_proFilePath).completeBaseName());
}
}
......@@ -460,5 +459,5 @@ QStringList Qt4RunConfigurationFactoryUser::canCreate(ProjectExplorer::Project *
QString Qt4RunConfigurationFactoryUser::nameForType(const QString &type) const
{
QString fileName = type.mid(QString("Qt4RunConfiguration.").size());
return QFileInfo(fileName).baseName();
return QFileInfo(fileName).completeBaseName();
}
......@@ -57,7 +57,7 @@ class Qt4RunConfiguration : public ProjectExplorer::ApplicationRunConfiguration
// to change the name and arguments
friend class Qt4RunConfigurationWidget;
public:
Qt4RunConfiguration(Qt4Project *pro, QString proFilePath);
Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath);
virtual ~Qt4RunConfiguration();
virtual QString type() const;
......
......@@ -36,7 +36,6 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/toolchain.h>
#include <QtCore/QDebug>
#include <QtCore/QPointer>
#include <QtGui/QWidget>
......@@ -45,7 +44,8 @@ namespace Internal {
class QtDirWidget;
class QtVersion {
class QtVersion
{
friend class QtDirWidget; //for changing name and path
friend class QtVersionManager;
public:
......
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