Commit b0040dc8 authored by con's avatar con
Browse files

Merge remote branch 'origin/2.0'

Conflicts:
	src/plugins/projectexplorer/taskwindow.cpp
	src/shared/proparser/profileevaluator.cpp
parents 726c3345 2de4a98c
......@@ -76,7 +76,7 @@
</snippet>
<snippet description="with targets">PropertyAction { targets: [<tab>name</tab>]; properties: "<tab>name</tab>" }
</snippet>
<snippet description="with target">PropertyAction { target: "<tab>name</tab>"; property: "<tab>name</tab>"; value: <tab>value</tab> }
<snippet description="with target">PropertyAction { target: <tab>name</tab>; property: "<tab>name</tab>"; value: <tab>value</tab> }
</snippet>
<snippet>PauseAnimation { duration: <tab>200</tab> }
</snippet>
......
......@@ -53,7 +53,7 @@ const Interpreter::Value *Evaluate::operator()(AST::Node *ast)
const Value *result = reference(ast);
if (const Reference *ref = value_cast<const Reference *>(result))
result = ref->value(_context);
result = _context->lookupReference(ref);
if (! result)
result = _engine->undefinedValue();
......
......@@ -1510,6 +1510,18 @@ const ObjectValue *Context::lookupType(const QmlJS::Document *doc, const QString
return objectValue;
}
const Value *Context::lookupReference(const Reference *reference)
{
if (_referenceStack.contains(reference))
return 0;
_referenceStack.append(reference);
const Value *v = reference->value(this);
_referenceStack.removeLast();
return v;
}
const Value *Context::property(const ObjectValue *object, const QString &name) const
{
const Properties properties = _properties.value(object);
......@@ -1659,7 +1671,7 @@ const ObjectValue *ObjectValue::prototype(Context *context) const
const ObjectValue *prototypeObject = value_cast<const ObjectValue *>(_prototype);
if (! prototypeObject) {
if (const Reference *prototypeReference = value_cast<const Reference *>(_prototype)) {
prototypeObject = value_cast<const ObjectValue *>(prototypeReference->value(context));
prototypeObject = value_cast<const ObjectValue *>(context->lookupReference(prototypeReference));
}
}
return prototypeObject;
......
......@@ -294,6 +294,7 @@ public:
const Value *lookup(const QString &name);
const ObjectValue *lookupType(const Document *doc, AST::UiQualifiedId *qmlTypeName);
const ObjectValue *lookupType(const Document *doc, const QStringList &qmlTypeName);
const Value *lookupReference(const Reference *reference);
const Value *property(const ObjectValue *object, const QString &name) const;
void setProperty(const ObjectValue *object, const QString &name, const Value *value);
......@@ -314,6 +315,7 @@ private:
ScopeChain _scopeChain;
int _qmlScopeObjectIndex;
bool _qmlScopeObjectSet;
QList<const Reference *> _referenceStack;
};
class QMLJS_EXPORT Reference: public Value
......@@ -323,14 +325,16 @@ public:
virtual ~Reference();
Engine *engine() const;
virtual const Value *value(Context *context) const;
// Value interface
virtual const Reference *asReference() const;
virtual void accept(ValueVisitor *) const;
private:
virtual const Value *value(Context *context) const;
Engine *_engine;
friend class Context;
};
class QMLJS_EXPORT ColorValue: public Value
......@@ -754,9 +758,9 @@ public:
AST::UiQualifiedId *qmlTypeName() const;
private:
virtual const Value *value(Context *context) const;
private:
AST::UiQualifiedId *_qmlTypeName;
const Document *_doc;
};
......@@ -769,6 +773,7 @@ public:
ASTVariableReference(AST::VariableDeclaration *ast, Engine *engine);
virtual ~ASTVariableReference();
private:
virtual const Value *value(Context *context) const;
};
......@@ -804,6 +809,8 @@ public:
QString onChangedSlotName() const { return _onChangedSlotName; }
virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
private:
virtual const Value *value(Context *context) const;
};
......@@ -821,6 +828,8 @@ public:
QString slotName() const { return _slotName; }
virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
private:
virtual const Value *value(Context *context) const;
};
......
......@@ -80,7 +80,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, const QString
m_buildTarget(target),
m_workingDirectory(workingDirectory),
m_title(title),
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase),
m_enabled(true)
{
ctor();
}
......@@ -94,7 +95,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfig
m_title(source->m_title),
m_arguments(source->m_arguments),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_baseEnvironmentBase(source->m_baseEnvironmentBase)
m_baseEnvironmentBase(source->m_baseEnvironmentBase),
m_enabled(source->m_enabled)
{
ctor();
}
......@@ -293,9 +295,21 @@ ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType()
return bc->toolChainType();
}
// Configuration widget
void CMakeRunConfiguration::setEnabled(bool b)
{
if (m_enabled == b)
return;
m_enabled = b;
emit isEnabledChanged(isEnabled());
setDisplayName(m_title + (m_enabled ? "" : tr(" (disabled)")));
}
bool CMakeRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *bc) const
{
return m_enabled && LocalApplicationRunConfiguration::isEnabled(bc);
}
// Configuration widget
CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent)
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
{
......
......@@ -81,6 +81,11 @@ public:
QVariantMap toMap() const;
void setEnabled(bool b);
bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
using LocalApplicationRunConfiguration::isEnabled;
signals:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
......@@ -115,6 +120,7 @@ private:
QString m_arguments;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
bool m_enabled;
};
class CMakeRunConfigurationWidget : public QWidget
......
......@@ -120,6 +120,7 @@ void CMakeTarget::updateRunConfigurations()
foreach (CMakeRunConfiguration *rc, list) {
rc->setExecutable(ct.executable);
rc->setWorkingDirectory(ct.workingDirectory);
rc->setEnabled(true);
}
existingRunConfigurations.remove(ct.title);
} else {
......@@ -131,7 +132,10 @@ void CMakeTarget::updateRunConfigurations()
existingRunConfigurations.constBegin();
for( ; it != existingRunConfigurations.constEnd(); ++it) {
CMakeRunConfiguration *rc = it.value();
removeRunConfiguration(rc);
// The executables for those runconfigurations aren't build by the current buildconfiguration
// We just set a disable flag and show that in the display name
rc->setEnabled(false);
// removeRunConfiguration(rc);
}
if (runConfigurations().isEmpty()) {
// Oh no, no run configuration,
......
......@@ -38,6 +38,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/filewizarddialog.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <QtCore/QDir>
#include <QtCore/QFile>
......@@ -540,7 +541,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
foreach (const GeneratedFile &generatedFile, files)
result.push_back(generatedFile.path());
switch (promptOverwrite(path, result, &errorMessage)) {
switch (promptOverwrite(result, &errorMessage)) {
case OverwriteCanceled:
return QStringList();
case OverwriteError:
......@@ -615,29 +616,34 @@ bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *e
return true;
}
BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &location,
const QStringList &files,
BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QStringList &files,
QString *errorMessage) const
{
if (debugWizard)
qDebug() << Q_FUNC_INFO << location << files;
qDebug() << Q_FUNC_INFO << files;
bool existingFilesFound = false;
QStringList existingFiles;
bool oddStuffFound = false;
static const QString readOnlyMsg = tr(" [read only]");
static const QString directoryMsg = tr(" [directory]");
static const QString symLinkMsg = tr(" [symbolic link]");
foreach (const QString &fileName, files) {
const QFileInfo fi(fileName);
if (fi.exists())
existingFiles.append(fileName);
}
// Note: Generated files are using native separators, no need to convert.
const QString commonExistingPath = Utils::commonPath(existingFiles);
// Format a file list message as ( "<file1> [readonly], <file2> [directory]").
QString fileNamesMsgPart;
foreach (const QString &fileName, files) {
foreach (const QString &fileName, existingFiles) {
const QFileInfo fi(fileName);
if (fi.exists()) {
existingFilesFound = true;
if (!fileNamesMsgPart.isEmpty())
fileNamesMsgPart += QLatin1String(", ");
fileNamesMsgPart += fi.fileName();
fileNamesMsgPart += fileName.mid(commonExistingPath.size() + 1);
do {
if (fi.isDir()) {
oddStuffFound = true;
......@@ -657,17 +663,17 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
}
}
if (!existingFilesFound)
if (existingFiles.isEmpty())
return OverwriteOk;
if (oddStuffFound) {
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.").arg(location).arg(fileNamesMsgPart);
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.").arg(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(location).arg(fileNamesMsgPart);
const QString message = messageFormat.arg(commonExistingPath).arg(fileNamesMsgPart);
const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
tr("Existing files"), message,
QMessageBox::Yes | QMessageBox::No,
......
......@@ -210,8 +210,7 @@ protected:
// Utility that performs an overwrite check on a set of files. It checks if
// the file exists, can be overwritten at all and prompts the user.
enum OverwriteResult { OverwriteOk, OverwriteError, OverwriteCanceled };
OverwriteResult promptOverwrite(const QString &location,
const QStringList &files,
OverwriteResult promptOverwrite(const QStringList &files,
QString *errorMessage) const;
// Utility to open the editors for the files whose attribute is set accordingly.
......
......@@ -61,6 +61,11 @@ CoreImpl::CoreImpl(MainWindow *mainwindow)
m_mainwindow = mainwindow;
}
CoreImpl::~CoreImpl()
{
m_instance = 0;
}
QStringList CoreImpl::showNewItemDialog(const QString &title,
const QList<IWizard *> &wizards,
const QString &defaultLocation)
......
......@@ -42,7 +42,7 @@ class CoreImpl : public ICore
public:
CoreImpl(MainWindow *mainwindow);
~CoreImpl() {}
~CoreImpl();
QStringList showNewItemDialog(const QString &title,
const QList<IWizard *> &wizards,
......
......@@ -90,7 +90,6 @@ struct FileIconProviderPrivate {
// Mapping of file suffix to icon.
StringIconPairList m_cache;
QFileIconProvider m_systemIconProvider;
QIcon m_unknownFileIcon;
// singleton pattern
......@@ -140,25 +139,15 @@ QIcon FileIconProvider::icon(const QFileInfo &fileInfo) const
}
// Get icon from OS.
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
return d->m_systemIconProvider.icon(fileInfo);
return QFileIconProvider::icon(fileInfo);
#else
// File icons are unknown on linux systems.
return (fileInfo.isDir()) ?
d->m_systemIconProvider.icon(fileInfo) :
QFileIconProvider::icon(fileInfo) :
d->m_unknownFileIcon;
#endif
}
QIcon FileIconProvider::icon(IconType type) const
{
return d->m_systemIconProvider.icon(type);
}
QString FileIconProvider::type(const QFileInfo &info) const
{
return d->m_systemIconProvider.type(info);
}
/*!
Creates a pixmap with baseicon at size and overlays overlayIcon over it.
See platform note in class documentation about recommended usage.
......
......@@ -56,9 +56,8 @@ public:
virtual ~FileIconProvider();
// Implement QFileIconProvider
virtual QIcon icon(IconType type) const;
virtual QIcon icon(const QFileInfo &info) const;
virtual QString type(const QFileInfo &info) const;
using QFileIconProvider::icon;
// Register additional overlay icons
static QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size);
......
......@@ -704,50 +704,6 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
static_cast<QHBoxLayout*>(w->layout())->insertWidget(0, m_methodCombo, 1);
}
void CPPEditor::inAllRenameSelections(EditOperation operation,
const QTextEdit::ExtraSelection &currentRenameSelection,
QTextCursor cursor,
const QString &text)
{
cursor.beginEditBlock();
const int startOffset = cursor.selectionStart() - currentRenameSelection.cursor.anchor();
const int endOffset = cursor.selectionEnd() - currentRenameSelection.cursor.anchor();
const int length = endOffset - startOffset;
for (int i = 0; i < m_renameSelections.size(); ++i) {
QTextEdit::ExtraSelection &s = m_renameSelections[i];
int pos = s.cursor.anchor();
int endPos = s.cursor.position();
s.cursor.setPosition(pos + startOffset);
s.cursor.setPosition(pos + endOffset, QTextCursor::KeepAnchor);
switch (operation) {
case DeletePreviousChar:
s.cursor.deletePreviousChar();
endPos -= qMax(1, length);
break;
case DeleteChar:
s.cursor.deleteChar();
endPos -= qMax(1, length);
break;
case InsertText:
s.cursor.insertText(text);
endPos += text.length() - length;
break;
}
s.cursor.setPosition(pos);
s.cursor.setPosition(endPos, QTextCursor::KeepAnchor);
}
cursor.endEditBlock();
setExtraSelections(CodeSemanticsSelection, m_renameSelections);
setTextCursor(cursor);
}
void CPPEditor::paste()
{
if (m_currentRenameSelection == -1) {
......
......@@ -268,15 +268,6 @@ private:
void createToolBar(CPPEditorEditable *editable);
enum EditOperation {
DeleteChar,
DeletePreviousChar,
InsertText
};
void inAllRenameSelections(EditOperation operation,
const QTextEdit::ExtraSelection &currentRenameSelection,
QTextCursor cursor,
const QString &text = QString());
void startRename();
void finishRename();
void abortRename();
......
......@@ -82,8 +82,8 @@ void AbstractProcessStep::setOutputParser(ProjectExplorer::IOutputParser *parser
m_outputParserChain = parser;
if (m_outputParserChain) {
connect(parser, SIGNAL(addOutput(QString)),
this, SLOT(outputAdded(QString)));
connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(outputAdded(QString, QTextCharFormat)));
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
}
......@@ -199,22 +199,34 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
void AbstractProcessStep::processStarted()
{
emit addOutput(tr("<font color=\"#0000ff\">Starting: \"%1\" %2</font>\n").arg(m_command, Qt::escape(m_arguments.join(" "))));
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("Starting: \"%1\" %2\n").arg(m_command, m_arguments.join(" ")), textCharFormat);
}
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
if (status == QProcess::NormalExit && exitCode == 0)
emit addOutput(tr("<font color=\"#0000ff\">The process \"%1\" exited normally.</font>").arg(m_command));
else if (status == QProcess::NormalExit)
emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" exited with code %2.</b></font>").arg(m_command, m_process->exitCode()));
else
emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" crashed.</b></font>").arg(m_command));
QTextCharFormat textCharFormat;
if (status == QProcess::NormalExit && exitCode == 0) {
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command), textCharFormat);
} else if (status == QProcess::NormalExit) {
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("The process \"%1\" exited with code %2.").arg(m_command, m_process->exitCode()), textCharFormat);
} else {
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("The process \"%1\" crashed.").arg(m_command), textCharFormat);
}
}
void AbstractProcessStep::processStartupFailed()
{
emit addOutput(tr("<font color=\"#ff0000\"><b>Could not start process \"%1\"</b></font>").arg(m_command));
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("Could not start process \"%1\"").arg(m_command), textCharFormat);
}
bool AbstractProcessStep::processSucceeded(int exitCode, QProcess::ExitStatus status)
......@@ -235,7 +247,8 @@ void AbstractProcessStep::stdOutput(const QString &line)
{
if (m_outputParserChain)
m_outputParserChain->stdOutput(line);
emit addOutput(Qt::escape(line));
QTextCharFormat textCharFormat;
emit addOutput(Qt::escape(line), textCharFormat);
}
void AbstractProcessStep::processReadyReadStdError()
......@@ -251,7 +264,9 @@ void AbstractProcessStep::stdError(const QString &line)
{
if (m_outputParserChain)
m_outputParserChain->stdError(line);
emit addOutput(QLatin1String("<font color=\"#ff0000\">") + Qt::escape(line) + QLatin1String("</font>"));
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
emit addOutput(line, textCharFormat);
}
void AbstractProcessStep::checkForCancel()
......@@ -312,9 +327,9 @@ void AbstractProcessStep::taskAdded(const ProjectExplorer::Task &task)
emit addTask(editable);
}
void AbstractProcessStep::outputAdded(const QString &string)
void AbstractProcessStep::outputAdded(const QString &string, const QTextCharFormat &textCharFormat)
{
emit addOutput(string);
emit addOutput(string, textCharFormat);
}
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
......
......@@ -147,8 +147,8 @@ private slots:
void checkForCancel();
void taskAdded(const ProjectExplorer::Task &task);
void outputAdded(const QString &string);
void outputAdded(const QString &string, const QTextCharFormat &format);
private:
QTimer *m_timer;
QFutureInterface<bool> *m_futureInterface;
......
......@@ -180,7 +180,9 @@ void BuildManager::finish()
void BuildManager::emitCancelMessage()
{
emit addToOutputWindow(tr("<font color=\"#ff0000\">Canceled build.</font>"));
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
emit addToOutputWindow(tr("Canceled build."), textCharFormat);
}
void BuildManager::clearBuildQueue()
......@@ -196,6 +198,7 @@ void BuildManager::clearBuildQueue()
m_buildQueue.clear();
m_running = false;
m_previousBuildStepProject = 0;
m_currentBuildStep = 0;
m_progressFutureInterface->reportCanceled();
m_progressFutureInterface->reportFinished();
......@@ -282,9 +285,9 @@ void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
m_taskWindow->addTask(task);
}
void BuildManager::addToOutputWindow(const QString &string)
void BuildManager::addToOutputWindow(const QString &string, const QTextCharFormat &format)
{
m_outputWindow->appendText(string);
m_outputWindow->appendText(string, format);
}
void BuildManager::nextBuildQueue()
......@@ -294,8 +297,8 @@ void BuildManager::nextBuildQueue()
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
++m_progress;
m_progressFutureInterface->setProgressValueAndText(m_progress*100, msgProgress(m_progress, m_maxProgress));
......@@ -306,8 +309,10 @@ void BuildManager::nextBuildQueue()
// Build Failure
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
const QString targetName = m_currentBuildStep->buildConfiguration()->target()->displayName();
addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1 (target: %2)</font>").arg(projectName, targetName));
addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName()));
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), textCharFormat);
addToOutputWindow(tr("When executing build step '%1'").arg(m_currentBuildStep->displayName()), textCharFormat);
// NBS TODO fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1 (target: %2)").arg(projectName, targetName));
}
......@@ -337,8 +342,10 @@ void BuildManager::nextStep()
if (m_currentBuildStep->buildConfiguration()->target()->project() != m_previousBuildStepProject) {
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
addToOutputWindow(tr("<b>Running build steps for project %2...</b>")
.arg(projectName));
QTextCharFormat textCharFormat;
textCharFormat.setFontWeight(QFont::Bold);
addToOutputWindow(tr("Running build steps for project %2...")
.arg(projectName), textCharFormat);
m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project();
}
m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep));
......@@ -347,6 +354,7 @@ void BuildManager::nextStep()