From d5b00aaef94a3868e13711049504ce0c08e697d0 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 3 Dec 2008 09:26:54 +0100 Subject: [PATCH 01/24] Forgot these two files in previous commit Should have been part of 83e3524b53f9625aab5c31fe8f27927786134d72 --- src/plugins/cmakeprojectmanager/cmakestep.cpp | 90 +++++++++++++++++++ src/plugins/cmakeprojectmanager/cmakestep.h | 48 ++++++++++ 2 files changed, 138 insertions(+) create mode 100644 src/plugins/cmakeprojectmanager/cmakestep.cpp create mode 100644 src/plugins/cmakeprojectmanager/cmakestep.h diff --git a/src/plugins/cmakeprojectmanager/cmakestep.cpp b/src/plugins/cmakeprojectmanager/cmakestep.cpp new file mode 100644 index 00000000000..25f383b4545 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakestep.cpp @@ -0,0 +1,90 @@ +#include "cmakestep.h" +#include "cmakeprojectconstants.h" +#include "cmakeproject.h" + +using namespace CMakeProjectManager; +using namespace CMakeProjectManager::Internal; + +CMakeStep::CMakeStep(CMakeProject *pro) + : BuildStep(pro), m_pro(pro) +{ + +} + +CMakeStep::~CMakeStep() +{ + +} + +bool CMakeStep::init(const QString &buildConfiguration) +{ + // TODO +} + +void CMakeStep::run(QFutureInterface &fi) +{ + // TODO + fi.reportResult(true); +} + +QString CMakeStep::name() +{ + return "CMake"; +} + +QString CMakeStep::displayName() +{ + return Constants::CMAKESTEP; +} + +ProjectExplorer::BuildStepConfigWidget *CMakeStep::createConfigWidget() +{ + return new CMakeBuildStepConfigWidget(); +} + +bool CMakeStep::immutable() const +{ + return true; +} + +// +// CMakeBuildStepConfigWidget +// + +QString CMakeBuildStepConfigWidget::displayName() const +{ + return "CMake"; +} + +void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration) +{ + // TODO +} + +// +// CMakeBuildStepFactory +// + +bool CMakeBuildStepFactory::canCreate(const QString &name) const +{ + return (Constants::CMAKESTEP == name); +} + +ProjectExplorer::BuildStep *CMakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const +{ + Q_ASSERT(name == Constants::CMAKESTEP); + CMakeProject *pro = qobject_cast(project); + Q_ASSERT(pro); + return new CMakeStep(pro); +} + +QStringList CMakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const +{ + return QStringList(); +} + +QString CMakeBuildStepFactory::displayNameForName(const QString &name) const +{ + return "CMake"; +} + diff --git a/src/plugins/cmakeprojectmanager/cmakestep.h b/src/plugins/cmakeprojectmanager/cmakestep.h new file mode 100644 index 00000000000..dea4499efc4 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakestep.h @@ -0,0 +1,48 @@ +#ifndef CMAKESTEP_H +#define CMAKESTEP_H + +#include + +namespace CMakeProjectManager { +namespace Internal { + +class CMakeProject; + +class CMakeBuildStepConfigWidget; + +class CMakeStep : public ProjectExplorer::BuildStep +{ +public: + CMakeStep(CMakeProject *pro); + ~CMakeStep(); + virtual bool init(const QString &buildConfiguration); + + virtual void run(QFutureInterface &fi); + + virtual QString name(); + virtual QString displayName(); + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + virtual bool immutable() const; +private: + CMakeProject *m_pro; +}; + +class CMakeBuildStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget +{ +public: + virtual QString displayName() const; + virtual void init(const QString &buildConfiguration); +}; + +class CMakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory +{ + virtual bool canCreate(const QString &name) const; + virtual ProjectExplorer::BuildStep *create(ProjectExplorer::Project *pro, const QString &name) const; + virtual QStringList canCreateForProject(ProjectExplorer::Project *pro) const; + virtual QString displayNameForName(const QString &name) const; +}; + + +} +} +#endif // CMAKESTEP_H From 8c741ede883af4ad117740b7b8c025603707ac28 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 09:31:29 +0100 Subject: [PATCH 02/24] Fixed possible crash when classifying chars. --- shared/cplusplus/Lexer.cpp | 2 +- shared/cplusplus/Lexer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/cplusplus/Lexer.cpp b/shared/cplusplus/Lexer.cpp index 6b08e2ad082..af6f09f74d2 100644 --- a/shared/cplusplus/Lexer.cpp +++ b/shared/cplusplus/Lexer.cpp @@ -221,7 +221,7 @@ void Lexer::scan_helper(Token *tok) return; } - char ch = _yychar; + unsigned char ch = _yychar; yyinp(); switch (ch) { diff --git a/shared/cplusplus/Lexer.h b/shared/cplusplus/Lexer.h index f2eebf2bacf..1d85a58eb9f 100644 --- a/shared/cplusplus/Lexer.h +++ b/shared/cplusplus/Lexer.h @@ -132,7 +132,7 @@ private: const char *_currentChar; const char *_lastChar; const char *_tokenStart; - char _yychar; + unsigned char _yychar; int _state; union { unsigned _flags; From 1a9446ebbd7100b78ea05dcd0d41a0139bc20d69 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Dec 2008 09:39:11 +0100 Subject: [PATCH 03/24] Fixes: Make Qt4 project manager compile --- src/plugins/qt4projectmanager/qt4nodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 8d0c11fe139..08ebe8aab95 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -33,8 +33,8 @@ #include "proeditormodel.h" -#include "profilecache.h" #include "profilereader.h" +#include "prowriter.h" #include "qt4nodes.h" #include "qt4project.h" #include "qt4projectmanager.h" From 0fcb8131bd6ad756870de43289adf7a8bbf878a6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 3 Dec 2008 10:16:16 +0100 Subject: [PATCH 04/24] Compile on MSVC 2003 Help the compiler pick the correct overload for the call to pow(). --- src/plugins/vcsbase/baseannotationhighlighter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/vcsbase/baseannotationhighlighter.cpp b/src/plugins/vcsbase/baseannotationhighlighter.cpp index 5b02bc9ea1a..167c1d7d31b 100644 --- a/src/plugins/vcsbase/baseannotationhighlighter.cpp +++ b/src/plugins/vcsbase/baseannotationhighlighter.cpp @@ -69,7 +69,7 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb // Assign a color gradient to annotation change numbers. Give // each change number a unique color. const double oneThird = 1.0 / 3.0; - const int step = qRound(ceil(pow(changeNumbers.count(), oneThird))); + const int step = qRound(ceil(pow(double(changeNumbers.count()), oneThird))); QList colors; const int factor = 255 / step; for (int i=0; i Date: Wed, 3 Dec 2008 09:41:51 +0100 Subject: [PATCH 05/24] Added macro protection. --- src/plugins/cpptools/rpp/pp-engine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/cpptools/rpp/pp-engine.cpp b/src/plugins/cpptools/rpp/pp-engine.cpp index a061b2942a9..70e802c5497 100644 --- a/src/plugins/cpptools/rpp/pp-engine.cpp +++ b/src/plugins/cpptools/rpp/pp-engine.cpp @@ -585,15 +585,19 @@ void pp::operator()(const QByteArray &source, QByteArray *result) } else { if (! m->function_like) { if (_dot->isNot(T_LPAREN)) { + m->hidden = true; expand(m->definition.constBegin(), m->definition.constEnd(), result); + m->hidden = false; continue; } else { QByteArray tmp; + m->hidden = true; expand(m->definition.constBegin(), m->definition.constEnd(), &tmp); + m->hidden = false; m = 0; // reset the active the macro @@ -636,7 +640,9 @@ void pp::operator()(const QByteArray &source, QByteArray *result) const char *beginOfText = startOfToken(*identifierToken); const char *endOfText = endOfToken(*_dot); ++_dot; // skip T_RPAREN + m->hidden = true; expand(beginOfText, endOfText, result); + m->hidden = false; } } } From b825ac4355e590cc60a4246bd403c55b84de9c4d Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 10:27:12 +0100 Subject: [PATCH 06/24] Fixed the build system. Generate the object files for release and debug builds in different directories. --- src/qworkbench.pri | 11 +++++++++++ src/qworkbenchplugin.pri | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/qworkbench.pri b/src/qworkbench.pri index d7ac4f34c5a..e869ce452a8 100644 --- a/src/qworkbench.pri +++ b/src/qworkbench.pri @@ -39,3 +39,14 @@ DEPENDPATH += \ $$IDE_SOURCE_TREE/tools \ LIBS += -L$$IDE_LIBRARY_PATH + +unix { + debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared + release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared + + debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared + release:MOC_DIR = $${OUT_PWD}/.moc/release-shared + + RCC_DIR = $${OUT_PWD}/.rcc/ + UI_DIR = $${OUT_PWD}/.uic/ +} diff --git a/src/qworkbenchplugin.pri b/src/qworkbenchplugin.pri index 50b667fc716..e598570259a 100644 --- a/src/qworkbenchplugin.pri +++ b/src/qworkbenchplugin.pri @@ -47,11 +47,4 @@ macx { } -unix { - OBJECTS_DIR = $${OUT_PWD}/.obj/ - MOC_DIR = $${OUT_PWD}/.moc/ - RCC_DIR = $${OUT_PWD}/.rcc/ - UI_DIR = $${OUT_PWD}/.uic/ -} - contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols From 56f788ccefc9b5a0a8fad88e53439fd08bb18263 Mon Sep 17 00:00:00 2001 From: con Date: Wed, 3 Dec 2008 11:27:20 +0100 Subject: [PATCH 07/24] Fixes: - Setting breakpoints on Mac Details: - Bad formatted command confused gdb completely --- src/plugins/debugger/gdbengine.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index bd1d564a609..df0eaa9f0b2 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1650,16 +1650,15 @@ bool GdbEngine::startDebugger() #ifdef Q_OS_MAC sendCommand("-gdb-set inferior-auto-start-cfm off"); sendCommand("-gdb-set sharedLibrary load-rules " - "dyld \".*libSystem.*\" " - "all dyld \".*libauto.*\" " - "all dyld \".*AppKit.*\" " - "all dyld \".*PBGDBIntrospectionSupport.*\" " - "all dyld \".*Foundation.*\" " - "all dyld \".*CFDataFormatters.*\" " - "all dyld \".*libobjc.*\" " - "all dyld \".*CarbonDataFormatters"); + "dyld \".*libSystem.*\" all " + "dyld \".*libauto.*\" all " + "dyld \".*AppKit.*\" all " + "dyld \".*PBGDBIntrospectionSupport.*\" all " + "dyld \".*Foundation.*\" all " + "dyld \".*CFDataFormatters.*\" all " + "dyld \".*libobjc.*\" all " + "dyld \".*CarbonDataFormatters.*\" all"); #endif - if (q->startMode() == q->attachExternal) { sendCommand("attach " + QString::number(q->m_attachedPID)); } From 27f866687cd4d810372ba8b8776650d314ea40ba Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 11:34:46 +0100 Subject: [PATCH 08/24] Added a simple auto test for our C++ front-end. --- tests/manual/cplusplus/c++ | 3 +++ tests/manual/cplusplus/conf.c++ | 7 ++++++ tests/manual/cplusplus/cplusplus.pro | 19 ++++++++++++++ tests/manual/cplusplus/main.cpp | 37 ++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100755 tests/manual/cplusplus/c++ create mode 100644 tests/manual/cplusplus/conf.c++ create mode 100644 tests/manual/cplusplus/cplusplus.pro create mode 100644 tests/manual/cplusplus/main.cpp diff --git a/tests/manual/cplusplus/c++ b/tests/manual/cplusplus/c++ new file mode 100755 index 00000000000..f4cbb4fe5ca --- /dev/null +++ b/tests/manual/cplusplus/c++ @@ -0,0 +1,3 @@ +#!/bin/sh +me=$(dirname $0) +${CPP-gcc} -xc++ -E -include $me/conf.c++ $* | $me/cplusplus0 diff --git a/tests/manual/cplusplus/conf.c++ b/tests/manual/cplusplus/conf.c++ new file mode 100644 index 00000000000..fbfad57a4bc --- /dev/null +++ b/tests/manual/cplusplus/conf.c++ @@ -0,0 +1,7 @@ +#define __extension__ +#define __context__ +#define __range__ +#define __asm(a...) +#define __asm__(a...) +#define restrict +#define __restrict diff --git a/tests/manual/cplusplus/cplusplus.pro b/tests/manual/cplusplus/cplusplus.pro new file mode 100644 index 00000000000..0d965b8ed0a --- /dev/null +++ b/tests/manual/cplusplus/cplusplus.pro @@ -0,0 +1,19 @@ +QT = core +macx:CONFIG -= app_bundle +TARGET = cplusplus0 + +include(../../../shared/cplusplus/cplusplus.pri) + +# Input +SOURCES += main.cpp + +unix { + debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared + release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared + + debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared + release:MOC_DIR = $${OUT_PWD}/.moc/release-shared + + RCC_DIR = $${OUT_PWD}/.rcc/ + UI_DIR = $${OUT_PWD}/.uic/ +} diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp new file mode 100644 index 00000000000..18b89137a58 --- /dev/null +++ b/tests/manual/cplusplus/main.cpp @@ -0,0 +1,37 @@ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +int main(int, char *[]) +{ + Control control; + StringLiteral *fileId = control.findOrInsertFileName(""); + + QFile in; + if (! in.open(stdin, QFile::ReadOnly)) + return EXIT_FAILURE; + + const QByteArray source = in.readAll(); + + TranslationUnit unit(&control, fileId); + unit.setSource(source.constData(), source.size()); + unit.parse(); + + if (TranslationUnitAST *ast = unit.ast()) { + Scope globalScope; + Semantic sem(&control); + for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) { + sem.check(decl, &globalScope); + } + } + + return EXIT_SUCCESS; +} From 3d9945238d43336812d35687d91873354f206471 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 11:37:35 +0100 Subject: [PATCH 09/24] oops! added the cpy header. --- tests/manual/cplusplus/main.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp index 18b89137a58..946bd5c735a 100644 --- a/tests/manual/cplusplus/main.cpp +++ b/tests/manual/cplusplus/main.cpp @@ -1,3 +1,35 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.2, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ #include From e689a1739561fd629152bda981d122ef7c332a9f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 11:59:11 +0100 Subject: [PATCH 10/24] Check for the wrong usage of ctor initializers. --- shared/cplusplus/CheckDeclaration.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/shared/cplusplus/CheckDeclaration.cpp b/shared/cplusplus/CheckDeclaration.cpp index b4c381d6175..6915faf82ce 100644 --- a/shared/cplusplus/CheckDeclaration.cpp +++ b/shared/cplusplus/CheckDeclaration.cpp @@ -236,13 +236,21 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) _scope->enterSymbol(fun); - if (ast->ctor_initializer && (ty.isValid() || (fun->identity() && ! fun->identity()->isNameId()))) { - translationUnit()->error(ast->ctor_initializer->firstToken(), - "only constructors take base initializers"); + if (ast->ctor_initializer) { + bool looksLikeCtor = false; + if (ty.isValid() || ! fun->identity()) + looksLikeCtor = false; + else if (fun->identity()->isNameId() || fun->identity()->isTemplateNameId()) + looksLikeCtor = true; + + if (! looksLikeCtor) { + translationUnit()->error(ast->ctor_initializer->firstToken(), + "only constructors take base initializers"); + } } - int previousVisibility = semantic()->switchVisibility(Symbol::Public); - int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod); + const int previousVisibility = semantic()->switchVisibility(Symbol::Public); + const int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod); semantic()->check(ast->function_body, fun->members()); From 58d89c4625e102058bcd8b73a9024898a7e76bfd Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 3 Dec 2008 12:03:46 +0100 Subject: [PATCH 11/24] issue a warning when trying to attaching to "wrong" pids --- src/plugins/debugger/debuggermanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 04875e12fd5..f696d728467 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -791,6 +791,11 @@ bool DebuggerManager::startNewDebugger(StartMode mode) m_processArgs = QStringList(); m_workingDir = QString(); m_attachedPID = dlg.attachPID(); + if (m_attachedPID == 0) { + QMessageBox::warning(mainWindow(), tr("Warning"), + tr("Cannot attach to PID 0")); + return false; + } } else if (startMode() == startInternal) { if (m_executable.isEmpty()) { QString startDirectory = m_executable; From 484a81834119fc78c21dc4c9039a7b615a750530 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 3 Dec 2008 12:02:08 +0100 Subject: [PATCH 12/24] possibility to reset the external editor command --- .../editormanager/editormanager.cpp | 41 +++++++++++++------ .../coreplugin/editormanager/editormanager.h | 1 + src/plugins/coreplugin/generalsettings.cpp | 6 +++ src/plugins/coreplugin/generalsettings.h | 1 + src/plugins/coreplugin/generalsettings.ui | 14 +++++++ 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index aa15e462f86..e546cc53de5 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -74,6 +74,19 @@ using namespace Core::Internal; enum { debugEditorManager=0 }; +QString EditorManager::defaultExternalEditor() { +#ifdef Q_OS_MAC + return m_d->m_externalEditor = m_d->m_core->resourcePath() + +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); +#elif defined(Q_OS_UNIX) + return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); +#elif defined (Q_OS_WIN) + return QLatin1String("notepad %f"); +#else + return QString(); +#endif +} + //===================EditorManager===================== EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0; @@ -342,13 +355,6 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : updateActions(); m_d->m_windowPopup = new OpenEditorsWindow(this); - -#ifdef Q_OS_MAC - m_d->m_externalEditor = m_d->m_core->resourcePath() - +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); -#elif defined(Q_OS_UNIX) - m_d->m_externalEditor = QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); -#endif } EditorManager::~EditorManager() @@ -1153,7 +1159,7 @@ void EditorManager::updateActions() m_d->m_duplicateAction->setEnabled(curEditor != 0 && curEditor->duplicateSupported()); - m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0 && !m_d->m_externalEditor.isEmpty()); + m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0); } QList EditorManager::openedEditors() const @@ -1364,7 +1370,7 @@ void EditorManager::saveSettings(QSettings *settings) m_d->m_splitter->saveSettings(settings); settings->setValue(QLatin1String("EditorManager/DocumentStates"), m_d->m_editorStates); - settings->setValue(QLatin1String("EditorManager/ExternalEditor"), + settings->setValue(QLatin1String("EditorManager/ExternalEditorCommand"), m_d->m_externalEditor); } @@ -1375,7 +1381,7 @@ void EditorManager::readSettings(QSettings *settings) m_d->m_editorStates = settings->value(QLatin1String("EditorManager/DocumentStates")) .value >(); if (settings->contains(QLatin1String("EditorManager/ExternalEditor"))) - m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditor")).toString(); + m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditorCommand")).toString(); } QByteArray EditorManager::saveOpenEditorList() const @@ -1489,7 +1495,11 @@ QString EditorManager::externalEditorHelpText() const void EditorManager::openInExternalEditor() { - if (m_d->m_externalEditor.isEmpty()) + QString command = m_d->m_externalEditor; + if (command.isEmpty()) + command = defaultExternalEditor(); + + if (command.isEmpty()) return; IEditor *editor = currentEditor(); @@ -1508,7 +1518,7 @@ void EditorManager::openInExternalEditor() QFontMetrics fm(font); rect.moveTo(editor->widget()->mapToGlobal(QPoint(0,0))); - QString pre = m_d->m_externalEditor; + QString pre = command; QString cmd; for (int i = 0; i < pre.size(); ++i) { QChar c = pre.at(i); @@ -1551,11 +1561,16 @@ void EditorManager::openInExternalEditor() void EditorManager::setExternalEditor(const QString &editor) { - m_d->m_externalEditor = editor; + if (editor.isEmpty() || editor == defaultExternalEditor()) + m_d->m_externalEditor = defaultExternalEditor(); + else + m_d->m_externalEditor = editor; } QString EditorManager::externalEditor() const { + if (m_d->m_externalEditor.isEmpty()) + return defaultExternalEditor(); return m_d->m_externalEditor; } diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 0a35ffcfaa9..480d99bf6bb 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -156,6 +156,7 @@ public: void setExternalEditor(const QString &); QString externalEditor() const; + static QString defaultExternalEditor(); QString externalEditorHelpText() const; signals: diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 7b0aadc1b3a..5aebb87d943 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -72,6 +72,8 @@ QWidget* GeneralSettings::createPage(QWidget *parent) connect(m_page->resetButton, SIGNAL(clicked()), this, SLOT(resetInterfaceColor())); + connect(m_page->resetEditorButton, SIGNAL(clicked()), + this, SLOT(resetExternalEditor())); connect(m_page->helpExternalEditorButton, SIGNAL(clicked()), this, SLOT(showHelpForExternalEditor())); @@ -95,6 +97,10 @@ void GeneralSettings::resetInterfaceColor() m_page->colorButton->setColor(0x666666); } +void GeneralSettings::resetExternalEditor() +{ + m_page->externalEditorEdit->setText(EditorManager::defaultExternalEditor()); +} void GeneralSettings::showHelpForExternalEditor() { diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h index 5d69e7cd641..3b6bbad33c3 100644 --- a/src/plugins/coreplugin/generalsettings.h +++ b/src/plugins/coreplugin/generalsettings.h @@ -59,6 +59,7 @@ public: private slots: void resetInterfaceColor(); + void resetExternalEditor(); void showHelpForExternalEditor(); private: diff --git a/src/plugins/coreplugin/generalsettings.ui b/src/plugins/coreplugin/generalsettings.ui index 1e5357d1547..316637e6a06 100644 --- a/src/plugins/coreplugin/generalsettings.ui +++ b/src/plugins/coreplugin/generalsettings.ui @@ -108,6 +108,20 @@ + + + + Reset to default + + + ... + + + + :/qworkbench/images/reset.png:/qworkbench/images/reset.png + + + From f8def2e26b0f6239d45a0f7223d98babdd65d1b0 Mon Sep 17 00:00:00 2001 From: "qtc-commiter@nokia.com" Date: Wed, 3 Dec 2008 12:07:52 +0100 Subject: [PATCH 13/24] Fixes: Compile for Karsten Task: - RevBy: - AutoTest: - Details: - --- src/plugins/cmakeprojectmanager/cmakestep.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/cmakeprojectmanager/cmakestep.cpp b/src/plugins/cmakeprojectmanager/cmakestep.cpp index 25f383b4545..821bf6b1bec 100644 --- a/src/plugins/cmakeprojectmanager/cmakestep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakestep.cpp @@ -19,6 +19,7 @@ CMakeStep::~CMakeStep() bool CMakeStep::init(const QString &buildConfiguration) { // TODO + return true; } void CMakeStep::run(QFutureInterface &fi) From 6bc0da69af4106bf64f38d286b45654f402d73b7 Mon Sep 17 00:00:00 2001 From: "qtc-commiter@nokia.com" Date: Wed, 3 Dec 2008 13:25:19 +0100 Subject: [PATCH 14/24] Fixes: Fix crash on windows while loading projects.pro. Task: Reported by eskil on irc. --- src/plugins/qt4projectmanager/profilereader.cpp | 2 +- src/plugins/qt4projectmanager/qt4nodes.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/qt4projectmanager/profilereader.cpp b/src/plugins/qt4projectmanager/profilereader.cpp index 0618fe6c730..0e7dd7ece2a 100644 --- a/src/plugins/qt4projectmanager/profilereader.cpp +++ b/src/plugins/qt4projectmanager/profilereader.cpp @@ -69,7 +69,7 @@ bool ProFileReader::readProFile(const QString &fileName) // return false; // } // } - QString fn = QFileInfo(fileName).filePath(); + QString fn = QFileInfo(fileName).filePath(); ProFile *pro = new ProFile(fn); if (!queryProFile(pro)) { delete pro; diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 08ebe8aab95..672ce8b835b 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -883,12 +883,12 @@ QStringList Qt4ProFileNode::subDirsPaths(ProFileReader *reader) const QString realFile; const QString subDirKey = subDirVar + QLatin1String(".subdir"); if (reader->contains(subDirKey)) - realDir = reader->value(subDirKey); + realDir = QFileInfo(reader->value(subDirKey)).filePath(); else realDir = subDirVar; QFileInfo info(realDir); if (!info.isAbsolute()) - realDir = QString("%1/%2").arg(m_projectDir, realDir); + realDir = m_projectDir + "/" + realDir; #ifdef QTEXTENDED_QBUILD_SUPPORT // QBuild only uses project files named qbuild.pro, and subdirs are implied From b8ce2b10312e4019fdc7f0944ea98154d328ff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 3 Dec 2008 13:21:50 +0100 Subject: [PATCH 15/24] Disambiguation for files in git commands With many git commands it is safer to disambiguate files from refs by putting '--' in front of the list of files. Also corrected a margin in the git submit panel. --- src/plugins/git/gitclient.cpp | 20 ++++++++++---------- src/plugins/git/gitsubmiteditorwidget.cpp | 4 ++-- src/plugins/git/gitsubmitpanel.ui | 3 +++ src/plugins/vcsbase/vcsbasesubmiteditor.cpp | 6 +++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 6b3eb20ad7f..fb73d4fe5e2 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -170,7 +170,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam if (Git::Constants::debug) qDebug() << "diff" << workingDirectory << fileNames; QStringList arguments; - arguments << QLatin1String("diff") << fileNames; + arguments << QLatin1String("diff") << QLatin1String("--") << fileNames; const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND); const QString title = tr("Git Diff"); @@ -187,7 +187,7 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName) QStringList arguments; arguments << QLatin1String("diff"); if (!fileName.isEmpty()) - arguments << fileName; + arguments << QLatin1String("--") << fileName; const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND); const QString title = tr("Git Diff %1").arg(fileName); @@ -246,7 +246,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName) if (Git::Constants::debug) qDebug() << "blame" << workingDirectory << fileName; QStringList arguments(QLatin1String("blame")); - arguments << fileName; + arguments << QLatin1String("--") << fileName; const QString kind = QLatin1String(Git::Constants::GIT_BLAME_EDITOR_KIND); const QString title = tr("Git Blame %1").arg(fileName); @@ -314,7 +314,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory, QByteArray outputText; QByteArray errorText; QStringList arguments; - arguments << QLatin1String("reset") << QLatin1String("HEAD") << files; + arguments << QLatin1String("reset") << QLatin1String("HEAD") << QLatin1String("--") << files; const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText); const QString output = QString::fromLocal8Bit(outputText); m_plugin->m_outputWindow->popup(false); @@ -643,9 +643,9 @@ GitCommand::~GitCommand() { } -void GitCommand::execute(const QStringList &arguments - , const QString &workingDirectory - , const ProjectExplorer::Environment &environment) +void GitCommand::execute(const QStringList &arguments, + const QString &workingDirectory, + const ProjectExplorer::Environment &environment) { if (Git::Constants::debug) qDebug() << "GitCommand::execute" << workingDirectory << arguments; @@ -663,9 +663,9 @@ void GitCommand::execute(const QStringList &arguments , Core::ProgressManagerInterface::CloseOnSuccess); } -void GitCommand::run(const QStringList &arguments - , const QString &workingDirectory - , const ProjectExplorer::Environment &environment) +void GitCommand::run(const QStringList &arguments, + const QString &workingDirectory, + const ProjectExplorer::Environment &environment) { if (Git::Constants::debug) qDebug() << "GitCommand::run" << workingDirectory << arguments; diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index 5d5cb0a2ef3..e9110f8fbeb 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -57,9 +57,9 @@ GitSubmitEditorPanelData GitSubmitEditorWidget::panelData() const rc.author = m_gitSubmitPanelUi.authorLineEdit->text(); rc.email = m_gitSubmitPanelUi.emailLineEdit->text(); return rc; -}; +} -void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data) +void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data) { m_gitSubmitPanelUi.authorLineEdit->setText(data.author); m_gitSubmitPanelUi.emailLineEdit->setText(data.email); diff --git a/src/plugins/git/gitsubmitpanel.ui b/src/plugins/git/gitsubmitpanel.ui index d408eeab11d..aba46b7c525 100644 --- a/src/plugins/git/gitsubmitpanel.ui +++ b/src/plugins/git/gitsubmitpanel.ui @@ -11,6 +11,9 @@ + + 0 + diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 3ac864f9ab4..6152a93b795 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -240,7 +240,7 @@ bool VCSBaseSubmitEditor::restoreState(const QByteArray &/*state*/) return true; } -QStringList VCSBaseSubmitEditor::checkedFiles() const +QStringList VCSBaseSubmitEditor::checkedFiles() const { return vcsFileListToFileList(m_d->m_widget->checkedFiles()); } @@ -255,7 +255,7 @@ void VCSBaseSubmitEditor::addFiles(const QStringList& list, bool checked, bool u m_d->m_widget->addFiles(list, checked, userCheckable); } -void VCSBaseSubmitEditor::slotDiffSelectedVCSFiles(const QStringList &rawList) +void VCSBaseSubmitEditor::slotDiffSelectedVCSFiles(const QStringList &rawList) { emit diffSelectedFiles(vcsFileListToFileList(rawList)); } @@ -299,4 +299,4 @@ QIcon VCSBaseSubmitEditor::submitIcon() return QIcon(QLatin1String(":/vcsbase/images/submit.png")); } -} +} // namespace VCSBase From 4222fae24b8cf0f914da032ce4d7ae2b03917bb1 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 14:00:49 +0100 Subject: [PATCH 16/24] Don't hide the expanding macro, when expeding function-like macros. --- src/plugins/cpptools/rpp/pp-engine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/cpptools/rpp/pp-engine.cpp b/src/plugins/cpptools/rpp/pp-engine.cpp index 70e802c5497..3a3e9245b30 100644 --- a/src/plugins/cpptools/rpp/pp-engine.cpp +++ b/src/plugins/cpptools/rpp/pp-engine.cpp @@ -640,9 +640,9 @@ void pp::operator()(const QByteArray &source, QByteArray *result) const char *beginOfText = startOfToken(*identifierToken); const char *endOfText = endOfToken(*_dot); ++_dot; // skip T_RPAREN - m->hidden = true; + //m->hidden = true; expand(beginOfText, endOfText, result); - m->hidden = false; + //m->hidden = false; } } } From e2e4fcd95b39fb00d132d4018eac15fcfcf9c228 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 14:01:19 +0100 Subject: [PATCH 17/24] Added different parsing mode to TranslationUnit/CppDocument. --- shared/cplusplus/TranslationUnit.cpp | 40 ++++++++++++++++++++++--- shared/cplusplus/TranslationUnit.h | 14 +++++++-- src/libs/cplusplus/CppDocument.cpp | 31 +++++++++++++++++-- src/libs/cplusplus/CppDocument.h | 9 +++++- src/libs/cplusplus/TypeOfExpression.cpp | 27 ++++------------- tests/manual/cplusplus/main.cpp | 4 ++- 6 files changed, 91 insertions(+), 34 deletions(-) diff --git a/shared/cplusplus/TranslationUnit.cpp b/shared/cplusplus/TranslationUnit.cpp index 896ab7d1a55..bc4d219e0f3 100644 --- a/shared/cplusplus/TranslationUnit.cpp +++ b/shared/cplusplus/TranslationUnit.cpp @@ -146,7 +146,7 @@ unsigned TranslationUnit::matchingBrace(unsigned index) const MemoryPool *TranslationUnit::memoryPool() const { return _pool; } -TranslationUnitAST *TranslationUnit::ast() const +AST *TranslationUnit::ast() const { return _ast; } bool TranslationUnit::isTokenized() const @@ -218,17 +218,49 @@ bool TranslationUnit::skipFunctionBody() const void TranslationUnit::setSkipFunctionBody(bool skipFunctionBody) { _skipFunctionBody = skipFunctionBody; } -void TranslationUnit::parse() +bool TranslationUnit::parse(ParseMode mode) { if (isParsed()) - return; + return false; if (! isTokenized()) tokenize(); Parser parser(this); parser.setQtMocRunEnabled(_qtMocRunEnabled); - parser.parseTranslationUnit(_ast); + + bool parsed = false; + + switch (mode) { + case ParseTranlationUnit: { + TranslationUnitAST *node = 0; + parsed = parser.parseTranslationUnit(node); + _ast = node; + } break; + + case ParseDeclaration: { + DeclarationAST *node = 0; + parsed = parser.parseDeclaration(node); + _ast = node; + } break; + + case ParseExpression: { + ExpressionAST *node = 0; + parsed = parser.parseExpression(node); + _ast = node; + } break; + + case ParseStatement: { + StatementAST *node = 0; + parsed = parser.parseStatement(node); + _ast = node; + } break; + + default: + break; + } // switch + + return parsed; } void TranslationUnit::pushLineOffset(unsigned offset) diff --git a/shared/cplusplus/TranslationUnit.h b/shared/cplusplus/TranslationUnit.h index 41f5a1d6e86..ae6b911aeee 100644 --- a/shared/cplusplus/TranslationUnit.h +++ b/shared/cplusplus/TranslationUnit.h @@ -95,7 +95,7 @@ public: NumericLiteral *numericLiteral(unsigned index) const; MemoryPool *memoryPool() const; - TranslationUnitAST *ast() const; + AST *ast() const; bool blockErrors(bool block); @@ -113,7 +113,15 @@ public: void setSkipFunctionBody(bool skipFunctionBody); bool isParsed() const; - void parse(); + + enum ParseMode { + ParseTranlationUnit, + ParseDeclaration, + ParseExpression, + ParseStatement + }; + + bool parse(ParseMode mode = ParseTranlationUnit); void resetAST(); void release(); @@ -169,7 +177,7 @@ private: std::vector _lineOffsets; std::vector _ppLines; MemoryPool *_pool; - TranslationUnitAST *_ast; + AST *_ast; TranslationUnit *_previousTranslationUnit; union { unsigned _flags; diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 3fe4ea86b63..782c14ff6d5 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -251,9 +251,31 @@ QSet Document::macroNames() const return _macroNames; } -void Document::parse() +bool Document::parse(ParseMode mode) { - _translationUnit->parse(); + TranslationUnit::ParseMode m = TranslationUnit::ParseTranlationUnit; + switch (mode) { + case ParseTranlationUnit: + m = TranslationUnit::ParseTranlationUnit; + break; + + case ParseDeclaration: + m = TranslationUnit::ParseDeclaration; + break; + + case ParseExpression: + m = TranslationUnit::ParseExpression; + break; + + case ParseStatement: + m = TranslationUnit::ParseStatement; + break; + + default: + break; + } + + return _translationUnit->parse(m); } void Document::check() @@ -264,7 +286,10 @@ void Document::check() _globalNamespace = _control->newNamespace(0); Scope *globals = _globalNamespace->members(); - if (TranslationUnitAST *ast = _translationUnit->ast()) { + if (! _translationUnit->ast()) + return; // nothing to do. + + if (TranslationUnitAST *ast = _translationUnit->ast()->asTranslationUnit()) { for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) { semantic.check(decl, globals); } diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index d4de240d3a4..17762200fa0 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -85,7 +85,14 @@ public: void startSkippingBlocks(unsigned offset); void stopSkippingBlocks(unsigned offset); - void parse(); // ### remove + enum ParseMode { // ### keep in sync with CPlusPlus::TranslationUnit + ParseTranlationUnit, + ParseDeclaration, + ParseExpression, + ParseStatement + }; + + bool parse(ParseMode mode = ParseTranlationUnit); void check(); void releaseTranslationUnit(); diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 7e3ed35af8b..2672bfb105f 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -81,34 +81,17 @@ ExpressionAST *TypeOfExpression::expressionAST() const ExpressionAST *TypeOfExpression::extractExpressionAST(Document::Ptr doc) const { - TranslationUnitAST *translationUnitAST = doc->translationUnit()->ast(); + if (! doc->translationUnit()->ast()) + return 0; - // ### evaluate the expression - ExpressionAST *expressionAST = 0; - if (translationUnitAST) { - DeclarationAST *declaration = translationUnitAST->declarations; - SimpleDeclarationAST *simpleDecl = 0; - if (declaration) - simpleDecl = declaration->asSimpleDeclaration(); - if (simpleDecl && simpleDecl->decl_specifier_seq) { - if (TypeofSpecifierAST *typeOfSpec = simpleDecl->decl_specifier_seq->asTypeofSpecifier()) - expressionAST = typeOfSpec->expression; - } - } - return expressionAST; + return doc->translationUnit()->ast()->asExpression(); } Document::Ptr TypeOfExpression::documentForExpression(const QString &expression) const { - // create a __typeof__ specifier - QByteArray declaration; - declaration += "__typeof__ "; - declaration += expression.toLatin1(); // C++ code needs to be in latin1 - declaration += ";"; - // create the expression's AST. Document::Ptr doc = Document::create(QLatin1String("")); - doc->setSource(declaration); - doc->parse(); + doc->setSource(expression.toUtf8()); + doc->parse(Document::ParseExpression); return doc; } diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp index 946bd5c735a..234c9684a39 100644 --- a/tests/manual/cplusplus/main.cpp +++ b/tests/manual/cplusplus/main.cpp @@ -56,8 +56,10 @@ int main(int, char *[]) TranslationUnit unit(&control, fileId); unit.setSource(source.constData(), source.size()); unit.parse(); + if (unit.ast()) { + TranslationUnitAST *ast = unit.ast()->asTranslationUnit(); + Q_ASSERT(ast != 0); - if (TranslationUnitAST *ast = unit.ast()) { Scope globalScope; Semantic sem(&control); for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) { From 5adee37c8c9638278cebee9fbbde44999bb9e2a9 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 3 Dec 2008 14:25:23 +0100 Subject: [PATCH 18/24] fix mac compile --- src/plugins/coreplugin/editormanager/editormanager.cpp | 7 ++++--- src/plugins/coreplugin/editormanager/editormanager.h | 2 +- src/plugins/coreplugin/generalsettings.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index e546cc53de5..0092513693b 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -74,10 +74,11 @@ using namespace Core::Internal; enum { debugEditorManager=0 }; -QString EditorManager::defaultExternalEditor() { +QString EditorManager::defaultExternalEditor() const +{ #ifdef Q_OS_MAC - return m_d->m_externalEditor = m_d->m_core->resourcePath() - +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); + return m_d->m_core->resourcePath() + +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); #elif defined(Q_OS_UNIX) return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); #elif defined (Q_OS_WIN) diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 480d99bf6bb..b71791f36bf 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -156,7 +156,7 @@ public: void setExternalEditor(const QString &); QString externalEditor() const; - static QString defaultExternalEditor(); + QString defaultExternalEditor() const; QString externalEditorHelpText() const; signals: diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 5aebb87d943..5edfda207e8 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -99,7 +99,7 @@ void GeneralSettings::resetInterfaceColor() void GeneralSettings::resetExternalEditor() { - m_page->externalEditorEdit->setText(EditorManager::defaultExternalEditor()); + m_page->externalEditorEdit->setText(EditorManager::instance()->defaultExternalEditor()); } void GeneralSettings::showHelpForExternalEditor() From 876c775805edb85ab15717f6e2dd767d31db0d65 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Dec 2008 14:17:39 +0100 Subject: [PATCH 19/24] Fixes: Enable switching of VCS according to currentProject Task: 205821 RevBy: Eike Details: Add a IVersionControl to git. Extend IF to able to return a name and add enabling options. Connect project explorer to enable the right VCS. --- src/plugins/git/gitversioncontrol.cpp | 104 ++++++++++++++++++++++++++ src/plugins/git/gitversioncontrol.h | 75 +++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 src/plugins/git/gitversioncontrol.cpp create mode 100644 src/plugins/git/gitversioncontrol.h diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp new file mode 100644 index 00000000000..5f403ef2b57 --- /dev/null +++ b/src/plugins/git/gitversioncontrol.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.2, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "gitversioncontrol.h" +#include "gitclient.h" + +namespace Git { +namespace Internal { + +GitVersionControl::GitVersionControl(GitClient *client) : + m_enabled(true), + m_client(client) +{ +} + +QString GitVersionControl::name() const +{ + return QLatin1String("git"); +} + +bool GitVersionControl::isEnabled() const +{ + return m_enabled; +} + +void GitVersionControl::setEnabled(bool enabled) +{ + if (m_enabled != enabled) { + m_enabled = enabled; + emit enabledChanged(m_enabled); + } +} + +bool GitVersionControl::supportsOperation(Operation operation) const +{ + bool rc = false; + switch (operation) { + case AddOperation: + case DeleteOperation: + case OpenOperation: + break; + } + return rc; +} + +bool GitVersionControl::vcsOpen(const QString & /*fileName*/) +{ + return false; +} + +bool GitVersionControl::vcsAdd(const QString & /*fileName*/) +{ + return false; +} + +bool GitVersionControl::vcsDelete(const QString & /*fileName*/) +{ + // TODO: implement using 'git rm'. + return false; +} + +bool GitVersionControl::managesDirectory(const QString &directory) const +{ + return !GitClient::findRepositoryForDirectory(directory).isEmpty(); + +} + +QString GitVersionControl::findTopLevelForDirectory(const QString &directory) const +{ + return GitClient::findRepositoryForDirectory(directory); +} + +} // Internal +} // Git diff --git a/src/plugins/git/gitversioncontrol.h b/src/plugins/git/gitversioncontrol.h new file mode 100644 index 00000000000..e12e7736713 --- /dev/null +++ b/src/plugins/git/gitversioncontrol.h @@ -0,0 +1,75 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.2, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#ifndef GITVERSIONCONTROL_H +#define GITVERSIONCONTROL_H + +#include + +namespace Git { +namespace Internal { + +class GitClient; + +// Just a proxy for GitPlugin +class GitVersionControl : public Core::IVersionControl +{ + Q_OBJECT +public: + explicit GitVersionControl(GitClient *plugin); + + virtual QString name() const; + + virtual bool isEnabled() const; + virtual void setEnabled(bool enabled); + + bool managesDirectory(const QString &directory) const; + virtual QString findTopLevelForDirectory(const QString &directory) const; + + virtual bool supportsOperation(Operation operation) const; + virtual bool vcsOpen(const QString &fileName); + virtual bool vcsAdd(const QString &fileName); + virtual bool vcsDelete(const QString &filename); + +signals: + void enabledChanged(bool); + +private: + bool m_enabled; + GitClient *m_client; +}; + +} // Internal +} // Git + +#endif // GITVERSIONCONTROL_H From 75f2c01d968640e19ece7e9ca1bab54964683f4c Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 3 Dec 2008 13:53:11 +0100 Subject: [PATCH 20/24] Fixes: Fixes saving of settings --- src/plugins/projectexplorer/projectexplorer.h | 1 - src/plugins/projectexplorer/session.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 039def13052..6a7f4beb831 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -139,7 +139,6 @@ private slots: void cancelBuild(); void debugProject(); void editDependencies(); - bool saveAction(ProjectExplorer::Project *pro = 0); void loadAction(); void unloadProject(); void clearSession(); diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 61ca7df05a9..876b8294a37 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -939,6 +939,7 @@ void SessionManager::removeProjects(QList remove) // Delete projects foreach (Project *pro, remove) { + pro->saveSettings(); m_file->m_projects.removeOne(pro); if (pro == m_file->m_startupProject) From 2a76e5f85ea434a563f2400fb4348937021ab7be Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 3 Dec 2008 13:58:40 +0100 Subject: [PATCH 21/24] Fixes: Merge the saveAction() function in the unload function. Details: Found while reading the code. It was only used in that function anyway, and this simplfies the code a little bit and removes some dubious left over. --- .../projectexplorer/projectexplorer.cpp | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index e04553763a3..c3a3fb3064d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -685,28 +685,19 @@ void ProjectExplorerPlugin::loadAction() updateActions(); } -bool ProjectExplorerPlugin::saveAction(Project *pro) +void ProjectExplorerPlugin::unloadProject() { if (debug) - qDebug() << "ProjectExplorerPlugin::saveAction"; + qDebug() << "ProjectExplorerPlugin::unloadProject"; - if (!pro) - pro = m_currentProject; - Q_ASSERT(pro); - - Core::IFile *fi = pro->file(); - - if (!fi) // TODO Why saving the session here???? - fi = m_session->file(); + Core::IFile *fi = m_currentProject->file(); if (!fi || fi->fileName().isEmpty()) //nothing to save? - return false; + return; QList filesToSave; - filesToSave << fi; - if (pro) - filesToSave << pro->dependencies(); + filesToSave << pro->dependencies(); // check the number of modified files int readonlycount = 0; @@ -721,20 +712,10 @@ bool ProjectExplorerPlugin::saveAction(Project *pro) else success = m_core->fileManager()->saveModifiedFilesSilently(filesToSave).isEmpty(); - if (success) - addToRecentProjects(fi->fileName()); - updateActions(); - return success; -} - -void ProjectExplorerPlugin::unloadProject() -{ - if (debug) - qDebug() << "ProjectExplorerPlugin::unloadProject"; - - if (!saveAction(m_currentProject)) + if (!success) return; + addToRecentProjects(fi->fileName()); m_session->removeProject(m_currentProject); updateActions(); } From e02f818f84907034c68b7e77b534fd43534206a6 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 14:28:33 +0100 Subject: [PATCH 22/24] Save the utf8 bytes in a QByteArray before invoking the parser. --- src/libs/cplusplus/TypeOfExpression.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 2672bfb105f..7dd669365fc 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -91,7 +91,8 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression) { // create the expression's AST. Document::Ptr doc = Document::create(QLatin1String("")); - doc->setSource(expression.toUtf8()); + const QByteArray bytes = expression.toUtf8(); + doc->setSource(bytes); doc->parse(Document::ParseExpression); return doc; } From 3d926c71c74064a5c6bb5dc822382c3c8cc50a64 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 3 Dec 2008 14:29:19 +0100 Subject: [PATCH 23/24] Compile. --- .../editormanager/editormanager.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 0092513693b..1593847ef85 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -74,20 +74,6 @@ using namespace Core::Internal; enum { debugEditorManager=0 }; -QString EditorManager::defaultExternalEditor() const -{ -#ifdef Q_OS_MAC - return m_d->m_core->resourcePath() - +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); -#elif defined(Q_OS_UNIX) - return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); -#elif defined (Q_OS_WIN) - return QLatin1String("notepad %f"); -#else - return QString(); -#endif -} - //===================EditorManager===================== EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0; @@ -388,6 +374,20 @@ QSize EditorManager::minimumSizeHint() const return QSize(400, 300); } +QString EditorManager::defaultExternalEditor() const +{ +#ifdef Q_OS_MAC + return m_d->m_core->resourcePath() + +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); +#elif defined(Q_OS_UNIX) + return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); +#elif defined (Q_OS_WIN) + return QLatin1String("notepad %f"); +#else + return QString(); +#endif +} + EditorSplitter *EditorManager::editorSplitter() const { return m_d->m_splitter; From 6477cec406ddf5a112ac9c5f68147e44bca3f71a Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 3 Dec 2008 14:29:59 +0100 Subject: [PATCH 24/24] Fixes: Actually compile. --- src/plugins/projectexplorer/projectexplorer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index c3a3fb3064d..1a9c24b994d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -697,7 +697,7 @@ void ProjectExplorerPlugin::unloadProject() QList filesToSave; filesToSave << fi; - filesToSave << pro->dependencies(); + filesToSave << m_currentProject->dependencies(); // check the number of modified files int readonlycount = 0;