Commit 43f9c27b authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

ProjectFileWizard/Add new: Handle profiles with identical basenames

correctly (disambiguate, add a tooltip indicating the path).
Task-number: QTCREATORBUG-819
parent 5b9d6614
......@@ -117,6 +117,8 @@ ProjectEntry::ProjectEntry(ProjectNode *n) :
// 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))
return drc;
if (const int brc = baseName.compare(rhs.baseName))
return brc;
if (type < rhs.type)
......@@ -276,8 +278,11 @@ QList<QWizardPage *> ProjectFileWizardExtension::extensionPages(const Core::IWiz
void ProjectFileWizardExtension::initProjectChoices(bool enabled)
{
// Set up project list which remains the same over duration of wizard execution
// As tooltip, set the directory for disambiguation (should someone have
// duplicate base names in differing directories).
//: No project selected
QStringList projectChoices(tr("<None>"));
QStringList projectToolTips( QString::null ); // Do not use QString() - gcc-bug.
if (enabled) {
typedef QMap<ProjectEntry, bool> ProjectEntryMap;
// Sort by base name and purge duplicated entries (resulting from dependencies)
......@@ -290,9 +295,11 @@ void ProjectFileWizardExtension::initProjectChoices(bool enabled)
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);
}
}
m_context->page->setProjects(projectChoices);
m_context->page->setProjectToolTips(projectToolTips);
}
bool ProjectFileWizardExtension::process(const QList<Core::GeneratedFile> &files, QString *errorMessage)
......
......@@ -40,6 +40,8 @@ ProjectWizardPage::ProjectWizardPage(QWidget *parent) :
m_ui(new Ui::WizardPage)
{
m_ui->setupUi(this);
connect(m_ui->projectComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotProjectChanged(int)));
}
ProjectWizardPage::~ProjectWizardPage()
......@@ -53,6 +55,11 @@ void ProjectWizardPage::setProjects(const QStringList &p)
m_ui->projectComboBox->addItems(p);
}
void ProjectWizardPage::setProjectToolTips(const QStringList &t)
{
m_projectToolTips = t;
}
int ProjectWizardPage::currentProjectIndex() const
{
return m_ui->projectComboBox->currentIndex();
......@@ -112,3 +119,15 @@ void ProjectWizardPage::setFilesDisplay(const QString &commonPath, const QString
}
m_ui->filesLabel->setText(fileMessage);
}
void ProjectWizardPage::setProjectToolTip(const QString &tt)
{
m_ui->projectComboBox->setToolTip(tt);
m_ui->projectLabel->setToolTip(tt);
}
void ProjectWizardPage::slotProjectChanged(int index)
{
setProjectToolTip(index >= 0 && index < m_projectToolTips.size() ?
m_projectToolTips.at(index) : QString());
}
......@@ -47,6 +47,8 @@ public:
virtual ~ProjectWizardPage();
void setProjects(const QStringList &);
void setProjectToolTips(const QStringList &);
int currentProjectIndex() const;
void setCurrentProjectIndex(int);
......@@ -61,8 +63,14 @@ public:
protected:
virtual void changeEvent(QEvent *e);
private slots:
void slotProjectChanged(int);
private:
inline void setProjectToolTip(const QString &);
Ui::WizardPage *m_ui;
QStringList m_projectToolTips;
};
} // namespace Internal
......
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