Qt4ProjectManager: Small refactoring in reportIssues

Do not report project dir specific issues next to each
buildconfiguration. Also move the code to a place the TargetSetupPage
can easily use, without having a hardcoded target list. Note: They
currently aren't shown at all, next step is to show them once per
target.

Reviewed-By: hunger
This commit is contained in:
dt
2011-03-11 15:58:33 +01:00
parent ffc8be6c88
commit 8a180f71df
12 changed files with 83 additions and 171 deletions

View File

@@ -244,7 +244,7 @@ bool QMakeStep::init()
node = qt4bc->subNodeBuild(); node = qt4bc->subNodeBuild();
QString proFile = node->path(); QString proFile = node->path();
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile, workingDirectory); m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile, workingDirectory, true);
m_scriptTemplate = node->projectType() == ScriptTemplate; m_scriptTemplate = node->projectType() == ScriptTemplate;
return AbstractProcessStep::init(); return AbstractProcessStep::init();

View File

@@ -5,7 +5,6 @@ SOURCES += $$PWD/s60manager.cpp \
$$PWD/s60emulatorrunconfiguration.cpp \ $$PWD/s60emulatorrunconfiguration.cpp \
$$PWD/s60devicerunconfiguration.cpp \ $$PWD/s60devicerunconfiguration.cpp \
$$PWD/s60devicerunconfigurationwidget.cpp \ $$PWD/s60devicerunconfigurationwidget.cpp \
$$PWD/s60projectchecker.cpp \
$$PWD/rvcttoolchain.cpp \ $$PWD/rvcttoolchain.cpp \
$$PWD/s60runconfigbluetoothstarter.cpp \ $$PWD/s60runconfigbluetoothstarter.cpp \
$$PWD/abldparser.cpp \ $$PWD/abldparser.cpp \
@@ -41,7 +40,6 @@ HEADERS += $$PWD/s60manager.h \
$$PWD/s60emulatorrunconfiguration.h \ $$PWD/s60emulatorrunconfiguration.h \
$$PWD/s60devicerunconfiguration.h \ $$PWD/s60devicerunconfiguration.h \
$$PWD/s60devicerunconfigurationwidget.h \ $$PWD/s60devicerunconfigurationwidget.h \
$$PWD/s60projectchecker.h \
$$PWD/rvcttoolchain.h \ $$PWD/rvcttoolchain.h \
$$PWD/s60runconfigbluetoothstarter.h \ $$PWD/s60runconfigbluetoothstarter.h \
$$PWD/abldparser.h \ $$PWD/abldparser.h \

View File

@@ -48,6 +48,7 @@
#include <projectexplorer/toolchainmanager.h> #include <projectexplorer/toolchainmanager.h>
using ProjectExplorer::idFromMap; using ProjectExplorer::idFromMap;
using ProjectExplorer::Task;
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
@@ -134,6 +135,34 @@ QString Qt4SymbianTargetFactory::defaultShadowBuildDirectory(const QString &proj
return QString(); return QString();
} }
QList<ProjectExplorer::Task> Qt4SymbianTargetFactory::reportIssues(const QString &proFile)
{
QList<ProjectExplorer::Task> results;
// Warn of strange characters in project name and path:
const QString projectName = proFile.mid(proFile.lastIndexOf(QLatin1Char('/')) + 1);
QString projectPath = proFile.left(proFile.lastIndexOf(QLatin1Char('/')));
#if defined (Q_OS_WIN)
if (projectPath.at(1) == QChar(':') && projectPath.at(0).toUpper() >= QChar('A') && projectPath.at(0).toUpper() <= QChar('Z'))
projectPath = projectPath.mid(2);
#endif
if (projectPath.contains(QLatin1Char(' '))) {
results.append(Task(Task::Warning,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian toolchain does not handle spaces "
"in the project path '%1'.").arg(projectPath),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
if (projectName.contains(QRegExp("[^a-zA-Z0-9.-]"))) {
results.append(Task(Task::Warning,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian toolchain does not handle special "
"characters in the project name '%1' well.")
.arg(projectName),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
return results;
}
QList<BuildConfigurationInfo> Qt4SymbianTargetFactory::availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion) QList<BuildConfigurationInfo> Qt4SymbianTargetFactory::availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion)
{ {
QList<BuildConfigurationInfo> infos; QList<BuildConfigurationInfo> infos;

View File

@@ -59,6 +59,7 @@ public:
virtual ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, Qt4TargetSetupWidget *widget); virtual ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, Qt4TargetSetupWidget *widget);
QString defaultShadowBuildDirectory(const QString &projectLocation, const QString &id); QString defaultShadowBuildDirectory(const QString &projectLocation, const QString &id);
QList<ProjectExplorer::Task> reportIssues(const QString &proFile);
QList<BuildConfigurationInfo> availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion); QList<BuildConfigurationInfo> availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion);
bool isMobileTarget(const QString &id); bool isMobileTarget(const QString &id);
}; };

