From 65f07aa2de0fa24430a6deccc72334dfe883174f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 13:27:59 +0100 Subject: [PATCH 01/39] Implemented support for C++ and iso646 operators. --- shared/cplusplus/Keywords.cpp | 137 ++++++++++++++++++++++++++++++++++ shared/cplusplus/Lexer.cpp | 9 ++- shared/cplusplus/Lexer.h | 1 + shared/cplusplus/Token.h | 14 +++- 4 files changed, 158 insertions(+), 3 deletions(-) diff --git a/shared/cplusplus/Keywords.cpp b/shared/cplusplus/Keywords.cpp index 0e19b6b1d4f..d5ec6b5d432 100644 --- a/shared/cplusplus/Keywords.cpp +++ b/shared/cplusplus/Keywords.cpp @@ -1208,4 +1208,141 @@ int Lexer::classify(const char *s, int n, bool q) { } // switch } +static inline int classifyOperator2(const char *s) { + if (s[0] == 'o') { + if (s[1] == 'r') { + return T_OR; + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator3(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + return T_AND; + } + } + } + else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + return T_NOT; + } + } + } + else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + return T_XOR; + } + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator5(const char *s) { + if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'o') { + if (s[4] == 'r') { + return T_BITOR; + } + } + } + } + } + else if (s[0] == 'c') { + if (s[1] == 'o') { + if (s[2] == 'm') { + if (s[3] == 'p') { + if (s[4] == 'l') { + return T_COMPL; + } + } + } + } + } + else if (s[0] == 'o') { + if (s[1] == 'r') { + if (s[2] == '_') { + if (s[3] == 'e') { + if (s[4] == 'q') { + return T_OR_EQ; + } + } + } + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator6(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_AND_EQ; + } + } + } + } + } + } + else if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'a') { + if (s[4] == 'n') { + if (s[5] == 'd') { + return T_BITAND; + } + } + } + } + } + } + else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_NOT_EQ; + } + } + } + } + } + } + else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_XOR_EQ; + } + } + } + } + } + } + return T_IDENTIFIER; +} + +int Lexer::classifyOperator(const char *s, int n) { + switch (n) { + case 2: return classifyOperator2(s); + case 3: return classifyOperator3(s); + case 5: return classifyOperator5(s); + case 6: return classifyOperator6(s); + default: return T_IDENTIFIER; + } // switch +} + CPLUSPLUS_END_NAMESPACE diff --git a/shared/cplusplus/Lexer.cpp b/shared/cplusplus/Lexer.cpp index af6f09f74d2..2e9ae98c1e0 100644 --- a/shared/cplusplus/Lexer.cpp +++ b/shared/cplusplus/Lexer.cpp @@ -589,8 +589,13 @@ void Lexer::scan_helper(Token *tok) tok->kind = classify(yytext, yylen, _qtMocRunEnabled); else tok->kind = T_IDENTIFIER; - if (tok->kind == T_IDENTIFIER && control()) - tok->identifier = control()->findOrInsertIdentifier(yytext, yylen); + + if (tok->kind == T_IDENTIFIER) { + tok->kind = classifyOperator(yytext, yylen); + + if (control()) + tok->identifier = control()->findOrInsertIdentifier(yytext, yylen); + } break; } else if (std::isdigit(ch)) { const char *yytext = _currentChar - 1; diff --git a/shared/cplusplus/Lexer.h b/shared/cplusplus/Lexer.h index 1d85a58eb9f..57f9d3e1362 100644 --- a/shared/cplusplus/Lexer.h +++ b/shared/cplusplus/Lexer.h @@ -112,6 +112,7 @@ private: void scan_helper(Token *tok); void setSource(const char *firstChar, const char *lastChar); static int classify(const char *string, int length, bool q); + static int classifyOperator(const char *string, int length); inline void yyinp() { diff --git a/shared/cplusplus/Token.h b/shared/cplusplus/Token.h index e172fea5680..f017bbc8e7e 100644 --- a/shared/cplusplus/Token.h +++ b/shared/cplusplus/Token.h @@ -209,7 +209,19 @@ enum Kind { T_LAST_KEYWORD = T_SLOTS, - // ### aliases + // aliases + T_OR = T_PIPE_PIPE, + T_AND = T_AMPER_AMPER, + T_NOT = T_EXCLAIM, + T_XOR = T_CARET, + T_BITOR = T_PIPE, + T_COMPL = T_TILDE, + T_OR_EQ = T_PIPE_EQUAL, + T_AND_EQ = T_AMPER_EQUAL, + T_BITAND = T_AMPER, + T_NOT_EQ = T_EXCLAIM_EQUAL, + T_XOR_EQ = T_CARET_EQUAL, + T___ASM = T_ASM, T___ASM__ = T_ASM, From 9c244bcbdebe00ce3b256308e36f441a227daf7f Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 13:58:02 +0100 Subject: [PATCH 02/39] Fixes: - Warning about wrong connect Details: - Bookmarks plugin accidentally thought all editors are text editors. --- src/plugins/bookmarks/bookmarksplugin.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 83c8ec397ee..615ba5ec2ac 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -201,14 +201,18 @@ void BookmarksPlugin::updateActions(int state) void BookmarksPlugin::editorOpened(Core::IEditor *editor) { - connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), - this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + if (qobject_cast(editor)) { + connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), + this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + } } void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor) { - disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), - this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + if (qobject_cast(editor)) { + disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), + this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + } } void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor, From 94c613c9fe801da696df62ad3db56a08ee07003f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 14:37:15 +0100 Subject: [PATCH 03/39] add custom dumpers for std::list --- bin/gdbmacros/gdbmacros.cpp | 73 +++++++++++++++ src/plugins/debugger/gdbengine.cpp | 2 + src/plugins/debugger/watchhandler.cpp | 22 ++++- tests/manual/gdbdebugger/simple/app.cpp | 119 ++++++++++++++++-------- 4 files changed, 170 insertions(+), 46 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 199b783f45d..e074ddd2a5d 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -122,6 +122,7 @@ int qtGhVersion = QT_VERSION; # include #endif +#include #include #include @@ -2101,6 +2102,76 @@ static void qDumpQVector(QDumper &d) d.disarm(); } +static void qDumpStdList(QDumper &d) +{ + const std::list &list = *reinterpret_cast *>(d.data); + const void *p = d.data; + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(addOffset(d.data, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + + int nn = 0; + std::list::const_iterator it = list.begin(); + for (int i = 0; i < 101 && it != list.end(); ++i, ++it) { + qCheckAccess(it.operator->()); + ++nn; + } + + if (nn > 100) + P(d, "value", ""); + else + P(d, "value", "<" << nn << " items>"); + P(d, "numchild", nn); + + P(d, "valuedisabled", "true"); + if (d.dumpChildren) { + unsigned innersize = d.extraInt[0]; + bool innerTypeIsPointer = isPointerType(d.innertype); + QByteArray strippedInnerType = stripPointerType(d.innertype); + d << ",children=["; + std::list::const_iterator it = list.begin(); + for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { + d.beginHash(); + P(d, "name", "[" << i << "]"); + P(d, "type", d.innertype); + const void *p = it.operator->(); + if (innerTypeIsPointer) { + if (deref(p)) { + qDumpInnerValue(d, strippedInnerType.data(), deref(p)); + } else { + P(d, "type", d.innertype); + P(d, "value", ""); + P(d, "numchild", "0"); + } + } else { + qDumpInnerValue(d, d.innertype, p); + } + d.endHash(); + } + if (it != list.end()) { + d.beginHash(); + P(d, "name", "[...]"); + P(d, "value", ""); + P(d, "type", d.innertype); + d.endHash(); + } + d << "]"; + } + d.disarm(); +} + static void qDumpStdString(QDumper &d) { const std::string &str = *reinterpret_cast(d.data); @@ -2325,6 +2396,8 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpStdVector(d); else if (isEqual(type, "std::vector::bool")) qDumpStdVectorBool(d); + else if (isEqual(type, "std::list")) + qDumpStdList(d); else if (isEqual(type, "string")) qDumpStdString(d); else if (isEqual(type, "std::string")) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index d7ac5b1aaa1..83473674782 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -2939,6 +2939,8 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const if (tmplate == "QSet") return true; } + if (tmplate == "std::list") + return true; if (tmplate == "std::vector" && inner != "bool") return true; if (tmplate == "std::basic_string") { diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 053fcadcd19..47f1593db36 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -402,18 +402,30 @@ bool WatchHandler::setData(const QModelIndex &idx, static QString niceType(QString type) { if (type.contains("std::")) { - static QRegExp re("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); - re.setMinimal(true); - + // std::string type.replace("std::basic_string, " "std::allocator >", "std::string"); + + // std::wstring type.replace("std::basic_string, " "std::allocator >", "std::wstring"); + // std::vector + static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); + re1.setMinimal(true); for (int i = 0; i != 10; ++i) { - if (re.indexIn(type) == -1 || re.cap(1) != re.cap(2)) + if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2)) break; - type.replace(re.cap(0), "std::vector<" + re.cap(1) + ">"); + type.replace(re1.cap(0), "std::vector<" + re1.cap(1) + ">"); + } + + // std::list + static QRegExp re2("std::list<(.*)\\s*,std::allocator<(.*)>\\s*>"); + re2.setMinimal(true); + for (int i = 0; i != 10; ++i) { + if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2)) + break; + type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">"); } type.replace(" >", ">"); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 958c8985b05..4dc01961958 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -53,6 +53,8 @@ #include #include +#include +#include #include #include @@ -373,65 +375,63 @@ void stringRefTest(const QString &refstring) Q_UNUSED(refstring); } - -int F(int a, int b) +void testStdList() { - return a + b; -} - -int add(int i) { return i + 2; } - -int mul(int i) { return i * 2; } - - -void testStdVector() -{ - int x = F(add(1), mul(2)); - Q_UNUSED(x); - std::vector plist1; + std::list plist1; plist1.push_back(new int(1)); plist1.push_back(0); plist1.push_back(new int(2)); - std::vector flist2; + std::list flist2; flist2.push_back(1); flist2.push_back(2); flist2.push_back(3); flist2.push_back(4); - int a = 1; - int b = 0; - - while (0) { - a += 1; - if (b) - break; - } - flist2.push_back(1); flist2.push_back(2); flist2.push_back(3); flist2.push_back(4); - std::vector plist; + std::list plist; plist.push_back(new Foo(1)); plist.push_back(0); plist.push_back(new Foo(2)); - std::vector flist; + std::list flist; flist.push_back(1); - flist.push_back(2); flist.push_back(3); flist.push_back(4); - //flist.takeFirst(); - //flist.takeFirst(); - std::vector vec; + std::list vec; vec.push_back(true); vec.push_back(false); } +void testStdStack() +{ + std::stack plist1; + plist1.push(new int(1)); + plist1.push(0); + plist1.push(new int(2)); + plist1.pop(); + plist1.pop(); + plist1.pop(); + + std::stack flist2; + flist2.push(1); + flist2.push(2); + + std::stack plist; + plist.push(new Foo(1)); + plist.push(new Foo(2)); + + std::stack flist; + flist.push(1); + flist.push(2); +} + void testStdString() { QString foo; @@ -470,6 +470,42 @@ void testStdString() v.push_back(str); } +void testStdVector() +{ + std::vector plist1; + plist1.push_back(new int(1)); + plist1.push_back(0); + plist1.push_back(new int(2)); + + std::vector flist2; + flist2.push_back(1); + flist2.push_back(2); + flist2.push_back(3); + flist2.push_back(4); + + flist2.push_back(1); + flist2.push_back(2); + flist2.push_back(3); + flist2.push_back(4); + + std::vector plist; + plist.push_back(new Foo(1)); + plist.push_back(0); + plist.push_back(new Foo(2)); + + std::vector flist; + flist.push_back(1); + flist.push_back(2); + flist.push_back(3); + flist.push_back(4); + //flist.takeFirst(); + //flist.takeFirst(); + + std::vector vec; + vec.push_back(true); + vec.push_back(false); +} + void testString() { QString str = "Hello "; @@ -729,16 +765,9 @@ void testNamespace() bar.doit(1); } -int main(int argc, char *argv[]) + +void testHidden() { - testIO(); - //QString s; - //s = "hallo"; - //QList *> vi; - //QList *> vd; - //int n = A::barz(); - - int n = 1; n = 2; n = 3; @@ -762,10 +791,18 @@ int main(int argc, char *argv[]) } ++n; ++n; +} +int main(int argc, char *argv[]) +{ + //testIO(); + testHidden(); testArray(); - testStdVector(); + + testStdList(); + testStdStack(); testStdString(); + testStdVector(); testPlugin(); testList(); From 0722e9568202066ddee8a9cf9cc73716057799fe Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 15:17:07 +0100 Subject: [PATCH 04/39] Fixes: - Don't popup the git output window at all operations --- src/plugins/git/gitclient.cpp | 58 +++++++++++++++++++---------- src/plugins/git/gitclient.h | 5 ++- src/plugins/git/gitoutputwindow.cpp | 1 - src/plugins/git/gitplugin.cpp | 3 +- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index ff0cdbde5e4..466307b4de3 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -197,7 +197,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam const QString title = tr("Git Diff"); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, workingDirectory, true, "originalFileName", workingDirectory); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } @@ -215,14 +215,14 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName) const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "originalFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::status(const QString &workingDirectory) { QStringList statusArgs(QLatin1String("status")); statusArgs << QLatin1String("-u"); - executeGit(workingDirectory, statusArgs, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, statusArgs, 0, true); } void GitClient::log(const QString &workingDirectory, const QString &fileName) @@ -242,7 +242,7 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName) const QString kind = QLatin1String(Git::Constants::GIT_LOG_EDITOR_KIND); const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, false, "logFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::show(const QString &source, const QString &id) @@ -258,7 +258,7 @@ void GitClient::show(const QString &source, const QString &id) const QFileInfo sourceFi(source); const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath(); - executeGit(workDir, arguments, m_plugin->outputWindow(), editor); + executeGit(workDir, arguments, editor); } void GitClient::blame(const QString &workingDirectory, const QString &fileName) @@ -273,7 +273,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName) const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "blameFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::checkout(const QString &workingDirectory, const QString &fileName) @@ -287,7 +287,7 @@ void GitClient::checkout(const QString &workingDirectory, const QString &fileNam arguments << QLatin1String("checkout") << QLatin1String("HEAD") << QLatin1String("--") << fileName; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::hardReset(const QString &workingDirectory, const QString &commit) @@ -297,7 +297,7 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit if (!commit.isEmpty()) arguments << commit; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::addFile(const QString &workingDirectory, const QString &fileName) @@ -305,7 +305,7 @@ void GitClient::addFile(const QString &workingDirectory, const QString &fileName QStringList arguments; arguments << QLatin1String("add") << fileName; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files) @@ -380,13 +380,14 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory, } void GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments, - GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor, + VCSBase::VCSBaseEditor* editor, bool outputToWindow) { if (Git::Constants::debug) qDebug() << "executeGit" << workingDirectory << arguments << editor; - m_plugin->outputWindow()->append(formatCommand(QLatin1String(kGitCommand), arguments)); + GitOutputWindow *outputWindow = m_plugin->outputWindow(); + outputWindow->append(formatCommand(QLatin1String(kGitCommand), arguments)); QProcess process; ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment(); @@ -396,8 +397,13 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a GitCommand* command = new GitCommand(); if (outputToWindow) { - connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString))); - connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); + if (!editor) { // assume that the commands output is the important thing + connect(command, SIGNAL(outputText(QString)), this, SLOT(appendAndPopup(QString))); + connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray))); + } else { + connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString))); + connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); + } } else { QTC_ASSERT(editor, /**/); connect(command, SIGNAL(outputText(QString)), editor, SLOT(setPlainText(QString))); @@ -405,11 +411,23 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a } if (outputWindow) - connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(append(QString))); + connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString))); command->execute(arguments, workingDirectory, environment); } +void GitClient::appendDataAndPopup(const QByteArray &data) +{ + m_plugin->outputWindow()->appendData(data); + m_plugin->outputWindow()->popup(false); +} + +void GitClient::appendAndPopup(const QString &text) +{ + m_plugin->outputWindow()->append(text); + m_plugin->outputWindow()->popup(false); +} + bool GitClient::synchronousGit(const QString &workingDirectory, const QStringList &arguments, QByteArray* outputText, @@ -810,12 +828,12 @@ void GitClient::revert(const QStringList &files) void GitClient::pull(const QString &workingDirectory) { - executeGit(workingDirectory, QStringList(QLatin1String("pull")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true); } void GitClient::push(const QString &workingDirectory) { - executeGit(workingDirectory, QStringList(QLatin1String("push")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true); } QString GitClient::msgNoChangedFiles() @@ -829,7 +847,7 @@ void GitClient::stash(const QString &workingDirectory) QString errorMessage; switch (gitStatus(workingDirectory, false, 0, &errorMessage)) { case StatusChanged: - executeGit(workingDirectory, QStringList(QLatin1String("stash")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true); break; case StatusUnchanged: m_plugin->outputWindow()->append(msgNoChangedFiles()); @@ -846,21 +864,21 @@ void GitClient::stashPop(const QString &workingDirectory) { QStringList arguments(QLatin1String("stash")); arguments << QLatin1String("pop"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::branchList(const QString &workingDirectory) { QStringList arguments(QLatin1String("branch")); arguments << QLatin1String("-r"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::stashList(const QString &workingDirectory) { QStringList arguments(QLatin1String("stash")); arguments << QLatin1String("list"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } QString GitClient::readConfig(const QString &workingDirectory, const QStringList &configVar) diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index efc767e5409..eb42b27efcb 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -130,6 +130,10 @@ public: public slots: void show(const QString &source, const QString &id); +private slots: + void appendAndPopup(const QString &text); + void appendDataAndPopup(const QByteArray &data); + private: VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind, QString title, @@ -141,7 +145,6 @@ private: void executeGit(const QString &workingDirectory, const QStringList &arguments, - GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor = 0, bool outputToWindow = false); diff --git a/src/plugins/git/gitoutputwindow.cpp b/src/plugins/git/gitoutputwindow.cpp index 375be909597..fbaed2c8413 100644 --- a/src/plugins/git/gitoutputwindow.cpp +++ b/src/plugins/git/gitoutputwindow.cpp @@ -105,7 +105,6 @@ void GitOutputWindow::append(const QString &text) foreach (const QString &s, lines) m_outputListWidget->addItem(s); m_outputListWidget->scrollToBottom(); - popup(); } void GitOutputWindow::setData(const QByteArray &data) diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index d9187f542a9..f7647fb2d1a 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -496,7 +496,7 @@ QString GitPlugin::getWorkingDirectory() if (workingDirectory.isEmpty()) { m_outputWindow->clearContents(); m_outputWindow->append(tr("Could not find working directory")); - m_outputWindow->popup(); + m_outputWindow->popup(false); return QString(); } return workingDirectory; @@ -612,6 +612,7 @@ void GitPlugin::startCommit() changeTmpFile->setAutoRemove(true); if (!changeTmpFile->open()) { m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); + m_outputWindow->popup(false); delete changeTmpFile; return; } From fdfae53abbdf57235fa35b0cc6e23e5f1a2bf18d Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 15:43:17 +0100 Subject: [PATCH 05/39] Don't use QTC_ASSERT in the C++ front-end library. The engine does not recover from invalid asserts, so it will crash anyway, but not in a controlled environment. --- src/libs/cplusplus/CppDocument.cpp | 4 +--- src/libs/cplusplus/OverviewModel.cpp | 12 +++++------- src/libs/cplusplus/ResolveExpression.cpp | 22 ++++++++++------------ src/libs/cplusplus/pp-environment.cpp | 4 +--- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 3e619548a23..e67214f63b8 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -33,8 +33,6 @@ #include "CppDocument.h" -#include - #include #include #include @@ -273,7 +271,7 @@ bool Document::parse(ParseMode mode) void Document::check() { - QTC_ASSERT(!_globalNamespace, return); + Q_ASSERT(!_globalNamespace); Semantic semantic(_control); diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp index 7f38cb8ba1a..b1b7267027c 100644 --- a/src/libs/cplusplus/OverviewModel.cpp +++ b/src/libs/cplusplus/OverviewModel.cpp @@ -34,8 +34,6 @@ #include "OverviewModel.h" #include "Overview.h" -#include - #include #include #include @@ -83,13 +81,13 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent) return createIndex(row, column, symbol); } else { Symbol *parentSymbol = static_cast(parent.internalPointer()); - QTC_ASSERT(parentSymbol, return QModelIndex()); + Q_ASSERT(parentSymbol); ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol(); - QTC_ASSERT(scopedSymbol, return QModelIndex()); + Q_ASSERT(scopedSymbol); Scope *scope = scopedSymbol->members(); - QTC_ASSERT(scope, return QModelIndex()); + Q_ASSERT(scope); return createIndex(row, 0, scope->symbolAt(row)); } @@ -126,12 +124,12 @@ int OverviewModel::rowCount(const QModelIndex &parent) const if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item return 0; Symbol *parentSymbol = static_cast(parent.internalPointer()); - QTC_ASSERT(parentSymbol, return 0); + Q_ASSERT(parentSymbol); if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) { if (!scopedSymbol->isFunction()) { Scope *parentScope = scopedSymbol->members(); - QTC_ASSERT(parentScope, return 0); + Q_ASSERT(parentScope); return parentScope->symbolCount(); } diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 6915e1169b0..0ea9018a353 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -45,8 +45,6 @@ #include #include -#include - #include #include @@ -100,7 +98,7 @@ protected: // types virtual void visit(PointerToMemberType * /*ty*/) { - QTC_ASSERT(false, /**/); + Q_ASSERT(false); } virtual void visit(PointerType *ty) @@ -152,32 +150,32 @@ protected: { /* nothing to do*/ } virtual void visit(Namespace *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(Class *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(Enum *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } // names virtual void visit(NameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(TemplateNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(DestructorNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(OperatorNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(ConversionNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(QualifiedNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } }; } // end of anonymous namespace diff --git a/src/libs/cplusplus/pp-environment.cpp b/src/libs/cplusplus/pp-environment.cpp index 20491727a4c..dd839087a40 100644 --- a/src/libs/cplusplus/pp-environment.cpp +++ b/src/libs/cplusplus/pp-environment.cpp @@ -53,8 +53,6 @@ #include "pp-environment.h" #include "pp.h" -#include - #include using namespace CPlusPlus; @@ -93,7 +91,7 @@ Macro *Environment::macroAt(unsigned index) const Macro *Environment::bind(const Macro &__macro) { - QTC_ASSERT(! __macro.name.isEmpty(), return 0); + Q_ASSERT(! __macro.name.isEmpty()); Macro *m = new Macro (__macro); m->hashcode = hash_code(m->name); From d4139efa28184ede180a5b940988111fd5db64fd Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 10 Dec 2008 16:13:05 +0100 Subject: [PATCH 06/39] Fixes: File System Quick open filter not working with absolute paths. RevBy: Found on irc Details: On windows. --- src/plugins/quickopen/filesystemfilter.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/plugins/quickopen/filesystemfilter.cpp b/src/plugins/quickopen/filesystemfilter.cpp index 8265f6a07ef..386523ebc43 100644 --- a/src/plugins/quickopen/filesystemfilter.cpp +++ b/src/plugins/quickopen/filesystemfilter.cpp @@ -54,14 +54,7 @@ QList FileSystemFilter::matchesFor(const QString &entry) QString name = entryInfo.fileName(); QString directory = entryInfo.path(); QString filePath = entryInfo.filePath(); - bool isDrive = false; - foreach (const QFileInfo &drive, QDir::drives()) { - if (filePath.startsWith(drive.path())) { - isDrive = true; - break; - } - } - if (!isDrive) { + if (entryInfo.isRelative()) { if (filePath.startsWith("~/")) { directory.replace(0, 1, QDir::homePath()); } else { From 3b31b5c98ce1ef1cc5158326b77d96d484f81aeb Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:31:50 +0100 Subject: [PATCH 07/39] work on std::list dumper; also a bit of refactoring --- bin/gdbmacros/gdbmacros.cpp | 155 +++++++++--------------- tests/manual/gdbdebugger/simple/app.cpp | 72 +++++------ 2 files changed, 89 insertions(+), 138 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index e074ddd2a5d..abca7066ee4 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -407,12 +407,13 @@ struct QDumper QDumper &operator<<(unsigned int i); QDumper &operator<<(const void *p); QDumper &operator<<(qulonglong c); - void put(char c); - void addCommaIfNeeded(); - void putBase64Encoded(const char *buf, int n); QDumper &operator<<(const char *str); QDumper &operator<<(const QByteArray &ba); QDumper &operator<<(const QString &str); + void put(char c); + void addCommaIfNeeded(); + void putBase64Encoded(const char *buf, int n); + void putEllipsis(); void disarm(); void beginHash(); // start of data hash output @@ -658,6 +659,14 @@ void QDumper::endHash() put('}'); } +void QDumper::putEllipsis() +{ + d.beginHash(); + P(d, "name", "Warning:"); + P(d, "value", ""); + P(d, "type", d.innertype); + d.endHash(); +} // // Some helpers to keep the dumper code short @@ -816,6 +825,27 @@ static void qDumpInnerValue(QDumper &d, const char *type, const void *addr) } +static void qDumpInnerValueOrPointer(QDumper &d, + const char *type, const char *strippedtype, const void *addr) +{ + if (strippedtype) { + if (deref(addr)) { + P(d, "addr", deref(addr)); + P(d, "type", strippedtype); + qDumpInnerValueHelper(d, strippedtype, deref(addr)); + } else { + P(d, "addr", addr); + P(d, "type", strippedtype); + P(d, "value", ""); + P(d, "numchild", "0"); + } + } else { + P(d, "addr", addr); + P(d, "type", type); + qDumpInnerValueHelper(d, type, addr); + } +} + ////////////////////////////////////////////////////////////////////////////// static void qDumpQByteArray(QDumper &d) @@ -1213,9 +1243,8 @@ static void qDumpQList(QDumper &d) bool isInternal = innerSize <= int(sizeof(void*)) && isMovableType(d.innertype); - P(d, "internal", (int)isInternal); - - P(d, "childtype", d.innertype); + P(d, "internal", (int)isInternal); + P(d, "childtype", d.innertype); if (n > 1000) n = 1000; d << ",children=["; @@ -1245,11 +1274,8 @@ static void qDumpQList(QDumper &d) } d.endHash(); } - if (n < nn) { - d.beginHash(); - P(d, "value", ""); - d.endHash(); - } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -1491,7 +1517,6 @@ static void qDumpQObject(QDumper &d) d.beginHash(); P(d, "name", "methods"); P(d, "exp", "*(class '"NS"QObject'*)" << d.data); - P(d, "type", NS"QObjectMethodList"); P(d, "value", "<" << mo->methodCount() << " items>"); P(d, "numchild", mo->methodCount()); d.endHash(); @@ -1877,11 +1902,7 @@ static void qDumpQSet(QDumper &d) d.endHash(); ++i; if (i > 10000) { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", ""); - d.endHash(); + d.putEllipsis(); break; } } @@ -1936,13 +1957,8 @@ static void qDumpQStringList(QDumper &d) P(d, "valueencoded", "1"); d.endHash(); } - if (n < list.size()) { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", ""); - d.endHash(); - } + if (n < list.size()) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2066,37 +2082,21 @@ static void qDumpQVector(QDumper &d) P(d, "valuedisabled", "true"); P(d, "numchild", n); if (d.dumpChildren) { - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); - + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; if (n > 1000) n = 1000; d << ",children=["; for (int i = 0; i != n; ++i) { d.beginHash(); P(d, "name", "[" << i << "]"); - const void *p = addOffset(v, i * innersize + typeddatasize); - if (innerTypeIsPointer) { - if (deref(p)) { - //P(d, "value","@" << p); - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (n < nn) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, + addOffset(v, i * innersize + typeddatasize)); d.endHash(); } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2111,23 +2111,17 @@ static void qDumpStdList(QDumper &d) qCheckAccess(p); p = deref(p); qCheckAccess(p); - p = deref(p); - qCheckAccess(p); p = deref(addOffset(d.data, sizeof(void*))); qCheckAccess(p); p = deref(addOffset(p, sizeof(void*))); qCheckAccess(p); p = deref(addOffset(p, sizeof(void*))); qCheckAccess(p); - p = deref(addOffset(p, sizeof(void*))); - qCheckAccess(p); int nn = 0; std::list::const_iterator it = list.begin(); - for (int i = 0; i < 101 && it != list.end(); ++i, ++it) { + for (nn < 101 && it != list.end(); ++nn, ++it) qCheckAccess(it.operator->()); - ++nn; - } if (nn > 100) P(d, "value", ""); @@ -2137,36 +2131,19 @@ static void qDumpStdList(QDumper &d) P(d, "valuedisabled", "true"); if (d.dumpChildren) { - unsigned innersize = d.extraInt[0]; - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; d << ",children=["; std::list::const_iterator it = list.begin(); for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { d.beginHash(); P(d, "name", "[" << i << "]"); - P(d, "type", d.innertype); - const void *p = it.operator->(); - if (innerTypeIsPointer) { - if (deref(p)) { - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (it != list.end()) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->()); d.endHash(); } + if (it != list.end()) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2238,37 +2215,21 @@ static void qDumpStdVector(QDumper &d) P(d, "numchild", n); if (d.dumpChildren) { unsigned innersize = d.extraInt[0]; - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); - + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; if (n > 1000) n = 1000; d << ",children=["; for (int i = 0; i != n; ++i) { d.beginHash(); P(d, "name", "[" << i << "]"); - const void *p = addOffset(v->start, i * innersize); - if (innerTypeIsPointer) { - if (deref(p)) { - //P(d, "value","@" << p); - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (n < nn) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, + addOffset(v->start, i * innersize)); d.endHash(); } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 4dc01961958..35933ec5a20 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -129,7 +129,7 @@ void testArray() } -void testByteArray() +void testQByteArray() { QByteArray ba = "Hello"; ba += '"'; @@ -140,7 +140,7 @@ void testByteArray() } -void testHash() +void testQHash() { QHash hgg0; hgg0[11] = 11.0; @@ -164,7 +164,7 @@ void testHash() hash.insert(".", QPointer(&ob)); } -void testImage() +void testQImage() { QImage im(QSize(200, 200), QImage::Format_RGB32); im.fill(QColor(200, 100, 130).rgba()); @@ -192,7 +192,7 @@ void testIO() } -void testList() +void testQList() { #if 1 QList li; @@ -254,7 +254,7 @@ void testList() v.push_back("dd"); } -void testMap() +void testQMap() { QMap ggl; ggl[11] = QStringList() << "11"; @@ -289,7 +289,7 @@ void testMap() #endif } -void testObject(int &argc, char *argv[]) +void testQObject(int &argc, char *argv[]) { QApplication app(argc, argv); QAction act("xxx", &app); @@ -317,7 +317,7 @@ void testObject(int &argc, char *argv[]) app.exec(); } -void testPixmap() +void testQPixmap() { QImage im(QSize(200, 200), QImage::Format_RGB32); im.fill(QColor(200, 100, 130).rgba()); @@ -353,7 +353,7 @@ void testPlugin() } } -void testSet() +void testQSet() { QSet hgg0; hgg0.insert(11); @@ -506,7 +506,7 @@ void testStdVector() vec.push_back(false); } -void testString() +void testQString() { QString str = "Hello "; str += " big, "; @@ -516,19 +516,9 @@ void testString() str += " World "; str += " World "; str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; } -void testString3() +void testQString3() { QString str = "Hello "; str += " big, "; @@ -544,7 +534,7 @@ void testString3() delete pstring; } -void testStringList() +void testQStringList() { QStringList l; l << "Hello "; @@ -578,7 +568,7 @@ private: int m_id; }; -void testThreads() +void testQThread() { Thread thread1(1); Thread thread2(2); @@ -588,7 +578,7 @@ void testThreads() thread2.wait(); } -void testVariant1() +void testQVariant1() { QVariant v; v = 1; @@ -597,7 +587,7 @@ void testVariant1() v = 1; } -void testVariant2() +void testQVariant2() { QVariant var; #if 0 @@ -622,7 +612,7 @@ void testVariant2() var.setValue(my); } -void testVariant3() +void testQVariant3() { QList list; list << 1 << 2 << 3; @@ -631,7 +621,7 @@ void testVariant3() list = qVariantValue >(variant); } -void testVector() +void testQVector() { QVector plist; plist.append(new Foo(1)); @@ -652,7 +642,7 @@ void testVector() vec.append(false); } -void testVectorOfList() +void testQVectorOfQList() { QVector > v; QVector > *pv = &v; @@ -805,28 +795,28 @@ int main(int argc, char *argv[]) testStdVector(); testPlugin(); - testList(); + testQList(); testNamespace(); //return 0; - testByteArray(); - testHash(); - testImage(); - testMap(); - testString(); - testSet(); - testStringList(); + testQByteArray(); + testQHash(); + testQImage(); + testQMap(); + testQString(); + testQSet(); + testQStringList(); testStruct(); //testThreads(); - testVariant1(); - testVariant2(); - testVariant3(); - testVector(); - testVectorOfList(); + testQVariant1(); + testQVariant2(); + testQVariant3(); + testQVector(); + testQVectorOfQList(); *(int *)0 = 0; - testObject(argc, argv); + testQObject(argc, argv); //QColor color(255,128,10); From 09da60f050b35b9150b1febdcdd546d7fcb981b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Dec 2008 16:22:45 +0100 Subject: [PATCH 08/39] Fix git configuration page resize behaviour Now it uses all the available space. --- src/plugins/git/settingspage.ui | 153 ++++++++++++++------------------ 1 file changed, 68 insertions(+), 85 deletions(-) diff --git a/src/plugins/git/settingspage.ui b/src/plugins/git/settingspage.ui index aa2337605b8..151608d03b0 100644 --- a/src/plugins/git/settingspage.ui +++ b/src/plugins/git/settingspage.ui @@ -6,114 +6,97 @@ 0 0 - 436 - 186 + 389 + 183 Form - + - - - - - true - - - Environment variables - - - true - - - - - - PATH: - - + + + true + + + Environment variables + + + true + + + + + + PATH: + + + + + + + - - - - - - - - - From system - - - - - - - + + - <b>Note:</b> - - - - - - - Git needs to find Perl in the environment as well. + From system + + + + + <b>Note:</b> + + + + + + + Git needs to find Perl in the environment as well. + + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Note that huge amount of commits might take some time. + + + 1000 + - - - - QFormLayout::ExpandingFieldsGrow + + + + Log commit display count: - - - - Note that huge amount of commits might take some time. - - - 1000 - - - - - - - Log commit display count: - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - + - + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 From 540c6de10830326c89da4f4c127551a97c2518a5 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:48:12 +0100 Subject: [PATCH 09/39] work on std::list dumper --- bin/gdbmacros/gdbmacros.cpp | 11 ++++------- tests/manual/gdbdebugger/simple/app.cpp | 5 +++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index abca7066ee4..9ea2a9aff56 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -661,11 +661,8 @@ void QDumper::endHash() void QDumper::putEllipsis() { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", d.innertype); - d.endHash(); + addCommaIfNeeded(); + *this << "{name=\"\",value=\"\",type=\"" << innertype << "\"}"; } // @@ -2120,7 +2117,7 @@ static void qDumpStdList(QDumper &d) int nn = 0; std::list::const_iterator it = list.begin(); - for (nn < 101 && it != list.end(); ++nn, ++it) + for (; nn < 101 && it != list.end(); ++nn, ++it) qCheckAccess(it.operator->()); if (nn > 100) @@ -2135,7 +2132,7 @@ static void qDumpStdList(QDumper &d) const char *stripped = isPointerType(d.innertype) ? strippedInnerType.data() : 0; d << ",children=["; - std::list::const_iterator it = list.begin(); + it = list.begin(); for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { d.beginHash(); P(d, "name", "[" << i << "]"); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 35933ec5a20..dbc7eebcd3c 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -73,6 +73,9 @@ uint qHash(const double & f) return int(f); } +#define X myns +X::QString str; + class Foo { public: @@ -623,6 +626,8 @@ void testQVariant3() void testQVector() { + QVector big(10000); + QVector plist; plist.append(new Foo(1)); plist.append(0); From e9d90710099376d585b73a872be62889b0fd24da Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 16:48:28 +0100 Subject: [PATCH 10/39] Fixes: - Restoring session doesn't end up with focus in editor RevBy: - dt Details: - ProjectWindow always grabbed the focus --- src/plugins/projectexplorer/projectwindow.cpp | 10 +++++++++- src/plugins/projectexplorer/session.cpp | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index c725c915c9e..e6732387424 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -190,7 +191,14 @@ void ProjectWindow::updateTreeWidget() // That one runs fully thorough and deletes all widgets, even that one that we are currently removing // from m_panelsTabWidget. // To prevent that, we simply prevent the focus switching.... - m_treeWidget->setFocus(); + QWidget *focusWidget = qApp->focusWidget(); + while (focusWidget) { + if (focusWidget == this) { + m_treeWidget->setFocus(); + break; + } + focusWidget = focusWidget->parentWidget(); + } m_treeWidget->clear(); foreach(Project *project, m_session->projects()) { diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index a9bded02c61..89716ce3f68 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -628,8 +628,10 @@ bool SessionManager::loadImpl(const QString &fileName) if (success) { // restore the active mode const QString &modeIdentifier = value(QLatin1String("ActiveMode")).toString(); - if (!modeIdentifier.isEmpty()) + if (!modeIdentifier.isEmpty()) { m_core->modeManager()->activateMode(modeIdentifier); + m_core->modeManager()->setFocusToCurrentMode(); + } } if (debug) From 154121279e1befa507c4077f813af5f9aa11a253 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:53:18 +0100 Subject: [PATCH 11/39] add to watchwindow was missing an update. --- src/plugins/debugger/debuggermanager.cpp | 1 - src/plugins/debugger/watchhandler.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index a01a3ddc57e..4981f199790 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -1033,7 +1033,6 @@ void DebuggerManager::addToWatchWindow() void DebuggerManager::watchExpression(const QString &expression) { watchHandler()->watchExpression(expression); - //engine()->updateWatchModel(); } void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 47f1593db36..6f443c92b47 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -877,9 +877,9 @@ void WatchHandler::watchExpression(const QString &exp) data.name = exp; data.iname = "watch." + exp; insertData(data); + emit watchModelUpdateRequested(); } - void WatchHandler::setDisplayedIName(const QString &iname, bool on) { WatchData *d = findData(iname); From d45460726479931ff7ed75fe0d34da8eea469718 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 17:21:01 +0100 Subject: [PATCH 12/39] Implemented tooltip and lookat for #include directives. --- src/libs/cplusplus/CppDocument.cpp | 10 +++++++--- src/libs/cplusplus/CppDocument.h | 23 +++++++++++++++++++++-- src/libs/cplusplus/pp-client.h | 3 ++- src/libs/cplusplus/pp-engine.cpp | 4 ++-- src/plugins/cppeditor/cppeditor.cpp | 12 +++++++++++- src/plugins/cpptools/cpphoverhandler.cpp | 10 ++++++++++ src/plugins/cpptools/cppmodelmanager.cpp | 10 ++++++---- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index e67214f63b8..d670e7e0018 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -131,12 +131,16 @@ QString Document::fileName() const QStringList Document::includedFiles() const { - return _includedFiles; + QStringList files; + foreach (const Include &i, _includes) + files.append(i.fileName()); + files.removeDuplicates(); + return files; } -void Document::addIncludeFile(const QString &fileName) +void Document::addIncludeFile(const QString &fileName, unsigned line) { - _includedFiles.append(fileName); + _includes.append(Include(fileName, line)); } void Document::appendMacro(const Macro ¯o) diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index aaca36c18ee..b31f0d2bc64 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -65,7 +65,7 @@ public: QString fileName() const; QStringList includedFiles() const; - void addIncludeFile(const QString &fileName); + void addIncludeFile(const QString &fileName, unsigned line); void appendMacro(const Macro ¯o); void addMacroUse(const Macro ¯o, unsigned offset, unsigned length); @@ -181,6 +181,22 @@ public: { return pos >= _begin && pos < _end; } }; + class Include { + QString _fileName; + unsigned _line; + + public: + Include(const QString &fileName, unsigned line) + : _fileName(fileName), _line(line) + { } + + QString fileName() const + { return _fileName; } + + unsigned line() const + { return _line; } + }; + class MacroUse: public Block { Macro _macro; @@ -196,6 +212,9 @@ public: { return _macro; } }; + QList includes() const + { return _includes; } + QList skippedBlocks() const { return _skippedBlocks; } @@ -207,11 +226,11 @@ private: private: QString _fileName; - QStringList _includedFiles; Control *_control; TranslationUnit *_translationUnit; Namespace *_globalNamespace; QList _diagnosticMessages; + QList _includes; QList _definedMacros; QList _skippedBlocks; QList _macroUses; diff --git a/src/libs/cplusplus/pp-client.h b/src/libs/cplusplus/pp-client.h index 2fc781f22f5..eead5bf4600 100644 --- a/src/libs/cplusplus/pp-client.h +++ b/src/libs/cplusplus/pp-client.h @@ -63,7 +63,8 @@ public: { } virtual void macroAdded(const Macro ¯o) = 0; - virtual void sourceNeeded(QString &fileName, IncludeType mode) = 0; // ### FIX the signature. + virtual void sourceNeeded(QString &fileName, IncludeType mode, + unsigned line) = 0; // ### FIX the signature. virtual void startExpandingMacro(unsigned offset, const Macro ¯o, diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 83386e8079c..c33fc8cb151 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -818,7 +818,7 @@ void pp::processInclude(bool skipCurentPath, QString fn = QString::fromUtf8(path.constData(), path.length()); if (client) - client->sourceNeeded(fn, Client::IncludeGlobal); + client->sourceNeeded(fn, Client::IncludeGlobal, firstToken->lineno); } else if (tk->is(T_ANGLE_STRING_LITERAL) || tk->is(T_STRING_LITERAL)) { const QByteArray spell = tokenSpell(*tk); const char *beginOfPath = spell.constBegin(); @@ -831,7 +831,7 @@ void pp::processInclude(bool skipCurentPath, QString fn = QString::fromUtf8(path.constData(), path.length()); if (client) - client->sourceNeeded(fn, Client::IncludeLocal); + client->sourceNeeded(fn, Client::IncludeLocal, firstToken->lineno); } } } diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 8d4a36178ce..f233c0121f8 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -480,13 +480,23 @@ void CPPEditor::jumpToDefinition() Document::Ptr doc = m_modelManager->document(file()->fileName()); if (!doc) return; + + QTextCursor tc = textCursor(); + unsigned lineno = tc.blockNumber() + 1; + foreach (const Document::Include &incl, doc->includes()) { + if (incl.line() == lineno) { + if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0)) + return; // done + break; + } + } + Symbol *lastSymbol = doc->findSymbolAt(line, column); if (!lastSymbol) return; // Get the expression under the cursor const int endOfName = endOfNameUnderCursor(); - QTextCursor tc = textCursor(); tc.setPosition(endOfName); ExpressionUnderCursor expressionUnderCursor; const QString expression = expressionUnderCursor(tc); diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index 338123bc5e6..f3831e5394d 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -177,6 +177,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } + if (m_toolTip.isEmpty()) { + unsigned lineno = tc.blockNumber() + 1; + foreach (const Document::Include &incl, doc->includes()) { + if (lineno == incl.line()) { + m_toolTip = incl.fileName(); + break; + } + } + } + if (m_toolTip.isEmpty()) { // Move to the end of a qualified name bool stop = false; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 40888d99f3f..9adc892713d 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -138,7 +138,8 @@ protected: virtual void stopExpandingMacro(unsigned offset, const Macro ¯o); virtual void startSkippingBlocks(unsigned offset); virtual void stopSkippingBlocks(unsigned offset); - virtual void sourceNeeded(QString &fileName, IncludeType type); + virtual void sourceNeeded(QString &fileName, IncludeType type, + unsigned line); private: QPointer m_modelManager; @@ -176,7 +177,7 @@ void CppPreprocessor::setProjectFiles(const QStringList &files) { m_projectFiles = files; } void CppPreprocessor::run(QString &fileName) -{ sourceNeeded(fileName, IncludeGlobal); } +{ sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); } void CppPreprocessor::operator()(QString &fileName) { run(fileName); } @@ -361,7 +362,8 @@ void CppPreprocessor::stopSkippingBlocks(unsigned offset) m_currentDoc->stopSkippingBlocks(offset); } -void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) +void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, + unsigned line) { if (fileName.isEmpty()) return; @@ -369,7 +371,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) QByteArray contents = tryIncludeFile(fileName, type); if (m_currentDoc) { - m_currentDoc->addIncludeFile(fileName); + m_currentDoc->addIncludeFile(fileName, line); if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) { QString msg; msg += fileName; From 0343c8bf2d3ce4d8291bccea95abeb4bde465bfb Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 17:24:06 +0100 Subject: [PATCH 13/39] Fixes: - Using Return in project tree on Mac to open files --- src/plugins/projectexplorer/projecttreewidget.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 6285bb81dee..c2197a2dc7c 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -90,6 +90,20 @@ protected: if (event->reason() != Qt::PopupFocusReason) QTreeView::focusOutEvent(event); } + +#ifdef Q_OS_MAC + void keyPressEvent(QKeyEvent *event) + { + if ((event->key() == Qt::Key_Return + || event->key() == Qt::Key_Enter) + && event->modifiers() == 0 + && currentIndex().isValid()) { + emit activated(currentIndex()); + return; + } + QTreeView::keyPressEvent(event); + } +#endif }; /*! From 13420d3e7669636f70f04124beca86bd7cd66224 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 10 Dec 2008 17:25:47 +0100 Subject: [PATCH 14/39] Fixes: Don't fall back to win95 on KDE4, at least use plastique. Task: - RevBy: - AutoTest: - Details: - --- src/plugins/coreplugin/mainwindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 4eab3fb5571..228c58a94ac 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -186,6 +186,15 @@ MainWindow::MainWindow() : QCoreApplication::setOrganizationName(QLatin1String("Nokia")); QSettings::setDefaultFormat(QSettings::IniFormat); QString baseName = qApp->style()->objectName(); + if (baseName == "windows") { + // Sometimes we get the standard windows 95 style as a fallback + // e.g. if we are running on a KDE4 desktop + QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION"); + if (desktopEnvironment == "kde") + baseName = "plastique"; + else + baseName = "cleanlooks"; + } qApp->setStyle(new ManhattanStyle(baseName)); statusBar()->setProperty("p_styled", true); } From 4556e602c5a60b52453f91cb4297a1def7dc1bc3 Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 17:31:19 +0100 Subject: [PATCH 15/39] Fixes: - At startup project tree filter setting and reality diverge --- src/plugins/projectexplorer/projectmodels.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index e5a2e702650..de4f851e5ce 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -626,7 +626,7 @@ QList DetailedModel::recursiveSubFolders(FolderNode *parentFolder) FlatModel::FlatModel(SessionNode *rootNode, QObject *parent) : QAbstractItemModel(parent), - m_filterProjects(true), + m_filterProjects(false), m_filterGeneratedFiles(true), m_rootNode(rootNode), m_startupProject(0), @@ -914,6 +914,8 @@ QModelIndex FlatModel::indexForNode(const Node *node_) void FlatModel::setProjectFilterEnabled(bool filter) { + if (filter == m_filterProjects) + return; m_filterProjects = filter; reset(); } From 8580234ec8729542ee5f084a9a65a8b90c02eaa5 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 10 Dec 2008 18:01:33 +0100 Subject: [PATCH 16/39] added Move Line Up and Move Line Down actions. Can be extended to support statements later. --- src/plugins/texteditor/basetexteditor.cpp | 64 ++++++++++++++++++- src/plugins/texteditor/basetexteditor.h | 4 ++ .../texteditor/texteditoractionhandler.cpp | 15 +++++ .../texteditor/texteditoractionhandler.h | 4 ++ src/plugins/texteditor/texteditorconstants.h | 2 + 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index db5413c3446..8d5bf3ff683 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -684,6 +684,64 @@ void BaseTextEditor::selectBlockDown() _q_matchParentheses(); } +void BaseTextEditor::moveLineUp() +{ + moveLineUpDown(true); +} + +void BaseTextEditor::moveLineDown() +{ + moveLineUpDown(false); +} + +void BaseTextEditor::moveLineUpDown(bool up) +{ + QTextCursor cursor = textCursor(); + QTextCursor move = cursor; + move.beginEditBlock(); + + bool hasSelection = cursor.hasSelection(); + + if (cursor.hasSelection()) { + move.setPosition(cursor.selectionStart()); + move.movePosition(QTextCursor::StartOfBlock); + move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor); + move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + } else { + move.movePosition(QTextCursor::StartOfBlock); + move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + } + QString text = move.selectedText(); + move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); + move.removeSelectedText(); + + if (up) { + move.movePosition(QTextCursor::PreviousBlock); + move.insertBlock(); + move.movePosition(QTextCursor::Left); + } else { + move.movePosition(QTextCursor::EndOfBlock); + if (move.atBlockStart()) { // empty block + move.movePosition(QTextCursor::NextBlock); + move.insertBlock(); + move.movePosition(QTextCursor::Left); + } else { + move.insertBlock(); + } + } + + int start = move.position(); + move.clearSelection(); + move.insertText(text); + int end = move.position(); + move.endEditBlock(); + if (hasSelection) { + move.setPosition(start); + move.setPosition(end, QTextCursor::KeepAnchor); + } + + setTextCursor(move); +} void BaseTextEditor::cleanWhitespace() { @@ -740,9 +798,13 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) QTextCursor cursor = textCursor(); if (d->m_inBlockSelectionMode) cursor.clearSelection(); - cursor.insertBlock(); if (d->m_document->tabSettings().m_autoIndent) { + cursor.beginEditBlock(); + cursor.insertBlock(); indent(document(), cursor, QChar::Null); + cursor.endEditBlock(); + } else { + cursor.insertBlock(); } e->accept(); setTextCursor(cursor); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 1219439fc98..7c2206722bf 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -329,6 +329,9 @@ public slots: void selectBlockUp(); void selectBlockDown(); + void moveLineUp(); + void moveLineDown(); + void cleanWhitespace(); signals: @@ -447,6 +450,7 @@ private: void indentOrUnindent(bool doIndent); void handleHomeKey(bool anchor); void handleBackspaceKey(); + void moveLineUpDown(bool up); void toggleBlockVisible(const QTextBlock &block); QRect collapseBox(const QTextBlock &block); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 12fc7d1fac5..39a12ee93fd 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -71,6 +71,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core, = m_gotoBlockStartAction = m_gotoBlockStartWithSelectionAction = m_gotoBlockEndAction = m_gotoBlockEndWithSelectionAction = m_selectBlockUpAction = m_selectBlockDownAction + = m_moveLineUpAction = m_moveLineDownAction = 0; m_contextId << m_core->uniqueIDManager()->uniqueIdentifier(context); @@ -223,6 +224,16 @@ void TextEditorActionHandler::createActions() command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown())); + + m_moveLineUpAction= new QAction(tr("Move Line Up"), this); + command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId); + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up"))); + connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp())); + + m_moveLineDownAction= new QAction(tr("Move Line Down"), this); + command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId); + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down"))); + connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown())); } bool TextEditorActionHandler::supportsAction(const QString & /*id */) const @@ -287,6 +298,8 @@ void TextEditorActionHandler::updateActions(UpdateMode um) m_gotoBlockEndWithSelectionAction->setEnabled(um != NoEditor); m_selectBlockUpAction->setEnabled(um != NoEditor); m_selectBlockDownAction->setEnabled(um != NoEditor); + m_moveLineUpAction->setEnabled(um != NoEditor); + m_moveLineDownAction->setEnabled(um != NoEditor); m_visualizeWhitespaceAction->setEnabled(um != NoEditor); if (m_currentEditor) @@ -390,6 +403,8 @@ FUNCTION(gotoBlockStartWithSelection) FUNCTION(gotoBlockEndWithSelection) FUNCTION(selectBlockUp) FUNCTION(selectBlockDown) +FUNCTION(moveLineUp) +FUNCTION(moveLineDown) void TextEditorActionHandler::updateCurrentEditor(Core::IContext *object) { diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 520ae26ddf6..98e8c9198a9 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -116,6 +116,8 @@ private slots: void gotoBlockEndWithSelection(); void selectBlockUp(); void selectBlockDown(); + void moveLineUp(); + void moveLineDown(); void updateCurrentEditor(Core::IContext *object); private: @@ -145,6 +147,8 @@ private: QAction *m_gotoBlockEndWithSelectionAction; QAction *m_selectBlockUpAction; QAction *m_selectBlockDownAction; + QAction *m_moveLineUpAction; + QAction *m_moveLineDownAction; uint m_optionalActions; QPointer m_currentEditor; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 192a07c257e..d9147a9a9e9 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -55,6 +55,8 @@ const char * const GOTO_BLOCK_END = "TextEditor.GotoBlockEnd"; const char * const GOTO_BLOCK_END_WITH_SELECTION = "TextEditor.GotoBlockEndWithSelection"; const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp"; const char * const SELECT_BLOCK_DOWN = "TextEditor.SelectBlockDown"; +const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp"; +const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown"; const char * const DELETE_LINE = "TextEditor.DeleteLine"; const char * const DELETE_WORD = "TextEditor.DeleteWord"; const char * const SELECT_ENCODING = "TextEditor.SelectEncoding"; From f1e67fa3a3a0ae773fcbc61da66206a0000a738f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 11 Dec 2008 10:28:39 +0100 Subject: [PATCH 17/39] Added `editorKind' to BaseTextEditor::openEditorAt(). We need it to force the CPPEDITOR kind when opening files from the C++ editor (e.g. when the user press F2 on #include ). --- src/plugins/cppeditor/cppeditor.cpp | 15 +++++++++++---- src/plugins/cppeditor/cppeditor.h | 3 +++ src/plugins/texteditor/basetexteditor.cpp | 11 ++++++----- src/plugins/texteditor/basetexteditor.h | 3 ++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index f233c0121f8..e3bf12757bd 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -485,7 +485,7 @@ void CPPEditor::jumpToDefinition() unsigned lineno = tc.blockNumber() + 1; foreach (const Document::Include &incl, doc->includes()) { if (incl.line() == lineno) { - if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0)) + if (openCppEditorAt(incl.fileName(), 0, 0)) return; // done break; } @@ -525,7 +525,7 @@ void CPPEditor::jumpToDefinition() QList candidates = context.resolve(namedType->name()); if (!candidates.isEmpty()) { Symbol *s = candidates.takeFirst(); - openEditorAt(s->fileName(), s->line(), s->column()); + openCppEditorAt(s->fileName(), s->line(), s->column()); } #endif } @@ -534,7 +534,7 @@ void CPPEditor::jumpToDefinition() if (use.contains(endOfName - 1)) { const Macro ¯o = use.macro(); const QString fileName = QString::fromUtf8(macro.fileName); - if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0)) + if (openCppEditorAt(fileName, macro.line, 0)) return; // done } } @@ -836,8 +836,15 @@ int CPPEditor::endOfNameUnderCursor() return pos; } +TextEditor::ITextEditor *CPPEditor::openCppEditorAt(const QString &fileName, + int line, int column) +{ + return TextEditor::BaseTextEditor::openEditorAt(fileName, line, column, + Constants::C_CPPEDITOR); +} + bool CPPEditor::openEditorAt(Symbol *s) { const QString fileName = QString::fromUtf8(s->fileName(), s->fileNameLength()); - return TextEditor::BaseTextEditor::openEditorAt(fileName, s->line(), s->column()); + return openCppEditorAt(fileName, s->line(), s->column()); } diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 05f2c5d9c74..2dd88d34993 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -123,6 +123,9 @@ private: CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol); virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar); + TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line, + int column = 0); + int previousBlockState(QTextBlock block) const; QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const; QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const; diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 8d5bf3ff683..59ee2c005a4 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -128,12 +128,13 @@ protected: ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName, int line, - int column) + int column, + const QString &editorKind) { Core::EditorManager *editorManager = ExtensionSystem::PluginManager::instance()->getObject()->editorManager(); editorManager->addCurrentPositionToNavigationHistory(true); - Core::IEditor *editor = editorManager->openEditor(fileName, QString(), true); + Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, true); TextEditor::ITextEditor *texteditor = qobject_cast(editor); if (texteditor) { texteditor->gotoLine(line, column); @@ -714,7 +715,7 @@ void BaseTextEditor::moveLineUpDown(bool up) QString text = move.selectedText(); move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); move.removeSelectedText(); - + if (up) { move.movePosition(QTextCursor::PreviousBlock); move.insertBlock(); @@ -729,7 +730,7 @@ void BaseTextEditor::moveLineUpDown(bool up) move.insertBlock(); } } - + int start = move.position(); move.clearSelection(); move.insertText(text); @@ -3376,7 +3377,7 @@ void BaseTextEditorPrivate::moveCursorVisible() if (!cursor.block().isVisible()) { cursor.setVisualNavigation(true); cursor.movePosition(QTextCursor::PreviousBlock); - q->setTextCursor(cursor); + q->setTextCursor(cursor); } q->ensureCursorVisible(); } diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 7c2206722bf..d75e174fea2 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -230,7 +230,8 @@ public: BaseTextEditor(QWidget *parent); ~BaseTextEditor(); - static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0); + static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0, + const QString &editorKind = QString()); // EditorInterface Core::IFile * file(); From 7239d03ee7afca7e46e3103bdc1224c94ac3143e Mon Sep 17 00:00:00 2001 From: con Date: Thu, 11 Dec 2008 11:26:42 +0100 Subject: [PATCH 18/39] Fixes: - Make plugin load order a bit more deterministic Details: - It will still change if the dependencies change, there's no way to avoid that though. --- src/app/main.cpp | 2 +- src/libs/extensionsystem/optionsparser.cpp | 2 +- src/libs/extensionsystem/pluginmanager.cpp | 15 +++++++++++---- src/libs/extensionsystem/pluginmanager.h | 2 +- src/libs/extensionsystem/pluginmanager_p.h | 2 +- src/libs/extensionsystem/pluginspec.cpp | 4 ++-- src/libs/extensionsystem/pluginspec_p.h | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index ad61ab0c750..eedc9e13653 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -69,7 +69,7 @@ static const char *HELP_OPTION4 = "--help"; static const char *VERSION_OPTION = "-version"; static const char *CLIENT_OPTION = "-client"; -typedef QSet PluginSpecSet; +typedef QList PluginSpecSet; // Helpers for displaying messages. Note that there is no console on Windows. #ifdef Q_WS_WIN diff --git a/src/libs/extensionsystem/optionsparser.cpp b/src/libs/extensionsystem/optionsparser.cpp index 8884cb378ce..09dbaa59b72 100644 --- a/src/libs/extensionsystem/optionsparser.cpp +++ b/src/libs/extensionsystem/optionsparser.cpp @@ -129,7 +129,7 @@ bool OptionsParser::checkForNoLoadOption() "The plugin '%1' does not exist.").arg(m_currentArg); m_hasError = true; } else { - m_pmPrivate->pluginSpecs.remove(spec); + m_pmPrivate->pluginSpecs.removeAll(spec); delete spec; m_isDependencyRefreshNeeded = true; } diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 3f7ba386e4e..90e6e4bb004 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -48,7 +48,7 @@ #include #endif -typedef QSet PluginSpecSet; +typedef QList PluginSpecSet; enum { debugLeaks = 0 }; @@ -162,6 +162,11 @@ enum { debugLeaks = 0 }; using namespace ExtensionSystem; using namespace ExtensionSystem::Internal; +static bool lessThanByPluginName(const PluginSpec *one, const PluginSpec *two) +{ + return one->name() < two->name(); +} + PluginManager *PluginManager::m_instance = 0; /*! @@ -306,7 +311,7 @@ QStringList PluginManager::arguments() const } /*! - \fn QSet PluginManager::plugins() const + \fn QList PluginManager::plugins() const List of all plugin specifications that have been found in the plugin search paths. This list is valid directly after the setPluginPaths() call. The plugin specifications contain the information from the plugins' xml description files @@ -315,7 +320,7 @@ QStringList PluginManager::arguments() const \sa setPluginPaths() */ -QSet PluginManager::plugins() const +QList PluginManager::plugins() const { return d->pluginSpecs; } @@ -703,9 +708,11 @@ void PluginManagerPrivate::readPluginPaths() foreach (const QString &specFile, specFiles) { PluginSpec *spec = new PluginSpec; spec->d->read(specFile); - pluginSpecs.insert(spec); + pluginSpecs.append(spec); } resolveDependencies(); + // ensure deterministic plugin load order by sorting + qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName); emit q->pluginsChanged(); } diff --git a/src/libs/extensionsystem/pluginmanager.h b/src/libs/extensionsystem/pluginmanager.h index e46451901e9..e621fbea17f 100644 --- a/src/libs/extensionsystem/pluginmanager.h +++ b/src/libs/extensionsystem/pluginmanager.h @@ -101,7 +101,7 @@ public: void loadPlugins(); QStringList pluginPaths() const; void setPluginPaths(const QStringList &paths); - QSet plugins() const; + QList plugins() const; void setFileExtension(const QString &extension); QString fileExtension() const; diff --git a/src/libs/extensionsystem/pluginmanager_p.h b/src/libs/extensionsystem/pluginmanager_p.h index 74cb84c8678..b286fdf2b1d 100644 --- a/src/libs/extensionsystem/pluginmanager_p.h +++ b/src/libs/extensionsystem/pluginmanager_p.h @@ -66,7 +66,7 @@ public: void loadPlugin(PluginSpec *spec, PluginSpec::State destState); void resolveDependencies(); - QSet pluginSpecs; + QList pluginSpecs; QList testSpecs; QStringList pluginPaths; QString extension; diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index 170cd72ba0b..a8694e29677 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -693,10 +693,10 @@ int PluginSpecPrivate::versionCompare(const QString &version1, const QString &ve } /*! - \fn bool PluginSpecPrivate::resolveDependencies(const QSet &specs) + \fn bool PluginSpecPrivate::resolveDependencies(const QList &specs) \internal */ -bool PluginSpecPrivate::resolveDependencies(const QSet &specs) +bool PluginSpecPrivate::resolveDependencies(const QList &specs) { if (hasError) return false; diff --git a/src/libs/extensionsystem/pluginspec_p.h b/src/libs/extensionsystem/pluginspec_p.h index 922fe36d05d..b4fefc59b32 100644 --- a/src/libs/extensionsystem/pluginspec_p.h +++ b/src/libs/extensionsystem/pluginspec_p.h @@ -56,7 +56,7 @@ public: bool read(const QString &fileName); bool provides(const QString &pluginName, const QString &version) const; - bool resolveDependencies(const QSet &specs); + bool resolveDependencies(const QList &specs); bool loadLibrary(); bool initializePlugin(); bool initializeExtensions(); From 4679f38a876bb66dbe38f22da231f7e14699b8e1 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 11 Dec 2008 11:27:07 +0100 Subject: [PATCH 19/39] Fixed code completion when using macros in the expression's code (e.g. in qApp->). --- src/libs/cplusplus/TypeOfExpression.cpp | 40 ++++++++++++++++++++-- src/libs/cplusplus/TypeOfExpression.h | 19 +++++++++- src/plugins/cpptools/cppcodecompletion.cpp | 3 +- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 487c9f8a469..53fa7e78396 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -37,6 +37,7 @@ #include #include #include +#include using namespace CPlusPlus; @@ -53,9 +54,13 @@ void TypeOfExpression::setDocuments(const QMap &document QList TypeOfExpression::operator()(const QString &expression, Document::Ptr document, - Symbol *lastVisibleSymbol) + Symbol *lastVisibleSymbol, + PreprocessMode mode) { - Document::Ptr expressionDoc = documentForExpression(expression); + QString code = expression; + if (mode == Preprocess) + code = preprocessedExpression(expression, m_documents, document); + Document::Ptr expressionDoc = documentForExpression(code); m_ast = extractExpressionAST(expressionDoc); m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc, @@ -97,3 +102,34 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression) doc->parse(Document::ParseExpression); return doc; } + +void TypeOfExpression::processEnvironment(QMap documents, + Document::Ptr doc, Environment *env, + QSet *processed) const +{ + if (processed->contains(doc->fileName())) + return; + processed->insert(doc->fileName()); + foreach (const Document::Include &incl, doc->includes()) { + processEnvironment(documents, + documents.value(incl.fileName()), + env, processed); + } + foreach (const Macro ¯o, doc->definedMacros()) + env->bind(macro); +} + +QString TypeOfExpression::preprocessedExpression(const QString &expression, + QMap documents, + Document::Ptr thisDocument) const +{ + Environment env; + QSet processed; + processEnvironment(documents, thisDocument, + &env, &processed); + const QByteArray code = expression.toUtf8(); + pp preproc(0, env); + QByteArray preprocessedCode; + preproc("", code, &preprocessedCode); + return QString::fromUtf8(preprocessedCode); +} diff --git a/src/libs/cplusplus/TypeOfExpression.h b/src/libs/cplusplus/TypeOfExpression.h index cd7a23441fd..e6a9a7f4b66 100644 --- a/src/libs/cplusplus/TypeOfExpression.h +++ b/src/libs/cplusplus/TypeOfExpression.h @@ -43,6 +43,9 @@ namespace CPlusPlus { +class Environment; +class Macro; + class CPLUSPLUS_EXPORT TypeOfExpression { public: @@ -60,6 +63,11 @@ public: */ void setDocuments(const QMap &documents); + enum PreprocessMode { + NoPreprocess, + Preprocess + }; + /** * Returns a list of possible fully specified types associated with the * given expression. @@ -73,7 +81,8 @@ public: * @param lastVisibleSymbol The last visible symbol in the document. */ QList operator()(const QString &expression, Document::Ptr document, - Symbol *lastVisibleSymbol); + Symbol *lastVisibleSymbol, + PreprocessMode mode = NoPreprocess); /** * Returns the AST of the last evaluated expression. @@ -91,6 +100,14 @@ private: ExpressionAST *extractExpressionAST(Document::Ptr doc) const; Document::Ptr documentForExpression(const QString &expression) const; + void processEnvironment(QMap documents, + CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env, + QSet *processed) const; + + QString preprocessedExpression(const QString &expression, + QMap documents, + CPlusPlus::Document::Ptr thisDocument) const; + QMap m_documents; ExpressionAST *m_ast; LookupContext m_lookupContext; diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 35206c2633b..4606bd948f3 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -439,7 +439,8 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) typeOfExpression.setDocuments(m_manager->documents()); - QList resolvedTypes = typeOfExpression(expression, thisDocument, symbol); + QList resolvedTypes = typeOfExpression(expression, thisDocument, symbol, + TypeOfExpression::Preprocess); LookupContext context = typeOfExpression.lookupContext(); if (!typeOfExpression.expressionAST() && (! m_completionOperator || From 9be862238132c93640c6cbd5bdd9415022a39ea2 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Thu, 11 Dec 2008 11:20:25 +0100 Subject: [PATCH 20/39] Fixes: Doc - updating the documentation to reflect the new changes. --- doc/qtcreator.qdoc | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 0db515fe434..b8d38a60c9a 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -23,6 +23,8 @@ \o \inlineimage qtcreator.png \o Qt Creator includes a wide range of useful features. Among them are: \list 1 + \o \bold{Smart Code Editor}: The code editor provides syntax + highlighting as well as code completion. \o \bold{Qt4 Project Generating Wizard}: This wizard allows the user to generate a project for a console application, a GUI application, or a C++ library. @@ -48,7 +50,7 @@ \o \l{Creating a Project in Qt Creator} \o \l{Build Settings} \o \l{Writing a Simple Program with Qt Creator} - \o \l{Quick Navigation} + \o \l{Navigating Quickly Around Your Code} \o \l{Debugging with Qt Creator} \o \l{Tips and Tricks} \o \l{Glossary} @@ -64,86 +66,85 @@ \title A Quick Tour Around Qt Creator - The labeled screenshot below shows some of the components of Qt Creator, - in \gui Edit mode. + The labeled screenshot below shows some of the components of Qt Creator, in + \gui Edit mode. \image qtcreator-breakdown.png \section1 The Mode Selectors - When working in Qt Creator, you can be in one of five modes: \bold Project, - \bold Edit, \bold Debug, \bold Help, and \bold Output. + When working in Qt Creator, you can be in one of six modes: \bold Welcome, + \bold Edit, \bold Debug, \bold Projects, \bold Help, and \bold Output. - Mode selectors allow you to quickly switch between tasks: Editing, - browsing the Qt manual, setting up the build environment, etc. You can + Mode selectors allow you to quickly switch between tasks: Editing, browsing + the Qt Creator manual, setting up the build environment, etc. You can activate a mode by either clicking on its mode selector, or using the \l{keyboard-shortcuts}{corresponding shortcut}. Certain actions also trigger a mode change, e.g., \gui{Debug}/\gui{Start Debugging} will switch to the \gui Debug mode. - \list \o \gui{Welcome Mode} - Displays a welcome screen allowing you to quickly - load recent sessions or individual projects. This is the first mode - displayed if Qt Creator is run without command line switches. + load recent sessions or individual projects. This is the mode you will see + if Qt Creator is run without command line switches. - \o \gui{Edit Mode} - You can edit both project and source files here. An - optional sidebar on the left provides different views to navigate between - files. + \o \gui{Edit Mode} - Lets you edit both project and source files. A sidebar + on the left provides different views to navigate between files. \o \gui{Debug Mode} - Provides various ways to inspect the state of the program while debugging. See \l{qtcreator-debugging}{Debugging With Qt - Creator} for a hands-on description of the mode. + Creator} for a hands-on description of how to use this mode. - \o \gui{Build & Run Mode} - Lets you configure how projects can be built - and executed. Under the list of projects, there are tabs to configure the - build and run settings. + \o \gui{Projects Mode} - Lets you configure how projects can be built and + executed. Under the list of projects, there are tabs to configure the + build, run, and editor settings. \o \gui{Help Mode} - Shows any documentation registered by Qt Assistant, such as the Qt library and Qt Creator documentation. - \o \gui{Output Mode} - Lets you examine various logs in detail, for example - the task list, the compiler and application output. Some of these logs can - also be viewed in the output panes. + \o \gui{Output Mode} - Lets you examine various data in detail, for example + build issues as well as compile and application output. This information + is also available in the output panes. \endlist \section1 The Output Panes - The task pane in Qt Creator can display one out of four different panes: - Task List, Search Results, Application Output, and Compile Output. These - panes are available in all modes. + The task pane in Qt Creator can display one of four different panes: + \gui{Build Issues}, \gui{Search Results}, \gui{Application Output}, and + \gui{Compile}. These panes are available in all modes. - \section2 Task List + \section2 Build Issues - The Task List provides a list of important tasks such as error messages - that need to be fixed. It filters out irrelevant output from the compiler - and collects them in the form of tasks. + The {Build Issues} pane provides a list of issues, e.g., error messages or + warnings that need to be fixed. It filters out irrelevant output from the + compiler and collects them in an organized way. - \image qtcreator-task-list.png + \image qtcreator-build-issues.png \section2 Search Results - The Search Results pane displays the results for global searches such as - searching within a current document, files on disk, or all projects. - In the screenshot below, we searched for all occurrences of \c{textfinder} - within the "/TextFinder" folder. + The \gui{Search Results} pane displays the results for global searches such + as searching within a current document, files on disk, or all projects. In + the screenshot below, we searched for all occurrences of \c{textfinder} + within the \c{"/TextFinder"} folder. \image qtcreator-search-pane.png \section2 Application Output - This pane displays the status of the program when it is executed, as - well as debug output, for example, output from qDebug(). + The \gui{Application Output} pane displays the status of the program when + it is executed and debug output, e.g., output from qDebug(). \image qtcreator-application-output.png - \section2 Compile Output + \section2 Compile - The Compile Output provides all the output from the compiler. In other - words, it is a more verbose version of the Task List. + The \gui{Compile} pane provides all the output from the compiler. In other + words, it is a more verbose version of information displayed in the + \gui{Build Issues} \image qtcreator-compile-pane.png @@ -521,7 +522,7 @@ \page creator-navigation.html \nextpage creator-debugging.html - \title Quick Navigation + \title Navigating Quickly Around Your Code With Qt Creator, navigating to different locations in your project or on your disk, such as files, classes and methods, is trivial using the input From 1ef9dc31d287f2d38c8e512d90e10f390e4b2ec3 Mon Sep 17 00:00:00 2001 From: goro Date: Thu, 11 Dec 2008 12:30:38 +0100 Subject: [PATCH 21/39] PathChooser migration for GDB macros page --- src/plugins/debugger/gdboptionpage.h | 1 - src/plugins/debugger/gdbtypemacros.cpp | 17 +-- src/plugins/debugger/gdbtypemacros.ui | 150 ++++++++++++------------- 3 files changed, 78 insertions(+), 90 deletions(-) diff --git a/src/plugins/debugger/gdboptionpage.h b/src/plugins/debugger/gdboptionpage.h index 1d71024bac1..e9ebd23d667 100644 --- a/src/plugins/debugger/gdboptionpage.h +++ b/src/plugins/debugger/gdboptionpage.h @@ -87,7 +87,6 @@ public: void finished(bool accepted); private slots: - void onScriptButton(); void onAddButton(); void onDelButton(); void currentItemChanged(QTreeWidgetItem *item); diff --git a/src/plugins/debugger/gdbtypemacros.cpp b/src/plugins/debugger/gdbtypemacros.cpp index 8610d01e39d..89178af268f 100644 --- a/src/plugins/debugger/gdbtypemacros.cpp +++ b/src/plugins/debugger/gdbtypemacros.cpp @@ -109,6 +109,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent) m_widget = new QWidget(parent); m_ui.setupUi(m_widget); + m_ui.scriptFile->setPromptDialogTitle(tr("Select Gdb Script")); + m_ui.scriptFile->setExpectedKind(Core::Utils::PathChooser::File); connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(onAddButton())); @@ -116,8 +118,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent) connect(m_ui.delButton, SIGNAL(clicked()), this, SLOT(onDelButton())); - connect(m_ui.scriptButton, SIGNAL(clicked()), - this, SLOT(onScriptButton())); + connect(m_ui.scriptFile, SIGNAL(validChanged()), + this, SLOT(updateButtonState())); connect(m_ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(currentItemChanged(QTreeWidgetItem *))); @@ -139,7 +141,7 @@ QWidget *TypeMacroPage::createPage(QWidget *parent) ++i; } - m_ui.scriptEdit->setText(m_settings->m_scriptFile); + m_ui.scriptFile->setPath(m_settings->m_scriptFile); updateButtonState(); @@ -152,7 +154,7 @@ void TypeMacroPage::finished(bool accepted) return; m_settings->m_typeMacros.clear(); - m_settings->m_scriptFile = m_ui.scriptEdit->text(); + m_settings->m_scriptFile = m_ui.scriptFile->path(); for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i); @@ -172,13 +174,6 @@ void TypeMacroPage::finished(bool accepted) } } -void TypeMacroPage::onScriptButton() -{ - QString fileName = QFileDialog::getOpenFileName(m_widget, tr("Select Gdb Script")); - m_ui.scriptEdit->setText(fileName); - updateButtonState(); -} - void TypeMacroPage::onAddButton() { if (m_ui.typeEdit->text().isEmpty() || m_ui.macroEdit->text().isEmpty()) diff --git a/src/plugins/debugger/gdbtypemacros.ui b/src/plugins/debugger/gdbtypemacros.ui index aa7215577b4..51a2670d84d 100644 --- a/src/plugins/debugger/gdbtypemacros.ui +++ b/src/plugins/debugger/gdbtypemacros.ui @@ -1,146 +1,133 @@ - - - - + + TypeMacroPage - - + + 0 0 519 - 238 + 263 - + Form - - - 9 - - + + 6 + + 9 + - - + + Script File - - - 9 - - + + 6 + + 9 + - - - - - - - 21 - 23 - - - - ... - - + - - + + 0 - + 6 - - - + + + false - + Type - + Macro - - - + + + 21 23 - + + - - :/gdbdebugger/images/newitem.png + + + :/gdbdebugger/images/newitem.png:/gdbdebugger/images/newitem.png - - - + + + Macro Name: - - - + + + Parse as: - - + + - - - + + + 0 - + 0 - - + + 21 23 - + - - - :/gdbdebugger/images/delete.png + + + :/gdbdebugger/images/delete.png:/gdbdebugger/images/delete.png - + Qt::Vertical - + 20 40 @@ -150,25 +137,25 @@ - - + + - - - + + + Type: - - + + - + ASCII (char *) - + Unicode (short) @@ -178,9 +165,16 @@ - + + + Core::Utils::PathChooser + QWidget +
utils/pathchooser.h
+ 1 +
+
- +
From 6adb3f617e5b89ac300df0530cac58ee78d3a466 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 11 Dec 2008 13:20:59 +0100 Subject: [PATCH 22/39] connect the parenthesis matcher with the ifdefed out information. --- src/plugins/texteditor/basetexteditor.cpp | 33 ++++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 8d5bf3ff683..d613db7a294 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -734,12 +734,15 @@ void BaseTextEditor::moveLineUpDown(bool up) move.clearSelection(); move.insertText(text); int end = move.position(); - move.endEditBlock(); + if (hasSelection) { move.setPosition(start); move.setPosition(end, QTextCursor::KeepAnchor); } + indent(document(), move, QChar::Null); + move.endEditBlock(); + setTextCursor(move); } @@ -2951,12 +2954,13 @@ void BaseTextEditor::markBlocksAsChanged(QList blockNumbers) { TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor *cursor, QChar c) { - if (!TextEditDocumentLayout::hasParentheses(cursor->block())) + QTextBlock block = cursor->block(); + if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block)) return NoMatch; - Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block()); + Parentheses parenList = TextEditDocumentLayout::parentheses(block); Parenthesis openParen, closedParen; - QTextBlock closedParenParag = cursor->block(); + QTextBlock closedParenParag = block; const int cursorPos = cursor->position() - closedParenParag.position(); int i = 0; @@ -2981,7 +2985,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor closedParenParag = closedParenParag.next(); if (!closedParenParag.isValid()) return NoMatch; - if (TextEditDocumentLayout::hasParentheses(closedParenParag)) { + if (TextEditDocumentLayout::hasParentheses(closedParenParag) + && !TextEditDocumentLayout::ifdefedOut(closedParenParag)) { parenList = TextEditDocumentLayout::parentheses(closedParenParag); break; } @@ -3018,12 +3023,13 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCursor *cursor, QChar c) { - if (!TextEditDocumentLayout::hasParentheses(cursor->block())) + QTextBlock block = cursor->block(); + if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block)) return NoMatch; - Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block()); + Parentheses parenList = TextEditDocumentLayout::parentheses(block); Parenthesis openParen, closedParen; - QTextBlock openParenParag = cursor->block(); + QTextBlock openParenParag = block; const int cursorPos = cursor->position() - openParenParag.position(); int i = parenList.count() - 1; @@ -3049,7 +3055,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCurs if (!openParenParag.isValid()) return NoMatch; - if (TextEditDocumentLayout::hasParentheses(openParenParag)) { + if (TextEditDocumentLayout::hasParentheses(openParenParag) + && !TextEditDocumentLayout::ifdefedOut(openParenParag)) { parenList = TextEditDocumentLayout::parentheses(openParenParag); break; } @@ -3091,7 +3098,7 @@ bool TextBlockUserData::findPreviousOpenParenthesis(QTextCursor *cursor, bool se int ignore = 0; while (block.isValid()) { Parentheses parenList = TextEditDocumentLayout::parentheses(block); - if (!parenList.isEmpty()) { + if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) { for (int i = parenList.count()-1; i >= 0; --i) { Parenthesis paren = parenList.at(i); if (block == cursor->block() && position - block.position() <= paren.pos + 1) @@ -3118,7 +3125,7 @@ bool TextBlockUserData::findNextClosingParenthesis(QTextCursor *cursor, bool sel int ignore = 0; while (block.isValid()) { Parentheses parenList = TextEditDocumentLayout::parentheses(block); - if (!parenList.isEmpty()) { + if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) { for (int i = 0; i < parenList.count(); ++i) { Parenthesis paren = parenList.at(i); if (block == cursor->block() && position - block.position() >= paren.pos) @@ -3143,7 +3150,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorBackward(QTextCursor cursor->clearSelection(); const QTextBlock block = cursor->block(); - if (!TextEditDocumentLayout::hasParentheses(block)) + if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block)) return NoMatch; const int relPos = cursor->position() - block.position(); @@ -3165,7 +3172,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorForward(QTextCursor * cursor->clearSelection(); const QTextBlock block = cursor->block(); - if (!TextEditDocumentLayout::hasParentheses(block)) + if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block)) return NoMatch; const int relPos = cursor->position() - block.position(); From fff956db026a4d1fbce96477aeb17cccb126fe3d Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 11 Dec 2008 13:23:03 +0100 Subject: [PATCH 23/39] Add preliminary version of coding convention/style recommnedation. More needed. It was suggested to copy parts from the twiki. --- doc/coding-style.qdoc | 246 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 doc/coding-style.qdoc diff --git a/doc/coding-style.qdoc b/doc/coding-style.qdoc new file mode 100644 index 00000000000..f028e56fe74 --- /dev/null +++ b/doc/coding-style.qdoc @@ -0,0 +1,246 @@ +/*! + +\contentpage{index.html}{Qt Creator} +\page coding-style.html + +\title Qt Creator Coding Rules + +THIS IS PRELIMINARY. + +\section1 Introduction + +The aim of this section is to serve as a guide for the developers, to aid us +to build understandable and maintainable code, to create less confusion and +surprises when working on Qt Creator. + +As usual: Rules are not set in stone. If there's a good reason to break one, +do it, preferably after making sure that there are others agreeing. + +This document is incomplete. + +In general, if you want to contribute to the main source, we expect at least +that you: + +\list 1 +\o The most important rule first: KISS (keep it simple ...): always + use a simple implementation in favor of a more complicated one. + This eases maintenance a lot. +\o Write good C++ code: Readable, well commented when necessary, + and taking advantage of the OO model. Follow the \l{Formatting} guidelines. + There are also certain \l{Code Constructs} that we try to follow. +\o Adapt the code to the structures already existing in Qt Creator, or in + the case that you have better ideas, discuss them with other developers + before writing the code. +\o Take advantage of Qt. Don't re-invent the wheel. Think about what parts + of your code are generic enough that they might be incorporated into + Qt proper. +\o Document interfaces. Right now we use qdoc, but changing to doxygen + is being considered. +\endlist + + + +\section1 Submitting Code + +It is implicitly understood that all patches contributed to The Qt Creator +Project are made under under the Gnu General Public License, version 2 or later +and + +If you have a problem with that, don't contribute code. + +Also please don't just pop up out of the blue with a huge patch (or +small) that changes something substantial in Qt Creator. Always discuss your +ideas with the other developers on mailing list first. + +When you create the patch, please use git or use "diff -up" since we find +that a lot easier to read than the other diff formats. Also please do not +send patches that implements or fixes several different things; several +patches is a much better option. + +We also require you to provide a commit message entry with every patch, +this describes in detail what the patch is doing. + + + +\section1 Code Constructs + +We have several guidelines on code constructs, some of these exist to +make the code faster, others to make the code clearer. Yet others +exist to allow us to take advantage of the strong type checking +in C++. + +\list 1 +\o Declaration of variables should wait as long as possible. The rule + is: "Don't declare it until you need it." In C++ there are a lot of + user defined types, and these can very often be expensive to + initialize. This rule connects to the next rule too. + +\o Make the scope of a variable as small as possible. + +\o Prefer preincrement to postincrement whenever possible. + Preincrement has potential of being faster than postincrement. Just + think about the obvious implementations of pre/post-increment. This + rule applies to decrement too. + +\code + ++T; + --U; + -NOT- + T++; // not used in Qt Creator + U--; // not used in Qt Creator +\endcode + +\o Try to minimize evaluation of the same code over and over. This is + aimed especially at loops. + +\code + + Container::iterator end = large.end(); + for (Container::iterator it = large.begin(); it != end; ++it) { + ...; + } + -NOT- + for (Container::iterator it = large.begin(); + it != large.end(); ++it) { + ...; + } +\endcode + + + +\section1 Formatting + +\section2 Declarations + +Only one declaration on each line. +\code + int a; + int b; + -NOT- + int a, b; // not used in Qt Creator +\endcode + + This is especially important when initialization is done at the same + time. +\code + QString a = "Joe"; + QString b = "Foo"; + -NOT- + QString a = "Joe", b = "Foo"; // not used in Qt Creator +\endcode + [Note that 'QString a = "Joe"' is formally calling a copy constructor + on a temporary constructed from a string literal and therefore has the + potential of being more expensive then direct construction by + 'QString a("joe")'. However the compiler is allowed to elide the copy + (even if it had side effects), and modern compilers typically do so. + Given these equal costs, Qt Creator code favours the '=' idiom as it is in + line with the traditional C-style initialization, _and_ cannot be + mistaken as function declaration, _and_ reduces the level of nested + parantheses in more initializations.] + + +\section2 Pointers and references + +\code + char *p = "flop"; + char &c = *p; + -NOT- + char* p = "flop"; // not used in Qt Creator + char & c = *p; // not used in Qt Creator +\endcode + + This is simply in line with the official Qt guide lines. + + Also note that we will have: +\code + const char *p; + -NOT- + char const * p; // not used in Qt Creator +\endcode + + + Using a plain 0 for Null pointer constants is always correct and least effort + to type. So: +\code + void *p = 0; + -NOT- + void *p = NULL; // not used in Qt Creator + -NOT- + void *p = '\0'; // not used in Qt Creator + -NOT- + void *p = 42 - 7 * 6; // also not used in Qt Creator +\endcode + Note: As an exception, imported third party code as well as code + interfacing the "native" APIs (src/support/os_*) can use NULL. + + +\section2 Operator names and parentheses +\code + operator==(type) + -NOT- + operator == (type) // not used in Qt Creator +\endcode + + The == is part of the function name, separating it makes the + declaration look like an expression. + + +\section2 Function names and parentheses +\code + void mangle() + -NOT- + void mangle () // not used in Qt Creator +\endcode + + + +\section2 Naming rules + + Simply follow the style of Qt proper. As examples: + \list + \o Use descriptive but simple and short names. Do not abbreviate. + + \o Class names are capitalized, and function names lowercased. + Enums are named like Classes, values are in lower-case. +\endlist + + + +\section2 Formatting + + Adapt the formatting of your code to the one used in the + other parts of Qt Creator. In case there is different formatting for + the same construct, use the one used more often. + + +\section2 Declarations + + - Use this order for the access sections of your class: public, + protected, private. The public section is interesting for every + user of the class. The private section is only of interest for the + implementors of the class (you). [Obviously not true since this is + for developers, and we do not want one developer only to be able to + read and understand the implementation of class internals. Lgb] + + - Avoid declaring global objects in the declaration file of the class. + If the same variable is used for all objects, use a static member. + + - Avoid global or static variables. + + +\section2 File headers + + If you create a new file, the top of the file should include a + header comment equal to the one found in other source files of Qt Creator. + +\section2 Documentation + + The documentation is generated from source and header files. + You document for the other developers, not for yourself. + In the header you should document interfaces, i.e. what the function does, + not the implementation. + In the .cpp files you document the implementation if the implementation + in non-obvious. + + +*/ From ddfd46b3224811d0e202e8a44a97150c50856d99 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 11 Dec 2008 13:35:58 +0100 Subject: [PATCH 24/39] nicer (un)comment selection, avoid C-style selections when you can do C++ style. --- src/plugins/cppeditor/cppeditor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index f233c0121f8..8aec6e39203 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -744,7 +744,8 @@ void CPPEditor::unCommentSelection() QString endText = endBlock.text(); int endPos = end - endBlock.position(); - bool hasTrailingCharacters = !endText.mid(endPos).trimmed().isEmpty(); + bool hasTrailingCharacters = !endText.left(endPos).remove(QLatin1String("//")).trimmed().isEmpty() + && !endText.mid(endPos).trimmed().isEmpty(); if ((endPos <= endText.length() - 2 && endText.at(endPos) == QLatin1Char('*') && endText.at(endPos+1) == QLatin1Char('/'))) { From a556ddada831c97c43d5c74bd1cb975b3da36fbc Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 11 Dec 2008 14:01:53 +0100 Subject: [PATCH 25/39] start sanitizing gdb options dialog --- src/plugins/debugger/debugger.pro | 2 - src/plugins/debugger/debuggerplugin.cpp | 8 -- src/plugins/debugger/debuggerplugin.h | 2 - src/plugins/debugger/gdbengine.h | 2 +- src/plugins/debugger/gdboptionpage.cpp | 47 ++++++-- src/plugins/debugger/gdboptionpage.h | 6 +- src/plugins/debugger/gdboptionpage.ui | 51 +++++++-- src/plugins/debugger/gdbtypemacros.ui | 144 +++++++++--------------- src/plugins/git/settingspage.cpp | 2 +- 9 files changed, 140 insertions(+), 124 deletions(-) diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 3d67e19c6aa..7308fb441c2 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -58,7 +58,6 @@ SOURCES += attachexternaldialog.cpp \ gdbengine.cpp \ gdbmi.cpp \ gdboptionpage.cpp \ - gdbtypemacros.cpp \ gdbengine.h \ moduleshandler.cpp \ moduleswindow.cpp \ @@ -79,7 +78,6 @@ FORMS += attachexternaldialog.ui \ breakcondition.ui \ mode.ui \ gdboptionpage.ui \ - gdbtypemacros.ui \ startexternaldialog.ui \ RESOURCES += debugger.qrc diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 37406f70cc1..d9217069c68 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -183,7 +183,6 @@ DebuggerPlugin::DebuggerPlugin() { m_pm = 0; m_generalOptionPage = 0; - m_typeMacroPage = 0; m_locationMark = 0; m_manager = 0; } @@ -202,7 +201,6 @@ void DebuggerPlugin::shutdown() //qDebug() << "DebuggerPlugin::~DebuggerPlugin"; removeObject(m_debugMode); removeObject(m_generalOptionPage); - removeObject(m_typeMacroPage); // FIXME: when using the line below, BreakWindow etc gets deleted twice. // so better leak for now... @@ -212,9 +210,6 @@ void DebuggerPlugin::shutdown() delete m_generalOptionPage; m_generalOptionPage = 0; - delete m_typeMacroPage; - m_typeMacroPage = 0; - delete m_locationMark; m_locationMark = 0; @@ -409,13 +404,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes mdebug->addAction(cmd); m_generalOptionPage = 0; - m_typeMacroPage = 0; // FIXME: m_generalOptionPage = new GdbOptionPage(&theGdbSettings()); addObject(m_generalOptionPage); - m_typeMacroPage = new TypeMacroPage(&theGdbSettings()); - addObject(m_typeMacroPage); m_locationMark = 0; diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index 91ffe4dbf77..ebf12b5e123 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -54,7 +54,6 @@ namespace Internal { class DebuggerManager; class DebugMode; class GdbOptionPage; -class TypeMacroPage; class LocationMark; class DebuggerPlugin : public ExtensionSystem::IPlugin @@ -103,7 +102,6 @@ private: ExtensionSystem::PluginManager *m_pm; GdbOptionPage *m_generalOptionPage; - TypeMacroPage *m_typeMacroPage; QString m_previousMode; LocationMark *m_locationMark; diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 56106a75244..6b3cbb15fee 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -80,7 +80,7 @@ enum DataDumperState DataDumperUnavailable, }; -// FIXME: Move to extra file? + class GdbSettings { public: diff --git a/src/plugins/debugger/gdboptionpage.cpp b/src/plugins/debugger/gdboptionpage.cpp index e05b811889a..8bf1b22a0fc 100644 --- a/src/plugins/debugger/gdboptionpage.cpp +++ b/src/plugins/debugger/gdboptionpage.cpp @@ -58,7 +58,11 @@ GdbOptionPage::GdbOptionPage(GdbSettings *settings) #if defined(Q_OS_WIN32) defaultCommand.append(".exe"); #endif + QString defaultScript = coreIFace->resourcePath() + + QLatin1String("/gdb/qt4macros"); + m_settings->m_gdbCmd = s->value("Location", defaultCommand).toString(); + m_settings->m_scriptFile= s->value("ScriptFile", defaultScript).toString(); m_settings->m_gdbEnv = s->value("Environment", "").toString(); m_settings->m_autoRun = s->value("AutoRun", true).toBool(); m_settings->m_autoQuit = s->value("AutoQuit", true).toBool(); @@ -72,36 +76,56 @@ QString GdbOptionPage::name() const QString GdbOptionPage::category() const { - return "Debugger|Gdb"; + return "Debugger"; } QString GdbOptionPage::trCategory() const { - return tr("Debugger|Gdb"); + return tr("Debugger"); } QWidget *GdbOptionPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); m_ui.setupUi(w); - m_ui.gdbEdit->setText(m_settings->m_gdbCmd); - m_ui.envEdit->setText(m_settings->m_gdbEnv); + m_ui.gdbLocationEdit->setText(m_settings->m_gdbCmd); + m_ui.environmentEdit->setText(m_settings->m_gdbEnv); m_ui.autoStartBox->setChecked(m_settings->m_autoRun); m_ui.autoQuitBox->setChecked(m_settings->m_autoQuit); - connect(m_ui.pushButtonBrowse, SIGNAL(clicked()), - this, SLOT(browse())); + m_ui.gdbStartupScriptEdit->setText(m_settings->m_scriptFile); + + // FIXME + m_ui.autoStartBox->hide(); + m_ui.autoQuitBox->hide(); + m_ui.environmentEdit->hide(); + m_ui.labelEnvironment->hide(); + + connect(m_ui.browseForGdbButton, SIGNAL(clicked()), + this, SLOT(browseForGdb())); + connect(m_ui.browseForScriptButton, SIGNAL(clicked()), + this, SLOT(browseForScript())); return w; } -void GdbOptionPage::browse() +void GdbOptionPage::browseForGdb() { - QString fileName = QFileDialog::getOpenFileName(m_ui.pushButtonBrowse, + QString fileName = QFileDialog::getOpenFileName(m_ui.browseForGdbButton, "Browse for gdb executable"); if (fileName.isEmpty()) return; m_settings->m_gdbCmd = fileName; - m_ui.gdbEdit->setText(fileName); + m_ui.gdbLocationEdit->setText(fileName); +} + +void GdbOptionPage::browseForScript() +{ + QString fileName = QFileDialog::getOpenFileName(m_ui.browseForGdbButton, + "Browse for gdb startup script"); + if (fileName.isEmpty()) + return; + m_settings->m_scriptFile = fileName; + m_ui.gdbStartupScriptEdit->setText(fileName); } void GdbOptionPage::finished(bool accepted) @@ -109,10 +133,11 @@ void GdbOptionPage::finished(bool accepted) if (!accepted) return; - m_settings->m_gdbCmd = m_ui.gdbEdit->text(); - m_settings->m_gdbEnv = m_ui.envEdit->text(); + m_settings->m_gdbCmd = m_ui.gdbLocationEdit->text(); + m_settings->m_gdbEnv = m_ui.environmentEdit->text(); m_settings->m_autoRun = m_ui.autoStartBox->isChecked(); m_settings->m_autoQuit = m_ui.autoQuitBox->isChecked(); + m_settings->m_scriptFile = m_ui.gdbStartupScriptEdit->text(); Core::ICore *coreIFace = m_pm->getObject(); if (!coreIFace || !coreIFace->settings()) diff --git a/src/plugins/debugger/gdboptionpage.h b/src/plugins/debugger/gdboptionpage.h index 1d71024bac1..684bd789771 100644 --- a/src/plugins/debugger/gdboptionpage.h +++ b/src/plugins/debugger/gdboptionpage.h @@ -35,7 +35,6 @@ #define GDBOPTIONPAGE_H #include "ui_gdboptionpage.h" -#include "ui_gdbtypemacros.h" #include @@ -63,7 +62,8 @@ public: void finished(bool accepted); public slots: - void browse(); + void browseForGdb(); + void browseForScript(); private: ExtensionSystem::PluginManager *m_pm; @@ -72,6 +72,7 @@ private: GdbSettings *m_settings; }; +#if 0 class TypeMacroPage : public Core::IOptionsPage { Q_OBJECT @@ -100,6 +101,7 @@ private: GdbSettings *m_settings; QWidget *m_widget; }; +#endif } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index 4b58d5d7140..a7496851188 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -7,7 +7,7 @@ 0 0 433 - 216 + 233 @@ -23,7 +23,7 @@ - Gdb Debug Options + Locations @@ -33,33 +33,36 @@ 6 - + - + - + + + This is either a full abolute path leading to the gdb binary you intend to use or the name of a gdb binary that wiull be searched in your PATH. + Gdb Location: - gdbEdit + gdbLocationEdit - + Environment: - envEdit + environmentEdit - + @@ -72,6 +75,36 @@
+ + + + + + + + 21 + 23 + + + + ... + + + + :/qworkbench/images/fileopen.png:/qworkbench/images/fileopen.png + + + + + + + This is either empty or points to a file containing gdb commands that will be executed immediately after gdb starts up. + + + Gdb Startup Script: + + +
diff --git a/src/plugins/debugger/gdbtypemacros.ui b/src/plugins/debugger/gdbtypemacros.ui index aa7215577b4..f42514e4e49 100644 --- a/src/plugins/debugger/gdbtypemacros.ui +++ b/src/plugins/debugger/gdbtypemacros.ui @@ -1,146 +1,115 @@ - - - - + + TypeMacroPage - - + + 0 0 519 - 238 + 263 - + Form - - - 9 - - + + 6 + + 9 + - - - Script File - - - - 9 - - - 6 - - - - - - - - - 21 - 23 - - - - ... - - - - - - - - - + + 0 - + 6 - - - + + + false - + Type - + Macro - - - + + + 21 23 - + + - - :/gdbdebugger/images/newitem.png + + + :/gdbdebugger/images/newitem.png:/gdbdebugger/images/newitem.png - - - + + + Macro Name: - - - + + + Parse as: - - + + - - - + + + 0 - + 0 - - + + 21 23 - + - - - :/gdbdebugger/images/delete.png + + + :/gdbdebugger/images/delete.png:/gdbdebugger/images/delete.png - + Qt::Vertical - + 20 40 @@ -150,25 +119,25 @@ - - + + - - - + + + Type: - - + + - + ASCII (char *) - + Unicode (short) @@ -178,9 +147,8 @@ - - + diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp index e1b14cb9ccc..7f0581fc3c3 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -77,7 +77,7 @@ QString SettingsPage::name() const return tr("General"); } - QString SettingsPage::category() const +QString SettingsPage::category() const { return QLatin1String("Git"); } From 9890705295a7dda84507b8969953925ade38169f Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 11 Dec 2008 14:11:28 +0100 Subject: [PATCH 26/39] make the home key jump to column 0 if the caret if before the first non-space --- src/plugins/texteditor/basetexteditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index d613db7a294..9b4e4254f59 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2767,6 +2767,8 @@ void BaseTextEditor::handleHomeKey(bool anchor) while (character == tab || character.category() == QChar::Separator_Space) { ++pos; + if (pos == initpos) + break; character = characterAt(pos); } From 9042ff32b05ade9388e552f0a872abe63fd309c8 Mon Sep 17 00:00:00 2001 From: goro Date: Thu, 11 Dec 2008 14:12:58 +0100 Subject: [PATCH 27/39] About dialog cosmetics --- src/plugins/coreplugin/versiondialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp index 0decae6cf18..e534a0d1eae 100644 --- a/src/plugins/coreplugin/versiondialog.cpp +++ b/src/plugins/coreplugin/versiondialog.cpp @@ -72,7 +72,7 @@ VersionDialog::VersionDialog(QWidget *parent) "
" "Built on " __DATE__ " at " __TIME__ "
" #ifdef IDE_REVISION - "Using revision %5
" + "From revision %5
" #endif "
" "
" From f149c17d17c2fc86654f770550d43ab98721056e Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 11 Dec 2008 14:44:24 +0100 Subject: [PATCH 28/39] Fixed possible crash when merging the evironments. --- src/libs/cplusplus/TypeOfExpression.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 53fa7e78396..68732f78ea0 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -107,6 +107,8 @@ void TypeOfExpression::processEnvironment(QMap documents Document::Ptr doc, Environment *env, QSet *processed) const { + if (! doc) + return; if (processed->contains(doc->fileName())) return; processed->insert(doc->fileName()); From 9da7aef44cbeba9a1869b7ce9df3187c3df3432a Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 11 Dec 2008 15:01:22 +0100 Subject: [PATCH 29/39] re-organizize gdb location selection again --- src/plugins/debugger/gdboptionpage.cpp | 38 ++++++++--------- src/plugins/debugger/gdboptionpage.h | 4 +- src/plugins/debugger/gdboptionpage.ui | 56 +++++++------------------- 3 files changed, 33 insertions(+), 65 deletions(-) diff --git a/src/plugins/debugger/gdboptionpage.cpp b/src/plugins/debugger/gdboptionpage.cpp index 8bf1b22a0fc..7d6742e9582 100644 --- a/src/plugins/debugger/gdboptionpage.cpp +++ b/src/plugins/debugger/gdboptionpage.cpp @@ -88,11 +88,15 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); m_ui.setupUi(w); - m_ui.gdbLocationEdit->setText(m_settings->m_gdbCmd); + m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command); + m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location")); + m_ui.gdbLocationChooser->setPath(m_settings->m_gdbCmd); + m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File); + m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); + m_ui.scriptFileChooser->setPath(m_settings->m_scriptFile); m_ui.environmentEdit->setText(m_settings->m_gdbEnv); m_ui.autoStartBox->setChecked(m_settings->m_autoRun); m_ui.autoQuitBox->setChecked(m_settings->m_autoQuit); - m_ui.gdbStartupScriptEdit->setText(m_settings->m_scriptFile); // FIXME m_ui.autoStartBox->hide(); @@ -100,32 +104,22 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.environmentEdit->hide(); m_ui.labelEnvironment->hide(); - connect(m_ui.browseForGdbButton, SIGNAL(clicked()), - this, SLOT(browseForGdb())); - connect(m_ui.browseForScriptButton, SIGNAL(clicked()), - this, SLOT(browseForScript())); + connect(m_ui.gdbLocationChooser, SIGNAL(changed()), + this, SLOT(onGdbLocationChanged())); + connect(m_ui.scriptFileChooser, SIGNAL(changed()), + this, SLOT(onScriptFileChanged())); return w; } -void GdbOptionPage::browseForGdb() +void GdbOptionPage::onGdbLocationChanged() { - QString fileName = QFileDialog::getOpenFileName(m_ui.browseForGdbButton, - "Browse for gdb executable"); - if (fileName.isEmpty()) - return; - m_settings->m_gdbCmd = fileName; - m_ui.gdbLocationEdit->setText(fileName); + m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path(); } -void GdbOptionPage::browseForScript() +void GdbOptionPage::onScriptFileChanged() { - QString fileName = QFileDialog::getOpenFileName(m_ui.browseForGdbButton, - "Browse for gdb startup script"); - if (fileName.isEmpty()) - return; - m_settings->m_scriptFile = fileName; - m_ui.gdbStartupScriptEdit->setText(fileName); + m_settings->m_scriptFile = m_ui.scriptFileChooser->path(); } void GdbOptionPage::finished(bool accepted) @@ -133,11 +127,11 @@ void GdbOptionPage::finished(bool accepted) if (!accepted) return; - m_settings->m_gdbCmd = m_ui.gdbLocationEdit->text(); + m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path(); m_settings->m_gdbEnv = m_ui.environmentEdit->text(); m_settings->m_autoRun = m_ui.autoStartBox->isChecked(); m_settings->m_autoQuit = m_ui.autoQuitBox->isChecked(); - m_settings->m_scriptFile = m_ui.gdbStartupScriptEdit->text(); + m_settings->m_scriptFile = m_ui.scriptFileChooser->path(); Core::ICore *coreIFace = m_pm->getObject(); if (!coreIFace || !coreIFace->settings()) diff --git a/src/plugins/debugger/gdboptionpage.h b/src/plugins/debugger/gdboptionpage.h index b9da4ea0111..d306e03e20f 100644 --- a/src/plugins/debugger/gdboptionpage.h +++ b/src/plugins/debugger/gdboptionpage.h @@ -62,8 +62,8 @@ public: void finished(bool accepted); public slots: - void browseForGdb(); - void browseForScript(); + void onGdbLocationChanged(); + void onScriptFileChanged(); private: ExtensionSystem::PluginManager *m_pm; diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index a7496851188..580f13c0d66 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -32,10 +32,7 @@ 6 - - - - + @@ -46,9 +43,6 @@ Gdb Location: - - gdbLocationEdit - @@ -61,40 +55,6 @@ - - - - - - - - :/qworkbench/images/fileopen.png:/qworkbench/images/fileopen.png - - - false - - - - - - - - - - - 21 - 23 - - - - ... - - - - :/qworkbench/images/fileopen.png:/qworkbench/images/fileopen.png - - - @@ -105,6 +65,12 @@ + + + + + +
@@ -137,6 +103,14 @@ + + + Core::Utils::PathChooser + QWidget +
utils/pathchooser.h
+ 1 +
+
From 4f370af4fe38afe904f9edb96fad9771da8078ab Mon Sep 17 00:00:00 2001 From: con Date: Thu, 11 Dec 2008 15:07:14 +0100 Subject: [PATCH 30/39] Fixes: - Avoid ugly toolbar by default on mac --- src/plugins/coreplugin/navigationwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 82ed13a29e8..8e84df39321 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -334,6 +334,10 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget) m_navigationComboBox = new NavComboBox(this); m_navigationWidget = 0; +#ifdef Q_OS_MAC + // this is to avoid ugly tool bar behavior + m_navigationComboBox->setMaximumWidth(130); +#endif m_toolbar = new QToolBar(this); m_toolbar->setContentsMargins(0, 0, 0, 0); From c4b222695e30276c6a911eb361721fd3f3ad87ac Mon Sep 17 00:00:00 2001 From: con Date: Thu, 11 Dec 2008 15:11:15 +0100 Subject: [PATCH 31/39] Fixes: - Choose... buttons are push buttons on mac --- src/libs/utils/pathchooser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 81a2228e669..100fdbe717f 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -46,11 +46,12 @@ #include #include #include +#include namespace Core { namespace Utils { -#ifdef Q_OS_OSX +#ifdef Q_OS_MAC /*static*/ const char * const PathChooser::browseButtonLabel = "Choose..."; #else /*static*/ const char * const PathChooser::browseButtonLabel = "Browse..."; @@ -112,7 +113,11 @@ PathChooser::PathChooser(QWidget *parent) : hLayout->addWidget(m_d->m_lineEdit); hLayout->setSizeConstraint(QLayout::SetMinimumSize); +#ifdef Q_OS_MAC + QPushButton *browseButton = new QPushButton; +#else QToolButton *browseButton = new QToolButton; +#endif browseButton->setText(tr(browseButtonLabel)); connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse())); From 18c8471158f89d7668c8c711c419b3b077d93526 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 11 Dec 2008 15:50:37 +0100 Subject: [PATCH 32/39] line is blockNumber + 1 --- src/plugins/texteditor/basetexteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 0772e4f154a..1cff254452c 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2517,7 +2517,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) } } else if (e->button() == Qt::RightButton) { QMenu * contextMenu = new QMenu(this); - emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber(), contextMenu); + emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber() + 1, contextMenu); if (!contextMenu->isEmpty()) contextMenu->exec(e->globalPos()); delete contextMenu; From 5ba9cbc56580782972ea025cf0b0a828d4233d90 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 11 Dec 2008 16:10:47 +0100 Subject: [PATCH 33/39] nicer type display for std::map (not including an actual dumper yet) --- src/plugins/debugger/watchhandler.cpp | 15 ++++++++-- tests/manual/gdbdebugger/simple/app.cpp | 39 +++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 6f443c92b47..5328a171aea 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -411,7 +411,7 @@ static QString niceType(QString type) "std::allocator >", "std::wstring"); // std::vector - static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); + static QRegExp re1("std::vector<(.*), std::allocator<(.*)>\\s*>"); re1.setMinimal(true); for (int i = 0; i != 10; ++i) { if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2)) @@ -420,7 +420,7 @@ static QString niceType(QString type) } // std::list - static QRegExp re2("std::list<(.*)\\s*,std::allocator<(.*)>\\s*>"); + static QRegExp re2("std::list<(.*), std::allocator<(.*)>\\s*>"); re2.setMinimal(true); for (int i = 0; i != 10; ++i) { if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2)) @@ -428,6 +428,17 @@ static QString niceType(QString type) type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">"); } + // std::map + static QRegExp re3("std::map<(.*), (.*), std::less<(.*)\\s*>, " + "std::allocator > >"); + re3.setMinimal(true); + for (int i = 0; i != 10; ++i) { + if (re3.indexIn(type) == -1 || re3.cap(1) != re3.cap(3) + || re3.cap(1) != re3.cap(4) || re3.cap(2) != re3.cap(5)) + break; + type.replace(re3.cap(0), "std::map<" + re3.cap(1) + ", " + re3.cap(2) + ">"); + } + type.replace(" >", ">"); } return type; diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index dbc7eebcd3c..ab5ee635b5a 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -53,6 +53,7 @@ #include #include +#include #include #include #include @@ -131,7 +132,6 @@ void testArray() } } - void testQByteArray() { QByteArray ba = "Hello"; @@ -142,7 +142,6 @@ void testQByteArray() ba += 2; } - void testQHash() { QHash hgg0; @@ -412,6 +411,41 @@ void testStdList() vec.push_back(false); } +void testStdMap() +{ + std::map ggl; + ggl[11] = QStringList() << "11"; + ggl[22] = QStringList() << "22"; + + typedef std::map T; + T ggt; + ggt[11] = QStringList() << "11"; + ggt[22] = QStringList() << "22"; + +#if 0 + std::map gg0; + gg0[11] = 11.0; + gg0[22] = 22.0; + + + std::map gg1; + gg1["22.0"] = 22.0; + + std::map gg2; + gg2[22] = "22.0"; + + std::map gg3; + gg3["22.0"] = Foo(22); + gg3["33.0"] = Foo(33); + + QObject ob; + std::map > map; + map.insert("Hallo", QPointer(&ob)); + map.insert("Welt", QPointer(&ob)); + map.insert(".", QPointer(&ob)); +#endif +} + void testStdStack() { std::stack plist1; @@ -795,6 +829,7 @@ int main(int argc, char *argv[]) testArray(); testStdList(); + testStdMap(); testStdStack(); testStdString(); testStdVector(); From 0df94d51918b70249bdaebf3c931cdb45fbb7f79 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 11 Dec 2008 16:16:56 +0100 Subject: [PATCH 34/39] minimum indent or tab width is 1 --- src/plugins/texteditor/generalsettingspage.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/texteditor/generalsettingspage.ui b/src/plugins/texteditor/generalsettingspage.ui index 11f6b8b997e..140f94628d6 100644 --- a/src/plugins/texteditor/generalsettingspage.ui +++ b/src/plugins/texteditor/generalsettingspage.ui @@ -66,6 +66,9 @@ 0 + + 1 + 20 @@ -132,6 +135,9 @@ 0 + + 1 + 20 From 0c20f6d9d154e181feabb21218be15e4348cda04 Mon Sep 17 00:00:00 2001 From: goro Date: Thu, 11 Dec 2008 16:19:07 +0100 Subject: [PATCH 35/39] Plural fix --- src/plugins/quickopen/opendocumentsfilter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/quickopen/opendocumentsfilter.h b/src/plugins/quickopen/opendocumentsfilter.h index 7b24aeeca02..6957119727e 100644 --- a/src/plugins/quickopen/opendocumentsfilter.h +++ b/src/plugins/quickopen/opendocumentsfilter.h @@ -54,8 +54,8 @@ class OpenDocumentsFilter : public QuickOpen::IQuickOpenFilter public: OpenDocumentsFilter(Core::EditorManager *editorManager); - QString trName() const { return tr("Open document"); } - QString name() const { return "Open document"; } + QString trName() const { return tr("Open documents"); } + QString name() const { return "Open documents"; } QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; } QList matchesFor(const QString &entry); void accept(QuickOpen::FilterEntry selection) const; From ce66bc3c1e64a8a4eb7f40824a75ec52420340cf Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 11 Dec 2008 16:35:50 +0100 Subject: [PATCH 36/39] Don't do a GC call when updating the project, it can remove useful "yet not parsed" documents. --- src/plugins/qt4projectmanager/qt4project.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index c9263201937..9e47ac404d2 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -498,12 +498,8 @@ void Qt4Project::updateCodeModel() pinfo.sourceFiles = files; modelmanager->updateProjectInfo(pinfo); - - modelmanager->GC(); modelmanager->updateSourceFiles(pinfo.sourceFiles); } - - // update info } From bab60d14b341edc4fd1f81ec12cc460441948c3b Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 12 Dec 2008 10:07:58 +0100 Subject: [PATCH 37/39] Introduced CPlusPlus::Snapshot, it contains a snap shot of the indexer's current state. This change removes a number of wrong usages of the CppModelManager::documents()/document(). --- src/libs/cplusplus/CppDocument.h | 12 ++++++++++- src/libs/cplusplus/LookupContext.cpp | 2 +- src/libs/cplusplus/LookupContext.h | 6 +++--- src/libs/cplusplus/TypeOfExpression.cpp | 12 +++++------ src/libs/cplusplus/TypeOfExpression.h | 8 +++---- src/plugins/cppeditor/cppeditor.cpp | 14 ++++++++----- src/plugins/cpptools/cppcodecompletion.cpp | 8 ++++--- src/plugins/cpptools/cpphoverhandler.cpp | 6 ++++-- src/plugins/cpptools/cppmodelmanager.cpp | 21 ++++++++----------- src/plugins/cpptools/cppmodelmanager.h | 5 ++--- .../cpptools/cppmodelmanagerinterface.h | 8 ++----- src/plugins/cpptools/searchsymbols.h | 1 + src/plugins/designer/workbenchintegration.cpp | 4 ++-- 13 files changed, 59 insertions(+), 48 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index b31f0d2bc64..54de3c801ea 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include #include @@ -236,6 +236,16 @@ private: QList _macroUses; }; +class CPLUSPLUS_EXPORT Snapshot: public QMap +{ +public: + Snapshot() + { } + + ~Snapshot() + { } +}; + } // end of namespace CPlusPlus #endif // CPPDOCUMENT_H diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 67eb05d7f4a..8b24b59f5ef 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -77,7 +77,7 @@ LookupContext::LookupContext(Control *control) LookupContext::LookupContext(Symbol *symbol, Document::Ptr expressionDocument, Document::Ptr thisDocument, - const QMap &documents) + const Snapshot &documents) : _symbol(symbol), _expressionDocument(expressionDocument), _thisDocument(thisDocument), diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 36ea6a8298f..18754bf6670 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -57,7 +57,7 @@ public: LookupContext(Symbol *symbol, Document::Ptr expressionDocument, Document::Ptr thisDocument, - const QMap &documents); + const Snapshot &documents); LookupContext(Symbol *symbol, const LookupContext &context); @@ -87,7 +87,7 @@ public: QList resolveClassOrNamespace(Name *name) const { return resolveClassOrNamespace(name, visibleScopes()); } - QMap documents() const + Snapshot snapshot() const { return _documents; } enum ResolveMode { @@ -140,7 +140,7 @@ private: Document::Ptr _thisDocument; // All documents. - QMap _documents; + Snapshot _documents; // Visible scopes. QList _visibleScopes; diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 68732f78ea0..cb373cce027 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -46,9 +46,9 @@ TypeOfExpression::TypeOfExpression(): { } -void TypeOfExpression::setDocuments(const QMap &documents) +void TypeOfExpression::setSnapshot(const Snapshot &documents) { - m_documents = documents; + m_snapshot = documents; m_lookupContext = LookupContext(); } @@ -59,12 +59,12 @@ QList TypeOfExpression::operator()(const QString &expr { QString code = expression; if (mode == Preprocess) - code = preprocessedExpression(expression, m_documents, document); + code = preprocessedExpression(expression, m_snapshot, document); Document::Ptr expressionDoc = documentForExpression(code); m_ast = extractExpressionAST(expressionDoc); m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc, - document, m_documents); + document, m_snapshot); ResolveExpression resolveExpression(m_lookupContext); return resolveExpression(m_ast); @@ -103,7 +103,7 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression) return doc; } -void TypeOfExpression::processEnvironment(QMap documents, +void TypeOfExpression::processEnvironment(Snapshot documents, Document::Ptr doc, Environment *env, QSet *processed) const { @@ -122,7 +122,7 @@ void TypeOfExpression::processEnvironment(QMap documents } QString TypeOfExpression::preprocessedExpression(const QString &expression, - QMap documents, + Snapshot documents, Document::Ptr thisDocument) const { Environment env; diff --git a/src/libs/cplusplus/TypeOfExpression.h b/src/libs/cplusplus/TypeOfExpression.h index e6a9a7f4b66..87d4113f30e 100644 --- a/src/libs/cplusplus/TypeOfExpression.h +++ b/src/libs/cplusplus/TypeOfExpression.h @@ -61,7 +61,7 @@ public: * Also clears the lookup context, so can be used to make sure references * to the documents previously used are removed. */ - void setDocuments(const QMap &documents); + void setSnapshot(const Snapshot &documents); enum PreprocessMode { NoPreprocess, @@ -100,15 +100,15 @@ private: ExpressionAST *extractExpressionAST(Document::Ptr doc) const; Document::Ptr documentForExpression(const QString &expression) const; - void processEnvironment(QMap documents, + void processEnvironment(CPlusPlus::Snapshot documents, CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env, QSet *processed) const; QString preprocessedExpression(const QString &expression, - QMap documents, + CPlusPlus::Snapshot documents, CPlusPlus::Document::Ptr thisDocument) const; - QMap m_documents; + Snapshot m_snapshot; ExpressionAST *m_ast; LookupContext m_lookupContext; }; diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index acf55f6d93f..49b130ebc1c 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -427,7 +427,9 @@ void CPPEditor::switchDeclarationDefinition() if (!m_modelManager) return; - Document::Ptr doc = m_modelManager->document(file()->fileName()); + const Snapshot snapshot = m_modelManager->snapshot(); + + Document::Ptr doc = snapshot.value(file()->fileName()); if (!doc) return; Symbol *lastSymbol = doc->findSymbolAt(line, column); @@ -445,7 +447,7 @@ void CPPEditor::switchDeclarationDefinition() if (f) { TypeOfExpression typeOfExpression; - typeOfExpression.setDocuments(m_modelManager->documents()); + typeOfExpression.setSnapshot(m_modelManager->snapshot()); QList resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol); const LookupContext &context = typeOfExpression.lookupContext(); @@ -474,10 +476,12 @@ void CPPEditor::jumpToDefinition() if (!m_modelManager) return; + const Snapshot snapshot = m_modelManager->snapshot(); + // Find the last symbol up to the cursor position int line = 0, column = 0; convertPosition(position(), &line, &column); - Document::Ptr doc = m_modelManager->document(file()->fileName()); + Document::Ptr doc = snapshot.value(file()->fileName()); if (!doc) return; @@ -503,7 +507,7 @@ void CPPEditor::jumpToDefinition() // Evaluate the type of the expression TypeOfExpression typeOfExpression; - typeOfExpression.setDocuments(m_modelManager->documents()); + typeOfExpression.setSnapshot(m_modelManager->snapshot()); QList resolvedSymbols = typeOfExpression(expression, doc, lastSymbol); @@ -572,7 +576,7 @@ Symbol *CPPEditor::findDefinition(Symbol *lastSymbol) QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size()); LookupContext context(&control); - const QMap documents = m_modelManager->documents(); + const Snapshot documents = m_modelManager->snapshot(); foreach (Document::Ptr doc, documents) { QList visibleScopes; visibleScopes.append(doc->globalSymbols()); diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 4606bd948f3..a0fbe82a542 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -434,10 +434,12 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) //if (! expression.isEmpty()) //qDebug() << "***** expression:" << expression; - if (Document::Ptr thisDocument = m_manager->document(fileName)) { + const Snapshot snapshot = m_manager->snapshot(); + + if (Document::Ptr thisDocument = snapshot.value(fileName)) { Symbol *symbol = thisDocument->findSymbolAt(line, column); - typeOfExpression.setDocuments(m_manager->documents()); + typeOfExpression.setSnapshot(m_manager->snapshot()); QList resolvedTypes = typeOfExpression(expression, thisDocument, symbol, TypeOfExpression::Preprocess); @@ -1034,7 +1036,7 @@ void CppCodeCompletion::cleanup() // Set empty map in order to avoid referencing old versions of the documents // until the next completion - typeOfExpression.setDocuments(QMap()); + typeOfExpression.setSnapshot(Snapshot()); } int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor) diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index f3831e5394d..fab0d83b31f 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -165,9 +165,11 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in QTextCursor tc(edit->document()); tc.setPosition(pos); + const Snapshot documents = m_manager->snapshot(); + const int lineNumber = tc.block().blockNumber() + 1; const QString fileName = editor->file()->fileName(); - Document::Ptr doc = m_manager->document(fileName); + Document::Ptr doc = documents.value(fileName); if (doc) { foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) { if (m.line() == lineNumber) { @@ -212,7 +214,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in Symbol *lastSymbol = doc->findSymbolAt(line, column); TypeOfExpression typeOfExpression; - typeOfExpression.setDocuments(m_manager->documents()); + typeOfExpression.setSnapshot(documents); QList types = typeOfExpression(expression, doc, lastSymbol); if (!types.isEmpty()) { diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 9adc892713d..a02656ee8c9 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -143,7 +143,7 @@ protected: private: QPointer m_modelManager; - CppModelManager::DocumentTable m_documents; + Snapshot m_snapshot; Environment env; pp m_proc; QStringList m_includePaths; @@ -160,7 +160,7 @@ private: CppPreprocessor::CppPreprocessor(QPointer modelManager) : m_modelManager(modelManager), - m_documents(modelManager->documents()), + m_snapshot(modelManager->snapshot()), m_proc(this, env) { } @@ -340,7 +340,7 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet *process processed->insert(fn); foreach (QString includedFile, doc->includedFiles()) { - mergeEnvironment(m_documents.value(includedFile), processed); + mergeEnvironment(m_snapshot.value(includedFile), processed); } foreach (const Macro macro, doc->definedMacros()) { @@ -386,7 +386,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, } if (! contents.isEmpty()) { - Document::Ptr cachedDoc = m_documents.value(fileName); + Document::Ptr cachedDoc = m_snapshot.value(fileName); if (cachedDoc && m_currentDoc) { mergeEnvironment(cachedDoc); } else { @@ -477,11 +477,8 @@ CppModelManager::CppModelManager(QObject *parent) : CppModelManager::~CppModelManager() { } -Document::Ptr CppModelManager::document(const QString &fileName) const -{ return m_documents.value(fileName); } - -CppModelManager::DocumentTable CppModelManager::documents() const -{ return m_documents; } +Snapshot CppModelManager::snapshot() const +{ return m_snapshot; } void CppModelManager::ensureUpdated() { @@ -672,7 +669,7 @@ void CppModelManager::emitDocumentUpdated(Document::Ptr doc) void CppModelManager::onDocumentUpdated(Document::Ptr doc) { const QString fileName = doc->fileName(); - m_documents[fileName] = doc; + m_snapshot[fileName] = doc; QList openedEditors = m_core->editorManager()->openedEditors(); foreach (Core::IEditor *editor, openedEditors) { if (editor->file()->fileName() == fileName) { @@ -837,7 +834,7 @@ void CppModelManager::parse(QFutureInterface &future, void CppModelManager::GC() { - DocumentTable documents = m_documents; + Snapshot documents = m_snapshot; QSet processed; QStringList todo = projectFiles(); @@ -868,7 +865,7 @@ void CppModelManager::GC() } emit aboutToRemoveFiles(removedFiles); - m_documents = documents; + m_snapshot = documents; } diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 3b2f4e19993..25947056203 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -76,8 +76,7 @@ public: virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const; virtual void updateProjectInfo(const ProjectInfo &pinfo); - virtual CPlusPlus::Document::Ptr document(const QString &fileName) const; - virtual DocumentTable documents() const; + virtual CPlusPlus::Snapshot snapshot() const; virtual void GC(); QFuture refreshSourceFiles(const QStringList &sourceFiles); @@ -146,7 +145,7 @@ private: Core::ICore *m_core; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; CppHoverHandler *m_hoverHandler; - DocumentTable m_documents; + CPlusPlus::Snapshot m_snapshot; // cache bool m_dirty; diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index e3ad4fe961b..6dc0da67ca0 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -46,14 +46,11 @@ namespace ProjectExplorer { namespace CppTools { -class CPPTOOLS_EXPORT CppModelManagerInterface - : public QObject +class CPPTOOLS_EXPORT CppModelManagerInterface: public QObject { Q_OBJECT public: - typedef QMap DocumentTable; // ### remove me - class ProjectInfo { public: @@ -89,8 +86,7 @@ public: virtual void GC() = 0; virtual void updateSourceFiles(const QStringList &sourceFiles) = 0; - virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0; - virtual DocumentTable documents() const = 0; + virtual CPlusPlus::Snapshot snapshot() const = 0; virtual QList projectInfos() const = 0; virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0; diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h index 4997e5cf049..494455f6d85 100644 --- a/src/plugins/cpptools/searchsymbols.h +++ b/src/plugins/cpptools/searchsymbols.h @@ -43,6 +43,7 @@ #include #include #include +#include #include diff --git a/src/plugins/designer/workbenchintegration.cpp b/src/plugins/designer/workbenchintegration.cpp index 4e49218a5c4..273aa2cfb82 100644 --- a/src/plugins/designer/workbenchintegration.cpp +++ b/src/plugins/designer/workbenchintegration.cpp @@ -95,7 +95,7 @@ QList WorkbenchIntegration::findDocuments(const QString &uiFileNa QList docList; // take all docs - CppTools::CppModelManagerInterface::DocumentTable docTable = cppModelManager->documents(); + CPlusPlus::Snapshot docTable = cppModelManager->snapshot(); foreach (Document::Ptr doc, docTable) { // we go through all documents QStringList includes = doc->includedFiles(); foreach (QString include, includes) { @@ -253,7 +253,7 @@ Document::Ptr WorkbenchIntegration::findDefinition(Function *functionDeclaration QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size()); LookupContext context(&control); - const QMap documents = cppModelManager->documents(); + const Snapshot documents = cppModelManager->snapshot(); foreach (Document::Ptr doc, documents) { QList visibleScopes; visibleScopes.append(doc->globalSymbols()); From aed481dec8e7b666b1ff999639fed9a1632149a0 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 12 Dec 2008 10:09:47 +0100 Subject: [PATCH 38/39] Don't hardode -O3 optimization level for cpptools. --- src/plugins/cpptools/cpptools.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index 74112379e39..170f62b5bf1 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -6,7 +6,6 @@ include(cpptools_dependencies.pri) # DEFINES += QT_NO_CAST_FROM_ASCII DEFINES += QT_NO_CAST_TO_ASCII -unix:QMAKE_CXXFLAGS_DEBUG += -O3 INCLUDEPATH += . DEFINES += CPPTOOLS_LIBRARY CONFIG += help From 0145a3dea966df75afbf5c85c824d37795ad645c Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 12 Dec 2008 10:40:25 +0100 Subject: [PATCH 39/39] Look at the signed/unsigned specifiers when checking function return types. --- src/plugins/cpptools/cppcodecompletion.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index a0fbe82a542..addf5301f79 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -966,8 +966,10 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) if (Function *function = symbol->type()->asFunction()) { // If the member is a function, automatically place the opening parenthesis, // except when it might take template parameters. - if (!function->returnType().isValid() - && (function->identity() && !function->identity()->isDestructorNameId())) { + const bool hasReturnType = function->returnType().isValid() || + function->returnType().isSigned() || + function->returnType().isUnsigned(); + if (! hasReturnType && (function->identity() && !function->identity()->isDestructorNameId())) { // Don't insert any magic, since the user might have just wanted to select the class } else if (function->templateParameterCount() != 0) {