diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2011-11-01 18:16:38 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-11-01 18:16:38 +0100 |
commit | 912cd548c0b0950b3a1e80f2597c99b3bf898c83 (patch) | |
tree | c9eeb5ac857dcabcfb404f60356ad4522471d9ed /src | |
parent | ddde938174f03544182adb79179d192502b50e51 (diff) | |
parent | 002820867cc0f4f5c67c5ae976eec26157275d4f (diff) | |
download | qt-creator-912cd548c0b0950b3a1e80f2597c99b3bf898c83.tar.gz |
Merge remote-tracking branch 'origin/2.4'
Conflicts:
src/libs/qmljs/qmljsinterpreter.cpp
src/libs/qmljs/qmljsinterpreter.h
src/plugins/madde/maemopackagecreationstep.cpp
src/plugins/projectexplorer/buildmanager.cpp
src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
src/plugins/qmljstools/qmljsqtstylecodeformatter.h
tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
Change-Id: I63ab2ba5dac006c37ccfbae55b023396a4676ff7
Diffstat (limited to 'src')
60 files changed, 567 insertions, 340 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 0df7704e09..f8ff42ca9c 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -918,11 +918,11 @@ void CPlusPlus::findMatchingDeclaration(const LookupContext &context, return; foreach (Symbol *s, binding->symbols()) { - Class *matchingClass = s->asClass(); - if (!matchingClass) + Scope *scope = s->asScope(); + if (!scope) continue; - for (Symbol *s = matchingClass->find(funcId); s; s = s->next()) { + for (Symbol *s = scope->find(funcId); s; s = s->next()) { if (! s->name()) continue; else if (! funcId->isEqualTo(s->identifier())) diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index 8948b9297e..432f6bcbe4 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -387,18 +387,6 @@ UseMinimalNames::~UseMinimalNames() } -static bool symbolIdentical(Symbol *s1, Symbol *s2) -{ - if (!s1 || !s2) - return false; - if (s1->line() != s2->line()) - return false; - if (s1->column() != s2->column()) - return false; - - return QByteArray(s1->fileName()) == QByteArray(s2->fileName()); -} - FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) const { SubstitutionEnvironment *env = rewrite->env; @@ -416,26 +404,7 @@ FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) co const QList<LookupItem> results = context.lookup(name, scope); foreach (const LookupItem &r, results) { if (Symbol *d = r.declaration()) { - const Name *n = 0; - QList<const Name *> names = LookupContext::fullyQualifiedName(d); - for (int i = names.size() - 1; i >= 0; --i) { - if (! n) - n = names.at(i); - else - n = control->qualifiedNameId(names.at(i), n); - if (_target) { - // minimize the qualifications - const QList<LookupItem> tresults = _target->lookup(n); - foreach (const LookupItem &tr, tresults) { - if (symbolIdentical(tr.declaration(), d)) { - i = 0; // break outer - break; - } - } - } - } - - return control->namedType(n); + return control->namedType(LookupContext::minimalName(d, _target, control)); } return r.type(); diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index f4089d1bec..88110c5da2 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -157,50 +157,40 @@ QList<const Name *> LookupContext::path(Symbol *symbol) return names; } - -const Name *LookupContext::minimalName(const Name *name, - Scope *scope, - ClassOrNamespace *target) const +static bool symbolIdentical(Symbol *s1, Symbol *s2) { - Q_UNUSED(name); - Q_UNUSED(scope); - Q_UNUSED(target); - - qWarning() << "TODO:" << Q_FUNC_INFO; - return name; + if (!s1 || !s2) + return false; + if (s1->line() != s2->line()) + return false; + if (s1->column() != s2->column()) + return false; -#if 0 - Q_ASSERT(name); - Q_ASSERT(source); - Q_ASSERT(target); + return QByteArray(s1->fileName()) == QByteArray(s2->fileName()); +} - QList<Symbol *> symbols = lookup(name, source); - if (symbols.isEmpty()) - return 0; +const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control) +{ + const Name *n = 0; + QList<const Name *> names = LookupContext::fullyQualifiedName(symbol); - Symbol *canonicalSymbol = symbols.first(); - std::vector<const Name *> fqNames = fullyQualifiedName(canonicalSymbol).toVector().toStdVector(); - if (const QualifiedNameId *qId = name->asQualifiedNameId()) - fqNames.push_back(qId->name()); - else - fqNames.push_back(name); - - const QualifiedNameId *lastWorking = 0; - for (unsigned i = 0; i < fqNames.size(); ++i) { - const QualifiedNameId *newName = control()->qualifiedNameId(&fqNames[i], - fqNames.size() - i); - QList<Symbol *> candidates = target->lookup(newName); - if (candidates.contains(canonicalSymbol)) - lastWorking = newName; + for (int i = names.size() - 1; i >= 0; --i) { + if (! n) + n = names.at(i); else - break; + n = control->qualifiedNameId(names.at(i), n); + + // once we're qualified enough to get the same symbol, break + if (target) { + const QList<LookupItem> tresults = target->lookup(n); + foreach (const LookupItem &tr, tresults) { + if (symbolIdentical(tr.declaration(), symbol)) + return n; + } + } } - if (lastWorking && lastWorking->nameCount() == 1) - return lastWorking->nameAt(0); - else - return lastWorking; -#endif + return n; } diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 578e19b094..2fa9655cd5 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -235,8 +235,7 @@ public: static QList<const Name *> fullyQualifiedName(Symbol *symbol); static QList<const Name *> path(Symbol *symbol); - const Name *minimalName(const Name *name, Scope *source, - ClassOrNamespace *target) const; + static const Name *minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control); private: // The current expression. diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp index fa5ef50eea..9d2ceb69f3 100644 --- a/src/libs/qmljs/qmljscodeformatter.cpp +++ b/src/libs/qmljs/qmljscodeformatter.cpp @@ -523,10 +523,10 @@ int CodeFormatter::indentForNewLineAfter(const QTextBlock &block) { restoreCurrentState(block); - int lexerState = loadLexerState(block); m_tokens.clear(); m_currentLine.clear(); - adjustIndent(m_tokens, lexerState, &m_indentDepth); + const int startLexerState = loadLexerState(block.previous()); + adjustIndent(m_tokens, startLexerState, &m_indentDepth); return m_indentDepth; } @@ -671,10 +671,11 @@ void CodeFormatter::leave(bool statementDone) void CodeFormatter::correctIndentation(const QTextBlock &block) { - const int lexerState = tokenizeBlock(block); + tokenizeBlock(block); Q_ASSERT(m_currentState.size() >= 1); - adjustIndent(m_tokens, lexerState, &m_indentDepth); + const int startLexerState = loadLexerState(block.previous()); + adjustIndent(m_tokens, startLexerState, &m_indentDepth); } bool CodeFormatter::tryInsideExpression(bool alsoExpression) @@ -1211,10 +1212,8 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd } } -void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerState, int *indentDepth) const +void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int startLexerState, int *indentDepth) const { - Q_UNUSED(lexerState) - State topState = state(); State previousState = state(1); @@ -1226,6 +1225,12 @@ void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerSta return; } } + // don't touch multi-line strings at all + if ((startLexerState & Scanner::MultiLineMask) == Scanner::MultiLineStringDQuote + || (startLexerState & Scanner::MultiLineMask) == Scanner::MultiLineStringSQuote) { + *indentDepth = -1; + return; + } const int kind = extendedTokenKind(tokenAt(0)); switch (kind) { diff --git a/src/libs/qmljs/qmljscodeformatter.h b/src/libs/qmljs/qmljscodeformatter.h index 7b5865f0e8..b3e2498d4d 100644 --- a/src/libs/qmljs/qmljscodeformatter.h +++ b/src/libs/qmljs/qmljscodeformatter.h @@ -71,7 +71,7 @@ public: protected: virtual void onEnter(int newState, int *indentDepth, int *savedIndentDepth) const = 0; - virtual void adjustIndent(const QList<Token> &tokens, int lexerState, int *indentDepth) const = 0; + virtual void adjustIndent(const QList<Token> &tokens, int startLexerState, int *indentDepth) const = 0; struct State; class QMLJS_EXPORT BlockData diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 3a1ff62e8c..8d52e137d4 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -337,6 +337,22 @@ const CppComponentValue *CppComponentValue::prototype() const return static_cast<const CppComponentValue *>(_prototype); } +/*! + \returns a list started by this object and followed by all its prototypes + + Prefer to use this over calling prototype() in a loop, as it avoids cycles. +*/ +QList<const CppComponentValue *> CppComponentValue::prototypes() const +{ + QList<const CppComponentValue *> protos; + for (const CppComponentValue *it = this; it; it = it->prototype()) { + if (protos.contains(it)) + break; + protos += it; + } + return protos; +} + const CppComponentValue *CppComponentValue::attachedType() const { return _attachedType; @@ -366,7 +382,7 @@ QString CppComponentValue::defaultPropertyName() const QString CppComponentValue::propertyType(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -378,7 +394,7 @@ QString CppComponentValue::propertyType(const QString &propertyName) const bool CppComponentValue::isListProperty(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -390,7 +406,7 @@ bool CppComponentValue::isListProperty(const QString &propertyName) const FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppComponentValue **foundInScope) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; const int index = iter->enumeratorIndex(typeName); if (index != -1) { @@ -406,7 +422,7 @@ FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppCompon const QmlEnumValue *CppComponentValue::getEnumValue(const QString &typeName, const CppComponentValue **foundInScope) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { if (const QmlEnumValue *e = it->_enums.value(typeName)) { if (foundInScope) *foundInScope = it; @@ -455,7 +471,7 @@ const ObjectValue *CppComponentValue::signalScope(const QString &signalName) con bool CppComponentValue::isWritable(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -467,7 +483,7 @@ bool CppComponentValue::isWritable(const QString &propertyName) const bool CppComponentValue::isPointer(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -487,7 +503,7 @@ bool CppComponentValue::hasLocalProperty(const QString &typeName) const bool CppComponentValue::hasProperty(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -499,7 +515,7 @@ bool CppComponentValue::hasProperty(const QString &propertyName) const bool CppComponentValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; if (iter == base) return true; diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h index 7b95f2d31f..50da224cc7 100644 --- a/src/libs/qmljs/qmljsinterpreter.h +++ b/src/libs/qmljs/qmljsinterpreter.h @@ -499,6 +499,7 @@ public: using ObjectValue::prototype; const CppComponentValue *prototype() const; + QList<const CppComponentValue *> prototypes() const; const CppComponentValue *attachedType() const; void setAttachedType(CppComponentValue *value); diff --git a/src/libs/utils/filesearch.cpp b/src/libs/utils/filesearch.cpp index 98386def46..d43fe8d0a1 100644 --- a/src/libs/utils/filesearch.cpp +++ b/src/libs/utils/filesearch.cpp @@ -70,6 +70,15 @@ static inline QString msgFound(const QString &searchTerm, int numMatches, int nu namespace { +const int MAX_LINE_SIZE = 400; + +QString clippedText(const QString &text, int maxLength) +{ + if (text.length() > maxLength) + return text.left(maxLength) + QChar(0x2026); // '...' + return text; +} + void runFileSearch(QFutureInterface<FileSearchResultList> &future, QString searchTerm, FileIterator *files, @@ -123,6 +132,7 @@ void runFileSearch(QFutureInterface<FileSearchResultList> &future, while (!stream.atEnd()) { ++lineNr; const QString chunk = stream.readLine(); + const QString resultItemText = clippedText(chunk, MAX_LINE_SIZE); int chunkLength = chunk.length(); const QChar *chunkPtr = chunk.constData(); const QChar *chunkEnd = chunkPtr + chunkLength - 1; @@ -166,7 +176,7 @@ void runFileSearch(QFutureInterface<FileSearchResultList> &future, } } if (equal) { - results << FileSearchResult(s, lineNr, chunk, + results << FileSearchResult(s, lineNr, resultItemText, regionPtr - chunkPtr, termLength, QStringList()); ++numMatches; @@ -244,10 +254,11 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResultList> &future, QString line; while (!stream.atEnd()) { line = stream.readLine(); + const QString resultItemText = clippedText(line, MAX_LINE_SIZE); int lengthOfLine = line.size(); int pos = 0; while ((pos = expression.indexIn(line, pos)) != -1) { - results << FileSearchResult(s, lineNr, line, + results << FileSearchResult(s, lineNr, resultItemText, pos, expression.matchedLength(), expression.capturedTexts()); ++numMatches; diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 485ce0652d..dac370a6e6 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -251,7 +251,7 @@ QStringList CMakeRunConfiguration::dumperLibraryLocations() const { QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(environment()); QString qtInstallData = ProjectExplorer::DebuggingHelperLibrary::qtInstallDataDir(qmakePath); - return ProjectExplorer::DebuggingHelperLibrary::locationsByInstallData(qtInstallData); + return ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData); } Utils::Environment CMakeRunConfiguration::baseEnvironment() const diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp index 5ea7e3e696..6847a4d672 100644 --- a/src/plugins/cppeditor/cppinsertdecldef.cpp +++ b/src/plugins/cppeditor/cppinsertdecldef.cpp @@ -261,13 +261,7 @@ public: FullySpecifiedType tn = rewriteType(m_decl->type(), &env, control); // rewrite the function name - QString name; - const FullySpecifiedType nametype = rewriteType(control->namedType(m_decl->name()), &env, control); - if (NamedType *nt = nametype.type()->asNamedType()) { - name = oo(nt->name()); - } else { - name = oo(LookupContext::fullyQualifiedName(m_decl)); - } + QString name = oo(LookupContext::minimalName(m_decl, targetCoN, control)); QString defText = oo.prettyType(tn, name) + "\n{\n}"; diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 4d69e61631..f4c03fe84a 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -1050,6 +1050,7 @@ StartRemoteEngineDialog::StartRemoteEngineDialog(QWidget *parent) : StartRemoteEngineDialog::~StartRemoteEngineDialog() { + delete m_ui; } QString StartRemoteEngineDialog::host() const diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index dc0bd2c356..a6270314f1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2544,7 +2544,7 @@ void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int tim void DebuggerPluginPrivate::showQtDumperLibraryWarning(const QString &details) { QMessageBox dialog(mainWindow()); - QPushButton *qtPref = dialog.addButton(tr("Open Qt4 Options"), + QPushButton *qtPref = dialog.addButton(tr("Open Qt Options"), QMessageBox::ActionRole); QPushButton *helperOff = dialog.addButton(tr("Turn off Helper Usage"), QMessageBox::ActionRole); diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp index 900cc28e0b..b089b2aa25 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -61,6 +61,7 @@ ModulesWindow::ModulesWindow(QWidget *parent) : BaseWindow(parent) { setWindowTitle(tr("Modules")); + setSortingEnabled(true); setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustModulesColumnWidths)); connect(this, SIGNAL(activated(QModelIndex)), diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp index ffbc5abf69..fc3a67436e 100644 --- a/src/plugins/debugger/sourcefileswindow.cpp +++ b/src/plugins/debugger/sourcefileswindow.cpp @@ -60,6 +60,7 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent) : BaseWindow(parent) { setWindowTitle(tr("Source Files")); + setSortingEnabled(true); } void SourceFilesWindow::rowActivated(const QModelIndex &index) diff --git a/src/plugins/debugger/threadswindow.cpp b/src/plugins/debugger/threadswindow.cpp index 55924f6ea0..7be6b8b14b 100644 --- a/src/plugins/debugger/threadswindow.cpp +++ b/src/plugins/debugger/threadswindow.cpp @@ -52,6 +52,7 @@ ThreadsWindow::ThreadsWindow(QWidget *parent) : BaseWindow(parent) { setWindowTitle(tr("Thread")); + setSortingEnabled(true); setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustThreadsColumnWidths)); setObjectName(QLatin1String("ThreadsWindow")); } diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 2be355a9b3..fc3159eba5 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -3296,6 +3296,7 @@ bool FakeVimHandler::Private::handleExSubstituteCommand(const ExCommand &cmd) i += caps.at(0).size(); } } + repl.replace("\\&", "&"); text = text.left(pos) + repl + text.mid(pos + matched.size()); pos += repl.size(); if (!global) diff --git a/src/plugins/find/searchresulttreeitemdelegate.cpp b/src/plugins/find/searchresulttreeitemdelegate.cpp index 4e9780c841..7560f1d8fa 100644 --- a/src/plugins/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/find/searchresulttreeitemdelegate.cpp @@ -162,8 +162,10 @@ void SearchResultTreeItemDelegate::drawMarker(QPainter *painter, const QModelInd { int searchTermStart = index.model()->data(index, ItemDataRoles::SearchTermStartRole).toInt(); int searchTermLength = index.model()->data(index, ItemDataRoles::SearchTermLengthRole).toInt(); - if (searchTermStart < 0 || searchTermLength < 1) + if (searchTermStart < 0 || searchTermStart >= text.length() || searchTermLength < 1) return; + // clip searchTermLength to end of line + searchTermLength = qMin(searchTermLength, text.length() - searchTermStart); const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; int searchTermStartPixels = painter->fontMetrics().width(text.left(searchTermStart)); int searchTermLengthPixels = painter->fontMetrics().width(text.mid(searchTermStart, searchTermLength)); diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index 9e3aa9c962..45c7b692ee 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -74,6 +74,7 @@ namespace Internal { QStackedWidget *m_widget; QList<SearchResult *> m_searchResults; int m_currentIndex; + QFont m_font; public slots: void setCurrentIndex(int index); @@ -317,6 +318,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label, d->m_searchResultWidgets.prepend(widget); d->m_widget->insertWidget(1, widget); connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged())); + widget->setTextEditorFont(d->m_font); widget->setShowReplaceUI(searchOrSearchAndReplace != SearchOnly); widget->setAutoExpandResults(d->m_expandCollapseAction->isChecked()); widget->setInfo(label, toolTip, searchTerm); @@ -390,6 +392,7 @@ void SearchResultWindow::setFocus() */ void SearchResultWindow::setTextEditorFont(const QFont &font) { + d->m_font = font; foreach (Internal::SearchResultWidget *widget, d->m_searchResultWidgets) widget->setTextEditorFont(font); } diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index 1c388305f7..06d02cb500 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -60,6 +60,11 @@ RemoteAdditionDialog::RemoteAdditionDialog(QWidget *parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); } +RemoteAdditionDialog::~RemoteAdditionDialog() +{ + delete m_ui; +} + QString RemoteAdditionDialog::remoteName() const { return m_ui->nameEdit->text(); diff --git a/src/plugins/git/remotedialog.h b/src/plugins/git/remotedialog.h index 4458bf544c..12e367b9bc 100644 --- a/src/plugins/git/remotedialog.h +++ b/src/plugins/git/remotedialog.h @@ -56,6 +56,7 @@ class RemoteAdditionDialog : public QDialog public: explicit RemoteAdditionDialog(QWidget *parent = 0); + ~RemoteAdditionDialog(); QString remoteName() const; QString remoteUrl() const; diff --git a/src/plugins/madde/maemopackagecreationstep.cpp b/src/plugins/madde/maemopackagecreationstep.cpp index 8542aa9c4f..ddde4c8fce 100644 --- a/src/plugins/madde/maemopackagecreationstep.cpp +++ b/src/plugins/madde/maemopackagecreationstep.cpp @@ -339,11 +339,8 @@ bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc, } } - if (inSourceBuild) { - buildProc->start(packagingCommand(m_maddeRoot, QLatin1String("dh_clean"))); - buildProc->waitForFinished(); - buildProc->terminate(); - } + if (inSourceBuild) + callPackagingCommand(buildProc, QStringList() << QLatin1String("dh_clean")); return true; } diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index c4b7a277b8..0e669458ea 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -51,6 +51,7 @@ #include <utils/qtcassert.h> #include <QtCore/QDir> +#include <QtCore/QTime> #include <QtCore/QTimer> #include <QtCore/QMetaType> #include <QtCore/QList> @@ -88,6 +89,8 @@ struct BuildManagerPrivate { QString m_currentConfiguration; // used to decide if we are building a project to decide when to emit buildStateChanged(Project *) QHash<Project *, int> m_activeBuildSteps; + QHash<Target *, int> m_activeBuildStepsPerTarget; + QHash<ProjectConfiguration *, int> m_activeBuildStepsPerProjectConfiguration; Project *m_previousBuildStepProject; // is set to true while canceling, so that nextBuildStep knows that the BuildStep finished because of canceling bool m_canceling; @@ -228,7 +231,7 @@ void BuildManager::cancel() QTimer::singleShot(0, this, SLOT(emitCancelMessage())); disconnectOutput(d->m_currentBuildStep); - decrementActiveBuildSteps(d->m_currentBuildStep->project()); + decrementActiveBuildSteps(d->m_currentBuildStep); d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Build/Deployment canceled")); //TODO NBS fix in qtconcurrent clearBuildQueue(); @@ -261,7 +264,7 @@ void BuildManager::emitCancelMessage() void BuildManager::clearBuildQueue() { foreach (BuildStep *bs, d->m_buildQueue) { - decrementActiveBuildSteps(bs->project()); + decrementActiveBuildSteps(bs); disconnectOutput(bs); } @@ -358,7 +361,12 @@ void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task) void BuildManager::addToOutputWindow(const QString &string, BuildStep::OutputFormat format, BuildStep::OutputNewlineSetting newLineSetting) { - QString stringToWrite = string; + QString stringToWrite; + if (format == BuildStep::MessageOutput || format == BuildStep::ErrorMessageOutput) { + stringToWrite = QTime::currentTime().toString(); + stringToWrite += QLatin1String(": "); + } + stringToWrite += string; if (newLineSetting == BuildStep::DoAppendNewline) stringToWrite += QLatin1Char('\n'); d->m_outputWindow->appendText(stringToWrite, format); @@ -387,7 +395,7 @@ void BuildManager::nextBuildQueue() disconnectOutput(d->m_currentBuildStep); ++d->m_progress; d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, msgProgress(d->m_progress, d->m_maxProgress)); - decrementActiveBuildSteps(d->m_currentBuildStep->project()); + decrementActiveBuildSteps(d->m_currentBuildStep); bool result = d->m_watcher.result(); if (!result) { @@ -496,7 +504,7 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps) for (i = 0; i < count; ++i) { ++d->m_maxProgress; d->m_buildQueue.append(steps.at(i)); - incrementActiveBuildSteps(steps.at(i)->target()->project()); + incrementActiveBuildSteps(steps.at(i)); } return true; } @@ -536,14 +544,29 @@ void BuildManager::appendStep(BuildStep *step) startBuildQueue(); } +template <class T> +int count(const QHash<T *, int> &hash, T *key) +{ + typename QHash<T *, int>::const_iterator it = hash.find(key); + typename QHash<T *, int>::const_iterator end = hash.end(); + if (it != end) + return *it; + return 0; +} + bool BuildManager::isBuilding(Project *pro) { - QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro); - QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end(); - if (it == end || *it == 0) - return false; - else - return true; + return count(d->m_activeBuildSteps, pro) > 0; +} + +bool BuildManager::isBuilding(Target *t) +{ + return count(d->m_activeBuildStepsPerTarget, t) > 0; +} + +bool BuildManager::isBuilding(ProjectConfiguration *p) +{ + return count(d->m_activeBuildStepsPerProjectConfiguration, p) > 0; } bool BuildManager::isBuilding(BuildStep *step) @@ -551,33 +574,51 @@ bool BuildManager::isBuilding(BuildStep *step) return (d->m_currentBuildStep == step) || d->m_buildQueue.contains(step); } -void BuildManager::incrementActiveBuildSteps(Project *pro) +template <class T> bool increment(QHash<T *, int> &hash, T *key) { - QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro); - QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end(); + typename QHash<T *, int>::iterator it = hash.find(key); + typename QHash<T *, int>::iterator end = hash.end(); if (it == end) { - d->m_activeBuildSteps.insert(pro, 1); - emit buildStateChanged(pro); + hash.insert(key, 1); + return true; } else if (*it == 0) { ++*it; - emit buildStateChanged(pro); + return true; } else { ++*it; } + return false; } -void BuildManager::decrementActiveBuildSteps(Project *pro) +template <class T> bool decrement(QHash<T *, int> &hash, T *key) { - QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro); - QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end(); + typename QHash<T *, int>::iterator it = hash.find(key); + typename QHash<T *, int>::iterator end = hash.end(); if (it == end) { - Q_ASSERT(false && "BuildManager d->m_activeBuildSteps says project is not building, but apparently a build step was still in the queue."); + // Can't happen } else if (*it == 1) { --*it; - emit buildStateChanged(pro); + return true; } else { --*it; } + return false; +} + +void BuildManager::incrementActiveBuildSteps(BuildStep *bs) +{ + increment<ProjectConfiguration>(d->m_activeBuildStepsPerProjectConfiguration, bs->projectConfiguration()); + increment<Target>(d->m_activeBuildStepsPerTarget, bs->target()); + if (increment<Project>(d->m_activeBuildSteps, bs->project())) + emit buildStateChanged(bs->project()); +} + +void BuildManager::decrementActiveBuildSteps(BuildStep *bs) +{ + decrement<ProjectConfiguration>(d->m_activeBuildStepsPerProjectConfiguration, bs->projectConfiguration()); + decrement<Target>(d->m_activeBuildStepsPerTarget, bs->target()); + if (decrement<Project>(d->m_activeBuildSteps, bs->project())) + emit buildStateChanged(bs->project()); } void BuildManager::disconnectOutput(BuildStep *bs) diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index 4d4c7326d4..053b6091b6 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -63,6 +63,8 @@ public: bool buildLists(QList<BuildStepList *> bsls); bool buildList(BuildStepList *bsl); bool isBuilding(Project *p); + bool isBuilding(Target *t); + bool isBuilding(ProjectConfiguration *p); bool isBuilding(BuildStep *step); // Append any build step to the list of build steps (currently only used to add the QMakeStep) @@ -104,8 +106,8 @@ private: void nextStep(); void clearBuildQueue(); bool buildQueueAppend(QList<BuildStep *> steps); - void incrementActiveBuildSteps(Project *pro); - void decrementActiveBuildSteps(Project *pro); + void incrementActiveBuildSteps(BuildStep *bs); + void decrementActiveBuildSteps(BuildStep *bs); void disconnectOutput(BuildStep *bs); BuildManagerPrivate *d; diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index 74db6361c5..917033174f 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -42,6 +42,8 @@ #include <coreplugin/coreconstants.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/buildmanager.h> #include <QtCore/QMargins> #include <QtCore/QTimer> @@ -370,6 +372,29 @@ void BuildSettingsWidget::deleteConfiguration(BuildConfiguration *deleteConfigur m_target->buildConfigurations().size() <= 1) return; + ProjectExplorer::BuildManager *bm = ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(deleteConfiguration)) { + QMessageBox box; + QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Build Configuration"), QMessageBox::AcceptRole); + QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole); + box.setDefaultButton(cancelClose); + box.setWindowTitle(tr("Remove Build Configuration %1?").arg(deleteConfiguration->displayName())); + box.setText(tr("The build configuration <b>%1</b> is currently being built.").arg(deleteConfiguration->displayName())); + box.setInformativeText(tr("Do you want to cancel the build process and remove the Build Configuration anyway?")); + box.exec(); + if (box.clickedButton() != closeAnyway) + return; + bm->cancel(); + } else { + QMessageBox msgBox(QMessageBox::Question, tr("Remove Build Configuration?"), + tr("Do you really want to delete build configuration <b>%1</b>?").arg(deleteConfiguration->displayName()), + QMessageBox::Yes|QMessageBox::No, this); + msgBox.setDefaultButton(QMessageBox::No); + msgBox.setEscapeButton(QMessageBox::No); + if (msgBox.exec() == QMessageBox::No) + return; + } + m_target->removeBuildConfiguration(deleteConfiguration); updateBuildSettings(); diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 6316be37b3..c4df1aeb98 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -150,6 +150,11 @@ DeployConfiguration *BuildStep::deployConfiguration() const return qobject_cast<DeployConfiguration *>(parent()->parent()); } +ProjectConfiguration *BuildStep::projectConfiguration() const +{ + return static_cast<ProjectConfiguration *>(parent()->parent()); +} + Target *BuildStep::target() const { return qobject_cast<Target *>(parent()->parent()->parent()); diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index f253534ffa..b43ef00510 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -72,12 +72,13 @@ public: BuildConfiguration *buildConfiguration() const; DeployConfiguration *deployConfiguration() const; + ProjectConfiguration *projectConfiguration() const; Target *target() const; + Project *project() const; enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput }; enum OutputNewlineSetting { DoAppendNewline, DontAppendNewline }; - Project *project() const; signals: void addTask(const ProjectExplorer::Task &task); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 345f3ffa7c..a470539075 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -332,7 +332,7 @@ QStringList CustomExecutableRunConfiguration::dumperLibraryLocations() const { QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(environment()); QString qtInstallData = ProjectExplorer::DebuggingHelperLibrary::qtInstallDataDir(qmakePath); - return ProjectExplorer::DebuggingHelperLibrary::locationsByInstallData(qtInstallData); + return ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData); } ProjectExplorer::Abi CustomExecutableRunConfiguration::abi() const diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp index f7cd47b072..7b0561145c 100644 --- a/src/plugins/projectexplorer/debugginghelper.cpp +++ b/src/plugins/projectexplorer/debugginghelper.cpp @@ -68,18 +68,6 @@ QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QStr return directories; } -QStringList DebuggingHelperLibrary::locationsByInstallData(const QString &qtInstallData) -{ - QStringList result; - QFileInfo fileInfo; - const QStringList binFilenames = validBinaryFilenames(); - foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData)) { - if (getHelperFileInfoFor(binFilenames, directory, &fileInfo)) - result << fileInfo.filePath(); - } - return result; -} - static QString sourcePath() { return Core::ICore::instance()->resourcePath() + QLatin1String("/dumper/"); diff --git a/src/plugins/projectexplorer/debugginghelper.h b/src/plugins/projectexplorer/debugginghelper.h index 2f5f764978..94edb1d4e5 100644 --- a/src/plugins/projectexplorer/debugginghelper.h +++ b/src/plugins/projectexplorer/debugginghelper.h @@ -47,7 +47,7 @@ class PROJECTEXPLORER_EXPORT DebuggingHelperLibrary : public Utils::BuildableHel { public: static QString debuggingHelperLibraryByInstallData(const QString &qtInstallData); - static QStringList locationsByInstallData(const QString &qtInstallData); + static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData); // Build the helpers and return the output log/errormessage. static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage); @@ -55,8 +55,6 @@ public: // Copy the source files to a target location and return the chosen target location. static QString copy(const QString &qtInstallData, QString *errorMessage); -private: - static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData); }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 1b8364bec1..01f5df32b9 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -582,7 +582,13 @@ QList<ToolChain *> Internal::GccToolChainFactory::autoDetect() // Fixme Prefer lldb once it is implemented: debuggers.push_back(QLatin1String("lldb")); #endif debuggers.push_back(QLatin1String("gdb")); - return autoDetectToolchains(QLatin1String("g++"), debuggers, Abi::hostAbi()); + QList<ToolChain *> tcs = autoDetectToolchains(QLatin1String("g++"), debuggers, Abi::hostAbi()); + + // Old mac compilers needed to support macx-gccXY mkspecs: + tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), debuggers, Abi::hostAbi())); + tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), debuggers, Abi::hostAbi())); + + return tcs; } // Used by the ToolChainManager to restore user-generated tool chains diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 7677381796..28f42d6cdc 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -43,6 +43,7 @@ #include <coreplugin/ifile.h> #include <coreplugin/icontext.h> #include <extensionsystem/pluginmanager.h> +#include <projectexplorer/buildmanager.h> #include <limits> #include <utils/qtcassert.h> @@ -166,9 +167,15 @@ void Project::addTarget(Target *t) setActiveTarget(t); } -void Project::removeTarget(Target *target) +bool Project::removeTarget(Target *target) { - QTC_ASSERT(target && d->m_targets.contains(target), return); + if (!target || !d->m_targets.contains(target)) + return false; + + ProjectExplorer::BuildManager *bm = + ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(target)) + return false; emit aboutToRemoveTarget(target); diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index cf3d67f354..b87d96f6f1 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -83,7 +83,7 @@ public: // Target: void addTarget(Target *target); - void removeTarget(Target *target); + bool removeTarget(Target *target); QList<Target *> targets() const; // Note: activeTarget can be 0 (if no targets are defined). diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 374b13c5bd..3b966f0159 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1039,6 +1039,20 @@ void ProjectExplorerPlugin::unloadProject() if (debug) qDebug() << "ProjectExplorerPlugin::unloadProject"; + if (buildManager()->isBuilding(d->m_currentProject)) { + QMessageBox box; + QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Unload"), QMessageBox::AcceptRole); + QPushButton *cancelClose = box.addButton(tr("Do Not Unload"), QMessageBox::RejectRole); + box.setDefaultButton(cancelClose); + box.setWindowTitle(tr("Unload Project %1?").arg(d->m_currentProject->displayName())); + box.setText(tr("The project %1 is currently being built.").arg(d->m_currentProject->displayName())); + box.setInformativeText(tr("Do you want to cancel the build process and unload the project anyway?")); + box.exec(); + if (box.clickedButton() != closeAnyway) + return; + buildManager()->cancel(); + } + Core::IFile *fi = d->m_currentProject->file(); if (!fi || fi->fileName().isEmpty()) //nothing to save? diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.cpp b/src/plugins/projectexplorer/runsettingspropertiespage.cpp index e1016ca460..e0497ca72e 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/runsettingspropertiespage.cpp @@ -42,6 +42,8 @@ #include <coreplugin/coreconstants.h> #include <extensionsystem/pluginmanager.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/buildmanager.h> #include <utils/qtcassert.h> #include <QtCore/QPair> @@ -389,15 +391,31 @@ void RunSettingsWidget::addDeployConfiguration() void RunSettingsWidget::removeDeployConfiguration() { DeployConfiguration *dc = m_target->activeDeployConfiguration(); - QMessageBox msgBox(QMessageBox::Question, tr("Remove Deploy Configuration?"), - tr("Do you really want to delete deploy configuration <b>%1</b>?").arg(dc->displayName()), - QMessageBox::Yes|QMessageBox::No, this); - msgBox.setDefaultButton(QMessageBox::No); - msgBox.setEscapeButton(QMessageBox::No); - if (msgBox.exec() == QMessageBox::No) - return; + ProjectExplorer::BuildManager *bm = ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(dc)) { + QMessageBox box; + QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Deploy Configuration"), QMessageBox::AcceptRole); + QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole); + box.setDefaultButton(cancelClose); + box.setWindowTitle(tr("Remove Deploy Configuration %1?").arg(dc->displayName())); + box.setText(tr("The deploy configuration <b>%1</b> is currently being built.").arg(dc->displayName())); + box.setInformativeText(tr("Do you want to cancel the build process and remove the Deploy Configuration anyway?")); + box.exec(); + if (box.clickedButton() != closeAnyway) + return; + bm->cancel(); + } else { + QMessageBox msgBox(QMessageBox::Question, tr("Remove Deploy Configuration?"), + tr("Do you really want to delete deploy configuration <b>%1</b>?").arg(dc->displayName()), + QMessageBox::Yes|QMessageBox::No, this); + msgBox.setDefaultButton(QMessageBox::No); + msgBox.setEscapeButton(QMessageBox::No); + if (msgBox.exec() == QMessageBox::No) + return; + } m_target->removeDeployConfiguration(dc); + m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1); } diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index ec5c57b39d..54f194606f 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -42,6 +42,8 @@ #include <limits> #include <extensionsystem/pluginmanager.h> +#include <projectexplorer/buildmanager.h> +#include <projectexplorer/projectexplorer.h> #include <utils/qtcassert.h> #include <QtGui/QIcon> @@ -174,11 +176,16 @@ void Target::addBuildConfiguration(BuildConfiguration *configuration) setActiveBuildConfiguration(configuration); } -void Target::removeBuildConfiguration(BuildConfiguration *configuration) +bool Target::removeBuildConfiguration(BuildConfiguration *configuration) { //todo: this might be error prone if (!d->m_buildConfigurations.contains(configuration)) - return; + return false; + + ProjectExplorer::BuildManager *bm = + ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(configuration)) + return false; d->m_buildConfigurations.removeOne(configuration); @@ -192,6 +199,7 @@ void Target::removeBuildConfiguration(BuildConfiguration *configuration) } delete configuration; + return true; } QList<BuildConfiguration *> Target::buildConfigurations() const @@ -242,11 +250,16 @@ void Target::addDeployConfiguration(DeployConfiguration *dc) Q_ASSERT(activeDeployConfiguration()); } -void Target::removeDeployConfiguration(DeployConfiguration *dc) +bool Target::removeDeployConfiguration(DeployConfiguration *dc) { //todo: this might be error prone if (!d->m_deployConfigurations.contains(dc)) - return; + return false; + + ProjectExplorer::BuildManager *bm = + ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(dc)) + return false; d->m_deployConfigurations.removeOne(dc); @@ -260,6 +273,7 @@ void Target::removeDeployConfiguration(DeployConfiguration *dc) } delete dc; + return true; } QList<DeployConfiguration *> Target::deployConfigurations() const diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index 1a2f3bf88a..f5e10d0bd2 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -67,7 +67,7 @@ public: // Build configuration void addBuildConfiguration(BuildConfiguration *configuration); - void removeBuildConfiguration(BuildConfiguration *configuration); + bool removeBuildConfiguration(BuildConfiguration *configuration); QList<BuildConfiguration *> buildConfigurations() const; BuildConfiguration *activeBuildConfiguration() const; @@ -77,7 +77,7 @@ public: // DeployConfiguration void addDeployConfiguration(DeployConfiguration *dc); - void removeDeployConfiguration(DeployConfiguration *dc); + bool removeDeployConfiguration(DeployConfiguration *dc); QList<DeployConfiguration *> deployConfigurations() const; DeployConfiguration *activeDeployConfiguration() const; diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 3a68ffa1c2..d7e2fc63e6 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -40,6 +40,8 @@ #include "targetsettingswidget.h" #include <extensionsystem/pluginmanager.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/buildmanager.h> #include <QtCore/QCoreApplication> #include <QtGui/QLabel> @@ -47,6 +49,7 @@ #include <QtGui/QMessageBox> #include <QtGui/QVBoxLayout> #include <QtGui/QStackedWidget> +#include <QtGui/QPushButton> using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; @@ -230,13 +233,33 @@ void TargetSettingsPanelWidget::removeTarget() { int index = m_selector->currentIndex(); Target *t = m_targets.at(index); - int ret = QMessageBox::warning(this, tr("Qt Creator"), - tr("Do you really want to remove the\n" - "\"%1\" target?").arg(t->displayName()), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (ret == QMessageBox::Yes) - m_project->removeTarget(t); + + ProjectExplorer::BuildManager *bm = ProjectExplorerPlugin::instance()->buildManager(); + if (bm->isBuilding(t)) { + QMessageBox box; + QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Target"), QMessageBox::AcceptRole); + QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole); + box.setDefaultButton(cancelClose); + box.setWindowTitle(tr("Remove Target %1?").arg(t->displayName())); + box.setText(tr("The target <b>%1</b> is currently being built.").arg(t->displayName())); + box.setInformativeText(tr("Do you want to cancel the build process and remove the Target anyway?")); + box.exec(); + if (box.clickedButton() != closeAnyway) + return; + bm->cancel(); + } else { + // We don't show the generic message box on removing the target, if we showed the still building one + int ret = QMessageBox::warning(this, tr("Qt Creator"), + tr("Do you really want to remove the\n" + "\"%1\" target?").arg(t->displayName()), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (ret != QMessageBox::Yes) + return; + } + + m_project->removeTarget(t); + } void TargetSettingsPanelWidget::targetAdded(ProjectExplorer::Target *target) diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index a24210b0d1..57a23677fa 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -448,9 +448,10 @@ void DesignDocumentController::changeCurrentModelTo(const ModelNode &node) if (Internal::DesignModeWidget::instance()->currentDesignDocumentController() != this) return; DesignDocumentControllerPrivate::clearCrumblePath = false; - while (!d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isRootNode()) + while (d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isValid() && + !d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isRootNode()) d->formEditorView->crumblePath()->popElement(); - if (node.isRootNode()) + if (node.isRootNode() && d->formEditorView->crumblePath()->dataForLastIndex().isValid()) d->formEditorView->crumblePath()->popElement(); changeToSubComponent(node); DesignDocumentControllerPrivate::clearCrumblePath = true; @@ -537,8 +538,10 @@ void DesignDocumentController::goIntoComponent() if (d->formEditorView) selectedNodes = d->formEditorView->selectedModelNodes(); + DesignDocumentControllerPrivate::clearCrumblePath = false; if (selectedNodes.count() == 1) ModelNodeAction::goIntoComponent(selectedNodes.first()); + DesignDocumentControllerPrivate::clearCrumblePath = true; } void DesignDocumentController::loadCurrentModel() diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index 5945e0d23c..d7ca6d6bb3 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -53,37 +53,6 @@ #include <QtGui/QPushButton> #include <QtGui/QMainWindow> -namespace { - const char * const QMLDESIGNER_INFO_BAR = "QmlJSEditor.QmlDesignerInfoBar"; - const char * const KEY_QMLGROUP = "QML"; - const char * const KEY_NAGABOUTDESIGNER = "AskAboutVisualDesigner"; - - bool isQmlDesignerExperimentallyDisabled() - { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - foreach (const ExtensionSystem::PluginSpec *spec, pm->plugins()) { - if (spec->name() == QLatin1String("QmlDesigner")) { - if (spec->isExperimental() && !spec->isEnabled()) - return true; - return false; - } - } - return false; - } - - bool isNaggingAboutExperimentalDesignerEnabled() - { - if (!isQmlDesignerExperimentallyDisabled()) { - return false; - } - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(QLatin1String(KEY_QMLGROUP)); - bool nag = settings->value(QLatin1String(KEY_NAGABOUTDESIGNER), true).toBool(); - settings->endGroup(); - return nag; - } -} - using namespace QmlJSEditor; using namespace QmlJSEditor::Internal; using namespace QmlJSEditor::Constants; @@ -123,13 +92,6 @@ Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) { QmlJSEditor::QmlJSTextEditorWidget *rc = new QmlJSEditor::QmlJSTextEditorWidget(parent); QmlJSEditorPlugin::instance()->initializeEditor(rc); - if (isNaggingAboutExperimentalDesignerEnabled()) { - Core::InfoBarEntry info(QMLDESIGNER_INFO_BAR, - tr("Do you want to enable the experimental Qt Quick Designer?")); - info.setCustomButtonInfo(tr("Enable Qt Quick Designer"), this, SLOT(activateQmlDesigner())); - info.setCancelButtonInfo(this, SLOT(neverAskAgainAboutQmlDesigner())); - rc->file()->infoBar()->addInfo(info); - } return rc->editor(); } @@ -137,50 +99,3 @@ QStringList QmlJSEditorFactory::mimeTypes() const { return m_mimeTypes; } - -void QmlJSEditorFactory::activateQmlDesigner() -{ - QString menu; -#ifdef Q_WS_MAC - menu = tr("Qt Creator -> About Plugins..."); -#else - menu = tr("Help -> About Plugins..."); -#endif - QMessageBox message(Core::ICore::instance()->mainWindow()); - message.setWindowTitle(tr("Enable experimental Qt Quick Designer?")); - message.setText(tr("Do you want to enable the experimental Qt Quick Designer? " - "After enabling it, you can access the visual design capabilities by switching to Design Mode. " - "This can affect the overall stability of Qt Creator. " - "To disable Qt Quick Designer again, visit the menu '%1' and disable 'QmlDesigner'.").arg(menu)); - message.setIcon(QMessageBox::Question); - QPushButton *enable = message.addButton(tr("Enable Qt Quick Designer"), QMessageBox::AcceptRole); - message.addButton(tr("Cancel"), QMessageBox::RejectRole); - message.exec(); - if (message.clickedButton() == enable) { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - foreach (ExtensionSystem::PluginSpec *spec, pm->plugins()) { - if (spec->name() == QLatin1String("QmlDesigner")) { - spec->setEnabled(true); - pm->writeSettings(); - QMessageBox::information(Core::ICore::instance()->mainWindow(), tr("Please restart Qt Creator"), - tr("Please restart Qt Creator to make the change effective.")); - foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors()) - if (qobject_cast<QmlJSEditorEditable *>(editor)) - editor->file()->infoBar()->removeInfo(QMLDESIGNER_INFO_BAR); - neverAskAgainAboutQmlDesigner(); - return; - } - } - } -} - -void QmlJSEditorFactory::neverAskAgainAboutQmlDesigner() -{ - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(QLatin1String(KEY_QMLGROUP)); - settings->setValue(QLatin1String(KEY_NAGABOUTDESIGNER), false); - settings->endGroup(); - settings->sync(); - disconnect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), - this, SLOT(updateEditorInfoBar(Core::IEditor*))); -} diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h index ee9047e7a2..adbea9ab47 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.h +++ b/src/plugins/qmljseditor/qmljseditorfactory.h @@ -54,10 +54,6 @@ public: Core::IFile *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); -private slots: - void activateQmlDesigner(); - void neverAskAgainAboutQmlDesigner(); - private: QStringList m_mimeTypes; }; diff --git a/src/plugins/qmljstools/qmljsindenter.cpp b/src/plugins/qmljstools/qmljsindenter.cpp index 3c08e61490..69cf555c26 100644 --- a/src/plugins/qmljstools/qmljsindenter.cpp +++ b/src/plugins/qmljstools/qmljsindenter.cpp @@ -70,6 +70,8 @@ void Indenter::indentBlock(QTextDocument *doc, codeFormatter.updateStateUntil(block); const int depth = codeFormatter.indentFor(block); + if (depth == -1) + return; if (isElectricCharacter(typedChar)) { // only reindent the current line when typing electric characters if the diff --git a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp index d30f8fd932..c86f51a482 100644 --- a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp +++ b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp @@ -69,7 +69,9 @@ public: codeFormatter.updateStateUntil(block); do { - tabSettings.indentLine(block, codeFormatter.indentFor(block)); + const int depth = codeFormatter.indentFor(block); + if (depth != -1) + tabSettings.indentLine(block, depth); codeFormatter.updateLineStateChange(block); block = block.next(); } while (block.isValid() && block != end); diff --git a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp index 52083b859c..60468138dc 100644 --- a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp @@ -409,6 +409,11 @@ RvctToolChainConfigWidget::RvctToolChainConfigWidget(RvctToolChain *tc) : setFromToolChain(); } +RvctToolChainConfigWidget::~RvctToolChainConfigWidget() +{ + delete m_ui; +} + void RvctToolChainConfigWidget::apply() { RvctToolChain *tc = static_cast<RvctToolChain *>(toolChain()); diff --git a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h index 6580afe5d4..b134f721d4 100644 --- a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h +++ b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h @@ -143,6 +143,7 @@ class RvctToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidget public: RvctToolChainConfigWidget(RvctToolChain *tc); + ~RvctToolChainConfigWidget(); void apply(); void discard() { setFromToolChain(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp index 367d6f52c0..0d93c8a4ac 100644 --- a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp @@ -319,6 +319,11 @@ WinscwToolChainConfigWidget::WinscwToolChainConfigWidget(WinscwToolChain *tc) : discard(); } +WinscwToolChainConfigWidget::~WinscwToolChainConfigWidget() +{ + delete m_ui; +} + void WinscwToolChainConfigWidget::apply() { WinscwToolChain *tc = static_cast<WinscwToolChain *>(toolChain()); diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h index 198b36bacf..aa8c13818a 100644 --- a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h +++ b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h @@ -105,6 +105,7 @@ class WinscwToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidge public: WinscwToolChainConfigWidget(WinscwToolChain *); + ~WinscwToolChainConfigWidget(); void apply(); void discard(); diff --git a/src/plugins/qt4projectmanager/qt4target.cpp b/src/plugins/qt4projectmanager/qt4target.cpp index dcc9246ac8..f50145771c 100644 --- a/src/plugins/qt4projectmanager/qt4target.cpp +++ b/src/plugins/qt4projectmanager/qt4target.cpp @@ -296,6 +296,20 @@ QList<ProjectExplorer::ToolChain *> Qt4BaseTarget::possibleToolChains(ProjectExp return result; } +ProjectExplorer::ToolChain *Qt4BaseTarget::preferredToolChain(ProjectExplorer::BuildConfiguration *bc) const +{ + Qt4BuildConfiguration *qtBc = qobject_cast<Qt4BuildConfiguration *>(bc); + if (!qtBc || !qtBc->qtVersion()) + return Target::preferredToolChain(bc); + + QList<ProjectExplorer::ToolChain *> tcs = possibleToolChains(bc); + const QString mkspec = qtBc->qtVersion()->mkspec(); + foreach (ProjectExplorer::ToolChain *tc, tcs) + if (tc->mkspec() == mkspec) + return tc; + return tcs.isEmpty() ? 0 : tcs.at(0); +} + void Qt4BaseTarget::removeUnconfiguredCustomExectutableRunConfigurations() { if (runConfigurations().count()) { diff --git a/src/plugins/qt4projectmanager/qt4target.h b/src/plugins/qt4projectmanager/qt4target.h index e79af16fe6..9f25795aee 100644 --- a/src/plugins/qt4projectmanager/qt4target.h +++ b/src/plugins/qt4projectmanager/qt4target.h @@ -90,6 +90,7 @@ public: virtual QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Node *n) = 0; QList<ProjectExplorer::ToolChain *> possibleToolChains(ProjectExplorer::BuildConfiguration *bc) const; + ProjectExplorer::ToolChain *preferredToolChain(ProjectExplorer::BuildConfiguration *) const; signals: void buildDirectoryInitialized(); diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index bba4f9a0a7..9e1a1bb4cd 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -955,7 +955,7 @@ QStringList BaseQtVersion::debuggingHelperLibraryLocations() const QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); if (qtInstallData.isEmpty()) return QStringList(); - return ProjectExplorer::DebuggingHelperLibrary::locationsByInstallData(qtInstallData); + return ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData); } bool BaseQtVersion::supportsBinaryDebuggingHelper() const diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index ee143ea0b7..4a19d0d06d 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -275,6 +275,9 @@ QStringList ExamplesListModel::exampleSources() const // Try to get dir from first Qt Version QtVersionManager *versionManager = QtVersionManager::instance(); foreach (BaseQtVersion *version, versionManager->validVersions()) { + // There is no good solution for Qt 5 yet + if (version->qtVersion().majorVersion != 4) + continue; QDir examplesDir(version->examplesPath()); if (examplesDir.exists()) { diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 3b2b3ceb0f..f53131e767 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -5538,8 +5538,13 @@ void BaseTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) void BaseTextEditorWidget::setTabSettings(const TabSettings &ts) { d->m_document->setTabSettings(ts); - int charWidth = QFontMetrics(font()).width(QChar(' ')); - setTabStopWidth(charWidth * ts.m_tabSize); + + // Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it + // to be set as an int. A work around is to access directly the QTextOption. + qreal charWidth = QFontMetricsF(font()).width(QChar(' ')); + QTextOption option = document()->defaultTextOption(); + option.setTabStop(charWidth * ts.m_tabSize); + document()->setDefaultTextOption(option); } void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds) diff --git a/src/plugins/texteditor/codestyleeditor.cpp b/src/plugins/texteditor/codestyleeditor.cpp index bdad029b47..976eef229d 100644 --- a/src/plugins/texteditor/codestyleeditor.cpp +++ b/src/plugins/texteditor/codestyleeditor.cpp @@ -69,6 +69,9 @@ CodeStyleEditor::CodeStyleEditor(ICodeStylePreferencesFactory *factory, tr("Edit preview contents to see how the current settings " "are applied to custom code snippets. Changes in the preview " "do not affect the current settings."), this); + QFont font = label->font(); + font.setItalic(true); + label->setFont(font); label->setWordWrap(true); m_layout->addWidget(selector); m_layout->addWidget(m_preview); diff --git a/src/plugins/texteditor/codestyleselectorwidget.cpp b/src/plugins/texteditor/codestyleselectorwidget.cpp index b291e4e2a4..b76d4f4025 100644 --- a/src/plugins/texteditor/codestyleselectorwidget.cpp +++ b/src/plugins/texteditor/codestyleselectorwidget.cpp @@ -31,6 +31,7 @@ **************************************************************************/ #include "codestyleselectorwidget.h" +#include "ui_codestyleselectorwidget.h" #include "icodestylepreferences.h" #include "icodestylepreferencesfactory.h" #include "codestylepool.h" @@ -67,15 +68,23 @@ public: ICodeStylePreferences *codeStyle, QWidget *parent = 0); ~CodeStyleDialog(); ICodeStylePreferences *codeStyle() const; - QString displayName() const; +private slots: + void slotCopyClicked(); + void slotDisplayNameChanged(); private: ICodeStylePreferences *m_codeStyle; QLineEdit *m_lineEdit; + QDialogButtonBox *m_buttons; + QLabel *m_warningLabel; + QPushButton *m_copyButton; + QString m_originalDisplayName; }; CodeStyleDialog::CodeStyleDialog(ICodeStylePreferencesFactory *factory, ICodeStylePreferences *codeStyle, QWidget *parent) - : QDialog(parent) + : QDialog(parent), + m_warningLabel(0), + m_copyButton(0) { setWindowTitle(tr("Edit Code Style")); QVBoxLayout *layout = new QVBoxLayout(this); @@ -85,17 +94,46 @@ CodeStyleDialog::CodeStyleDialog(ICodeStylePreferencesFactory *factory, nameLayout->addWidget(label); nameLayout->addWidget(m_lineEdit); layout->addLayout(nameLayout); + + if (codeStyle->isReadOnly()) { + QHBoxLayout *warningLayout = new QHBoxLayout(); + m_warningLabel = new QLabel( + tr("You cannot save changes to a built-in code style. " + "Copy it first to create your own version."), this); + QFont font = m_warningLabel->font(); + font.setItalic(true); + m_warningLabel->setFont(font); + m_warningLabel->setWordWrap(true); + m_copyButton = new QPushButton(tr("Copy Built-in Code Style"), this); + m_copyButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + connect(m_copyButton, SIGNAL(clicked()), + this, SLOT(slotCopyClicked())); + warningLayout->addWidget(m_warningLabel); + warningLayout->addWidget(m_copyButton); + layout->addLayout(warningLayout); + } + + m_originalDisplayName = codeStyle->displayName(); m_codeStyle = factory->createCodeStyle(); m_codeStyle->setTabSettings(codeStyle->tabSettings()); m_codeStyle->setValue(codeStyle->value()); + m_codeStyle->setDisplayName(m_originalDisplayName); QWidget *editor = factory->createEditor(m_codeStyle, this); - QDialogButtonBox *buttons = new QDialogButtonBox( + + m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); + if (codeStyle->isReadOnly()) { + QPushButton *okButton = m_buttons->button(QDialogButtonBox::Ok); + okButton->setEnabled(false); + } + if (editor) layout->addWidget(editor); - layout->addWidget(buttons); - connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); + layout->addWidget(m_buttons); + + connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotDisplayNameChanged())); + connect(m_buttons, SIGNAL(accepted()), this, SLOT(accept())); + connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject())); } ICodeStylePreferences *CodeStyleDialog::codeStyle() const @@ -103,9 +141,22 @@ ICodeStylePreferences *CodeStyleDialog::codeStyle() const return m_codeStyle; } -QString CodeStyleDialog::displayName() const +void CodeStyleDialog::slotCopyClicked() +{ + if (m_warningLabel) + m_warningLabel->hide(); + if (m_copyButton) + m_copyButton->hide(); + QPushButton *okButton = m_buttons->button(QDialogButtonBox::Ok); + okButton->setEnabled(true); + if (m_lineEdit->text() == m_originalDisplayName) + m_lineEdit->setText(tr("%1 (Copy)").arg(m_lineEdit->text())); + m_lineEdit->selectAll(); +} + +void CodeStyleDialog::slotDisplayNameChanged() { - return m_lineEdit->text(); + m_codeStyle->setDisplayName(m_lineEdit->text()); } CodeStyleDialog::~CodeStyleDialog() @@ -120,48 +171,32 @@ CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *f QWidget(parent), m_factory(factory), m_codeStyle(0), - m_layout(0), - m_comboBox(0), - m_comboBoxLabel(0), + m_ui(new Ui::CodeStyleSelectorWidget), m_ignoreGuiSignals(false) { - m_layout = new QHBoxLayout(this); - m_layout->setContentsMargins(QMargins()); - m_copyButton = new QPushButton(tr("Copy..."), this); - m_editButton = new QPushButton(tr("Edit..."), this); - m_removeButton = new QPushButton(tr("Remove"), this); - m_importButton = new QPushButton(tr("Import..."), this); - m_exportButton = new QPushButton(tr("Export..."), this); - m_importButton->setEnabled(false); - m_exportButton->setEnabled(false); - - m_comboBoxLabel = new QLabel(tr("Current settings:"), this); - m_comboBoxLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - m_layout->addWidget(m_comboBoxLabel); - m_comboBox = new QComboBox(this); - m_comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - m_layout->addWidget(m_comboBox); - connect(m_comboBox, SIGNAL(activated(int)), - this, SLOT(slotComboBoxActivated(int))); - - m_layout->addWidget(m_copyButton); - m_layout->addWidget(m_editButton); - m_layout->addWidget(m_removeButton); - m_layout->addWidget(m_importButton); - m_layout->addWidget(m_exportButton); + m_ui->setupUi(this); + m_ui->importButton->setEnabled(false); + m_ui->exportButton->setEnabled(false); - connect(m_copyButton, SIGNAL(clicked()), + connect(m_ui->delegateComboBox, SIGNAL(activated(int)), + this, SLOT(slotComboBoxActivated(int))); + connect(m_ui->copyButton, SIGNAL(clicked()), this, SLOT(slotCopyClicked())); - connect(m_editButton, SIGNAL(clicked()), + connect(m_ui->editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked())); - connect(m_removeButton, SIGNAL(clicked()), + connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked())); - connect(m_importButton, SIGNAL(clicked()), + connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(slotImportClicked())); - connect(m_exportButton, SIGNAL(clicked()), + connect(m_ui->exportButton, SIGNAL(clicked()), this, SLOT(slotExportClicked())); } +CodeStyleSelectorWidget::~CodeStyleSelectorWidget() +{ + delete m_ui; +} + void CodeStyleSelectorWidget::setCodeStyle(TextEditor::ICodeStylePreferences *codeStyle) { if (m_codeStyle == codeStyle) @@ -179,9 +214,9 @@ void CodeStyleSelectorWidget::setCodeStyle(TextEditor::ICodeStylePreferences *co disconnect(m_codeStyle, SIGNAL(currentDelegateChanged(ICodeStylePreferences*)), this, SLOT(slotCurrentDelegateChanged(ICodeStylePreferences*))); - m_exportButton->setEnabled(false); - m_importButton->setEnabled(false); - m_comboBox->clear(); + m_ui->exportButton->setEnabled(false); + m_ui->importButton->setEnabled(false); + m_ui->delegateComboBox->clear(); } m_codeStyle = codeStyle; // fillup new @@ -195,8 +230,8 @@ void CodeStyleSelectorWidget::setCodeStyle(TextEditor::ICodeStylePreferences *co this, SLOT(slotCodeStyleAdded(ICodeStylePreferences*))); connect(codeStylePool, SIGNAL(codeStyleRemoved(ICodeStylePreferences*)), this, SLOT(slotCodeStyleRemoved(ICodeStylePreferences*))); - m_exportButton->setEnabled(true); - m_importButton->setEnabled(true); + m_ui->exportButton->setEnabled(true); + m_ui->importButton->setEnabled(true); } for (int i = 0; i < delegates.count(); i++) @@ -214,10 +249,10 @@ void CodeStyleSelectorWidget::slotComboBoxActivated(int index) if (m_ignoreGuiSignals) return; - if (!m_comboBox || index < 0 || index >= m_comboBox->count()) + if (index < 0 || index >= m_ui->delegateComboBox->count()) return; TextEditor::ICodeStylePreferences *delegate = - m_comboBox->itemData(index).value<TextEditor::ICodeStylePreferences *>(); + m_ui->delegateComboBox->itemData(index).value<TextEditor::ICodeStylePreferences *>(); const bool wasBlocked = blockSignals(true); m_codeStyle->setCurrentDelegate(delegate); @@ -227,15 +262,12 @@ void CodeStyleSelectorWidget::slotComboBoxActivated(int index) void CodeStyleSelectorWidget::slotCurrentDelegateChanged(TextEditor::ICodeStylePreferences *delegate) { m_ignoreGuiSignals = true; - if (m_comboBox) { - m_comboBox->setCurrentIndex(m_comboBox->findData(QVariant::fromValue(delegate))); - m_comboBox->setToolTip(m_comboBox->currentText()); - } + m_ui->delegateComboBox->setCurrentIndex(m_ui->delegateComboBox->findData(QVariant::fromValue(delegate))); + m_ui->delegateComboBox->setToolTip(m_ui->delegateComboBox->currentText()); m_ignoreGuiSignals = false; - const bool enableEdit = delegate && !delegate->isReadOnly() && !delegate->currentDelegate(); - m_editButton->setEnabled(enableEdit); - m_removeButton->setEnabled(enableEdit); + const bool removeEnabled = delegate && !delegate->isReadOnly() && !delegate->currentDelegate(); + m_ui->removeButton->setEnabled(removeEnabled); } void CodeStyleSelectorWidget::slotCopyClicked() @@ -271,9 +303,16 @@ void CodeStyleSelectorWidget::slotEditClicked() Internal::CodeStyleDialog dialog(m_factory, codeStyle, this); if (dialog.exec() == QDialog::Accepted) { ICodeStylePreferences *dialogCodeStyle = dialog.codeStyle(); + if (codeStyle->isReadOnly()) { + CodeStylePool *codeStylePool = m_codeStyle->delegatingPool(); + codeStyle = codeStylePool->cloneCodeStyle(dialogCodeStyle); + if (codeStyle) + m_codeStyle->setCurrentDelegate(codeStyle); + return; + } codeStyle->setTabSettings(dialogCodeStyle->tabSettings()); codeStyle->setValue(dialogCodeStyle->value()); - codeStyle->setDisplayName(dialog.displayName()); + codeStyle->setDisplayName(dialogCodeStyle->displayName()); } } @@ -337,8 +376,8 @@ void CodeStyleSelectorWidget::slotCodeStyleAdded(ICodeStylePreferences *codeStyl const QVariant data = QVariant::fromValue(codeStylePreferences); const QString name = displayName(codeStylePreferences); - m_comboBox->addItem(name, data); - m_comboBox->setItemData(m_comboBox->count() - 1, name, Qt::ToolTipRole); + m_ui->delegateComboBox->addItem(name, data); + m_ui->delegateComboBox->setItemData(m_ui->delegateComboBox->count() - 1, name, Qt::ToolTipRole); connect(codeStylePreferences, SIGNAL(displayNameChanged(QString)), this, SLOT(slotUpdateName())); if (codeStylePreferences->delegatingPool()) { @@ -350,7 +389,7 @@ void CodeStyleSelectorWidget::slotCodeStyleAdded(ICodeStylePreferences *codeStyl void CodeStyleSelectorWidget::slotCodeStyleRemoved(ICodeStylePreferences *codeStylePreferences) { m_ignoreGuiSignals = true; - m_comboBox->removeItem(m_comboBox->findData(QVariant::fromValue(codeStylePreferences))); + m_ui->delegateComboBox->removeItem(m_ui->delegateComboBox->findData(QVariant::fromValue(codeStylePreferences))); disconnect(codeStylePreferences, SIGNAL(displayNameChanged(QString)), this, SLOT(slotUpdateName())); if (codeStylePreferences->delegatingPool()) { @@ -375,18 +414,18 @@ void CodeStyleSelectorWidget::slotUpdateName() updateName(codeStyle); } - m_comboBox->setToolTip(m_comboBox->currentText()); + m_ui->delegateComboBox->setToolTip(m_ui->delegateComboBox->currentText()); } void CodeStyleSelectorWidget::updateName(ICodeStylePreferences *codeStyle) { - const int idx = m_comboBox->findData(QVariant::fromValue(codeStyle)); + const int idx = m_ui->delegateComboBox->findData(QVariant::fromValue(codeStyle)); if (idx < 0) return; const QString name = displayName(codeStyle); - m_comboBox->setItemText(idx, name); - m_comboBox->setItemData(idx, name, Qt::ToolTipRole); + m_ui->delegateComboBox->setItemText(idx, name); + m_ui->delegateComboBox->setItemData(idx, name, Qt::ToolTipRole); } QString CodeStyleSelectorWidget::displayName(ICodeStylePreferences *codeStyle) const diff --git a/src/plugins/texteditor/codestyleselectorwidget.h b/src/plugins/texteditor/codestyleselectorwidget.h index a8cd5fa421..0759a916b4 100644 --- a/src/plugins/texteditor/codestyleselectorwidget.h +++ b/src/plugins/texteditor/codestyleselectorwidget.h @@ -50,11 +50,16 @@ namespace TextEditor { class ICodeStylePreferences; class ICodeStylePreferencesFactory; +namespace Ui { +class CodeStyleSelectorWidget; +} + class TEXTEDITOR_EXPORT CodeStyleSelectorWidget : public QWidget { Q_OBJECT public: explicit CodeStyleSelectorWidget(ICodeStylePreferencesFactory *factory, QWidget *parent = 0); + ~CodeStyleSelectorWidget(); void setCodeStyle(TextEditor::ICodeStylePreferences *codeStyle); QString searchKeywords() const; @@ -80,15 +85,7 @@ private: QString displayName(ICodeStylePreferences *codeStyle) const; - QHBoxLayout *m_layout; - - QComboBox *m_comboBox; - QLabel *m_comboBoxLabel; - QPushButton *m_copyButton; - QPushButton *m_editButton; - QPushButton *m_removeButton; - QPushButton *m_importButton; - QPushButton *m_exportButton; + Ui::CodeStyleSelectorWidget *m_ui; bool m_ignoreGuiSignals; }; diff --git a/src/plugins/texteditor/codestyleselectorwidget.ui b/src/plugins/texteditor/codestyleselectorwidget.ui new file mode 100644 index 0000000000..462062cd94 --- /dev/null +++ b/src/plugins/texteditor/codestyleselectorwidget.ui @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TextEditor::CodeStyleSelectorWidget</class> + <widget class="QWidget" name="TextEditor::CodeStyleSelectorWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>523</width> + <height>58</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>0</number> + </property> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Current settings:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="delegateComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="copyButton"> + <property name="text"> + <string>Copy...</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="editButton"> + <property name="text"> + <string>Edit...</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QPushButton" name="removeButton"> + <property name="text"> + <string>Remove</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QPushButton" name="exportButton"> + <property name="text"> + <string>Export...</string> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QPushButton" name="importButton"> + <property name="text"> + <string>Import...</string> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>delegateComboBox</tabstop> + <tabstop>copyButton</tabstop> + <tabstop>editButton</tabstop> + <tabstop>removeButton</tabstop> + <tabstop>exportButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index d5b418533f..afe8095614 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -234,7 +234,8 @@ FORMS += \ snippets/snippetssettingspage.ui \ behaviorsettingswidget.ui \ behaviorsettingspage.ui \ - tabsettingswidget.ui + tabsettingswidget.ui \ + codestyleselectorwidget.ui RESOURCES += texteditor.qrc OTHER_FILES += TextEditor.mimetypes.xml @@ -246,3 +247,4 @@ OTHER_FILES += TextEditor.mimetypes.xml + diff --git a/src/plugins/valgrind/suppressiondialog.cpp b/src/plugins/valgrind/suppressiondialog.cpp index e5e3470534..cdd78e45e6 100644 --- a/src/plugins/valgrind/suppressiondialog.cpp +++ b/src/plugins/valgrind/suppressiondialog.cpp @@ -170,6 +170,11 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view) setWindowTitle(tr("Save Suppression")); } +SuppressionDialog::~SuppressionDialog() +{ + delete m_ui; +} + bool SuppressionDialog::shouldShow() const { return !m_errors.isEmpty(); diff --git a/src/plugins/valgrind/suppressiondialog.h b/src/plugins/valgrind/suppressiondialog.h index 3dc6ff7013..f5d65c0584 100644 --- a/src/plugins/valgrind/suppressiondialog.h +++ b/src/plugins/valgrind/suppressiondialog.h @@ -58,6 +58,7 @@ class SuppressionDialog : public QDialog public: SuppressionDialog(MemcheckErrorView *view); + ~SuppressionDialog(); virtual void accept(); virtual void reject(); diff --git a/src/tools/qmlprofilertool/qmlprofilertool.pro b/src/tools/qmlprofilertool/qmlprofilertool.pro index ff3cadb929..875c6ce1ed 100644 --- a/src/tools/qmlprofilertool/qmlprofilertool.pro +++ b/src/tools/qmlprofilertool/qmlprofilertool.pro @@ -3,7 +3,7 @@ include(../../rpath.pri) TEMPLATE = app TARGET = qmlprofiler -DESTDIR = $$IDE_APP_PATH +DESTDIR = $$IDE_BIN_PATH QT = core CONFIG += console |