View File

@@ -1,91 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "s60projectchecker.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <qt4projectmanager/qt-s60/s60manager.h>
#include <qt4projectmanager/qt4project.h>
#include <QtCore/QCoreApplication>
using namespace ProjectExplorer;
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
QList<ProjectExplorer::Task>
S60ProjectChecker::reportIssues(const QString &proFile)
{
QList<ProjectExplorer::Task> results;
#if defined (Q_OS_WIN)
const QString epocRootDir = version->systemRoot();
// Report an error if project- and epoc directory are on different drives:
if (!epocRootDir.startsWith(proFile.left(3), Qt::CaseInsensitive) && !version->isBuildWithSymbianSbsV2()) {
results.append(Task(Task::Error,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian SDK and the project sources must reside on the same drive."),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
#endif
// Warn of strange characters in project name and path:
const QString projectName = proFile.mid(proFile.lastIndexOf(QLatin1Char('/')) + 1);
QString projectPath = proFile.left(proFile.lastIndexOf(QLatin1Char('/')));
#if defined (Q_OS_WIN)
if (projectPath.at(1) == QChar(':') && projectPath.at(0).toUpper() >= QChar('A') && projectPath.at(0).toUpper() <= QChar('Z'))
projectPath = projectPath.mid(2);
#endif
if (projectPath.contains(QLatin1Char(' '))) {
results.append(Task(Task::Warning,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian toolchain does not handle spaces "
"in the project path '%1'.").arg(projectPath),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
if (projectName.contains(QRegExp("[^a-zA-Z0-9.-]"))) {
results.append(Task(Task::Warning,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian toolchain does not handle special "
"characters in the project name '%1' well.")
.arg(projectName),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
return results;
}
QList<ProjectExplorer::Task>
S60ProjectChecker::reportIssues(const Qt4Project *project)
{
QString proFile = project->file()->fileName();
return reportIssues(proFile);
}

View File

@@ -1,66 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef S60PROJECTCHECKER_H
#define S60PROJECTCHECKER_H
#include <projectexplorer/taskwindow.h>
namespace Qt4ProjectManager {
class QtVersion;
class Qt4Project;
namespace Internal {
class S60ProjectChecker
{
public:
/// Check a .pro-file/Qt version combination on possible issues with
/// its symbian setup.
/// @return a list of tasks, ordered on severity (errors first, then
/// warnings and finally info items.
static QList<ProjectExplorer::Task>
reportIssues(const QString &proFile);
/// Check a project/Qt version combination on possible issues with
/// its symbian setup.
/// @return a list of tasks, ordered on severity (errors first, then
/// warnings and finally info items.
static QList<ProjectExplorer::Task>
reportIssues(const Qt4Project *project);
};
} // namespace Internal
} // namespace Qt4ProjectExplorer
#endif // S60PROJECTCHECKER_H

View File

@@ -36,6 +36,7 @@
#include "qt4projectmanager_global.h" #include "qt4projectmanager_global.h"
#include <projectexplorer/task.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <QtCore/QList> #include <QtCore/QList>
@@ -62,6 +63,8 @@ public:
/// used by the default implementation of createTargetSetupWidget /// used by the default implementation of createTargetSetupWidget
/// not needed otherwise /// not needed otherwise
virtual QList<BuildConfigurationInfo> availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion) = 0; virtual QList<BuildConfigurationInfo> availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion) = 0;
virtual QList<ProjectExplorer::Task> reportIssues(const QString &proFile);
/// only used in the TargetSetupPage /// only used in the TargetSetupPage
virtual QIcon iconForId(const QString &id) const = 0; virtual QIcon iconForId(const QString &id) const = 0;

View File

@@ -368,7 +368,8 @@ void Qt4ProjectConfigWidget::updateImportLabel()
if (m_buildConfiguration->shadowBuild()) if (m_buildConfiguration->shadowBuild())
buildDirectory = m_buildConfiguration->buildDirectory(); buildDirectory = m_buildConfiguration->buildDirectory();
QList<ProjectExplorer::Task> issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(), QList<ProjectExplorer::Task> issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(),
buildDirectory); buildDirectory,
true);
if (incompatibleBuild) { if (incompatibleBuild) {
m_ui->problemLabel->setVisible(true); m_ui->problemLabel->setVisible(true);

View File

@@ -116,6 +116,11 @@ QString Qt4BaseTargetFactory::msgBuildConfigurationName(const BuildConfiguration
tr("%1 Release").arg(qtVersionName); tr("%1 Release").arg(qtVersionName);
} }
QList<ProjectExplorer::Task> Qt4BaseTargetFactory::reportIssues(const QString &proFile)
{
return QList<ProjectExplorer::Task>();
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Qt4BaseTarget // Qt4BaseTarget
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@@ -536,6 +541,7 @@ void Qt4DefaultTargetSetupWidget::setBuildConfigurationInfos(const QList<BuildCo
clearWidgets(); clearWidgets();
setupWidgets(); setupWidgets();
} else { } else {
bool foundIssues = false;
m_ignoreChange = true; m_ignoreChange = true;
QString sourceDir = QFileInfo(m_proFilePath).absolutePath(); QString sourceDir = QFileInfo(m_proFilePath).absolutePath();
for (int i=0; i < m_checkboxes.size(); ++i) { for (int i=0; i < m_checkboxes.size(); ++i) {
@@ -546,9 +552,11 @@ void Qt4DefaultTargetSetupWidget::setBuildConfigurationInfos(const QList<BuildCo
m_pathChoosers[i]->setPath(info.directory); m_pathChoosers[i]->setPath(info.directory);
else else
m_pathChoosers[i]->setPath(sourceDir); m_pathChoosers[i]->setPath(sourceDir);
reportIssues(i); foundIssues &= reportIssues(i);
} }
m_ignoreChange = false; m_ignoreChange = false;
if (foundIssues)
m_detailsWidget->setState(Utils::DetailsWidget::Expanded);
} }
} }
@@ -575,6 +583,7 @@ void Qt4DefaultTargetSetupWidget::setupWidgets()
{ {
m_ignoreChange = true; m_ignoreChange = true;
QString sourceDir = QFileInfo(m_proFilePath).absolutePath(); QString sourceDir = QFileInfo(m_proFilePath).absolutePath();
bool foundIssues = false;
for (int i = 0; i < m_infos.size(); ++i) { for (int i = 0; i < m_infos.size(); ++i) {
const BuildConfigurationInfo &info = m_infos.at(i); const BuildConfigurationInfo &info = m_infos.at(i);
QCheckBox *checkbox = new QCheckBox; QCheckBox *checkbox = new QCheckBox;
@@ -604,8 +613,10 @@ void Qt4DefaultTargetSetupWidget::setupWidgets()
m_checkboxes.append(checkbox); m_checkboxes.append(checkbox);
m_pathChoosers.append(pathChooser); m_pathChoosers.append(pathChooser);
m_reportIssuesLabels.append(reportIssuesLabel); m_reportIssuesLabels.append(reportIssuesLabel);
reportIssues(i); foundIssues = reportIssues(i);
} }
if (foundIssues)
m_detailsWidget->setState(Utils::DetailsWidget::Expanded);
m_ignoreChange = false; m_ignoreChange = false;
} }
@@ -685,12 +696,13 @@ void Qt4DefaultTargetSetupWidget::shadowBuildingToggled()
m_ignoreChange = false; m_ignoreChange = false;
} }
void Qt4DefaultTargetSetupWidget::reportIssues(int index) bool Qt4DefaultTargetSetupWidget::reportIssues(int index)
{ {
QPair<ProjectExplorer::Task::TaskType, QString> issues = findIssues(m_infos.at(index)); QPair<ProjectExplorer::Task::TaskType, QString> issues = findIssues(m_infos.at(index));
QLabel *reportIssuesLabel = m_reportIssuesLabels.at(index); QLabel *reportIssuesLabel = m_reportIssuesLabels.at(index);
reportIssuesLabel->setText(issues.second); reportIssuesLabel->setText(issues.second);
reportIssuesLabel->setVisible(issues.first != ProjectExplorer::Task::Unknown); reportIssuesLabel->setVisible(issues.first != ProjectExplorer::Task::Unknown);
return issues.first != ProjectExplorer::Task::Unknown;
} }
QPair<ProjectExplorer::Task::TaskType, QString> Qt4DefaultTargetSetupWidget::findIssues(const BuildConfigurationInfo &info) QPair<ProjectExplorer::Task::TaskType, QString> Qt4DefaultTargetSetupWidget::findIssues(const BuildConfigurationInfo &info)
@@ -701,7 +713,7 @@ QPair<ProjectExplorer::Task::TaskType, QString> Qt4DefaultTargetSetupWidget::fin
QString buildDir = info.directory; QString buildDir = info.directory;
QtVersion *version = info.version; QtVersion *version = info.version;
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath, buildDir); QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath, buildDir, false);
QString text; QString text;
ProjectExplorer::Task::TaskType highestType = ProjectExplorer::Task::Unknown; ProjectExplorer::Task::TaskType highestType = ProjectExplorer::Task::Unknown;

