diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 47b26368bf09167a52f8dac57b3c2899a466ad94..1778edad4635a6a1b346b555acb7d578177d8851 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -29,12 +29,6 @@ #include <qglobal.h> -// this relies on contents copied from qobject_p.h -#define PRIVATE_OBJECT_ALLOWED 1 - -#ifdef HAS_QOBJECT_P_H // Detected by qmake -# include <QtCore/private/qobject_p.h> -#endif #include <QtCore/QDateTime> #include <QtCore/QDebug> #include <QtCore/QDir> @@ -149,68 +143,76 @@ int qtGhVersion = QT_VERSION; # define NSY "" #endif -#if PRIVATE_OBJECT_ALLOWED && !defined(HAS_QOBJECT_P_H) - #if defined(QT_BEGIN_NAMESPACE) QT_BEGIN_NAMESPACE #endif -class QVariant; -class QThreadData; -class QObjectConnectionListVector; +struct Sender { QObject *sender; int signal; int ref; }; -class QObjectPrivate : public QObjectData -{ - Q_DECLARE_PUBLIC(QObject) - -public: - QObjectPrivate() {} - virtual ~QObjectPrivate() {} +#if QT_VERSION < 0x040600 + struct Connection + { + QObject *receiver; + int method; + uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking + QBasicAtomicPointer<int> argumentTypes; + }; - // preserve binary compatibility with code compiled without Qt 3 support - QList<QObject *> pendingChildInsertedEvents; // unused + typedef QList<Connection> ConnectionList; + typedef QList<Sender> SenderList; - // id of the thread that owns the object - QThreadData *threadData; + const Connection &connectionAt(const ConnectionList &l, int i) { return l.at(i); } + const QObject *senderAt(const SenderList &l, int i) { return l.at(i).sender; } + int signalAt(const SenderList &l, int i) { return l.at(i).signal; } +#endif - struct Sender +#if QT_VERSION >= 0x040600 + struct Connection { QObject *sender; - int signal; - int ref; + QObject *receiver; + int method; + uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking + QBasicAtomicPointer<int> argumentTypes; }; - Sender *currentSender; // object currently activating the object - QObject *currentChildBeingDeleted; + typedef QList<Connection *> ConnectionList; + typedef ConnectionList SenderList; + + const Connection &connectionAt(const ConnectionList &l, int i) { return *l.at(i); } + const QObject *senderAt(const SenderList &l, int i) { return l.at(i)->sender; } + // FIXME: 'method' is wrong + int signalAt(const SenderList &l, int i) { return l.at(i)->method; } +#endif + +class QObjectPrivate : public QObjectData +{ +public: + QObjectPrivate() {} + virtual ~QObjectPrivate() {} + + QList<QObject *> pendingChildInsertedEvents; + void *threadData; + void *currentSender; + void *currentChildBeingDeleted; QList<QPointer<QObject> > eventFilters; - struct ExtraData; - ExtraData *extraData; + void *extraData; mutable quint32 connectedSignals; QString objectName; - struct Connection - { - QObject *receiver; - int method; - uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking - QBasicAtomicPointer<int> argumentTypes; - }; - typedef QList<Connection> ConnectionList; - - QObjectConnectionListVector *connectionLists; - QList<Sender> senders; + void *connectionLists; + SenderList senders; int *deleteWatch; }; + #if defined(QT_BEGIN_NAMESPACE) QT_END_NAMESPACE #endif -#endif // PRIVATE_OBJECT_ALLOWED - // This can be mangled typenames of nested templates, each char-by-char // comma-separated integer list... @@ -1547,13 +1549,6 @@ static void qDumpQObject(QDumper &d) const QObject *ob = reinterpret_cast<const QObject *>(d.data); const QMetaObject *mo = ob->metaObject(); unsigned childrenOffset = d.extraInt[0]; -#ifdef HAS_QOBJECT_P_H - // QObject child offset if known - if (!childrenOffset) { - QObjectPrivate qop; - childrenOffset = (char*)&qop.children - (char*)&qop; - } -#endif P(d, "value", ob->objectName()); P(d, "valueencoded", "2"); P(d, "type", NS"QObject"); @@ -1594,7 +1589,6 @@ static void qDumpQObject(QDumper &d) P(d, "type", NS"QList<"NS"QObjectPrivateSender>"); d.endHash(); #endif -#if PRIVATE_OBJECT_ALLOWED d.beginHash(); P(d, "name", "signals"); P(d, "exp", "*(class '"NS"QObject'*)" << d.data); @@ -1609,7 +1603,6 @@ static void qDumpQObject(QDumper &d) P(d, "value", "<" << slotCount << " items>"); P(d, "numchild", slotCount); d.endHash(); -#endif if (childrenOffset) { d.beginHash(); P(d, "name", "children"); @@ -1624,24 +1617,6 @@ static void qDumpQObject(QDumper &d) P(d, "numchild", children.size()); d.endHash(); } -#if 0 - // Unneeded (and not working): Connections are listes as childen - // of the signal or slot they are connected to. - // d.beginHash(); - // P(d, "name", "connections"); - // P(d, "exp", "*(*(class "NS"QObjectPrivate*)" << dfunc(ob) << ")->connectionLists"); - // P(d, "type", NS"QVector<"NS"QList<"NS"QObjectPrivate::Connection> >"); - // d.endHash(); -#endif -#if 0 - d.beginHash(); - P(d, "name", "objectprivate"); - P(d, "type", NS"QObjectPrivate"); - P(d, "addr", dfunc(ob)); - P(d, "value", ""); - P(d, "numchild", "1"); - d.endHash(); -#endif d.beginHash(); P(d, "name", "parent"); qDumpInnerValueHelper(d, NS"QObject *", ob->parent()); @@ -1720,7 +1695,6 @@ static void qDumpQObjectMethodList(QDumper &d) d.disarm(); } -#if PRIVATE_OBJECT_ALLOWED const char * qConnectionTypes[] ={ "auto", "direct", @@ -1730,13 +1704,13 @@ const char * qConnectionTypes[] ={ }; #if QT_VERSION >= 0x040400 -static const QObjectPrivate::ConnectionList &qConnectionList(const QObject *ob, int signalNumber) +static const ConnectionList &qConnectionList(const QObject *ob, int signalNumber) { - static const QObjectPrivate::ConnectionList emptyList; + static const ConnectionList emptyList; const QObjectPrivate *p = reinterpret_cast<const QObjectPrivate *>(dfunc(ob)); if (!p->connectionLists) return emptyList; - typedef QVector<QObjectPrivate::ConnectionList> ConnLists; + typedef QVector<ConnectionList> ConnLists; const ConnLists *lists = reinterpret_cast<const ConnLists *>(p->connectionLists); // there's an optimization making the lists only large enough to hold the // last non-empty item @@ -1758,9 +1732,9 @@ static void qDumpQObjectSignal(QDumper &d) if (d.dumpChildren) { const QObject *ob = reinterpret_cast<const QObject *>(d.data); d << ",children=["; - const QObjectPrivate::ConnectionList &connList = qConnectionList(ob, signalNumber); + const ConnectionList &connList = qConnectionList(ob, signalNumber); for (int i = 0; i != connList.size(); ++i) { - const QObjectPrivate::Connection &conn = connList.at(i); + const Connection &conn = connectionAt(connList, i); d.beginHash(); P(d, "name", i << " receiver"); qDumpInnerValueHelper(d, NS"QObject *", conn.receiver); @@ -1804,7 +1778,7 @@ static void qDumpQObjectSignalList(QDumper &d) const QMetaMethod & method = mo->method(i); if (method.methodType() == QMetaMethod::Signal) { int k = mo->indexOfSignal(method.signature()); - const QObjectPrivate::ConnectionList &connList = qConnectionList(ob, k); + const ConnectionList &connList = qConnectionList(ob, k); d.beginHash(); P(d, "name", k); P(d, "value", method.signature()); @@ -1836,18 +1810,17 @@ static void qDumpQObjectSlot(QDumper &d) const QObject *ob = reinterpret_cast<const QObject *>(d.data); const QObjectPrivate *p = reinterpret_cast<const QObjectPrivate *>(dfunc(ob)); for (int s = 0; s != p->senders.size(); ++s) { - const QObjectPrivate::Sender &sender = p->senders.at(s); - const QObjectPrivate::ConnectionList &connList - = qConnectionList(sender.sender, sender.signal); + const QObject *sender = senderAt(p->senders, s); + int signal = signalAt(p->senders, s); + const ConnectionList &connList = qConnectionList(sender, signal); for (int i = 0; i != connList.size(); ++i) { - const QObjectPrivate::Connection &conn = connList.at(i); + const Connection &conn = connectionAt(connList, i); if (conn.receiver == ob && conn.method == slotNumber) { ++numchild; - const QMetaMethod & method = - sender.sender->metaObject()->method(sender.signal); + const QMetaMethod &method = sender->metaObject()->method(signal); d.beginHash(); P(d, "name", s << " sender"); - qDumpInnerValueHelper(d, NS"QObject *", sender.sender); + qDumpInnerValueHelper(d, NS"QObject *", sender); d.endHash(); d.beginHash(); P(d, "name", s << " signal"); @@ -1899,11 +1872,11 @@ static void qDumpQObjectSlotList(QDumper &d) // count senders. expensive... int numchild = 0; for (int s = 0; s != p->senders.size(); ++s) { - const QObjectPrivate::Sender & sender = p->senders.at(s); - const QObjectPrivate::ConnectionList &connList - = qConnectionList(sender.sender, sender.signal); + const QObject *sender = senderAt(p->senders, s); + int signal = signalAt(p->senders, s); + const ConnectionList &connList = qConnectionList(sender, signal); for (int c = 0; c != connList.size(); ++c) { - const QObjectPrivate::Connection &conn = connList.at(c); + const Connection &conn = connectionAt(connList, c); if (conn.receiver == ob && conn.method == k) ++numchild; } @@ -1919,7 +1892,6 @@ static void qDumpQObjectSlotList(QDumper &d) #endif d.disarm(); } -#endif // PRIVATE_OBJECT_ALLOWED static void qDumpQPixmap(QDumper &d) @@ -2609,7 +2581,6 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpQObjectPropertyList(d); else if (isEqual(type, "QObjectMethodList")) qDumpQObjectMethodList(d); - #if PRIVATE_OBJECT_ALLOWED else if (isEqual(type, "QObjectSignal")) qDumpQObjectSignal(d); else if (isEqual(type, "QObjectSignalList")) @@ -2618,7 +2589,6 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpQObjectSlot(d); else if (isEqual(type, "QObjectSlotList")) qDumpQObjectSlotList(d); - #endif break; case 'P': if (isEqual(type, "QPixmap")) @@ -2728,12 +2698,10 @@ void *qDumpObjectData440( "\""NS"QObject\"," "\""NS"QObjectMethodList\"," // hack to get nested properties display "\""NS"QObjectPropertyList\"," -#if PRIVATE_OBJECT_ALLOWED "\""NS"QObjectSignal\"," "\""NS"QObjectSignalList\"," "\""NS"QObjectSlot\"," "\""NS"QObjectSlotList\"," -#endif // PRIVATE_OBJECT_ALLOWED // << "\""NS"QRegion\"," "\""NS"QSet\"," "\""NS"QSharedPointer\"," diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index cc1cd5fff95b56600c91dc8f141ce3f3d81b677c..c362c6fcf53dd6e46f3b85ab03af4589397870e7 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -590,6 +590,24 @@ void Preprocessor::expand(const char *first, const char *last, QByteArray *resul return expand(source, result); } +void Preprocessor::out(const QByteArray &text) +{ + if (_result) + _result->append(text); +} + +void Preprocessor::out(char ch) +{ + if (_result) + _result->append(ch); +} + +void Preprocessor::out(const char *s) +{ + if (_result) + _result->append(s); +} + Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source) const { State state; @@ -611,16 +629,16 @@ void Preprocessor::processNewline(bool force) return; if (force || env->currentLine > _dot->lineno) { - _result->append("\n# "); - _result->append(QByteArray::number(_dot->lineno)); - _result->append(' '); - _result->append('"'); - _result->append(env->currentFile); - _result->append('"'); - _result->append('\n'); + out("\n# "); + out(QByteArray::number(_dot->lineno)); + out(' '); + out('"'); + out(env->currentFile); + out('"'); + out('\n'); } else { for (unsigned i = env->currentLine; i < _dot->lineno; ++i) - _result->append('\n'); + out('\n'); } env->currentLine = _dot->lineno; @@ -661,9 +679,9 @@ bool Preprocessor::markGeneratedTokens(bool markGeneratedTokens, dot = _dot; if (_markGeneratedTokens) - _result->append("\n#gen true"); + out("\n#gen true"); else - _result->append("\n#gen false"); + out("\n#gen false"); processNewline(/*force = */ true); @@ -684,10 +702,10 @@ bool Preprocessor::markGeneratedTokens(bool markGeneratedTokens, for (; it != end; ++it) { if (! std::isspace(*it)) - _result->append(' '); + out(' '); else - _result->append(*it); + out(*it); } } @@ -737,7 +755,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour } else { if (_dot->joined) - _result->append("\\\n"); + out("\\\n"); else if (_dot->whitespace) { const unsigned endOfPreviousToken = (_dot - 1)->end(); @@ -755,15 +773,15 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour for (; it != end; ++it) { if (std::isspace(*it)) - _result->append(*it); + out(*it); else - _result->append(' '); + out(' '); } } if (_dot->isNot(T_IDENTIFIER)) { - _result->append(tokenSpell(*_dot)); + out(tokenSpell(*_dot)); ++_dot; } else { @@ -798,7 +816,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour } // it's not a function or object-like macro. - _result->append(spell); + out(spell); } } } @@ -893,7 +911,7 @@ Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken, } const bool was = markGeneratedTokens(true, identifierToken); - _result->append(tmp); + out(tmp); (void) markGeneratedTokens(was); return 0; } diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h index 3b0e0d1b22617b6fa7a567c6c1d9f32abb2868ab..2895e2eddf3eb87719893908e5ddf68be404bb16 100644 --- a/src/libs/cplusplus/pp-engine.h +++ b/src/libs/cplusplus/pp-engine.h @@ -70,6 +70,10 @@ public: QByteArray operator()(const QByteArray &filename, const QByteArray &source); + void preprocess(const QByteArray &filename, + const QByteArray &source, + QByteArray *result); + private: enum { MAX_LEVEL = 512 }; @@ -99,10 +103,6 @@ private: bool markGeneratedTokens(bool markGeneratedTokens, TokenIterator dot = 0); - void preprocess(const QByteArray &filename, - const QByteArray &source, - QByteArray *result); - QByteArray expand(const QByteArray &source); void expand(const QByteArray &source, QByteArray *result); void expand(const char *first, const char *last, QByteArray *result); @@ -165,6 +165,10 @@ private: State createStateFromSource(const QByteArray &source) const; + void out(const QByteArray &text); + void out(char ch); + void out(const char *s); + private: Client *client; Environment *env; diff --git a/src/libs/utils/reloadpromptutils.cpp b/src/libs/utils/reloadpromptutils.cpp index befa54308d51824dab8484d32815a917d5e904c6..9681f05fc6fe44916f6cb92c261fa739090a4cd6 100644 --- a/src/libs/utils/reloadpromptutils.cpp +++ b/src/libs/utils/reloadpromptutils.cpp @@ -30,6 +30,7 @@ #include "reloadpromptutils.h" #include <QtGui/QMessageBox> +#include <QtCore/QCoreApplication> using namespace Core; using namespace Core::Utils; @@ -37,9 +38,10 @@ using namespace Core::Utils; QTCREATOR_UTILS_EXPORT Core::Utils::ReloadPromptAnswer Core::Utils::reloadPrompt(const QString &fileName, QWidget *parent) { - return reloadPrompt(QObject::tr("File Changed"), - QObject::tr("The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(fileName), - parent); + const QString title = QCoreApplication::translate("Core::Utils::reloadPrompt", "File Changed"); + const QString msg = QCoreApplication::translate("Core::Utils::reloadPrompt", + "The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(fileName); + return reloadPrompt(title, msg, parent); } QTCREATOR_UTILS_EXPORT Core::Utils::ReloadPromptAnswer diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 4c4d91b188d7e2d177f785484892daddf914a32b..94b56e6c317ac88cd01959db7e6856818243d577 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1241,19 +1241,19 @@ EditorManager::ReadOnlyAction QWidget *parent, bool displaySaveAsButton) { - QMessageBox msgBox(QMessageBox::Question, QObject::tr("File is Read Only"), - QObject::tr("The file %1 is read only.").arg(fileName), + QMessageBox msgBox(QMessageBox::Question, tr("File is Read Only"), + tr("The file %1 is read only.").arg(fileName), QMessageBox::Cancel, parent); QPushButton *sccButton = 0; if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) - sccButton = msgBox.addButton(QObject::tr("Open with VCS (%1)").arg(versionControl->name()), QMessageBox::AcceptRole); + sccButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->name()), QMessageBox::AcceptRole); - QPushButton *makeWritableButton = msgBox.addButton(QObject::tr("Make writable"), QMessageBox::AcceptRole); + QPushButton *makeWritableButton = msgBox.addButton(tr("Make writable"), QMessageBox::AcceptRole); QPushButton *saveAsButton = 0; if (displaySaveAsButton) - saveAsButton = msgBox.addButton(QObject::tr("Save as ..."), QMessageBox::ActionRole); + saveAsButton = msgBox.addButton(tr("Save as ..."), QMessageBox::ActionRole); msgBox.setDefaultButton(sccButton ? sccButton : makeWritableButton); msgBox.exec(); diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp index 2464ad31d8e33a4ad1c2b59899b5bc2d43e3a678..1a5f457ecb5a7020ad58bf8a71d345c87696cc8c 100644 --- a/src/plugins/coreplugin/mimedatabase.cpp +++ b/src/plugins/coreplugin/mimedatabase.cpp @@ -647,7 +647,7 @@ static bool parseNumber(const QString &n, int *target, QString *errorMessage) bool ok; *target = n.toInt(&ok); if (!ok) { - *errorMessage = QCoreApplication::translate("MimeDatabase", "Not a number '%1'.").arg(n); + *errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n); return false; } return true; @@ -667,7 +667,7 @@ static bool addMagicMatchRule(const QXmlStreamAttributes &atts, } const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString(); if (value.isEmpty()) { - *errorMessage = QCoreApplication::translate("MimeDatabase", "Empty match value detected."); + *errorMessage = QString::fromLatin1("Empty match value detected."); return false; } // Parse for offset as "1" or "1:10" @@ -699,7 +699,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString case ParseMimeType: { // start parsing a type const QString type = reader.attributes().value(QLatin1String(mimeTypeAttributeC)).toString(); if (type.isEmpty()) { - reader.raiseError(QCoreApplication::translate("MimeDatabase", "Missing 'type'-attribute")); + reader.raiseError(QString::fromLatin1("Missing 'type'-attribute")); } else { data.type = type; } @@ -748,7 +748,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString return false; break; case ParseError: - reader.raiseError(QCoreApplication::translate("MimeDatabase", "Unexpected element <%1>").arg(reader.name().toString())); + reader.raiseError(QString::fromLatin1("Unexpected element <%1>").arg(reader.name().toString())); break; default: break; @@ -775,7 +775,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString } if (reader.hasError()) { - *errorMessage = QCoreApplication::translate("MimeDatabase", "An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString()); + *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString()); return false; } return true; @@ -890,7 +890,7 @@ bool MimeDatabasePrivate::addMimeTypes(const QString &fileName, QString *errorMe { QFile file(fileName); if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) { - *errorMessage = QCoreApplication::translate("MimeDatabase", "Cannot open %1: %2").arg(fileName, file.errorString()); + *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString()); return false; } return addMimeTypes(&file, fileName, errorMessage); diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index c746aead41158f503b5f62a77ee34ddaf1767106..3d553ea4acca7649ee4eeed3570ba51122cc69e2 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -189,6 +189,7 @@ CPPEditorEditable::CPPEditorEditable(CPPEditor *editor) CPPEditor::CPPEditor(QWidget *parent) : TextEditor::BaseTextEditor(parent) + , m_mouseNavigationEnabled(true) , m_showingLink(false) { setParenthesesMatchingEnabled(true); @@ -901,7 +902,7 @@ void CPPEditor::mouseMoveEvent(QMouseEvent *e) { bool linkFound = false; - if (e->modifiers() & Qt::ControlModifier) { + if (m_mouseNavigationEnabled && e->modifiers() & Qt::ControlModifier) { // Link emulation behaviour for 'go to definition' const QTextCursor cursor = cursorForPosition(e->pos()); @@ -1027,6 +1028,11 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) m_linkFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LINK)); } +void CPPEditor::setDisplaySettings(const TextEditor::DisplaySettings &ds) +{ + TextEditor::BaseTextEditor::setDisplaySettings(ds); + m_mouseNavigationEnabled = ds.m_mouseNavigation; +} void CPPEditor::unCommentSelection() { diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index bd76281894f4b25d2cc1bdbf29595170b0aff3cb..526faff87a7e01f7bd36f0073164a97bb7b6816f 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -87,6 +87,7 @@ public: public slots: virtual void setFontSettings(const TextEditor::FontSettings &); + virtual void setDisplaySettings(const TextEditor::DisplaySettings &); void setSortedMethodOverview(bool sort); void switchDeclarationDefinition(); void jumpToDefinition(); @@ -153,11 +154,13 @@ private: void showLink(const Link &); void clearLink(); - bool m_showingLink; Link findLinkAt(const QTextCursor &, bool lookupDefinition = true); static Link linkToSymbol(CPlusPlus::Symbol *symbol); bool openCppEditorAt(const Link &); + + bool m_mouseNavigationEnabled; + bool m_showingLink; QTextCharFormat m_linkFormat; CppTools::CppModelManagerInterface *m_modelManager; diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index fcc2e166d24c70d92bef88b7434b2f12f13b1bee..96b7c0e4cc5b7cc86a6bb3d25fe4ddeca81c7ed1 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -46,6 +46,21 @@ bool StackFrame::isUsable() const return !file.isEmpty() && QFileInfo(file).isReadable(); } +QString StackFrame::toToolTip() const +{ + QString res; + QTextStream str(&res); + str << "<html><body><table>" + << "<tr><td>" << StackHandler::tr("Address:") << "</td><td>" << address << "</td></tr>" + << "<tr><td>" << StackHandler::tr("Function:") << "</td><td>" << function << "</td></tr>" + << "<tr><td>" << StackHandler::tr("File:") << "</td><td>" << file << "</td></tr>" + << "<tr><td>" << StackHandler::tr("Line:") << "</td><td>" << line << "</td></tr>" + << "<tr><td>" << StackHandler::tr("From:") << "</td><td>" << from << "</td></tr>" + << "<tr><td>" << StackHandler::tr("To:") << "</td><td>" << to << "</td></tr>" + << "</table></body></html>"; + return res; +} + //////////////////////////////////////////////////////////////////////// // // StackHandler @@ -104,14 +119,7 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const } } else if (role == Qt::ToolTipRole) { //: Tooltip for variable - return tr("<table><tr><td>Address:</td><td>%1</td></tr>" - "<tr><td>Function: </td><td>%2</td></tr>" - "<tr><td>File: </td><td>%3</td></tr>" - "<tr><td>Line: </td><td>%4</td></tr>" - "<tr><td>From: </td><td>%5</td></tr></table>" - "<tr><td>To: </td><td>%6</td></tr></table>") - .arg(frame.address, frame.function, - frame.file, QString::number(frame.line), frame.from, frame.to); + return frame.toToolTip(); } else if (role == Qt::DecorationRole && index.column() == 0) { // Return icon that indicates whether this is the active stack frame return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon; diff --git a/src/plugins/debugger/stackhandler.h b/src/plugins/debugger/stackhandler.h index 12f771464a86390ba360cca6e11d4e2f753b1427..5435ecafaf9bc2eeb8ee799faafe72c0a28bbe51 100644 --- a/src/plugins/debugger/stackhandler.h +++ b/src/plugins/debugger/stackhandler.h @@ -48,6 +48,7 @@ struct StackFrame { StackFrame(int level = 0); bool isUsable() const; + QString toToolTip() const; int level; QString function; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 144f85f4f8dd9af3e40aed65a8ffb2845f8c7dcc..fe03cf9c9ee05af346e77f6560cd9a578dd99561 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -236,6 +236,35 @@ QString WatchData::toString() const return res + QLatin1Char('}'); } +// Format a tooltip fow with aligned colon +template <class Streamable> + inline void formatToolTipRow(QTextStream &str, + const QString &category, + const Streamable &value) +{ + str << "<tr><td>" << category << "</td><td> : </td><td>" << value << "</td></tr>"; +} + +QString WatchData::toToolTip() const +{ + QString res; + QTextStream str(&res); + str << "<html><body><table>"; + formatToolTipRow(str, WatchHandler::tr("Expression"), Qt::escape(exp)); + formatToolTipRow(str, WatchHandler::tr("Type"), Qt::escape(type)); + QString val = value; + if (value.size() > 1000) { + val.truncate(1000); + val += WatchHandler::tr(" ... <cut off>"); + } + formatToolTipRow(str, WatchHandler::tr("Value"), Qt::escape(val)); + formatToolTipRow(str, WatchHandler::tr("Object Address"), Qt::escape(addr)); + formatToolTipRow(str, WatchHandler::tr("Stored Address"), Qt::escape(saddr)); + formatToolTipRow(str, WatchHandler::tr("iname"), Qt::escape(iname)); + str << "</table></body></html>"; + return res; +} + static bool iNameSorter(const WatchData &d1, const WatchData &d2) { if (d1.level != d2.level) @@ -482,36 +511,8 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const break; } - case Qt::ToolTipRole: { - QString val = data.value; - if (val.size() > 1000) - val = val.left(1000) + QLatin1String(" ... <cut off>"); - - QString tt = QLatin1String("<table>"); - //tt += QLatin1String("<tr><td>internal name</td><td> : </td><td>"); - //tt += Qt::escape(iname) + QLatin1String("</td></tr>"); - tt += QLatin1String("<tr><td>expression</td><td> : </td><td>"); - tt += Qt::escape(data.exp) + QLatin1String("</td></tr>"); - tt += QLatin1String("<tr><td>type</td><td> : </td><td>"); - tt += Qt::escape(data.type) + QLatin1String("</td></tr>"); - //if (!valuetooltip.isEmpty()) - // tt += valuetooltip; - //else - tt += QLatin1String("<tr><td>value</td><td> : </td><td>"); - tt += Qt::escape(data.value) + QLatin1String("</td></tr>"); - tt += QLatin1String("<tr><td>object addr</td><td> : </td><td>"); - tt += Qt::escape(data.addr) + QLatin1String("</td></tr>"); - tt += QLatin1String("<tr><td>stored addr</td><td> : </td><td>"); - tt += Qt::escape(data.saddr) + QLatin1String("</td></tr>"); - tt += QLatin1String("<tr><td>iname</td><td> : </td><td>"); - tt += Qt::escape(data.iname) + QLatin1String("</td></tr>"); - tt += QLatin1String("</table>"); - tt.replace(QLatin1String("@value@"), Qt::escape(data.value)); - - if (tt.size() > 10000) - tt = tt.left(10000) + QLatin1String(" ... <cut off>"); - return tt; - } + case Qt::ToolTipRole: + return data.toToolTip(); case Qt::ForegroundRole: { static const QVariant red(QColor(200, 0, 0)); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index aaefbe6f8cc70925844bc6230b30b5d669ad3f48..389f52b2dc64a669684e4f759c42073e25746daf 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -101,6 +101,7 @@ public: WatchData pointerChildPlaceHolder() const; QString toString() const; + QString toToolTip() const; bool isLocal() const { return iname.startsWith(QLatin1String("local.")); } bool isWatcher() const { return iname.startsWith(QLatin1String("watch.")); } bool isValid() const { return !iname.isEmpty(); } diff --git a/src/plugins/designer/cpp/formclasswizard.cpp b/src/plugins/designer/cpp/formclasswizard.cpp index d208372a7247faf41957ab62d7f3d61296781f0b..937abf0db2c0b175d92e60adab525256d77ca6c4 100644 --- a/src/plugins/designer/cpp/formclasswizard.cpp +++ b/src/plugins/designer/cpp/formclasswizard.cpp @@ -90,7 +90,7 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e const FormClassWizardParameters params = wizardDialog->parameters(); if (params.uiTemplate.isEmpty()) { - *errorMessage = tr("Internal error: FormClassWizard::generateFiles: empty template contents"); + *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents"); return Core::GeneratedFiles(); } diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index e3d623c2660a5a69da0a197ef55069fc2299836f..fc98b7a3d8694e361cfe94100bbf36ad1c0556cc 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -38,6 +38,8 @@ #include <projectexplorer/projectnodes.h> #include <projectexplorer/nodesvisitor.h> +#include <utils/qtcassert.h> + #include <QtDesigner/QDesignerFormWindowInterface> #include <QtDesigner/QDesignerFormEditorInterface> #include <QtDesigner/QDesignerFormWindowManagerInterface> @@ -359,7 +361,19 @@ QString FormWindowEditor::contextHelpId() const QString FormWindowEditor::contents() const { - if (m_host && m_host->formWindow()) - return m_host->formWindow()->contents(); - return QString::null; + if (!m_formWindow) + return QString::null; +// Activate once all Qt branches around have integrated 4.5.2 +// (Kinetic) +/* +#if QT_VERSION > 0x040501 + // Quiet save as of Qt 4.5.2 + qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(m_formWindow); + QTC_ASSERT(fwb, return QString::null); + return fwb->fileContents(); +#else + return m_formWindow->contents(); +#endif +*/ + return m_formWindow->contents(); } diff --git a/src/plugins/designer/qt_private/formwindowbase_p.h b/src/plugins/designer/qt_private/formwindowbase_p.h index 7c6d649e77f55e5b873955919d13c6639625cb16..b49fb88ea6969ae95358656da5f29709c34e43d7 100644 --- a/src/plugins/designer/qt_private/formwindowbase_p.h +++ b/src/plugins/designer/qt_private/formwindowbase_p.h @@ -78,6 +78,9 @@ public: QVariantMap formData(); void setFormData(const QVariantMap &vm); + // Return contents without warnings. Should be 'contents(bool quiet)' + QString fileContents() const; + // Return the widget containing the form. This is used to // apply embedded design settings to that are inherited (for example font). // These are meant to be applied to the form only and not to the other editors diff --git a/src/plugins/designer/qt_private/qdesigner_formwindowmanager_p.h b/src/plugins/designer/qt_private/qdesigner_formwindowmanager_p.h index 91f0c9c96d60592f0dee14c69e88a2d8f733172a..36aae1956c0732c3f02eb57b6f9c844560c809e8 100644 --- a/src/plugins/designer/qt_private/qdesigner_formwindowmanager_p.h +++ b/src/plugins/designer/qt_private/qdesigner_formwindowmanager_p.h @@ -74,6 +74,7 @@ Q_SIGNALS: public Q_SLOTS: virtual void closeAllPreviews() = 0; + void aboutPlugins(); private: void *m_unused; diff --git a/src/plugins/designer/syncqtheader.sh b/src/plugins/designer/syncqtheader.sh index c184711451cf134e845fabd555f87fc50ce564a5..d9e98a85f9575d7544f4f84e216063360ed0a19e 100755 --- a/src/plugins/designer/syncqtheader.sh +++ b/src/plugins/designer/syncqtheader.sh @@ -55,8 +55,8 @@ syncHeader() TARGET=qt_private/$HDR # Exchange license header - head -n 32 formwindowfile.h > $TARGET || exit 1 - tail -n +11 $QTHDR >> $TARGET || exit 1 + head -n 28 formwindowfile.h > $TARGET || exit 1 + tail -n +41 $QTHDR >> $TARGET || exit 1 } for H in $REQUIRED_HEADERS diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp index fff5a008ce7fbcb3d94f55ef0f36f4a4970e8bbd..6024c1e8a2c5501fe9e6551ed84cefeb95812a76 100644 --- a/src/plugins/fakevim/fakevimactions.cpp +++ b/src/plugins/fakevim/fakevimactions.cpp @@ -45,6 +45,7 @@ #include <QtCore/QRegExp> #include <QtCore/QTextStream> #include <QtCore/QtAlgorithms> +#include <QtCore/QCoreApplication> #include <QtCore/QStack> using namespace Core::Utils; @@ -113,58 +114,59 @@ FakeVimSettings *theFakeVimSettings() SavedAction *item = 0; + const QString group = QLatin1String("FakeVim"); item = new SavedAction(instance); - item->setText(QObject::tr("Toggle vim-style editing")); - item->setSettingsKey("FakeVim", "UseFakeVim"); + item->setText(QCoreApplication::translate("FakeVim::Internal", "Toggle vim-style editing")); + item->setSettingsKey(group, QLatin1String("UseFakeVim")); item->setCheckable(true); instance->insertItem(ConfigUseFakeVim, item); item = new SavedAction(instance); item->setDefaultValue(false); - item->setSettingsKey("FakeVim", "StartOfLine"); + item->setSettingsKey(group, QLatin1String("StartOfLine")); item->setCheckable(true); - instance->insertItem(ConfigStartOfLine, item, "startofline", "sol"); + instance->insertItem(ConfigStartOfLine, item, QLatin1String("startofline"), QLatin1String("sol")); item = new SavedAction(instance); item->setDefaultValue(8); - item->setSettingsKey("FakeVim", "TabStop"); - instance->insertItem(ConfigTabStop, item, "tabstop", "ts"); + item->setSettingsKey(group, QLatin1String("TabStop")); + instance->insertItem(ConfigTabStop, item, QLatin1String("tabstop"), QLatin1String("ts")); item = new SavedAction(instance); item->setDefaultValue(false); - item->setSettingsKey("FakeVim", "SmartTab"); - instance->insertItem(ConfigSmartTab, item, "smarttab", "sta"); + item->setSettingsKey(group, QLatin1String("SmartTab")); + instance->insertItem(ConfigSmartTab, item, QLatin1String("smarttab"), QLatin1String("sta")); item = new SavedAction(instance); item->setDefaultValue(true); - item->setSettingsKey("FakeVim", "HlSearch"); + item->setSettingsKey(group, QLatin1String("HlSearch")); item->setCheckable(true); - instance->insertItem(ConfigHlSearch, item, "hlsearch", "hls"); + instance->insertItem(ConfigHlSearch, item, QLatin1String("hlsearch"), QLatin1String("hls")); item = new SavedAction(instance); item->setDefaultValue(8); - item->setSettingsKey("FakeVim", "ShiftWidth"); - instance->insertItem(ConfigShiftWidth, item, "shiftwidth", "sw"); + item->setSettingsKey(group, QLatin1String("ShiftWidth")); + instance->insertItem(ConfigShiftWidth, item, QLatin1String("shiftwidth"), QLatin1String("sw")); item = new SavedAction(instance); item->setDefaultValue(false); - item->setSettingsKey("FakeVim", "ExpandTab"); + item->setSettingsKey(group, QLatin1String("ExpandTab")); item->setCheckable(true); - instance->insertItem(ConfigExpandTab, item, "expandtab", "et"); + instance->insertItem(ConfigExpandTab, item, QLatin1String("expandtab"), QLatin1String("et")); item = new SavedAction(instance); item->setDefaultValue(false); - item->setSettingsKey("FakeVim", "AutoIndent"); + item->setSettingsKey(group, QLatin1String("AutoIndent")); item->setCheckable(true); - instance->insertItem(ConfigAutoIndent, item, "autoindent", "ai"); + instance->insertItem(ConfigAutoIndent, item, QLatin1String("autoindent"), QLatin1String("ai")); item = new SavedAction(instance); - item->setDefaultValue("indent,eol,start"); - item->setSettingsKey("FakeVim", "Backspace"); - instance->insertItem(ConfigBackspace, item, "backspace", "bs"); + item->setDefaultValue(QLatin1String("indent,eol,start")); + item->setSettingsKey(group, QLatin1String("Backspace")); + instance->insertItem(ConfigBackspace, item, QLatin1String("backspace"), QLatin1String("bs")); item = new SavedAction(instance); - item->setText(QObject::tr("FakeVim properties...")); + item->setText(QCoreApplication::translate("FakeVim::Internal", "FakeVim properties...")); instance->insertItem(SettingsDialog, item); return instance; diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index be063ead32f2ab73685c6e2024d174cca5947e16..ccff2bb67dc29c434275f33d9881b38a5727cf34 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -495,7 +495,7 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project) QComboBox *toolChainChooser = new QComboBox; toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains()); toolChainChooser->setCurrentIndex(toolChainChooser->findText(m_project->toolChainId())); - fl->addRow(tr("Tool chain:"), toolChainChooser); + fl->addRow(tr("Toolchain:"), toolChainChooser); connect(toolChainChooser, SIGNAL(activated(QString)), m_project, SLOT(setToolChainId(QString))); } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 037a6fef08368bbcd3c94dd9680669402f7f4459..0ddb1bf9d5ec9debfbebf48131e44d6a6a977f86 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -501,7 +501,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // build action m_buildAction = new QAction(tr("Build Project"), this); cmd = am->registerAction(m_buildAction, Constants::BUILD, globalcontext); - cmd->setAttribute(Core::Command::CA_UpdateText); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B"))); mbuild->addAction(cmd, Constants::G_BUILD_PROJECT); mproject->addAction(cmd, Constants::G_PROJECT_BUILD); @@ -518,6 +517,34 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mbuild->addAction(cmd, Constants::G_BUILD_PROJECT); mproject->addAction(cmd, Constants::G_PROJECT_BUILD); + // build project only menu + Core::ActionContainer *mpo = am->createMenu(Constants::BUILDPROJECTONLYMENU); + m_buildProjectOnlyMenu = mpo->menu(); + m_buildProjectOnlyMenu->setTitle(tr("Project Only")); + mbuild->addMenu(mpo, Constants::G_BUILD_PROJECT); + mproject->addMenu(mpo, Constants::G_PROJECT_BUILD); + + // build action + m_buildProjectOnlyAction = new QAction(tr("Build Project Only"), this); + cmd = am->registerAction(m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext); + cmd->setAttribute(Core::Command::CA_UpdateText); + cmd->setDefaultText(m_buildProjectOnlyAction->text()); + mpo->addAction(cmd); + + // rebuild action + m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Project only"), this); + cmd = am->registerAction(m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext); + cmd->setAttribute(Core::Command::CA_UpdateText); + cmd->setDefaultText(m_rebuildProjectOnlyAction->text()); + mpo->addAction(cmd); + + // clean action + m_cleanProjectOnlyAction = new QAction(tr("Clean Project only"), this); + cmd = am->registerAction(m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext); + cmd->setAttribute(Core::Command::CA_UpdateText); + cmd->setDefaultText(m_cleanProjectOnlyAction->text()); + mpo->addAction(cmd); + // Add Set Build Configuration to menu mbuild->addMenu(mbc, Constants::G_BUILD_PROJECT); mproject->addMenu(mbc, Constants::G_PROJECT_CONFIG); @@ -644,10 +671,13 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er #if 0 connect(m_loadAction, SIGNAL(triggered()), this, SLOT(loadAction())); #endif + connect(m_buildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(buildProjectOnly())); connect(m_buildAction, SIGNAL(triggered()), this, SLOT(buildProject())); connect(m_buildSessionAction, SIGNAL(triggered()), this, SLOT(buildSession())); + connect(m_rebuildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(rebuildProjectOnly())); connect(m_rebuildAction, SIGNAL(triggered()), this, SLOT(rebuildProject())); connect(m_rebuildSessionAction, SIGNAL(triggered()), this, SLOT(rebuildSession())); + connect(m_cleanProjectOnlyAction, SIGNAL(triggered()), this, SLOT(cleanProjectOnly())); connect(m_cleanAction, SIGNAL(triggered()), this, SLOT(cleanProject())); connect(m_cleanSessionAction, SIGNAL(triggered()), this, SLOT(cleanSession())); connect(m_runAction, SIGNAL(triggered()), this, SLOT(runProject())); @@ -1010,7 +1040,6 @@ void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode) void ProjectExplorerPlugin::restoreSession() { - if (debug) qDebug() << "ProjectExplorerPlugin::restoreSession"; @@ -1247,15 +1276,27 @@ void ProjectExplorerPlugin::updateActions() m_unloadAction->setEnabled(m_currentProject != 0); if (m_currentProject == 0) { m_unloadAction->setText(tr("Close Project")); - m_buildAction->setText(tr("Build Project")); + m_buildProjectOnlyMenu->setTitle(tr("Project only")); + m_buildProjectOnlyAction->setText(tr("Build Project only")); + m_rebuildProjectOnlyAction->setText(tr("Rebuild Project only")); + m_cleanProjectOnlyAction->setText(tr("Clean Project only")); } else { m_unloadAction->setText(tr("Close Project \"%1\"").arg(m_currentProject->name())); - m_buildAction->setText(tr("Build Project \"%1\"").arg(m_currentProject->name())); + m_buildProjectOnlyMenu->setTitle(tr("Project \"%1\" only").arg(m_currentProject->name())); + m_buildProjectOnlyAction->setText(tr("Build Project \"%1\" only").arg(m_currentProject->name())); + m_rebuildProjectOnlyAction->setText(tr("Rebuild Project \"%1\" only").arg(m_currentProject->name())); + m_cleanProjectOnlyAction->setText(tr("Clean Project \"%1\" only").arg(m_currentProject->name())); } m_buildAction->setEnabled(enableBuildActions); m_rebuildAction->setEnabled(enableBuildActions); m_cleanAction->setEnabled(enableBuildActions); + + m_buildProjectOnlyMenu->setEnabled(enableBuildActions); + m_buildProjectOnlyAction->setEnabled(enableBuildActions); + m_rebuildProjectOnlyAction->setEnabled(enableBuildActions); + m_cleanProjectOnlyAction->setEnabled(enableBuildActions); + m_clearSession->setEnabled(hasProjects && !building); m_buildSessionAction->setEnabled(hasProjects && !building); m_rebuildSessionAction->setEnabled(hasProjects && !building); @@ -1285,7 +1326,7 @@ QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro) return filesToSave; } -bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects) +bool ProjectExplorerPlugin::saveModifiedFiles() { if (debug) qDebug() << "ProjectExplorerPlugin::saveModifiedFiles"; @@ -1312,13 +1353,32 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects) //NBS handle case where there is no activeBuildConfiguration // because someone delete all build configurations +void ProjectExplorerPlugin::buildProjectOnly() +{ + if (debug) + qDebug() << "ProjectExplorerPlugin::buildProjectOnly"; + + if (saveModifiedFiles()) + buildManager()->buildProject(m_currentProject, m_currentProject->activeBuildConfiguration()); +} + +static QStringList configurations(const QList<Project *> &projects) +{ + QStringList result; + foreach (const Project * pro, projects) + result << pro->activeBuildConfiguration(); + return result; +} + void ProjectExplorerPlugin::buildProject() { if (debug) qDebug() << "ProjectExplorerPlugin::buildProject"; - if (saveModifiedFiles(QList<Project *>() << m_currentProject)) - buildManager()->buildProject(m_currentProject, m_currentProject->activeBuildConfiguration()); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(m_currentProject); + m_buildManager->buildProjects(projects, configurations(projects)); + } } void ProjectExplorerPlugin::buildSession() @@ -1326,13 +1386,20 @@ void ProjectExplorerPlugin::buildSession() if (debug) qDebug() << "ProjectExplorerPlugin::buildSession"; - const QList<Project *> & projects = m_session->projectOrder(); - if (saveModifiedFiles(projects)) { - QStringList configurations; - foreach (const Project * pro, projects) - configurations << pro->activeBuildConfiguration(); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(); + m_buildManager->buildProjects(projects, configurations(projects)); + } +} + +void ProjectExplorerPlugin::rebuildProjectOnly() +{ + if (debug) + qDebug() << "ProjectExplorerPlugin::rebuildProjectOnly"; - m_buildManager->buildProjects(projects, configurations); + if (saveModifiedFiles()) { + m_buildManager->cleanProject(m_currentProject, m_currentProject->activeBuildConfiguration()); + m_buildManager->buildProject(m_currentProject, m_currentProject->activeBuildConfiguration()); } } @@ -1341,9 +1408,12 @@ void ProjectExplorerPlugin::rebuildProject() if (debug) qDebug() << "ProjectExplorerPlugin::rebuildProject"; - if (saveModifiedFiles(QList<Project *>() << m_currentProject)) { - m_buildManager->cleanProject(m_currentProject, m_currentProject->activeBuildConfiguration()); - m_buildManager->buildProject(m_currentProject, m_currentProject->activeBuildConfiguration()); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(m_currentProject); + const QStringList configs = configurations(projects); + + m_buildManager->cleanProjects(projects, configs); + m_buildManager->buildProjects(projects, configs); } } @@ -1352,24 +1422,33 @@ void ProjectExplorerPlugin::rebuildSession() if (debug) qDebug() << "ProjectExplorerPlugin::rebuildSession"; - const QList<Project *> & projects = m_session->projectOrder(); - if (saveModifiedFiles(projects)) { - QStringList configurations; - foreach (const Project * pro, projects) - configurations << pro->activeBuildConfiguration(); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(); + const QStringList configs = configurations(projects); - m_buildManager->cleanProjects(projects, configurations); - m_buildManager->buildProjects(projects, configurations); + m_buildManager->cleanProjects(projects, configs); + m_buildManager->buildProjects(projects, configs); } } +void ProjectExplorerPlugin::cleanProjectOnly() +{ + if (debug) + qDebug() << "ProjectExplorerPlugin::cleanProjectOnly"; + + if (saveModifiedFiles()) + m_buildManager->cleanProject(m_currentProject, m_currentProject->activeBuildConfiguration()); +} + void ProjectExplorerPlugin::cleanProject() { if (debug) qDebug() << "ProjectExplorerPlugin::cleanProject"; - if (saveModifiedFiles(QList<Project *>() << m_currentProject)) - m_buildManager->cleanProject(m_currentProject, m_currentProject->activeBuildConfiguration()); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(m_currentProject); + m_buildManager->cleanProjects(projects, configurations(projects)); + } } void ProjectExplorerPlugin::cleanSession() @@ -1377,13 +1456,9 @@ void ProjectExplorerPlugin::cleanSession() if (debug) qDebug() << "ProjectExplorerPlugin::cleanSession"; - const QList<Project *> & projects = m_session->projectOrder(); - if (saveModifiedFiles(projects)) { - QStringList configurations; - foreach (const Project * pro, projects) - configurations << pro->activeBuildConfiguration(); - - m_buildManager->cleanProjects(projects, configurations); + if (saveModifiedFiles()) { + const QList<Project *> & projects = m_session->projectOrder(); + m_buildManager->cleanProjects(projects, configurations(projects)); } } @@ -1403,12 +1478,12 @@ void ProjectExplorerPlugin::runProjectImpl(Project *pro) return; if (m_projectExplorerSettings.buildBeforeRun) { - if (saveModifiedFiles(QList<Project *>() << pro)) { + if (saveModifiedFiles()) { m_runMode = ProjectExplorer::Constants::RUNMODE; m_delayedRunConfiguration = pro->activeRunConfiguration(); - //NBS TODO make the build project step take into account project dependencies - m_buildManager->buildProject(pro, pro->activeBuildConfiguration()); + const QList<Project *> & projects = m_session->projectOrder(pro); + m_buildManager->buildProjects(projects, configurations(projects)); } } else { executeRunConfiguration(pro->activeRunConfiguration(), ProjectExplorer::Constants::RUNMODE); @@ -1422,11 +1497,13 @@ void ProjectExplorerPlugin::debugProject() return; if (m_projectExplorerSettings.buildBeforeRun) { - if (saveModifiedFiles(QList<Project *>() << pro)) { + if (saveModifiedFiles()) { m_runMode = ProjectExplorer::Constants::DEBUGMODE; m_delayedRunConfiguration = pro->activeRunConfiguration(); - //NBS TODO make the build project step take into account project dependencies - m_buildManager->buildProject(pro, pro->activeBuildConfiguration()); + + const QList<Project *> & projects = m_session->projectOrder(pro); + m_buildManager->buildProjects(projects, configurations(projects)); + updateRunAction(); } } else { diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 6beca9504f98bd21ed0ada55a9d48963c577991a..377cbab84c487e3b2681e7cfc56799e0a1117d78 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -106,7 +106,7 @@ public: BuildManager *buildManager() const; - bool saveModifiedFiles(const QList<Project *> & projects); + bool saveModifiedFiles(); void showContextMenu(const QPoint &globalPos, Node *node); @@ -133,10 +133,13 @@ signals: private slots: void buildStateChanged(ProjectExplorer::Project * pro); void buildQueueFinished(bool success); + void buildProjectOnly(); void buildProject(); void buildSession(); + void rebuildProjectOnly(); void rebuildProject(); void rebuildSession(); + void cleanProjectOnly(); void cleanProject(); void cleanSession(); void cancelBuild(); @@ -224,10 +227,13 @@ private: #endif QAction *m_unloadAction; QAction *m_clearSession; + QAction *m_buildProjectOnlyAction; QAction *m_buildAction; QAction *m_buildSessionAction; + QAction *m_rebuildProjectOnlyAction; QAction *m_rebuildAction; QAction *m_rebuildSessionAction; + QAction *m_cleanProjectOnlyAction; QAction *m_cleanAction; QAction *m_cleanSessionAction; QAction *m_runAction; @@ -244,6 +250,7 @@ private: QAction *m_removeFileAction; QAction *m_renameFileAction; + QMenu *m_buildProjectOnlyMenu; QMenu *m_buildConfigurationMenu; QActionGroup *m_buildConfigurationActionGroup; QMenu *m_runConfigurationMenu; diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 351f333a27e5b0dda1b3368c85baa96aa833187e..105a715beabdd00c9765a8c1f45fc464e2a00cdd 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -43,12 +43,16 @@ const char * const NEWPROJECT = "ProjectExplorer.NewProject"; const char * const LOAD = "ProjectExplorer.Load"; const char * const UNLOAD = "ProjectExplorer.Unload"; const char * const CLEARSESSION = "ProjectExplorer.ClearSession"; +const char * const BUILDPROJECTONLY = "ProjectExplorer.BuildProjectOnly"; const char * const BUILD = "ProjectExplorer.Build"; const char * const BUILDSESSION = "ProjectExplorer.BuildSession"; +const char * const REBUILDPROJECTONLY = "ProjectExplorer.RebuildProjectOnly"; const char * const REBUILD = "ProjectExplorer.Rebuild"; const char * const REBUILDSESSION = "ProjectExplorer.RebuildSession"; +const char * const CLEANPROJECTONLY = "ProjectExplorer.CleanProjectOnly"; const char * const CLEAN = "ProjectExplorer.Clean"; const char * const CLEANSESSION = "ProjectExplorer.CleanSession"; +const char * const BUILDPROJECTONLYMENU = "ProjectExplorer.BuildProjectOnlyMenu"; const char * const BUILDCONFIGURATIONMENU = "ProjectExplorer.BuildConfigurationMenu"; const char * const CANCELBUILD = "ProjectExplorer.CancelBuild"; const char * const RUNCONFIGURATIONMENU = "ProjectExplorer.RunConfigurationMenu"; diff --git a/src/plugins/qt4projectmanager/embeddedpropertiespage.ui b/src/plugins/qt4projectmanager/embeddedpropertiespage.ui index 6185473212d3342191da9b9fb8a0c7f82021bee8..f4f42aa80cbde5c848f8f567b215ce29d4eaddcb 100644 --- a/src/plugins/qt4projectmanager/embeddedpropertiespage.ui +++ b/src/plugins/qt4projectmanager/embeddedpropertiespage.ui @@ -20,7 +20,7 @@ <property name="text" > <string>Use Virtual Box
 Note: This adds the toolchain to the build environment and runs the program inside a virtual machine.
 -It also automatically sets the correct qt version.</string> +It also automatically sets the correct Qt version.</string> </property> </widget> </item> diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index ab27fb981ced6976102c0116e40138c46bcc415f..1d1667cc14221d581a5e7fbfa13c1dbe9b0587bd 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -210,7 +210,7 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil import2Label = new QLabel(importPage); import2Label->setTextFormat(Qt::RichText); if (m_temporaryVersion) - import2Label->setText(tr("<b>Note:</b> Importing the settings will automatically add the Qt Version from:<br><b>%1</b> to the list of qt versions.") + import2Label->setText(tr("<b>Note:</b> Importing the settings will automatically add the Qt Version from:<br><b>%1</b> to the list of Qt versions.") .arg(QDir::toNativeSeparators(m_importVersion->path()))); importLayout->addWidget(import2Label); addPage(importPage); diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index 3848763524fd25888ffc72db5667567d29170134..59efc8f678f520967c0b3e27daa78a938d71b0d8 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -290,7 +290,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") .arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); else - m_ui->errorLabel->setText(tr("%1 is not a valid qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + m_ui->errorLabel->setText(tr("%1 is not a valid Qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); } else { //ProjectExplorer::ToolChain::GCC m_ui->msvcComboBox->setVisible(false); makeMingwVisible(false); diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp index 031da0eb28e2026a41ec7a7c455f841656b2d680..e6b18d21e5d6ec740fe8e6f37e83136e980be84d 100644 --- a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp @@ -51,7 +51,7 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName, m_introPage->setDescription(tr("This wizard generates a Qt4 console application " "project. The application derives from QCoreApplication and does not " - "present a GUI. You can press 'Finish' at any point in time.")); + "provide a GUI.")); addPage(m_introPage); diff --git a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp index 685973adc8ba5e07e241e65fdb9b8b3746e79277..a943e92252805bcd22bcd921baf2030eb2a1365b 100644 --- a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp @@ -48,8 +48,7 @@ EmptyProjectWizardDialog::EmptyProjectWizardDialog(const QString &templateName, Core::BaseFileWizard::setupWizard(this); m_introPage->setDescription(tr("This wizard generates an empty Qt4 project. " - "Add files to it later on by using the other wizards. " - "You can press 'Finish' at any point in time.")); + "Add files to it later on by using the other wizards.")); addPage(m_introPage); diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp index 1ff95ca1482e1e5f90cc53949735e71f264b05a5..724da5a9e166abe8dad4ce20d4a48cfb7e81869e 100644 --- a/src/plugins/texteditor/behaviorsettingspage.cpp +++ b/src/plugins/texteditor/behaviorsettingspage.cpp @@ -126,7 +126,7 @@ void BehaviorSettingsPage::apply() } void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings, - StorageSettings &storageSettings) const + StorageSettings &storageSettings) const { tabSettings.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked(); tabSettings.m_autoIndent = m_d->m_page.autoIndent->isChecked(); diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index b0273a2c887a264124f1a016dabb080cce93490e..a9aabe7996340b6fec0e892bb9813d331bf3a1b0 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -43,6 +43,7 @@ static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers"; static const char * const highlightCurrentLineKey = "HighlightCurrentLineKeyV2"; static const char * const highlightBlocksKey = "HighlightBlocksKey"; static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey"; +static const char * const mouseNavigationKey = "MouseNavigation"; static const char * const groupPostfix = "DisplaySettings"; namespace TextEditor { @@ -56,7 +57,8 @@ DisplaySettings::DisplaySettings() : m_displayFoldingMarkers(true), m_highlightCurrentLine(false), m_highlightBlocks(false), - m_animateMatchingParentheses(true) + m_animateMatchingParentheses(true), + m_mouseNavigation(true) { } @@ -75,6 +77,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine); s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks); s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses); + s->setValue(QLatin1String(mouseNavigationKey), m_mouseNavigation); s->endGroup(); } @@ -96,6 +99,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s) m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool(); m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool(); m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool(); + m_mouseNavigation = s->value(group + QLatin1String(mouseNavigationKey), m_mouseNavigation).toBool(); } bool DisplaySettings::equals(const DisplaySettings &ds) const @@ -109,6 +113,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const && m_highlightCurrentLine == ds.m_highlightCurrentLine && m_highlightBlocks == ds.m_highlightBlocks && m_animateMatchingParentheses == ds.m_animateMatchingParentheses + && m_mouseNavigation == ds.m_mouseNavigation ; } diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h index 06a7d0fa381381458aba1f1780c490cdf49c6fa2..bcbb18462ea03364c0a1118c6a058e2d4666c4d0 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -54,6 +54,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings bool m_highlightCurrentLine; bool m_highlightBlocks; bool m_animateMatchingParentheses; + bool m_mouseNavigation; bool equals(const DisplaySettings &ds) const; }; diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp index ec7ae6a221093855a563e6512a92181ec4a3c2ce..8cd42c5299253a80c2d437283099514b54a8dff8 100644 --- a/src/plugins/texteditor/displaysettingspage.cpp +++ b/src/plugins/texteditor/displaysettingspage.cpp @@ -123,7 +123,8 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked(); displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked(); displaySettings.m_highlightBlocks = m_d->m_page.highlightBlocks->isChecked(); - displaySettings.m_animateMatchingParentheses= m_d->m_page.animateMatchingParentheses->isChecked(); + displaySettings.m_animateMatchingParentheses = m_d->m_page.animateMatchingParentheses->isChecked(); + displaySettings.m_mouseNavigation = m_d->m_page.mouseNavigation->isChecked(); } void DisplaySettingsPage::settingsToUI() @@ -138,6 +139,7 @@ void DisplaySettingsPage::settingsToUI() m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine); m_d->m_page.highlightBlocks->setChecked(displaySettings.m_highlightBlocks); m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses); + m_d->m_page.mouseNavigation->setChecked(displaySettings.m_mouseNavigation); } DisplaySettings DisplaySettingsPage::displaySettings() const diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui index d040a94b89958b8259a113eed0cea907268c7e5a..c1e984389c3f570974a2ec70e64d770861f2911d 100644 --- a/src/plugins/texteditor/displaysettingspage.ui +++ b/src/plugins/texteditor/displaysettingspage.ui @@ -7,11 +7,11 @@ <x>0</x> <y>0</y> <width>381</width> - <height>335</height> + <height>402</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_3"> - <item row="2" column="0"> + <item row="3" column="0"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -128,6 +128,22 @@ </layout> </widget> </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBoxNavigation"> + <property name="title"> + <string>Navigation</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="mouseNavigation"> + <property name="text"> + <string>Enable &mouse navigation</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <resources/> diff --git a/src/shared/cplusplus/PrettyPrinter.cpp b/src/shared/cplusplus/PrettyPrinter.cpp index c97de44140057596285fdaf14684fe843fffa12e..da116f7e7d3ca3e1065ae411baa76e1cf1b3a31f 100644 --- a/src/shared/cplusplus/PrettyPrinter.cpp +++ b/src/shared/cplusplus/PrettyPrinter.cpp @@ -30,10 +30,14 @@ #include "PrettyPrinter.h" #include "AST.h" #include "Token.h" + #include <iostream> #include <string> +#include <sstream> #include <cassert> +#include <QString> + CPLUSPLUS_USE_NAMESPACE PrettyPrinter::PrettyPrinter(Control *control, std::ostream &out) @@ -73,13 +77,38 @@ void PrettyPrinter::outToken(unsigned token) const unsigned end = t.begin(); _lastToken = token; + std::ostringstream oss; + // Preserve non-AST text QByteArray ba(_contents.constData() + start, end - start); - _out << ba.constData(); + oss << ba.constData(); // Print the token itself QByteArray tt(_contents.constData() + t.begin(), t.length); - _out << tt.constData(); + oss << tt.constData(); + + QString stuff = QString::fromUtf8(oss.str().c_str()); + QString indent = QString(_depth * 4, QLatin1Char(' ')); + + int from = 0; + int index = 0; + while ((index = stuff.indexOf(QLatin1Char('\n'), from)) != -1) { + from = index + 1; + int firstNonWhitespace = from; + + while (firstNonWhitespace < stuff.length()) { + const QChar c = stuff.at(firstNonWhitespace); + if (c.isSpace() && c != QLatin1Char('\n')) + ++firstNonWhitespace; + else + break; + } + + if (firstNonWhitespace != from) + stuff.replace(from, firstNonWhitespace - from, indent); + } + + _out << stuff.toUtf8().constData(); } bool PrettyPrinter::visit(AccessDeclarationAST *ast) diff --git a/src/shared/qrceditor/resourcefile.cpp b/src/shared/qrceditor/resourcefile.cpp index a259cf49ff34dedd94dd6124c5b1585411139690..f8986b529667950f84d8983294d567ac4dbaac57 100644 --- a/src/shared/qrceditor/resourcefile.cpp +++ b/src/shared/qrceditor/resourcefile.cpp @@ -44,10 +44,16 @@ QT_BEGIN_NAMESPACE + /* TRANSLATOR qdesigner_internal::ResourceModel */ +static QString msgFileNameEmpty() +{ + return QCoreApplication::translate("Designer", "The file name is empty."); +} + namespace qdesigner_internal { @@ -82,7 +88,7 @@ bool ResourceFile::load() m_error_message.clear(); if (m_file_name.isEmpty()) { - m_error_message = QCoreApplication::translate("Designer", "file name is empty"); + m_error_message = msgFileNameEmpty(); return false; } @@ -106,7 +112,7 @@ bool ResourceFile::load() QDomElement root = doc.firstChildElement(QLatin1String("RCC")); if (root.isNull()) { - m_error_message = QCoreApplication::translate("Designer", "no <RCC> root element"); + m_error_message = QCoreApplication::translate("Designer", "The <RCC> root element is missing."); return false; } @@ -145,7 +151,7 @@ bool ResourceFile::save() m_error_message.clear(); if (m_file_name.isEmpty()) { - m_error_message = QCoreApplication::translate("Designer", "file name is empty"); + m_error_message = msgFileNameEmpty(); return false; } diff --git a/tests/manual/preprocessor/main.cpp b/tests/manual/preprocessor/main.cpp index e38f0aecf7afe032a77979b6495623151b17dc21..b8395334f580108f7fbf797d80af924359834213 100644 --- a/tests/manual/preprocessor/main.cpp +++ b/tests/manual/preprocessor/main.cpp @@ -3,25 +3,96 @@ #include <PreprocessorClient.h> #include <pp.h> +#include <QCoreApplication> #include <QFile> +#include <QStringList> +#include <QDir> +#include <QtDebug> + #include <iostream> using namespace CPlusPlus; -int main() +class MakeDepend: public Client { - Client *client = 0; - Environment env; - Preprocessor preprocess(client, &env); + Environment *env; + QList<QDir> systemDirs; + +public: + MakeDepend(Environment *env) + : env(env) + { } + + void addSystemDir(const QDir &dir) + { systemDirs.append(dir); } + + void addSystemDir(const QString &path) + { systemDirs.append(QDir(path)); } + + virtual void macroAdded(const Macro &) + { } + + virtual void sourceNeeded(QString &fileName, IncludeType mode, unsigned) + { + if (mode == IncludeLocal) { + // ### cache + const QFileInfo currentFile(QFile::decodeName(env->currentFile)); + const QDir dir = currentFile.dir(); + + QFileInfo fileInfo(dir, fileName); + if (fileInfo.exists()) { + fileName = fileInfo.absoluteFilePath(); + std::cout << ' ' << qPrintable(fileName); + return; + } + } - QFile in; - if (! in.open(stdin, QFile::ReadOnly)) - return 0; + foreach (const QDir &dir, systemDirs) { + QFileInfo fileInfo(dir, fileName); + if (fileInfo.exists() && fileInfo.isFile()) { + fileName = fileInfo.absoluteFilePath(); + std::cout << ' ' << qPrintable(fileName); + return; + } + } + + std::cerr << "file '" << qPrintable(fileName) << "' not found" << std::endl; + } + + virtual void startExpandingMacro(unsigned, const Macro &, + const QByteArray &, + const QVector<MacroArgumentReference> &) + { } + + virtual void stopExpandingMacro(unsigned, const Macro &) + { } + + virtual void startSkippingBlocks(unsigned) + { } + + virtual void stopSkippingBlocks(unsigned) + { } +}; + +int main(int argc, char *argv[]) +{ + Environment env; + MakeDepend client(&env); - const QByteArray source = in.readAll(); - const QByteArray preprocessedCode = preprocess("<stdin>", source); + client.addSystemDir(QLatin1String("/usr/include")); + Preprocessor preproc(&client, &env); - std::cout << preprocessedCode.constData(); + for (int i = 1; i < argc; ++i) { + const QByteArray fileName = argv[i]; + std::cout << fileName.constData() << ':'; + QFile file(QFile::decodeName(fileName)); + if (file.open(QFile::ReadOnly)) { + // ### we should QTextStream here. + const QByteArray code = file.readAll(); + preproc.preprocess(fileName, code, /*result = */ 0); + } + std::cout << std::endl; + } return 0; }