View File

@@ -135,7 +135,7 @@ public slots:
private: private:
void setBuildConfigurationInfos(const QList<BuildConfigurationInfo> &list, bool resetEnabled = true); void setBuildConfigurationInfos(const QList<BuildConfigurationInfo> &list, bool resetEnabled = true);
void reportIssues(int index); bool reportIssues(int index);
QPair<ProjectExplorer::Task::TaskType, QString> findIssues(const BuildConfigurationInfo &info); QPair<ProjectExplorer::Task::TaskType, QString> findIssues(const BuildConfigurationInfo &info);
void createImportWidget(const BuildConfigurationInfo &info, int pos); void createImportWidget(const BuildConfigurationInfo &info, int pos);

View File

@@ -40,11 +40,11 @@
#include "qt-maemo/maemoglobal.h" #include "qt-maemo/maemoglobal.h"
#include "qt-maemo/maemomanager.h" #include "qt-maemo/maemomanager.h"
#include "qt-s60/s60manager.h" #include "qt-s60/s60manager.h"
#include "qt-s60/s60projectchecker.h"
#include "qt-s60/abldparser.h" #include "qt-s60/abldparser.h"
#include "qt-s60/sbsv2parser.h" #include "qt-s60/sbsv2parser.h"
#include "qt-s60/gccetoolchain.h" #include "qt-s60/gccetoolchain.h"
#include "qt-s60/winscwtoolchain.h" #include "qt-s60/winscwtoolchain.h"
#include "qt4basetargetfactory.h"
#include "qmlobservertool.h" #include "qmlobservertool.h"
#include "qmldumptool.h" #include "qmldumptool.h"
@@ -85,6 +85,8 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <algorithm>
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
@@ -766,7 +768,7 @@ ProjectExplorer::IOutputParser *QtVersion::createOutputParser() const
} }
QList<ProjectExplorer::Task> QList<ProjectExplorer::Task>
QtVersion::reportIssues(const QString &proFile, const QString &buildDir) QtVersion::reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors)
{ {
QList<ProjectExplorer::Task> results; QList<ProjectExplorer::Task> results;
@@ -807,10 +809,33 @@ QtVersion::reportIssues(const QString &proFile, const QString &buildDir)
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
} }
#if defined (Q_OS_WIN)
QSet<QString> targets = supportedTargetIds(); QSet<QString> targets = supportedTargetIds();
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) || if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
targets.contains(Constants::S60_EMULATOR_TARGET_ID)) targets.contains(Constants::S60_EMULATOR_TARGET_ID)) {
results.append(S60ProjectChecker::reportIssues(proFile)); const QString epocRootDir = systemRoot();
// Report an error if project- and epoc directory are on different drives:
if (!epocRootDir.startsWith(proFile.left(3), Qt::CaseInsensitive) && !isBuildWithSymbianSbsV2()) {
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error,
QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
"The Symbian SDK and the project sources must reside on the same drive."),
QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
}
#endif
if (includeTargetSpecificErrors) {
QList<Qt4BaseTargetFactory *> factories;
foreach (const QString &id, supportedTargetIds())
if (Qt4BaseTargetFactory *factory = Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(id))
factories << factory;
qSort(factories);
QList<Qt4BaseTargetFactory *>::iterator newend = std::unique(factories.begin(), factories.end());
QList<Qt4BaseTargetFactory *>::iterator it = factories.begin();
for ( ; it != newend; ++it)
results.append((*it)->reportIssues(proFile));
}
return results; return results;
} }

View File

@@ -189,7 +189,7 @@ public:
/// its symbian setup. /// its symbian setup.
/// @return a list of tasks, ordered on severity (errors first, then /// @return a list of tasks, ordered on severity (errors first, then
/// warnings and finally info items. /// warnings and finally info items.
QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir); QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors);
ProjectExplorer::IOutputParser *createOutputParser() const; ProjectExplorer::IOutputParser *createOutputParser() const;