diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index 5aca5dc1668083b387b063f62933a6f504921b7b..4897b584092a680c2dc918ecf0b830faa04a10f7 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -843,7 +843,7 @@ DOCSET_FEEDNAME = "Qt Creator API" # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. -DOCSET_BUNDLE_ID = com.qtsoftware.qt-creator +DOCSET_BUNDLE_ID = com.nokia.qt-creator # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the diff --git a/doc/eike_doc.patch b/doc/eike_doc.patch deleted file mode 100644 index f23c589de23a2df9d5d1f85309d744c6a23448aa..0000000000000000000000000000000000000000 --- a/doc/eike_doc.patch +++ /dev/null @@ -1,138 +0,0 @@ -diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc -index 0441666..7012ea6 100644 ---- a/doc/addressbook-sdk.qdoc -+++ b/doc/addressbook-sdk.qdoc -@@ -139,7 +139,7 @@ - \section1 Placing Widgets on The Form - - In the \gui{Project Sidebar}, double-click on the \c{addressbook.ui} file. -- The \QD plugin will be launched, allowing you to design your program's user -+ The \QD form editor will be launched, allowing you to design your program's user - interface. - - We require two \l{QLabel}s to label the input fields as well as a QLineEdit -@@ -156,6 +156,7 @@ - diagram below shows the layout cells and the position of our widgets. Place - your widgets accordingly and save the form by choosing - \gui{File | Save} or using the \key{Ctrl+S} shortcut. -+ (We have to actually layout the widgets in a grid layout, this step seems to be missing to me?) - - \image addressbook-tutorial-part1-labeled-screenshot.png - -@@ -311,7 +312,7 @@ - \snippet examples/addressbook-sdk/part2/addressbook.h slot definition - - Since the \c AddressBook class is a subclass of QWidget, Qt Creator -- includes QWidget in the hedaer file. -+ includes QWidget in the header file. - - \snippet examples/addressbook-sdk/part2/addressbook.h include - -@@ -323,7 +324,7 @@ - \snippet examples/addressbook-sdk/part2/addressbook.h members - - We also declare two private QString objects, \c oldName and \c oldAddress. -- These objects are needed to hold the name and address of hte contact that -+ These objects are needed to hold the name and address of the contact that - was last displayed, before the user clicked \gui Add. So, when the user - clicks \gui Cancel, we can revert to displaying the details of the last - contact. -@@ -499,7 +500,7 @@ - - \snippet examples/addressbook-sdk/part3/addressbook.cpp enable navigation - -- We also include these lins of code in the \c cancel() function. -+ We also include these lines of code in the \c cancel() function. - - Recall that we intend to emulate a circularly-linked list with our QMap - object, \c contacts. So in the \c next() function, we obtain an iterator -@@ -722,11 +723,12 @@ - - #image - -- We begin by adding a new \c{.ui} file to our project. Right click on your -+ We begin by adding a new \c{.ui} file and a corresponding class to our project. Right click on your - project and select \gui{Add New...}. In the \gui{New File} dialog, select -- \gui{Qt Designer Form}. In the \gui{Qt Designer Form} dialog, select -- \e{Dialog without buttons}. Name it \c{finddialog.ui} and add it to your -- project. The \QD plugin within Qt Creator will now display your new form. -+ \gui{Qt Designer Form Class}. In the \gui{Qt Designer Form Class} dialog, select -+ \e{Dialog without buttons}. Name the class \c{FindDialog} and add the files it to your -+ project. Open your new form in the \QD form editor within Qt Creator by -+ double-clicking on the \c{finddialog.ui} file in the \gui{Project Sidebar}. - - To replicate the screenshot above, we need a label, a line edit, and a push - button. Drag these onto your form. Set their text accordingly and name them -@@ -759,6 +761,9 @@ - \c findContact() function know when the \c FindDialog object has been - closed. We will explain this logic in further detail when discussing the - \c findContact() function. -+ (The above paragraph is not up to date, since clicked() is not connected -+ to accept(). The description of accept() can move below to the implementation -+ of findClicked().) - - \image addressbook-tutorial-part5-signals-and-slots.png - -@@ -766,17 +771,17 @@ - \gui Find button without entering a contact's name. Then, we set - \c findText to the search string, extracted from \c lineEdit. After that, - we clear the contents of \c lineEdit and hide the dialog. -+ (There is no findText member. The description of accept() should move here, together -+ with words about reject.) - - \snippet examples/addressbook-sdk/part5/finddialog.cpp findClicked - -- The \c findText variable has a public getter function, \c getFindText(), -- associated with it. Since we only ever set \c findText directly in both -- the constructor and in hte \c findClicked() function, we do not create a -- setter function to accompany \c getFindText(). Because \c getFindText() is -+ The \c text of the find dialog's line edit has a public getter function, \c findText(), -+ associated with it. Because \c findText() is - public, classes instantiating and using \c FindDialog can always access the - search string that the user has entered and accepted. - -- \snippet examples/addressbook-sdk/part5/finddialog.cpp getFindText -+ \snippet examples/addressbook-sdk/part5/finddialog.cpp findText - - - \section1 The AddressBook Class -@@ -788,23 +793,9 @@ - - So far, all our address book features have a QPushButton and a - corresponding slot. Similarly, for the \gui Find feature, we have -- \c findButton and \c findContact(). -+ \c {ui->findButton} and \c findContact(). - - \snippet examples/addressbook-sdk/part5/addressbook.h slot definition -- \dots -- \snippet examples/addressbook-sdk/part5/addressbook.h private members -- -- Lastly, we declare the private variable, \c dialog, which we will use to -- refer to an instance of \c FindDialog. -- -- Once we have instantiated a dialog, we might want to use it more than once; -- using a private variable allows us to refer to it from more than one place -- in the class. -- -- Within the \c AddressBook class's constructor, we insantiate our private -- objects, \c findButton and \c dialog: -- -- \snippet examples/addressbook-sdk/part5/addressbook.cpp private members - - Next, we connect the \c{findButton}'s \l{QPushButton::}{clicked()} signal - to \c findContact(). -@@ -818,10 +809,12 @@ - We start out by displaying the \c FindDialog instance, \c dialog. This is - when the user enters a contact name to look up. Once the user clicks the - dialog's \c findButton, the dialog is hidden and the result code is set to -- QDialog::Accepted. THis ensures that our \c if statement is always true. -+ either QDialog::Accepted or QDialog::Rejected by the FindDialog's -+ \c findClicked() method. This ensures that we only search for a contact -+ if the user typed something in the FindDialog's line edit. - - We then proceed to extract the search string, which in this case is -- \c contactName, using \c{FindDialog}'s \c getFindText() function. If the -+ \c contactName, using \c{FindDialog}'s \c findText() function. If the - contact exists in our address book, we display it immediately. Otherwise, - we display the QMessageBox shown below to indicate that their search - failed. diff --git a/share/qtcreator/gdbmacros/test/main.cpp b/share/qtcreator/gdbmacros/test/main.cpp index de8fc9f91f209a3c41137d081995825a9dc6a911..f77486fae49873ae9fcee9549d7ffee8dbc3e420 100644 --- a/share/qtcreator/gdbmacros/test/main.cpp +++ b/share/qtcreator/gdbmacros/test/main.cpp @@ -35,6 +35,8 @@ #include <QtCore/QMap> #include <QtCore/QSet> #include <QtCore/QVariant> +#include <QtCore/QFileInfo> +#include <QtCore/QCoreApplication> #include <QtGui/QAction> #include <string> @@ -51,6 +53,7 @@ bool optTestUninitialized = false; bool optTestAll = false; bool optEmptyContainers = false; unsigned optVerbose = 0; +const char *appPath = 0; // Provide address of type of be tested. // When testing unitialized memory, allocate at random. @@ -482,7 +485,6 @@ static int dumpStdMapStringString() return 0; } - static int dumpQObject() { // Requires the childOffset to be know, but that is not critical @@ -517,6 +519,16 @@ static int dumpQObject() return 0; } +static int dumpQFileInfo() +{ + QFileInfo test(QString::fromLatin1(appPath)); + prepareInBuffer("QFileInfo", "local.qfileinfo", "local.qfileinfo",""); + qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0); + fputs(qDumpOutBuffer, stdout); + fputc('\n', stdout); + return 0; +} + static int dumpQObjectList() { // Requires the childOffset to be know, but that is not critical @@ -566,6 +578,7 @@ static TypeDumpFunctionMap registerTypes() rc.insert("set<QString>", dumpStdQStringSet); rc.insert("map<int,string>", dumpStdMapIntString); rc.insert("map<string,string>", dumpStdMapStringString); + rc.insert("QFileInfo", dumpQFileInfo); rc.insert("QObject", dumpQObject); rc.insert("QObjectList", dumpQObjectList); rc.insert("QVariant", dumpQVariant); @@ -592,6 +605,7 @@ static void usage(const char *b, const TypeDumpFunctionMap &tdm) int main(int argc, char *argv[]) { + appPath = argv[0]; printf("\nQt Creator Debugging Helper testing tool\n\n"); printf("Running query protocol\n"); qDumpObjectData440(1, 42, 0, 1, 0, 0, 0, 0); diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.cpp b/src/libs/cplusplus/CheckUndefinedSymbols.cpp index 51d02a0dc475f8cc79480051616dc654369435eb..ee5d76bf7e8fa4e9778d7dcd285ff507488db21e 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.cpp +++ b/src/libs/cplusplus/CheckUndefinedSymbols.cpp @@ -65,7 +65,7 @@ void CheckUndefinedSymbols::operator()(AST *ast) QByteArray CheckUndefinedSymbols::templateParameterName(NameAST *ast) const { if (ast && ast->name) { - if (Identifier *id = ast->name->identifier()) + if (const Identifier *id = ast->name->identifier()) return QByteArray::fromRawData(id->chars(), id->size()); } @@ -92,7 +92,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const Symbol *member = members->symbolAt(m); if (member->isTypedef() && member->isDeclaration()) { - if (Identifier *id = member->identifier()) { + if (const Identifier *id = member->identifier()) { if (name == id->chars()) return true; } @@ -114,7 +114,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const return _types.contains(name); } -bool CheckUndefinedSymbols::isType(Identifier *id) const +bool CheckUndefinedSymbols::isType(const Identifier *id) const { if (! id) return false; @@ -122,21 +122,21 @@ bool CheckUndefinedSymbols::isType(Identifier *id) const return isType(QByteArray::fromRawData(id->chars(), id->size())); } -void CheckUndefinedSymbols::addType(Name *name) +void CheckUndefinedSymbols::addType(const Name *name) { if (! name) return; - if (Identifier *id = name->identifier()) + if (const Identifier *id = name->identifier()) _types.insert(QByteArray(id->chars(), id->size())); } -void CheckUndefinedSymbols::addProtocol(Name *name) +void CheckUndefinedSymbols::addProtocol(const Name *name) { if (!name) return; - if (Identifier *id = name->identifier()) + if (const Identifier *id = name->identifier()) _protocols.insert(QByteArray(id->chars(), id->size())); } @@ -176,7 +176,7 @@ void CheckUndefinedSymbols::buildTypeMap(NamespaceBinding *binding, QSet<Namespa if (! processed->contains(binding)) { processed->insert(binding); - if (Identifier *id = binding->identifier()) { + if (const Identifier *id = binding->identifier()) { _namespaceNames.insert(QByteArray(id->chars(), id->size())); } @@ -256,7 +256,7 @@ bool CheckUndefinedSymbols::visit(NamedTypeSpecifierAST *ast) unsigned line, col; getTokenStartPosition(ast->firstToken(), &line, &col); // qWarning() << _doc->fileName() << line << col; - } else if (Identifier *id = ast->name->name->identifier()) { + } else if (const Identifier *id = ast->name->name->identifier()) { if (! isType(id)) { if (FunctionDeclaratorAST *functionDeclarator = currentFunctionDeclarator()) { if (functionDeclarator->as_cpp_initializer) @@ -294,7 +294,7 @@ bool CheckUndefinedSymbols::visit(ClassSpecifierAST *ast) Symbol *symbol = klass->memberAt(i); if (symbol->name() && symbol->name()->isNameId()) { - NameId *nameId = symbol->name()->asNameId(); + const NameId *nameId = symbol->name()->asNameId(); if (! qstrcmp(nameId->identifier()->chars(), "qt_check_for_QOBJECT_macro")) { hasQ_OBJECT_CHECK = true; @@ -367,8 +367,8 @@ bool CheckUndefinedSymbols::visit(BaseSpecifierAST *base) if (NameAST *nameAST = base->name) { bool resolvedBaseClassName = false; - if (Name *name = nameAST->name) { - Identifier *id = name->identifier(); + if (const Name *name = nameAST->name) { + const Identifier *id = name->identifier(); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); if (isType(spell)) resolvedBaseClassName = true; @@ -403,10 +403,10 @@ bool CheckUndefinedSymbols::visit(UsingDirectiveAST *ast) bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast) { if (ast->name) { - QualifiedNameId *q = ast->name->asQualifiedNameId(); + const QualifiedNameId *q = ast->name->asQualifiedNameId(); for (unsigned i = 0; i < q->nameCount() - 1; ++i) { - Name *name = q->nameAt(i); - if (Identifier *id = name->identifier()) { + const Name *name = q->nameAt(i); + if (const Identifier *id = name->identifier()) { const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); if (! (_namespaceNames.contains(spell) || isType(id))) { translationUnit()->warning(ast->firstToken(), @@ -474,8 +474,8 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast) if (NameAST *nameAST = ast->superclass) { bool resolvedSuperClassName = false; - if (Name *name = nameAST->name) { - Identifier *id = name->identifier(); + if (const Name *name = nameAST->name) { + const Identifier *id = name->identifier(); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); if (isType(spell)) resolvedSuperClassName = true; @@ -496,8 +496,8 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast) if (NameAST *nameAST = iter->value) { bool resolvedProtocolName = false; - if (Name *name = nameAST->name) { - Identifier *id = name->identifier(); + if (const Name *name = nameAST->name) { + const Identifier *id = name->identifier(); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); if (isProtocol(spell)) resolvedProtocolName = true; @@ -522,11 +522,11 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast) bool CheckUndefinedSymbols::visit(ObjCPropertyDeclarationAST *ast) { for (List<ObjCPropertyDeclaration *> *iter = ast->symbols; iter; iter = iter->next) { - if (Name *getterName = iter->value->getterName()) { + if (/*Name *getterName = */ iter->value->getterName()) { // FIXME: resolve the symbol for the name, and check its signature. } - if (Name *setterName = iter->value->setterName()) { + if (/*Name *setterName = */ iter->value->setterName()) { // FIXME: resolve the symbol for the name, and check its signature. } } diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.h b/src/libs/cplusplus/CheckUndefinedSymbols.h index 4a13b6ee2dcf9f9502d9b545c5f061777e670310..c8569bd21033dcdf2278c1b8dc006209694be0f3 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.h +++ b/src/libs/cplusplus/CheckUndefinedSymbols.h @@ -52,14 +52,14 @@ public: protected: using ASTVisitor::visit; - bool isType(Identifier *id) const; + bool isType(const Identifier *id) const; bool isType(const QByteArray &name) const; - void addType(Name *name); + void addType(const Name *name); void buildTypeMap(Class *klass); void buildMemberTypeMap(Symbol *member); void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed); - void addProtocol(Name *name); + void addProtocol(const Name *name); bool isProtocol(const QByteArray &name) const; FunctionDeclaratorAST *currentFunctionDeclarator() const; diff --git a/src/libs/cplusplus/CppBindings.cpp b/src/libs/cplusplus/CppBindings.cpp index c916ab4b8b15640397e77d47516f76a6ee4817af..d9b0a32eacd1d23449756a3391238430799a9718 100644 --- a/src/libs/cplusplus/CppBindings.cpp +++ b/src/libs/cplusplus/CppBindings.cpp @@ -57,7 +57,7 @@ Location::Location(Symbol *symbol) _sourceLocation(symbol->sourceLocation()) { } -Location::Location(StringLiteral *fileId, unsigned sourceLocation) +Location::Location(const StringLiteral *fileId, unsigned sourceLocation) : _fileId(fileId), _sourceLocation(sourceLocation) { } @@ -79,11 +79,11 @@ NamespaceBinding::~NamespaceBinding() qDeleteAll(classBindings); } -NameId *NamespaceBinding::name() const +const NameId *NamespaceBinding::name() const { if (symbols.size()) { - if (Name *name = symbols.first()->name()) { - NameId *nameId = name->asNameId(); + if (const Name *name = symbols.first()->name()) { + const NameId *nameId = name->asNameId(); Q_ASSERT(nameId != 0); return nameId; @@ -93,9 +93,9 @@ NameId *NamespaceBinding::name() const return 0; } -Identifier *NamespaceBinding::identifier() const +const Identifier *NamespaceBinding::identifier() const { - if (NameId *nameId = name()) + if (const NameId *nameId = name()) return nameId->identifier(); return 0; @@ -113,7 +113,7 @@ NamespaceBinding *NamespaceBinding::globalNamespaceBinding() return it; } -Binding *NamespaceBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed) +Binding *NamespaceBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) { if (processed->contains(this)) return 0; @@ -144,7 +144,7 @@ Binding *NamespaceBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Bind return 0; } -ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *processed) +ClassBinding *NamespaceBinding::findClassBinding(const Name *name, QSet<Binding *> *processed) { if (! name) return 0; @@ -156,7 +156,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr Binding *current = this; for (unsigned i = 0; i < q->nameCount(); ++i) { - Identifier *nameId = q->nameAt(i)->identifier(); + const Identifier *nameId = q->nameAt(i)->identifier(); if (! nameId) return 0; @@ -173,7 +173,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr processed->insert(this); - Identifier *id = name->identifier(); + const Identifier *id = name->identifier(); foreach (ClassBinding *classBinding, classBindings) { if (id->isEqualTo(classBinding->identifier())) @@ -191,19 +191,19 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr return 0; } -NamespaceBinding *NamespaceBinding::findNamespaceBinding(Name *name) +NamespaceBinding *NamespaceBinding::findNamespaceBinding(const Name *name) { if (! name) return anonymousNamespaceBinding; - else if (NameId *nameId = name->asNameId()) + else if (const NameId *nameId = name->asNameId()) return findNamespaceBindingForNameId(nameId, /*lookAtParent = */ true); else if (const QualifiedNameId *q = name->asQualifiedNameId()) { NamespaceBinding *current = this; for (unsigned i = 0; i < q->nameCount(); ++i) { - NameId *namespaceName = q->nameAt(i)->asNameId(); + const NameId *namespaceName = q->nameAt(i)->asNameId(); if (! namespaceName) return 0; @@ -225,14 +225,14 @@ NamespaceBinding *NamespaceBinding::findNamespaceBinding(Name *name) return 0; } -NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId(NameId *name, +NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId(const NameId *name, bool lookAtParentNamespace) { QSet<NamespaceBinding *> processed; return findNamespaceBindingForNameId_helper(name, lookAtParentNamespace, &processed); } -NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(NameId *name, +NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(const NameId *name, bool lookAtParentNamespace, QSet<NamespaceBinding *> *processed) { @@ -242,12 +242,12 @@ NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(NameId processed->insert(this); foreach (NamespaceBinding *binding, children) { - Name *bindingName = binding->name(); + const Name *bindingName = binding->name(); if (! bindingName) continue; - if (NameId *bindingNameId = bindingName->asNameId()) { + if (const NameId *bindingNameId = bindingName->asNameId()) { if (name->isEqualTo(bindingNameId)) return binding; } @@ -296,7 +296,7 @@ NamespaceBinding *NamespaceBinding::findOrCreateNamespaceBinding(Namespace *symb } static void closure(const Location &loc, - NamespaceBinding *binding, Name *name, + NamespaceBinding *binding, const Name *name, QList<NamespaceBinding *> *bindings) { if (bindings->contains(binding)) @@ -306,7 +306,7 @@ static void closure(const Location &loc, Q_ASSERT(name->isNameId()); - Identifier *id = name->asNameId()->identifier(); + const Identifier *id = name->asNameId()->identifier(); bool ignoreUsingDirectives = false; foreach (Namespace *symbol, binding->symbols) { @@ -334,13 +334,13 @@ static void closure(const Location &loc, NamespaceBinding *NamespaceBinding::resolveNamespace(const Location &loc, - Name *name, + const Name *name, bool lookAtParent) { if (! name) return 0; - else if (NameId *nameId = name->asNameId()) { + else if (const NameId *nameId = name->asNameId()) { QList<NamespaceBinding *> bindings; closure(loc, this, nameId, &bindings); @@ -394,7 +394,7 @@ QByteArray NamespaceBinding::qualifiedId() const s.append(parent->qualifiedId()); s.append("::"); - if (Identifier *id = identifier()) + if (const Identifier *id = identifier()) s.append(id->chars(), id->size()); else @@ -409,7 +409,7 @@ QByteArray ClassBinding::qualifiedId() const QByteArray s = parent->qualifiedId(); s += "::"; - if (Identifier *id = identifier()) + if (const Identifier *id = identifier()) s.append(id->chars(), id->size()); else @@ -418,7 +418,7 @@ QByteArray ClassBinding::qualifiedId() const return s; } -Binding *ClassBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed) +Binding *ClassBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) { if (id->isEqualTo(identifier())) return this; @@ -447,7 +447,7 @@ Binding *ClassBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding return 0; } -ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *processed) +ClassBinding *ClassBinding::findClassBinding(const Name *name, QSet<Binding *> *processed) { if (! name) return 0; @@ -461,7 +461,7 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces Binding *currentBinding = this; for (unsigned i = 0; i < q->nameCount() - 1; ++i) { - Identifier *id = q->nameAt(i)->identifier(); + const Identifier *id = q->nameAt(i)->identifier(); if (! id) return 0; @@ -479,12 +479,12 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces return 0; } - if (Identifier *id = name->identifier()) { + if (const Identifier *id = name->identifier()) { if (id->isEqualTo(identifier())) return this; foreach (ClassBinding *nestedClassBinding, children) { - if (Identifier *nestedClassId = nestedClassBinding->identifier()) { + if (const Identifier *nestedClassId = nestedClassBinding->identifier()) { if (nestedClassId->isEqualTo(id)) return nestedClassBinding; } @@ -549,7 +549,7 @@ ClassBinding::ClassBinding(ClassBinding *parentClass) ClassBinding::~ClassBinding() { qDeleteAll(children); } -Name *ClassBinding::name() const +const Name *ClassBinding::name() const { if (symbols.isEmpty()) return 0; @@ -557,9 +557,9 @@ Name *ClassBinding::name() const return symbols.first()->name(); } -Identifier *ClassBinding::identifier() const +const Identifier *ClassBinding::identifier() const { - if (Name *n = name()) + if (const Name *n = name()) return n->identifier(); return 0; @@ -623,12 +623,12 @@ protected: NamespaceBinding *bind(Symbol *symbol, NamespaceBinding *binding); NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol); - NamespaceBinding *resolveNamespace(const Location &loc, Name *name); + NamespaceBinding *resolveNamespace(const Location &loc, const Name *name); NamespaceBinding *switchNamespaceBinding(NamespaceBinding *binding); ClassBinding *findOrCreateClassBinding(Class *classSymbol); - ClassBinding *findClassBinding(Name *name); + ClassBinding *findClassBinding(const Name *name); ClassBinding *switchClassBinding(ClassBinding *binding); @@ -665,7 +665,7 @@ NamespaceBinding *Binder::bind(Symbol *symbol, NamespaceBinding *binding) NamespaceBinding *Binder::findOrCreateNamespaceBinding(Namespace *symbol) { return namespaceBinding->findOrCreateNamespaceBinding(symbol); } -NamespaceBinding *Binder::resolveNamespace(const Location &loc, Name *name) +NamespaceBinding *Binder::resolveNamespace(const Location &loc, const Name *name) { if (! namespaceBinding) return 0; @@ -694,7 +694,7 @@ ClassBinding *Binder::findOrCreateClassBinding(Class *classSymbol) return binding; } -ClassBinding *Binder::findClassBinding(Name *name) +ClassBinding *Binder::findClassBinding(const Name *name) { QSet<Binding *> processed; diff --git a/src/libs/cplusplus/CppBindings.h b/src/libs/cplusplus/CppBindings.h index 0ba95de09849c4b5316c4d3779acb991b668415a..41ed9638c71e2ebdc61f851af44dc0512d69c4b3 100644 --- a/src/libs/cplusplus/CppBindings.h +++ b/src/libs/cplusplus/CppBindings.h @@ -53,7 +53,7 @@ class CPLUSPLUS_EXPORT Location public: Location(); Location(Symbol *symbol); - Location(StringLiteral *fileId, unsigned sourceLocation); + Location(const StringLiteral *fileId, unsigned sourceLocation); inline bool isValid() const { return _fileId != 0; } @@ -61,14 +61,14 @@ public: inline operator bool() const { return _fileId != 0; } - inline StringLiteral *fileId() const + inline const StringLiteral *fileId() const { return _fileId; } inline unsigned sourceLocation() const { return _sourceLocation; } private: - StringLiteral *_fileId; + const StringLiteral *_fileId; unsigned _sourceLocation; }; @@ -84,8 +84,8 @@ public: virtual NamespaceBinding *asNamespaceBinding() { return 0; } virtual ClassBinding *asClassBinding() { return 0; } - virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed) = 0; - virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed) = 0; + virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed) = 0; + virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) = 0; }; class CPLUSPLUS_EXPORT NamespaceBinding: public Binding @@ -98,26 +98,26 @@ public: virtual ~NamespaceBinding(); /// Returns this binding's name. - NameId *name() const; + const NameId *name() const; /// Returns this binding's identifier. - Identifier *identifier() const; + const Identifier *identifier() const; /// Returns the binding for the global namespace (aka ::). NamespaceBinding *globalNamespaceBinding(); /// Returns the binding for the given namespace symbol. - NamespaceBinding *findNamespaceBinding(Name *name); + NamespaceBinding *findNamespaceBinding(const Name *name); /// Returns the binding associated with the given symbol. NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol); NamespaceBinding *resolveNamespace(const Location &loc, - Name *name, + const Name *name, bool lookAtParent = true); - virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed); - virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed); + virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed); + virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed); /// Helpers. virtual QByteArray qualifiedId() const; @@ -129,10 +129,10 @@ public: static ClassBinding *find(Class *symbol, NamespaceBinding *binding); private: - NamespaceBinding *findNamespaceBindingForNameId(NameId *name, + NamespaceBinding *findNamespaceBindingForNameId(const NameId *name, bool lookAtParentNamespace); - NamespaceBinding *findNamespaceBindingForNameId_helper(NameId *name, + NamespaceBinding *findNamespaceBindingForNameId_helper(const NameId *name, bool lookAtParentNamespace, QSet<NamespaceBinding *> *processed); @@ -165,14 +165,14 @@ public: virtual ClassBinding *asClassBinding() { return this; } /// Returns this binding's name. - Name *name() const; + const Name *name() const; /// Returns this binding's identifier. - Identifier *identifier() const; + const Identifier *identifier() const; virtual QByteArray qualifiedId() const; - virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed); - virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed); + virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed); + virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed); void dump(); diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 24614c06e198b5d1f35c1f5bc476e8b5c9594ddc..ba6409280ac014056c5d50ea23323e45cad31cc3 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -66,7 +66,7 @@ public: { } virtual void report(int level, - StringLiteral *fileId, + const StringLiteral *fileId, unsigned line, unsigned column, const char *format, va_list ap) { @@ -118,8 +118,8 @@ Document::Document(const QString &fileName) _control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages)); const QByteArray localFileName = fileName.toUtf8(); - StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(), - localFileName.size()); + const StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(), + localFileName.size()); _translationUnit = new TranslationUnit(_control, fileId); _translationUnit->setQtMocRunEnabled(true); _translationUnit->setObjCEnabled(true); diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 396e9c8a5e79d7485ba34a6d8a5d18be8a288de5..bc9175740f887f052f36bbf3a477f4b8ddafc24e 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -57,7 +57,7 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi _globalNamespaceBinding = globalNamespaceBinding; } -QList<int> FindUsages::operator()(Symbol *symbol, Identifier *id, AST *ast) +QList<int> FindUsages::operator()(Symbol *symbol, const Identifier *id, AST *ast) { _processed.clear(); _references.clear(); @@ -344,7 +344,7 @@ bool FindUsages::visit(QualifiedNameAST *ast) bool FindUsages::visit(EnumeratorAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); if (id == _id) { LookupContext context = currentContext(ast); const QList<Symbol *> candidates = context.resolve(control()->nameId(id)); @@ -358,7 +358,7 @@ bool FindUsages::visit(EnumeratorAST *ast) bool FindUsages::visit(SimpleNameAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); if (id == _id) { LookupContext context = currentContext(ast); const QList<Symbol *> candidates = context.resolve(ast->name); @@ -370,7 +370,7 @@ bool FindUsages::visit(SimpleNameAST *ast) bool FindUsages::visit(DestructorNameAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); if (id == _id) { LookupContext context = currentContext(ast); const QList<Symbol *> candidates = context.resolve(ast->name); diff --git a/src/libs/cplusplus/FindUsages.h b/src/libs/cplusplus/FindUsages.h index 667ad18485a310421a2372d08395b1781f3cbc75..4109a252df13333f0cd64c42a0e38f5a453da207 100644 --- a/src/libs/cplusplus/FindUsages.h +++ b/src/libs/cplusplus/FindUsages.h @@ -64,7 +64,7 @@ public: void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding); - QList<int> operator()(Symbol *symbol, Identifier *id, AST *ast); + QList<int> operator()(Symbol *symbol, const Identifier *id, AST *ast); protected: using ASTVisitor::visit; @@ -101,7 +101,7 @@ protected: private: QFutureInterface<Usage> *_future; - Identifier *_id; + const Identifier *_id; Symbol *_declSymbol; Document::Ptr _doc; Snapshot _snapshot; diff --git a/src/libs/cplusplus/GenTemplateInstance.cpp b/src/libs/cplusplus/GenTemplateInstance.cpp index 0267efeefa8e165a530f90a5a11f676e684b573f..16aee2f9577921afb6bd119946f60d78704c7ace 100644 --- a/src/libs/cplusplus/GenTemplateInstance.cpp +++ b/src/libs/cplusplus/GenTemplateInstance.cpp @@ -52,10 +52,10 @@ public: Control *control() const { return context.control(); } - FullySpecifiedType apply(Name *name); + FullySpecifiedType apply(const Name *name); FullySpecifiedType apply(const FullySpecifiedType &type); - int findSubstitution(Identifier *id) const; + int findSubstitution(const Identifier *id) const; FullySpecifiedType applySubstitution(int index) const; private: @@ -207,7 +207,7 @@ private: public: ApplyToName(ApplySubstitution *q): q(q) {} - FullySpecifiedType operator()(Name *name) + FullySpecifiedType operator()(const Name *name) { FullySpecifiedType previousType = switchType(FullySpecifiedType()); accept(name); @@ -218,7 +218,7 @@ private: Control *control() const { return q->control(); } - int findSubstitution(Identifier *id) const + int findSubstitution(const Identifier *id) const { return q->findSubstitution(id); } FullySpecifiedType applySubstitution(int index) const @@ -231,7 +231,7 @@ private: return previousType; } - virtual void visit(NameId *name) + virtual void visit(const NameId *name) { int index = findSubstitution(name->identifier()); @@ -242,7 +242,7 @@ private: _type = control()->namedType(name); } - virtual void visit(TemplateNameId *name) + virtual void visit(const TemplateNameId *name) { QVarLengthArray<FullySpecifiedType, 8> arguments(name->templateArgumentCount()); for (unsigned i = 0; i < name->templateArgumentCount(); ++i) { @@ -250,17 +250,19 @@ private: arguments[i] = q->apply(argTy); } - TemplateNameId *templId = control()->templateNameId(name->identifier(), arguments.data(), arguments.size()); + const TemplateNameId *templId = control()->templateNameId(name->identifier(), + arguments.data(), + arguments.size()); _type = control()->namedType(templId); } - virtual void visit(QualifiedNameId *name) + virtual void visit(const QualifiedNameId *name) { - QVarLengthArray<Name *, 8> names(name->nameCount()); + QVarLengthArray<const Name *, 8> names(name->nameCount()); for (unsigned i = 0; i < name->nameCount(); ++i) { - Name *n = name->nameAt(i); + const Name *n = name->nameAt(i); - if (TemplateNameId *templId = n->asTemplateNameId()) { + if (const TemplateNameId *templId = n->asTemplateNameId()) { QVarLengthArray<FullySpecifiedType, 8> arguments(templId->templateArgumentCount()); for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) { FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex); @@ -273,29 +275,29 @@ private: names[i] = n; } - QualifiedNameId *q = control()->qualifiedNameId(names.data(), names.size(), name->isGlobal()); + const QualifiedNameId *q = control()->qualifiedNameId(names.data(), names.size(), name->isGlobal()); _type = control()->namedType(q); } - virtual void visit(DestructorNameId *name) + virtual void visit(const DestructorNameId *name) { Overview oo; qWarning() << "ignored name:" << oo(name); } - virtual void visit(OperatorNameId *name) + virtual void visit(const OperatorNameId *name) { Overview oo; qWarning() << "ignored name:" << oo(name); } - virtual void visit(ConversionNameId *name) + virtual void visit(const ConversionNameId *name) { Overview oo; qWarning() << "ignored name:" << oo(name); } - virtual void visit(SelectorNameId *name) + virtual void visit(const SelectorNameId *name) { Overview oo; qWarning() << "ignored name:" << oo(name); @@ -325,7 +327,7 @@ ApplySubstitution::~ApplySubstitution() { } -FullySpecifiedType ApplySubstitution::apply(Name *name) +FullySpecifiedType ApplySubstitution::apply(const Name *name) { FullySpecifiedType ty = applyToName(name); return ty; @@ -337,12 +339,12 @@ FullySpecifiedType ApplySubstitution::apply(const FullySpecifiedType &type) return ty; } -int ApplySubstitution::findSubstitution(Identifier *id) const +int ApplySubstitution::findSubstitution(const Identifier *id) const { Q_ASSERT(id != 0); for (int index = 0; index < substitution.size(); ++index) { - QPair<Identifier *, FullySpecifiedType> s = substitution.at(index); + QPair<const Identifier *, FullySpecifiedType> s = substitution.at(index); if (id->isEqualTo(s.first)) return index; diff --git a/src/libs/cplusplus/GenTemplateInstance.h b/src/libs/cplusplus/GenTemplateInstance.h index a59d1a74717ac50368ac97febca2e5693b97f2f4..8db5bd9d934f1abefb28179ebb7318bc812130da 100644 --- a/src/libs/cplusplus/GenTemplateInstance.h +++ b/src/libs/cplusplus/GenTemplateInstance.h @@ -44,7 +44,7 @@ namespace CPlusPlus { class CPLUSPLUS_EXPORT GenTemplateInstance { public: - typedef QList< QPair<Identifier *, FullySpecifiedType> > Substitution; + typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution; public: GenTemplateInstance(const LookupContext &context, const Substitution &substitution); diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index f125d202cd4206058bf1b15c35e3d31bdabf629e..942c0dc764e1e68a35579bc0bbd98252d96e21f2 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -109,14 +109,14 @@ bool LookupContext::maybeValidSymbol(Symbol *symbol, return false; } -QList<Scope *> LookupContext::resolveNestedNameSpecifier(QualifiedNameId *q, - const QList<Scope *> &visibleScopes) const +QList<Scope *> LookupContext::resolveNestedNameSpecifier(const QualifiedNameId *q, + const QList<Scope *> &visibleScopes) const { QList<Symbol *> candidates; QList<Scope *> scopes = visibleScopes; for (unsigned i = 0; i < q->nameCount() - 1; ++i) { - Name *name = q->nameAt(i); + const Name *name = q->nameAt(i); candidates = resolveClassOrNamespace(name, scopes); @@ -137,7 +137,7 @@ QList<Scope *> LookupContext::resolveNestedNameSpecifier(QualifiedNameId *q, return scopes; } -QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, +QList<Symbol *> LookupContext::resolveQualifiedNameId(const QualifiedNameId *q, const QList<Scope *> &visibleScopes, ResolveMode mode) const { @@ -153,7 +153,7 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, else if (! symbol->isClass()) continue; - QualifiedNameId *qq = symbol->name()->asQualifiedNameId(); + const QualifiedNameId *qq = symbol->name()->asQualifiedNameId(); if (! qq) continue; @@ -167,8 +167,8 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, unsigned j = 0; for (; j < q->nameCount(); ++j) { - Name *classOrNamespaceName1 = q->nameAt(j); - Name *classOrNamespaceName2 = qq->nameAt(j); + const Name *classOrNamespaceName1 = q->nameAt(j); + const Name *classOrNamespaceName2 = qq->nameAt(j); if (! classOrNamespaceName1->isEqualTo(classOrNamespaceName2)) break; @@ -205,7 +205,7 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, return candidates; } -QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId, +QList<Symbol *> LookupContext::resolveOperatorNameId(const OperatorNameId *opId, const QList<Scope *> &visibleScopes, ResolveMode) const { @@ -226,7 +226,7 @@ QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId, return candidates; } -QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes, +QList<Symbol *> LookupContext::resolve(const Name *name, const QList<Scope *> &visibleScopes, ResolveMode mode) const { QList<Symbol *> candidates; @@ -234,13 +234,13 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible if (!name) return candidates; // nothing to do, the symbol is anonymous. - else if (QualifiedNameId *q = name->asQualifiedNameId()) + else if (const QualifiedNameId *q = name->asQualifiedNameId()) return resolveQualifiedNameId(q, visibleScopes, mode); - else if (OperatorNameId *opId = name->asOperatorNameId()) + else if (const OperatorNameId *opId = name->asOperatorNameId()) return resolveOperatorNameId(opId, visibleScopes, mode); - else if (Identifier *id = name->identifier()) { + else if (const Identifier *id = name->identifier()) { for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) { Scope *scope = visibleScopes.at(scopeIndex); @@ -251,21 +251,21 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible else if (! maybeValidSymbol(symbol, mode, candidates)) continue; // skip it, we're not looking for this kind of symbols - else if (Identifier *symbolId = symbol->identifier()) { + else if (const Identifier *symbolId = symbol->identifier()) { if (! symbolId->isEqualTo(id)) continue; // skip it, the symbol's id is not compatible with this lookup. } - if (QualifiedNameId *q = symbol->name()->asQualifiedNameId()) { + if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) { if (name->isDestructorNameId() != q->unqualifiedNameId()->isDestructorNameId()) continue; else if (q->nameCount() > 1) { - Name *classOrNamespaceName = control()->qualifiedNameId(q->names(), - q->nameCount() - 1); + const Name *classOrNamespaceName = control()->qualifiedNameId(q->names(), + q->nameCount() - 1); - if (Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) { + if (const Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) { if (classOrNamespaceNameId->isEqualTo(id)) continue; } @@ -299,7 +299,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible return candidates; } -Identifier *LookupContext::identifier(const Name *name) const +const Identifier *LookupContext::identifier(const Name *name) const { if (name) return name->identifier(); @@ -418,7 +418,7 @@ void LookupContext::expandNamespace(Namespace *ns, if (Scope *encl = ns->enclosingNamespaceScope()) expand(encl, visibleScopes, expandedScopes); - if (Name *nsName = ns->name()) { + if (const Name *nsName = ns->name()) { const QList<Symbol *> namespaceList = resolveNamespace(nsName, visibleScopes); foreach (Symbol *otherNs, namespaceList) { if (otherNs == ns) @@ -478,7 +478,7 @@ void LookupContext::expandClass(Class *klass, for (unsigned i = 0; i < klass->baseClassCount(); ++i) { BaseClass *baseClass = klass->baseClassAt(i); - Name *baseClassName = baseClass->name(); + const Name *baseClassName = baseClass->name(); const QList<Symbol *> baseClassCandidates = resolveClass(baseClassName, classVisibleScopes); @@ -515,8 +515,8 @@ void LookupContext::expandFunction(Function *function, if (! expandedScopes->contains(function->arguments())) expandedScopes->append(function->arguments()); - if (QualifiedNameId *q = function->name()->asQualifiedNameId()) { - Name *nestedNameSpec = 0; + if (const QualifiedNameId *q = function->name()->asQualifiedNameId()) { + const Name *nestedNameSpec = 0; if (q->nameCount() == 1) nestedNameSpec = q->nameAt(0); else @@ -565,7 +565,7 @@ void LookupContext::expandObjCClass(ObjCClass *klass, // expand the base class: if (ObjCBaseClass *baseClass = klass->baseClass()) { - Name *baseClassName = baseClass->name(); + const Name *baseClassName = baseClass->name(); const QList<Symbol *> baseClassCandidates = resolveObjCClass(baseClassName, visibleScopes); @@ -577,7 +577,7 @@ void LookupContext::expandObjCClass(ObjCClass *klass, // expand the protocols: for (unsigned i = 0; i < klass->protocolCount(); ++i) { - Name *protocolName = klass->protocolAt(i)->name(); + const Name *protocolName = klass->protocolAt(i)->name(); const QList<Symbol *> protocolCandidates = resolveObjCProtocol(protocolName, visibleScopes); for (int j = 0; j < protocolCandidates.size(); ++j) { if (ObjCProtocol *protocolSymbol = protocolCandidates.at(j)->asObjCProtocol()) @@ -667,7 +667,7 @@ Symbol *LookupContext::canonicalSymbol(Symbol *symbol, if (! canonicalSymbol) return 0; - if (Identifier *symbolId = canonicalSymbol->identifier()) { + if (const Identifier *symbolId = canonicalSymbol->identifier()) { if (symbolId && canonicalSymbol->type()->isFunctionType()) { Class *enclosingClass = canonicalSymbol->scope()->owner()->asClass(); const QList<ClassBinding *> classBindings = visibleClassBindings(enclosingClass, globalNamespace); diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 3eca2fce3152c6d187943bfc5e1fdd743257c1ee..bced5f4cf49073a0e29e841f3dfb6a2ee3dffe52 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -94,22 +94,22 @@ public: static Symbol *canonicalSymbol(const QList<LookupItem> &candidates, NamespaceBinding *globalNamespaceBinding); - QList<Symbol *> resolve(Name *name) const + QList<Symbol *> resolve(const Name *name) const { return resolve(name, visibleScopes()); } - QList<Symbol *> resolveNamespace(Name *name) const + QList<Symbol *> resolveNamespace(const Name *name) const { return resolveNamespace(name, visibleScopes()); } - QList<Symbol *> resolveClass(Name *name) const + QList<Symbol *> resolveClass(const Name *name) const { return resolveClass(name, visibleScopes()); } - QList<Symbol *> resolveClassOrNamespace(Name *name) const + QList<Symbol *> resolveClassOrNamespace(const Name *name) const { return resolveClassOrNamespace(name, visibleScopes()); } - QList<Symbol *> resolveObjCClass(Name *name) const + QList<Symbol *> resolveObjCClass(const Name *name) const { return resolveObjCClass(name, visibleScopes()); } - QList<Symbol *> resolveObjCProtocol(Name *name) const + QList<Symbol *> resolveObjCProtocol(const Name *name) const { return resolveObjCProtocol(name, visibleScopes()); } enum ResolveMode { @@ -122,22 +122,22 @@ public: ResolveAll = ResolveSymbol | ResolveClassOrNamespace | ResolveObjCClass | ResolveObjCProtocol }; - QList<Symbol *> resolve(Name *name, const QList<Scope *> &visibleScopes, + QList<Symbol *> resolve(const Name *name, const QList<Scope *> &visibleScopes, ResolveMode mode = ResolveAll) const; - QList<Symbol *> resolveNamespace(Name *name, const QList<Scope *> &visibleScopes) const + QList<Symbol *> resolveNamespace(const Name *name, const QList<Scope *> &visibleScopes) const { return resolve(name, visibleScopes, ResolveNamespace); } - QList<Symbol *> resolveClass(Name *name, const QList<Scope *> &visibleScopes) const + QList<Symbol *> resolveClass(const Name *name, const QList<Scope *> &visibleScopes) const { return resolve(name, visibleScopes, ResolveClass); } - QList<Symbol *> resolveClassOrNamespace(Name *name, const QList<Scope *> &visibleScopes) const + QList<Symbol *> resolveClassOrNamespace(const Name *name, const QList<Scope *> &visibleScopes) const { return resolve(name, visibleScopes, ResolveClassOrNamespace); } - QList<Symbol *> resolveObjCClass(Name *name, const QList<Scope *> &visibleScopes) const + QList<Symbol *> resolveObjCClass(const Name *name, const QList<Scope *> &visibleScopes) const { return resolve(name, visibleScopes, ResolveObjCClass); } - QList<Symbol *> resolveObjCProtocol(Name *name, const QList<Scope *> &visibleScopes) const + QList<Symbol *> resolveObjCProtocol(const Name *name, const QList<Scope *> &visibleScopes) const { return resolve(name, visibleScopes, ResolveObjCProtocol); } QList<Scope *> visibleScopes() const @@ -187,18 +187,18 @@ public: private: static Symbol *canonicalSymbol(Symbol *symbol); - QList<Symbol *> resolveQualifiedNameId(QualifiedNameId *q, + QList<Symbol *> resolveQualifiedNameId(const QualifiedNameId *q, const QList<Scope *> &visibleScopes, ResolveMode mode) const; - QList<Symbol *> resolveOperatorNameId(OperatorNameId *opId, + QList<Symbol *> resolveOperatorNameId(const OperatorNameId *opId, const QList<Scope *> &visibleScopes, ResolveMode mode) const; - QList<Scope *> resolveNestedNameSpecifier(QualifiedNameId *q, + QList<Scope *> resolveNestedNameSpecifier(const QualifiedNameId *q, const QList<Scope *> &visibleScopes) const; - Identifier *identifier(const Name *name) const; + const Identifier *identifier(const Name *name) const; QList<Scope *> buildVisibleScopes(); diff --git a/src/libs/cplusplus/NamePrettyPrinter.cpp b/src/libs/cplusplus/NamePrettyPrinter.cpp index cee4f77fea9ce34406c084c67562879e739ea6a4..99274198a2ab6900230a05e1469c39b6b24aa689 100644 --- a/src/libs/cplusplus/NamePrettyPrinter.cpp +++ b/src/libs/cplusplus/NamePrettyPrinter.cpp @@ -48,7 +48,7 @@ const Overview *NamePrettyPrinter::overview() const return _overview; } -QString NamePrettyPrinter::operator()(Name *name) +QString NamePrettyPrinter::operator()(const Name *name) { QString previousName = switchName(); accept(name); @@ -62,18 +62,18 @@ QString NamePrettyPrinter::switchName(const QString &name) return previousName; } -void NamePrettyPrinter::visit(NameId *name) +void NamePrettyPrinter::visit(const NameId *name) { - Identifier *id = name->identifier(); + const Identifier *id = name->identifier(); if (id) _name = QString::fromLatin1(id->chars(), id->size()); else _name = QLatin1String("anonymous"); } -void NamePrettyPrinter::visit(TemplateNameId *name) +void NamePrettyPrinter::visit(const TemplateNameId *name) { - Identifier *id = name->identifier(); + const Identifier *id = name->identifier(); if (id) _name = QString::fromLatin1(id->chars(), id->size()); else @@ -93,14 +93,14 @@ void NamePrettyPrinter::visit(TemplateNameId *name) _name += QLatin1Char('>'); } -void NamePrettyPrinter::visit(DestructorNameId *name) +void NamePrettyPrinter::visit(const DestructorNameId *name) { - Identifier *id = name->identifier(); + const Identifier *id = name->identifier(); _name += QLatin1Char('~'); _name += QString::fromLatin1(id->chars(), id->size()); } -void NamePrettyPrinter::visit(OperatorNameId *name) +void NamePrettyPrinter::visit(const OperatorNameId *name) { _name += QLatin1String("operator "); switch (name->kind()) { // ### i should probably do this in OperatorNameId @@ -236,13 +236,13 @@ void NamePrettyPrinter::visit(OperatorNameId *name) } // switch } -void NamePrettyPrinter::visit(ConversionNameId *name) +void NamePrettyPrinter::visit(const ConversionNameId *name) { _name += QLatin1String("operator "); _name += overview()->prettyType(name->type()); } -void NamePrettyPrinter::visit(QualifiedNameId *name) +void NamePrettyPrinter::visit(const QualifiedNameId *name) { if (name->isGlobal()) _name += QLatin1String("::"); @@ -254,15 +254,14 @@ void NamePrettyPrinter::visit(QualifiedNameId *name) } } -void NamePrettyPrinter::visit(SelectorNameId *name) +void NamePrettyPrinter::visit(const SelectorNameId *name) { for (unsigned i = 0; i < name->nameCount(); ++i) { - Name *n = name->nameAt(i); + const Name *n = name->nameAt(i); if (!n) continue; - Identifier *id = n->identifier(); - if (id) { + if (const Identifier *id = n->identifier()) { _name += QString::fromLatin1(id->chars(), id->size()); if (name->hasArguments() || name->nameCount() > 1) diff --git a/src/libs/cplusplus/NamePrettyPrinter.h b/src/libs/cplusplus/NamePrettyPrinter.h index f1855bb2ab50168ae177c32ba0ae069b97d6357b..d1d40696252d14c75857c919c8ba4504b43ba8ef 100644 --- a/src/libs/cplusplus/NamePrettyPrinter.h +++ b/src/libs/cplusplus/NamePrettyPrinter.h @@ -44,18 +44,18 @@ public: virtual ~NamePrettyPrinter(); const Overview *overview() const; - QString operator()(Name *name); + QString operator()(const Name *name); protected: QString switchName(const QString &name = QString()); - virtual void visit(NameId *name); - virtual void visit(TemplateNameId *name); - virtual void visit(DestructorNameId *name); - virtual void visit(OperatorNameId *name); - virtual void visit(ConversionNameId *name); - virtual void visit(QualifiedNameId *name); - virtual void visit(SelectorNameId *name); + virtual void visit(const NameId *name); + virtual void visit(const TemplateNameId *name); + virtual void visit(const DestructorNameId *name); + virtual void visit(const OperatorNameId *name); + virtual void visit(const ConversionNameId *name); + virtual void visit(const QualifiedNameId *name); + virtual void visit(const SelectorNameId *name); private: const Overview *_overview; diff --git a/src/libs/cplusplus/Overview.cpp b/src/libs/cplusplus/Overview.cpp index 19ac3b95bbe5d1df151a5917e5cf8249a19967ad..6f4483187ef726645d8cb90d1c1b1c53620f1945 100644 --- a/src/libs/cplusplus/Overview.cpp +++ b/src/libs/cplusplus/Overview.cpp @@ -117,13 +117,13 @@ void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames) _showFullyQualifiedNames = showFullyQualifiedNames; } -QString Overview::prettyName(Name *name) const +QString Overview::prettyName(const Name *name) const { NamePrettyPrinter pp(this); return pp(name); } -QString Overview::prettyType(const FullySpecifiedType &ty, Name *name) const +QString Overview::prettyType(const FullySpecifiedType &ty, const Name *name) const { return prettyType(ty, prettyName(name)); } diff --git a/src/libs/cplusplus/Overview.h b/src/libs/cplusplus/Overview.h index 95ab7515db33ac7e33ec93df5e4674c00285352d..756a2307fe6924df998bab33daeaf1db17149c3c 100644 --- a/src/libs/cplusplus/Overview.h +++ b/src/libs/cplusplus/Overview.h @@ -66,14 +66,14 @@ public: int markedArgumentEnd() const; void setMarkedArgumentEnd(int end); - QString operator()(Name *name) const + QString operator()(const Name *name) const { return prettyName(name); } - QString operator()(const FullySpecifiedType &type, Name *name = 0) const + QString operator()(const FullySpecifiedType &type, const Name *name = 0) const { return prettyType(type, name); } - QString prettyName(Name *name) const; - QString prettyType(const FullySpecifiedType &type, Name *name = 0) const; + QString prettyName(const Name *name) const; + QString prettyType(const FullySpecifiedType &type, const Name *name = 0) const; QString prettyType(const FullySpecifiedType &type, const QString &name) const; private: diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 2d2b3defa1a258b4f32973528d616f98808f568b..c6aa2f9ae0f55504fb27bca3122b4ac502c41a5c 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -181,11 +181,11 @@ bool ResolveExpression::visit(NewExpressionAST *ast) bool ResolveExpression::visit(TypeidExpressionAST *) { - Name *std_type_info[2]; + const Name *std_type_info[2]; std_type_info[0] = control()->nameId(control()->findOrInsertIdentifier("std")); std_type_info[1] = control()->nameId(control()->findOrInsertIdentifier("type_info")); - Name *q = control()->qualifiedNameId(std_type_info, 2, /*global=*/ true); + const Name *q = control()->qualifiedNameId(std_type_info, 2, /*global=*/ true); FullySpecifiedType ty(control()->namedType(q)); addResult(ty); @@ -226,7 +226,7 @@ bool ResolveExpression::visit(SizeofExpressionAST *) bool ResolveExpression::visit(NumericLiteralAST *ast) { Type *type = 0; - NumericLiteral *literal = numericLiteral(ast->literal_token); + const NumericLiteral *literal = numericLiteral(ast->literal_token); if (literal->isChar()) type = control()->integerType(IntegerType::Char); @@ -277,8 +277,8 @@ bool ResolveExpression::visit(ThisExpressionAST *) FullySpecifiedType ptrTy(control()->pointerType(classTy)); addResult(ptrTy, fun); break; - } else if (QualifiedNameId *q = fun->name()->asQualifiedNameId()) { - Name *nestedNameSpecifier = 0; + } else if (const QualifiedNameId *q = fun->name()->asQualifiedNameId()) { + const Name *nestedNameSpecifier = 0; if (q->nameCount() == 1 && q->isGlobal()) nestedNameSpecifier = q->nameAt(0); else @@ -355,7 +355,7 @@ bool ResolveExpression::visit(CompoundLiteralAST *ast) bool ResolveExpression::visit(QualifiedNameAST *ast) { ResolveClass resolveClass; - Name *name = ast->name; + const Name *name = ast->name; QList<Symbol *> symbols = _context.resolve(name); foreach (Symbol *symbol, symbols) { @@ -451,7 +451,7 @@ bool ResolveExpression::visit(CallAST *ast) ++actualArgumentCount; } - Name *functionCallOp = control()->operatorNameId(OperatorNameId::FunctionCallOp); + const Name *functionCallOp = control()->operatorNameId(OperatorNameId::FunctionCallOp); foreach (const LookupItem &result, baseResults) { FullySpecifiedType ty = result.type().simplified(); @@ -495,7 +495,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast) const QList<LookupItem> indexResults = operator()(ast->expression); ResolveClass resolveClass; - Name *arrayAccessOp = control()->operatorNameId(OperatorNameId::ArrayAccessOp); + const Name *arrayAccessOp = control()->operatorNameId(OperatorNameId::ArrayAccessOp); foreach (const LookupItem &result, baseResults) { FullySpecifiedType ty = result.type().simplified(); @@ -537,7 +537,7 @@ bool ResolveExpression::visit(MemberAccessAST *ast) QList<LookupItem> baseResults = _results; // Evaluate the expression-id that follows the access operator. - Name *memberName = 0; + const Name *memberName = 0; if (ast->member_name) memberName = ast->member_name->name; @@ -594,7 +594,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i if (NamedType *namedTy = ty->asNamedType()) { ResolveClass resolveClass; - Name *arrowAccessOp = control()->operatorNameId(OperatorNameId::ArrowOp); + const Name *arrowAccessOp = control()->operatorNameId(OperatorNameId::ArrowOp); const QList<Symbol *> candidates = resolveClass(namedTy->name(), result, _context); foreach (Symbol *classObject, candidates) { @@ -663,7 +663,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i QList<LookupItem> ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults, unsigned accessOp, - Name *memberName, + const Name *memberName, bool *replacedDotOperator) const { ResolveClass resolveClass; @@ -677,7 +677,7 @@ ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults, results += resolveMember(memberName, klass); else if (NamedType *namedTy = ty->asNamedType()) { - Name *className = namedTy->name(); + const Name *className = namedTy->name(); const QList<Symbol *> classes = resolveClass(className, r, _context); foreach (Symbol *c, classes) { @@ -691,8 +691,8 @@ ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults, } QList<LookupItem> -ResolveExpression::resolveMember(Name *memberName, Class *klass, - Name *className) const +ResolveExpression::resolveMember(const Name *memberName, Class *klass, + const Name *className) const { QList<LookupItem> results; @@ -709,21 +709,21 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass, foreach (Symbol *candidate, candidates) { FullySpecifiedType ty = candidate->type(); - Name *unqualifiedNameId = className; + const Name *unqualifiedNameId = className; - if (QualifiedNameId *q = className->asQualifiedNameId()) + if (const QualifiedNameId *q = className->asQualifiedNameId()) unqualifiedNameId = q->unqualifiedNameId(); - if (TemplateNameId *templId = unqualifiedNameId->asTemplateNameId()) { + if (const TemplateNameId *templId = unqualifiedNameId->asTemplateNameId()) { GenTemplateInstance::Substitution subst; for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) { FullySpecifiedType templArgTy = templId->templateArgumentAt(i); if (i < klass->templateParameterCount()) { - Name *templArgName = klass->templateParameterAt(i)->name(); + const Name *templArgName = klass->templateParameterAt(i)->name(); if (templArgName && templArgName->identifier()) { - Identifier *templArgId = templArgName->identifier(); + const Identifier *templArgId = templArgName->identifier(); subst.append(qMakePair(templArgId, templArgTy)); } } @@ -741,7 +741,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass, QList<LookupItem> -ResolveExpression::resolveMember(Name *memberName, ObjCClass *klass) const +ResolveExpression::resolveMember(const Name *memberName, ObjCClass *klass) const { QList<LookupItem> results; @@ -774,7 +774,7 @@ bool ResolveExpression::visit(ObjCMessageExpressionAST *ast) if (!receiverResults.isEmpty()) { LookupItem result = receiverResults.first(); FullySpecifiedType ty = result.type().simplified(); - Name *klassName = 0; + const Name *klassName = 0; if (const ObjCClass *classTy = ty->asObjCClassType()) { // static access, e.g.: @@ -805,7 +805,7 @@ bool ResolveExpression::visit(ObjCMessageExpressionAST *ast) ResolveClass::ResolveClass() { } -QList<Symbol *> ResolveClass::operator()(Name *name, +QList<Symbol *> ResolveClass::operator()(const Name *name, const LookupItem &p, const LookupContext &context) { @@ -815,7 +815,7 @@ QList<Symbol *> ResolveClass::operator()(Name *name, return symbols; } -QList<Symbol *> ResolveClass::resolveClass(Name *name, +QList<Symbol *> ResolveClass::resolveClass(const Name *name, const LookupItem &p, const LookupContext &context) { @@ -873,7 +873,7 @@ QList<Symbol *> ResolveClass::resolveClass(Name *name, ResolveObjCClass::ResolveObjCClass() {} -QList<Symbol *> ResolveObjCClass::operator ()(Name *name, +QList<Symbol *> ResolveObjCClass::operator ()(const Name *name, const LookupItem &p, const LookupContext &context) { diff --git a/src/libs/cplusplus/ResolveExpression.h b/src/libs/cplusplus/ResolveExpression.h index f4c00352daa840f34e88f2669ac8bdb3dd0d9305..1d613228d83deefdb5a17bda8bd59a3e5a383d96 100644 --- a/src/libs/cplusplus/ResolveExpression.h +++ b/src/libs/cplusplus/ResolveExpression.h @@ -48,17 +48,17 @@ public: QList<LookupItem> resolveMemberExpression(const QList<LookupItem> &baseResults, unsigned accessOp, - Name *memberName, + const Name *memberName, bool *replacedDotOperator = 0) const; QList<LookupItem> resolveBaseExpression(const QList<LookupItem> &baseResults, int accessOp, bool *replacedDotOperator = 0) const; - QList<LookupItem> resolveMember(Name *memberName, Class *klass, - Name *className = 0) const; + QList<LookupItem> resolveMember(const Name *memberName, Class *klass, + const Name *className = 0) const; - QList<LookupItem> resolveMember(Name *memberName, ObjCClass *klass) const; + QList<LookupItem> resolveMember(const Name *memberName, ObjCClass *klass) const; protected: QList<LookupItem> switchResults(const QList<LookupItem> &symbols); @@ -125,12 +125,12 @@ class CPLUSPLUS_EXPORT ResolveClass public: ResolveClass(); - QList<Symbol *> operator()(Name *name, + QList<Symbol *> operator()(const Name *name, const LookupItem &p, const LookupContext &context); private: - QList<Symbol *> resolveClass(Name *name, + QList<Symbol *> resolveClass(const Name *name, const LookupItem &p, const LookupContext &context); @@ -143,7 +143,7 @@ class CPLUSPLUS_EXPORT ResolveObjCClass public: ResolveObjCClass(); - QList<Symbol *> operator()(Name *name, + QList<Symbol *> operator()(const Name *name, const LookupItem &p, const LookupContext &context); }; diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 3baa14c06d0ce9d718be782510f778380deb3e9d..2434e866127cf34877b3d994e7de2db13de1c518 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -327,7 +327,7 @@ void TypePrettyPrinter::visit(Function *type) if (index + 1 == _overview->markedArgument()) const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length()); - Name *name = 0; + const Name *name = 0; if (_overview->showArgumentNames()) name = arg->name(); diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index c2bb068bced63fd7b9fcfa78481c12e020a31a06..2341df2423de3fb684dc18f4ab97b61fd492180d 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -1462,6 +1462,10 @@ bool Preprocessor::isQtReservedWord(const QByteArray ¯oId) const return true; else if (size == 6 && macroId.at(0) == 'Q' && macroId == "Q_SLOT") return true; + else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_D") + return true; + else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_Q") + return true; else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL") return true; else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT") diff --git a/src/libs/utils/detailswidget.cpp b/src/libs/utils/detailswidget.cpp index b0b9db7724cdc7f6f19aa4152793e86bec1e8f75..982fbb2f822d98eaee0608fce47834db2449bb6c 100644 --- a/src/libs/utils/detailswidget.cpp +++ b/src/libs/utils/detailswidget.cpp @@ -9,31 +9,41 @@ using namespace Utils; -DetailsWidget::DetailsWidget(QWidget *parent) - : QWidget(parent), - m_summaryLabel(new QLabel(this)), - m_detailsButton(new DetailsButton(this)), - m_widget(0), - m_toolWidget(0), - m_grid(new QGridLayout(this)) +namespace { +const int MARGIN=8; +} +// This widget is using a grid layout and places the items +// in the following way: +// +// +------------+-------------------------+---------------+ +// + toolWidget | summaryLabel | detailsButton | +// +------------+-------------------------+---------------+ +// | | widget | +// +------------+-------------------------+---------------+ + +DetailsWidget::DetailsWidget(QWidget *parent) : + QWidget(parent), + m_detailsButton(new DetailsButton(this)), + m_grid(new QGridLayout(this)), + m_summaryLabel(new QLabel(this)), + m_toolWidget(0), + m_widget(0), + m_hovered(false) { - m_grid->setContentsMargins(4, 3, 4, 3); - m_summaryLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_summaryLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + m_summaryLabel->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN); - m_grid->addWidget(m_summaryLabel, 0, 0); - m_grid->addWidget(m_detailsButton, 0, 2, 1, 1, Qt::AlignBottom); + m_grid->setContentsMargins(0, 0, 0, 0); + m_grid->setSpacing(0); + m_grid->addWidget(m_summaryLabel, 0, 1); + m_grid->addWidget(m_detailsButton, 0, 2, 1, 1, Qt::AlignCenter); - m_dummyWidget = new QWidget(this); - m_dummyWidget->setMaximumHeight(4); - m_dummyWidget->setMaximumHeight(4); - m_dummyWidget->setVisible(false); - m_grid->addWidget(m_dummyWidget, 2, 0, 1, 1); + m_detailsButton->setEnabled(false); - connect(m_detailsButton, SIGNAL(clicked()), - this, SLOT(detailsButtonClicked())); + connect(m_detailsButton, SIGNAL(toggled(bool)), + this, SLOT(setExpanded(bool))); } DetailsWidget::~DetailsWidget() @@ -43,53 +53,36 @@ DetailsWidget::~DetailsWidget() void DetailsWidget::paintEvent(QPaintEvent *paintEvent) { - //TL--> ___________ <-- TR - // | | - //ML-> ______________| <--MM | <--MR - // | | - //BL-> |_________________________| <-- BR - - QWidget::paintEvent(paintEvent); - if (!m_detailsButton->isToggled()) - return; - - const QRect detailsGeometry = m_detailsButton->geometry(); - const QRect widgetGeometry = m_widget ? m_widget->geometry() : QRect(x(), y() + height(), width(), 0); - - QPoint tl(detailsGeometry.topLeft()); - tl += QPoint(-3, -3); - - QPoint tr(detailsGeometry.topRight()); - tr += QPoint(3, -3); - - QPoint mm(detailsGeometry.left() - 3, widgetGeometry.top() - 3); - - QPoint ml(1, mm.y()); - - QPoint mr(tr.x(), mm.y()); - - int bottom = geometry().height() - 3; - QPoint bl(1, bottom); - QPoint br(tr.x(), bottom); - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - p.setPen(Qt::NoPen); - p.setBrush(palette().dark()); - p.drawRoundedRect(QRect(tl, br), 5, 5); - p.drawRoundedRect(QRect(ml, br), 5, 5); + const QRect paintArea(m_summaryLabel->geometry().topLeft(), + contentsRect().bottomRight()); + + if (!isExpanded()) { + if (m_collapsedPixmap.isNull() || + m_collapsedPixmap.size() != size()) + m_collapsedPixmap = cacheBackground(paintArea.size(), false); + p.drawPixmap(paintArea, m_collapsedPixmap); + } else { + if (m_expandedPixmap.isNull() || + m_expandedPixmap.size() != size()) + m_expandedPixmap = cacheBackground(paintArea.size(), true); + p.drawPixmap(paintArea, m_expandedPixmap); + } } -void DetailsWidget::detailsButtonClicked() +void DetailsWidget::enterEvent(QEvent * event) { - bool visible = m_detailsButton->isToggled(); - if (m_widget) - m_widget->setVisible(visible); - m_dummyWidget->setVisible(visible); - fixUpLayout(); + QWidget::enterEvent(event); + changeHoverState(true); +} + +void DetailsWidget::leaveEvent(QEvent * event) +{ + QWidget::leaveEvent(event); + changeHoverState(false); } void DetailsWidget::setSummaryText(const QString &text) @@ -102,15 +95,21 @@ QString DetailsWidget::summaryText() const return m_summaryLabel->text(); } -bool DetailsWidget::expanded() const +bool DetailsWidget::isExpanded() const { - return m_detailsButton->isToggled(); + if (!m_widget) + return false; + return m_widget->isVisible(); } -void DetailsWidget::setExpanded(bool v) +void DetailsWidget::setExpanded(bool visible) { - if (expanded() != v) - m_detailsButton->animateClick(); + if (!m_widget) + return; + + m_summaryLabel->setEnabled(!visible); + m_widget->setVisible(visible); + m_detailsButton->setChecked(visible); } QWidget *DetailsWidget::widget() const @@ -122,31 +121,40 @@ void DetailsWidget::setWidget(QWidget *widget) { if (m_widget == widget) return; - if (m_widget) { + + const bool wasExpanded(isExpanded()); + + if (m_widget) m_grid->removeWidget(m_widget); - m_widget = 0; - } + m_widget = widget; + if (widget) { - m_grid->addWidget(widget, 1, 0, 1, 3); - m_widget = widget; - bool visible = m_detailsButton->isToggled(); - m_widget->setVisible(visible); - m_dummyWidget->setVisible(visible); + m_widget->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN); + m_grid->addWidget(widget, 1, 1, 1, 2); + setExpanded(wasExpanded); + } else { + m_detailsButton->setEnabled(false); } + m_detailsButton->setEnabled(0 != m_widget); } void DetailsWidget::setToolWidget(QWidget *widget) { if (m_toolWidget == widget) return; - if (m_toolWidget) { - m_grid->removeWidget(m_toolWidget); - m_toolWidget = 0; - } - if (widget) { - m_grid->addWidget(widget, 0, 1, 1, 1, Qt::AlignBottom); - m_toolWidget = widget; - } + + m_toolWidget = widget; + + if (!m_toolWidget) + return; + + m_toolWidget->adjustSize(); + m_grid->addWidget(m_toolWidget, 0, 0, 1, 1, Qt::AlignCenter); + + m_grid->setColumnMinimumWidth(0, m_toolWidget->width()); + m_grid->setRowMinimumHeight(0, m_toolWidget->height()); + + changeHoverState(m_hovered); } QWidget *DetailsWidget::toolWidget() const @@ -154,25 +162,35 @@ QWidget *DetailsWidget::toolWidget() const return m_toolWidget; } -// This function works around a qt limitation. -// In a deeply nested widget structure, nested layouts -// tell their parents per a delayed invocation that they -// need to repaint. Thus hiding a widget triggers -// one relayout (and repaint) for each level of widget -// nesting. We circumvent that, by forcing a update() -// activate() on the widget after hiding. -void DetailsWidget::fixUpLayout() +QPixmap DetailsWidget::cacheBackground(const QSize &size, bool expanded) { - if (!m_widget) - return; - QWidget *parent = m_widget; - QStack<QWidget *> widgets; - while((parent = parent->parentWidget()) && parent && parent->layout()) { - widgets.push(parent); - parent->layout()->update(); - } + QLinearGradient lg; + lg.setCoordinateMode(QGradient::ObjectBoundingMode); + lg.setFinalStop(0, 1); + + lg.setColorAt(0, palette().color(QPalette::Midlight)); + lg.setColorAt(1, palette().color(QPalette::Button)); + + QPixmap pixmap(size); + QPainter p(&pixmap); + p.setBrush(lg); + p.setPen(QPen(palette().color(QPalette::Mid))); + + p.drawRect(0, 0, size.width() - 1, size.height() - 1); - while(!widgets.isEmpty()) { - widgets.pop()->layout()->activate(); + if (expanded) { + p.drawLine(0, m_summaryLabel->height(), + size.width(), m_summaryLabel->height()); } + + return pixmap; +} + +void DetailsWidget::changeHoverState(bool hovered) +{ + m_hovered = hovered; + if (!m_toolWidget) + return; + + m_toolWidget->setVisible(m_hovered); } diff --git a/src/libs/utils/detailswidget.h b/src/libs/utils/detailswidget.h index 781fc4026edc53449126163c2ea79e96bb2903a8..6304dc3c3c64583ae24ddc46bfeb660510121047 100644 --- a/src/libs/utils/detailswidget.h +++ b/src/libs/utils/detailswidget.h @@ -3,6 +3,7 @@ #include "utils_global.h" +#include <QtGui/QPixmap> #include <QtGui/QWidget> QT_BEGIN_NAMESPACE @@ -17,7 +18,8 @@ class QTCREATOR_UTILS_EXPORT DetailsWidget : public QWidget { Q_OBJECT Q_PROPERTY(QString summaryText READ summaryText WRITE setSummaryText DESIGNABLE true) - Q_PROPERTY(bool expanded READ expanded WRITE setExpanded DESIGNABLE true) + Q_PROPERTY(bool expanded READ isExpanded WRITE setExpanded DESIGNABLE true) + public: DetailsWidget(QWidget *parent = 0); ~DetailsWidget(); @@ -25,8 +27,7 @@ public: void setSummaryText(const QString &text); QString summaryText() const; - bool expanded() const; - void setExpanded(bool); + bool isExpanded() const; void setWidget(QWidget *widget); QWidget *widget() const; @@ -34,21 +35,28 @@ public: void setToolWidget(QWidget *widget); QWidget *toolWidget() const; +public slots: + void setExpanded(bool); + protected: void paintEvent(QPaintEvent *paintEvent); - -private slots: - void detailsButtonClicked(); + void enterEvent(QEvent *event); + void leaveEvent(QEvent *event); private: - void fixUpLayout(); - QLabel *m_summaryLabel; - DetailsButton *m_detailsButton; + QPixmap cacheBackground(const QSize &size, bool expanded); + void changeHoverState(bool hovered); - QWidget *m_widget; - QWidget *m_toolWidget; - QWidget *m_dummyWidget; + DetailsButton *m_detailsButton; QGridLayout *m_grid; + QLabel *m_summaryLabel; + QWidget *m_toolWidget; + QWidget *m_widget; + + QPixmap m_collapsedPixmap; + QPixmap m_expandedPixmap; + + bool m_hovered; }; } diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp index e6ee2921bffcc6a85f551cde082cfd7b5edb2b71..3c77494b2505c1b3ec68d664e079112a6d66d738 100644 --- a/src/libs/utils/projectintropage.cpp +++ b/src/libs/utils/projectintropage.cpp @@ -63,7 +63,7 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) : m_d->m_ui.setupUi(this); hideStatusLabel(); m_d->m_ui.nameLineEdit->setInitialText(tr("<Enter_Name>")); - m_d->m_ui.nameLineEdit->setFocus(Qt::TabFocusReason); + m_d->m_ui.nameLineEdit->setFocus(); connect(m_d->m_ui.pathChooser, SIGNAL(changed(QString)), this, SLOT(slotChanged())); connect(m_d->m_ui.nameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotChanged())); connect(m_d->m_ui.pathChooser, SIGNAL(returnPressed()), this, SLOT(slotActivated())); @@ -98,6 +98,7 @@ void ProjectIntroPage::setPath(const QString &path) void ProjectIntroPage::setName(const QString &name) { m_d->m_ui.nameLineEdit->setText(name); + m_d->m_ui.nameLineEdit->selectAll(); } QString ProjectIntroPage::description() const diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8af44707c45d7e0681d6e9c51d054c56ef98b2ff --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -0,0 +1,165 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "cmakebuildconfiguration.h" +#include "cmakeproject.h" +#include <projectexplorer/projectexplorerconstants.h> + +using namespace CMakeProjectManager; +using namespace Internal; + +CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro) + : BuildConfiguration(pro), m_toolChain(0) +{ + +} + +CMakeBuildConfiguration::CMakeBuildConfiguration(BuildConfiguration *source) + : BuildConfiguration(source), m_toolChain(0) +{ + +} + +CMakeBuildConfiguration::~CMakeBuildConfiguration() +{ + delete m_toolChain; +} + +CMakeProject *CMakeBuildConfiguration::cmakeProject() const +{ + return static_cast<CMakeProject *>(project()); +} + +ProjectExplorer::Environment CMakeBuildConfiguration::baseEnvironment() const +{ + ProjectExplorer::Environment env = useSystemEnvironment() ? + ProjectExplorer::Environment(QProcess::systemEnvironment()) : + ProjectExplorer::Environment(); + return env; +} + +ProjectExplorer::Environment CMakeBuildConfiguration::environment() const +{ + ProjectExplorer::Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +void CMakeBuildConfiguration::setUseSystemEnvironment(bool b) +{ + if (b == useSystemEnvironment()) + return; + setValue("clearSystemEnvironment", !b); + emit environmentChanged(); +} + +bool CMakeBuildConfiguration::useSystemEnvironment() const +{ + bool b = !(value("clearSystemEnvironment").isValid() && + value("clearSystemEnvironment").toBool()); + return b; +} + +QList<ProjectExplorer::EnvironmentItem> CMakeBuildConfiguration::userEnvironmentChanges() const +{ + return ProjectExplorer::EnvironmentItem::fromStringList(value("userEnvironmentChanges").toStringList()); +} + +void CMakeBuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + QStringList list = ProjectExplorer::EnvironmentItem::toStringList(diff); + if (list == value("userEnvironmentChanges")) + return; + setValue("userEnvironmentChanges", list); + emit environmentChanged(); +} + +QString CMakeBuildConfiguration::buildDirectory() const +{ + QString buildDirectory = value("buildDirectory").toString(); + if (buildDirectory.isEmpty()) + buildDirectory = cmakeProject()->sourceDirectory() + "/qtcreator-build"; + return buildDirectory; +} + +QString CMakeBuildConfiguration::buildParser() const +{ + // TODO this is actually slightly wrong, but do i care? + // this should call toolchain(configuration) + if (!m_toolChain) + return QString::null; + if (m_toolChain->type() == ProjectExplorer::ToolChain::GCC + //|| m_toolChain->type() == ProjectExplorer::ToolChain::LinuxICC + || m_toolChain->type() == ProjectExplorer::ToolChain::MinGW) { + return ProjectExplorer::Constants::BUILD_PARSER_GCC; + } else if (m_toolChain->type() == ProjectExplorer::ToolChain::MSVC + || m_toolChain->type() == ProjectExplorer::ToolChain::WINCE) { + return ProjectExplorer::Constants::BUILD_PARSER_MSVC; + } + return QString::null; +} + +ProjectExplorer::ToolChain::ToolChainType CMakeBuildConfiguration::toolChainType() const +{ + if (m_toolChain) + return m_toolChain->type(); + return ProjectExplorer::ToolChain::UNKNOWN; +} + +ProjectExplorer::ToolChain *CMakeBuildConfiguration::toolChain() const +{ + return m_toolChain; +} + +void CMakeBuildConfiguration::updateToolChain(const QString &compiler) +{ + //qDebug()<<"CodeBlocks Compilername"<<compiler + ProjectExplorer::ToolChain *newToolChain = 0; + if (compiler == "gcc") { +#ifdef Q_OS_WIN + newToolChain = ProjectExplorer::ToolChain::createMinGWToolChain("gcc", QString()); +#else + newToolChain = ProjectExplorer::ToolChain::createGccToolChain("gcc"); +#endif + } else if (compiler == "msvc8") { + newToolChain = ProjectExplorer::ToolChain::createMSVCToolChain(value("msvcVersion").toString(), false); + } else { + } + + if (ProjectExplorer::ToolChain::equals(newToolChain, m_toolChain)) { + delete newToolChain; + newToolChain = 0; + } else { + delete m_toolChain; + m_toolChain = newToolChain; + } +} + + + diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h new file mode 100644 index 0000000000000000000000000000000000000000..6078ac577d398da92bdef2ca48d80c3e47ce2097 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h @@ -0,0 +1,73 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef CMAKEBUILDCONFIGURATION_H +#define CMAKEBUILDCONFIGURATION_H + +#include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/toolchain.h> + +namespace CMakeProjectManager { +namespace Internal { + +class CMakeProject; + +class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration +{ + Q_OBJECT +public: + CMakeBuildConfiguration(CMakeProject *pro); + CMakeBuildConfiguration(BuildConfiguration *source); + ~CMakeBuildConfiguration(); + + CMakeProject *cmakeProject() const; + + ProjectExplorer::Environment environment() const; + ProjectExplorer::Environment baseEnvironment() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + bool useSystemEnvironment() const; + void setUseSystemEnvironment(bool b); + + virtual QString buildDirectory() const; + QString buildParser() const; + + ProjectExplorer::ToolChain::ToolChainType toolChainType() const; + ProjectExplorer::ToolChain *toolChain() const; + + void updateToolChain(const QString &compiler); +private: + ProjectExplorer::ToolChain *m_toolChain; +}; + + +} // namespace Internal +} // namespace CMakeProjectManager + +#endif // CMAKEBUILDCONFIGURATION_H diff --git a/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.cpp b/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.cpp index ecae63b84113badada6ea0652f77a5879e7d6688..887c0d40b29b7a6c4c167ffade09d8650046585f 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.cpp @@ -29,6 +29,7 @@ #include "cmakebuildenvironmentwidget.h" #include "cmakeproject.h" +#include "cmakebuildconfiguration.h" #include <projectexplorer/environmenteditmodel.h> #include <QtGui/QVBoxLayout> #include <QtGui/QCheckBox> @@ -41,7 +42,7 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project) - : BuildConfigWidget(), m_pro(project) + : BuildConfigWidget(), m_pro(project), m_buildConfiguration(0) { QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); @@ -63,29 +64,26 @@ QString CMakeBuildEnvironmentWidget::displayName() const return tr("Build Environment"); } -void CMakeBuildEnvironmentWidget::init(const QString &buildConfigurationName) +void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc) { if (debug) qDebug() << "Qt4BuildConfigWidget::init()"; - m_buildConfiguration = buildConfigurationName; + m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc); - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfigurationName); - m_clearSystemEnvironmentCheckBox->setChecked(!m_pro->useSystemEnvironment(bc)); - m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc)); - m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(bc)); + m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment()); + m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); + m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges()); m_buildEnvironmentWidget->updateButtons(); } void CMakeBuildEnvironmentWidget::environmentModelUserChangesUpdated() { - m_pro->setUserEnvironmentChanges( - m_pro->buildConfiguration(m_buildConfiguration), m_buildEnvironmentWidget->userChanges()); + m_buildConfiguration->setUserEnvironmentChanges(m_buildEnvironmentWidget->userChanges()); } void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked) { - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - m_pro->setUseSystemEnvironment(bc, !checked); - m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc)); + m_buildConfiguration->setUseSystemEnvironment(!checked); + m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); } diff --git a/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.h b/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.h index e059783849aa26d2e9bc512ef08a27208339f901..ee910b261d07aee122095d551c6264ec4455d37f 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildenvironmentwidget.h @@ -42,6 +42,7 @@ class EnvironmentWidget; namespace CMakeProjectManager { namespace Internal { class CMakeProject; +class CMakeBuildConfiguration; class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget { @@ -51,7 +52,7 @@ public: CMakeBuildEnvironmentWidget(CMakeProject *project); QString displayName() const; - void init(const QString &buildConfiguration); + void init(ProjectExplorer::BuildConfiguration *bc); private slots: void environmentModelUserChangesUpdated(); @@ -61,7 +62,7 @@ private: ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget; QCheckBox *m_clearSystemEnvironmentCheckBox; CMakeProject *m_pro; - QString m_buildConfiguration; + CMakeBuildConfiguration *m_buildConfiguration; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 8363b7491b5ef183cc3f85638aac3376abde8d7b..98258c13375c30974827c614d1a9fed8613f1b55 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -34,6 +34,7 @@ #include "makestep.h" #include "cmakeopenprojectwizard.h" #include "cmakebuildenvironmentwidget.h" +#include "cmakebuildconfiguration.h" #include <projectexplorer/projectexplorerconstants.h> #include <cpptools/cppmodelmanagerinterface.h> @@ -89,7 +90,7 @@ QString CMakeBuildConfigurationFactory::displayNameForType(const QString & /* ty return tr("Create"); } -bool CMakeBuildConfigurationFactory::create(const QString &type) const +BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type) const { QTC_ASSERT(type == "Create", return false); @@ -103,19 +104,20 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const &ok); if (!ok || buildConfigurationName.isEmpty()) return false; - BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName); + BuildConfiguration *bc = new CMakeBuildConfiguration(m_project); + bc->setDisplayName(buildConfigurationName); - MakeStep *makeStep = new MakeStep(m_project, bc); + MakeStep *makeStep = new MakeStep(bc); bc->insertBuildStep(0, makeStep); - MakeStep *cleanMakeStep = new MakeStep(m_project, bc); + MakeStep *cleanMakeStep = new MakeStep(bc); bc->insertCleanStep(0, cleanMakeStep); cleanMakeStep->setClean(true); CMakeOpenProjectWizard copw(m_project->projectManager(), m_project->sourceDirectory(), - m_project->buildDirectory(bc), - m_project->environment(bc)); + bc->buildDirectory(), + bc->environment()); if (copw.exec() != QDialog::Accepted) { delete bc; return false; @@ -129,7 +131,20 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const // Default to all if (m_project->targets().contains("all")) makeStep->setBuildTarget("all", true); - return true; + return bc; +} + +BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const +{ + CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source); + CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old); + return bc; +} + +BuildConfiguration *CMakeBuildConfigurationFactory::restore() const +{ + CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project); + return bc; } /*! @@ -140,7 +155,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) m_fileName(fileName), m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)), m_rootNode(new CMakeProjectNode(m_fileName)), - m_toolChain(0), m_insideFileChanged(false) { m_file = new CMakeFile(this, fileName); @@ -149,7 +163,11 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) CMakeProject::~CMakeProject() { delete m_rootNode; - delete m_toolChain; +} + +CMakeBuildConfiguration *CMakeProject::activeCMakeBuildConfiguration() const +{ + return static_cast<CMakeBuildConfiguration *>(activeBuildConfiguration()); } IBuildConfigurationFactory *CMakeProject::buildConfigurationFactory() const @@ -163,7 +181,7 @@ void CMakeProject::slotActiveBuildConfiguration() // Pop up a dialog asking the user to rerun cmake QFileInfo sourceFileInfo(m_fileName); - QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBC))); + QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory())); QFileInfo cbpFileFi(cbpFile); CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing; if (!cbpFileFi.exists()) { @@ -180,9 +198,9 @@ void CMakeProject::slotActiveBuildConfiguration() if (mode != CMakeOpenProjectWizard::Nothing) { CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), - buildDirectory(activeBC), + activeBC->buildDirectory(), mode, - environment(activeBC)); + activeBC->environment()); copw.exec(); activeBC->setValue("msvcVersion", copw.msvcVersion()); } @@ -200,39 +218,6 @@ void CMakeProject::fileChanged(const QString &fileName) m_insideFileChanged = false; } -void CMakeProject::updateToolChain(const QString &compiler) -{ - //qDebug()<<"CodeBlocks Compilername"<<compiler - ProjectExplorer::ToolChain *newToolChain = 0; - if (compiler == "gcc") { -#ifdef Q_OS_WIN - newToolChain = ProjectExplorer::ToolChain::createMinGWToolChain("gcc", QString()); -#else - newToolChain = ProjectExplorer::ToolChain::createGccToolChain("gcc"); -#endif - } else if (compiler == "msvc8") { - newToolChain = ProjectExplorer::ToolChain::createMSVCToolChain(activeBuildConfiguration()->value("msvcVersion").toString(), false); - } else { - // TODO other toolchains - qDebug()<<"Not implemented yet!!! Qt Creator doesn't know which toolchain to use for"<<compiler; - } - - if (ProjectExplorer::ToolChain::equals(newToolChain, m_toolChain)) { - delete newToolChain; - newToolChain = 0; - } else { - delete m_toolChain; - m_toolChain = newToolChain; - } -} - -ProjectExplorer::ToolChain *CMakeProject::toolChain(BuildConfiguration *configuration) const -{ - if (configuration != activeBuildConfiguration()) - qWarning()<<"CMakeProject asked for toolchain of a not active buildconfiguration"; - return m_toolChain; -} - void CMakeProject::changeBuildDirectory(BuildConfiguration *configuration, const QString &newBuildDirectory) { configuration->setValue("buildDirectory", newBuildDirectory); @@ -247,7 +232,8 @@ QString CMakeProject::sourceDirectory() const bool CMakeProject::parseCMakeLists() { // Find cbp file - QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration())); + CMakeBuildConfiguration *activeBC = activeCMakeBuildConfiguration(); + QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory()); // setFolderName m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName()); @@ -256,7 +242,7 @@ bool CMakeProject::parseCMakeLists() //qDebug()<<"Parsing file "<<cbpFile; if (cbpparser.parseCbpFile(cbpFile)) { // ToolChain - updateToolChain(cbpparser.compilerName()); + activeBC->updateToolChain(cbpparser.compilerName()); m_projectName = cbpparser.projectName(); m_rootNode->setFolderName(cbpparser.projectName()); @@ -309,7 +295,7 @@ bool CMakeProject::parseCMakeLists() QStringList allIncludePaths; QStringList allFrameworkPaths; - QList<ProjectExplorer::HeaderPath> allHeaderPaths = m_toolChain->systemHeaderPaths(); + QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeBC->toolChain()->systemHeaderPaths(); foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) { if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) allFrameworkPaths.append(headerPath.path()); @@ -325,12 +311,12 @@ bool CMakeProject::parseCMakeLists() CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); if (pinfo.includePaths != allIncludePaths || pinfo.sourceFiles != m_files - || pinfo.defines != m_toolChain->predefinedMacros() + || pinfo.defines != activeBC->toolChain()->predefinedMacros() || pinfo.frameworkPaths != allFrameworkPaths) { pinfo.includePaths = allIncludePaths; // TODO we only want C++ files, not all other stuff that might be in the project pinfo.sourceFiles = m_files; - pinfo.defines = m_toolChain->predefinedMacros(); // TODO this is to simplistic + pinfo.defines = activeBC->toolChain()->predefinedMacros(); // TODO this is to simplistic pinfo.frameworkPaths = allFrameworkPaths; modelmanager->updateProjectInfo(pinfo); modelmanager->updateSourceFiles(pinfo.sourceFiles); @@ -388,31 +374,12 @@ bool CMakeProject::parseCMakeLists() } else { // TODO report error qDebug()<<"Parsing failed"; - delete m_toolChain; - m_toolChain = 0; + activeBC->updateToolChain(QString::null); return false; } return true; } -QString CMakeProject::buildParser(BuildConfiguration *configuration) const -{ - Q_UNUSED(configuration) - // TODO this is actually slightly wrong, but do i care? - // this should call toolchain(configuration) - if (!m_toolChain) - return QString::null; - if (m_toolChain->type() == ProjectExplorer::ToolChain::GCC - //|| m_toolChain->type() == ProjectExplorer::ToolChain::LinuxICC - || m_toolChain->type() == ProjectExplorer::ToolChain::MinGW) { - return ProjectExplorer::Constants::BUILD_PARSER_GCC; - } else if (m_toolChain->type() == ProjectExplorer::ToolChain::MSVC - || m_toolChain->type() == ProjectExplorer::ToolChain::WINCE) { - return ProjectExplorer::Constants::BUILD_PARSER_MSVC; - } - return QString::null; -} - QStringList CMakeProject::targets() const { QStringList results; @@ -535,8 +502,6 @@ QString CMakeProject::name() const return m_projectName; } - - Core::IFile *CMakeProject::file() const { return m_file; @@ -557,56 +522,6 @@ bool CMakeProject::isApplication() const return true; } -ProjectExplorer::Environment CMakeProject::baseEnvironment(BuildConfiguration *configuration) const -{ - Environment env = useSystemEnvironment(configuration) ? Environment(QProcess::systemEnvironment()) : Environment(); - return env; -} - -ProjectExplorer::Environment CMakeProject::environment(BuildConfiguration *configuration) const -{ - Environment env = baseEnvironment(configuration); - env.modify(userEnvironmentChanges(configuration)); - return env; -} - -void CMakeProject::setUseSystemEnvironment(BuildConfiguration *configuration, bool b) -{ - if (b == useSystemEnvironment(configuration)) - return; - configuration->setValue("clearSystemEnvironment", !b); - emit environmentChanged(configuration->name()); -} - -bool CMakeProject::useSystemEnvironment(BuildConfiguration *configuration) const -{ - bool b = !(configuration->value("clearSystemEnvironment").isValid() && - configuration->value("clearSystemEnvironment").toBool()); - return b; -} - -QList<ProjectExplorer::EnvironmentItem> CMakeProject::userEnvironmentChanges(BuildConfiguration *configuration) const -{ - return EnvironmentItem::fromStringList(configuration->value("userEnvironmentChanges").toStringList()); -} - -void CMakeProject::setUserEnvironmentChanges(BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff) -{ - QStringList list = EnvironmentItem::toStringList(diff); - if (list == configuration->value("userEnvironmentChanges")) - return; - configuration->setValue("userEnvironmentChanges", list); - emit environmentChanged(configuration->name()); -} - -QString CMakeProject::buildDirectory(BuildConfiguration *configuration) const -{ - QString buildDirectory = configuration->value("buildDirectory").toString(); - if (buildDirectory.isEmpty()) - buildDirectory = sourceDirectory() + "/qtcreator-build"; - return buildDirectory; -} - ProjectExplorer::BuildConfigWidget *CMakeProject::createConfigWidget() { return new CMakeBuildSettingsWidget(this); @@ -649,18 +564,19 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader if (copw.exec() != QDialog::Accepted) return false; - ProjectExplorer::BuildConfiguration *bc = new ProjectExplorer::BuildConfiguration("all"); + CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(this); + bc->setDisplayName("all"); addBuildConfiguration(bc); bc->setValue("msvcVersion", copw.msvcVersion()); if (!copw.buildDirectory().isEmpty()) bc->setValue("buildDirectory", copw.buildDirectory()); // Now create a standard build configuration - makeStep = new MakeStep(this, bc); + makeStep = new MakeStep(bc); bc->insertBuildStep(0, makeStep); //TODO save arguments somewhere copw.arguments() - MakeStep *cleanMakeStep = new MakeStep(this, bc); + MakeStep *cleanMakeStep = new MakeStep(bc); bc->insertCleanStep(0, cleanMakeStep); cleanMakeStep->setClean(true); setActiveBuildConfiguration(bc); @@ -668,10 +584,8 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader // We have a user file, but we could still be missing the cbp file // or simply run createXml with the saved settings QFileInfo sourceFileInfo(m_fileName); - QStringList needToCreate; - QStringList needToUpdate; BuildConfiguration *activeBC = activeBuildConfiguration(); - QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBC))); + QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory())); QFileInfo cbpFileFi(cbpFile); CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing; @@ -683,9 +597,9 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader if (mode != CMakeOpenProjectWizard::Nothing) { CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), - buildDirectory(activeBC), + activeBC->buildDirectory(), mode, - environment(activeBC)); + activeBC->environment()); if (copw.exec() != QDialog::Accepted) return false; activeBC->setValue("msvcVersion", copw.msvcVersion()); @@ -714,13 +628,6 @@ CMakeTarget CMakeProject::targetForTitle(const QString &title) return CMakeTarget(); } -ProjectExplorer::ToolChain::ToolChainType CMakeProject::toolChainType() const -{ - if (m_toolChain) - return m_toolChain->type(); - return ProjectExplorer::ToolChain::UNKNOWN; -} - // CMakeFile CMakeFile::CMakeFile(CMakeProject *parent, QString fileName) @@ -779,7 +686,7 @@ void CMakeFile::modified(ReloadBehavior *behavior) } CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project) - : m_project(project) + : m_project(project), m_buildConfiguration(0) { QFormLayout *fl = new QFormLayout(this); fl->setContentsMargins(20, -1, 0, -1); @@ -808,12 +715,11 @@ QString CMakeBuildSettingsWidget::displayName() const return "CMake"; } -void CMakeBuildSettingsWidget::init(const QString &buildConfigurationName) +void CMakeBuildSettingsWidget::init(BuildConfiguration *bc) { - m_buildConfiguration = buildConfigurationName; - BuildConfiguration *bc = m_project->buildConfiguration(buildConfigurationName); - m_pathLineEdit->setText(m_project->buildDirectory(bc)); - if (m_project->buildDirectory(bc) == m_project->sourceDirectory()) + m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc); + m_pathLineEdit->setText(m_buildConfiguration->buildDirectory()); + if (m_buildConfiguration->buildDirectory() == m_project->sourceDirectory()) m_changeButton->setEnabled(false); else m_changeButton->setEnabled(true); @@ -821,14 +727,13 @@ void CMakeBuildSettingsWidget::init(const QString &buildConfigurationName) void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() { - BuildConfiguration *bc = m_project->buildConfiguration(m_buildConfiguration); CMakeOpenProjectWizard copw(m_project->projectManager(), m_project->sourceDirectory(), - m_project->buildDirectory(bc), - m_project->environment(bc)); + m_buildConfiguration->buildDirectory(), + m_buildConfiguration->environment()); if (copw.exec() == QDialog::Accepted) { - m_project->changeBuildDirectory(bc, copw.buildDirectory()); - m_pathLineEdit->setText(m_project->buildDirectory(bc)); + m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory()); + m_pathLineEdit->setText(m_buildConfiguration->buildDirectory()); } } diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 126061c61bebc4f92a0b3553d38d485457b13dd7..1693faca7a8cda0995d18f1fbe1924fc5db74ac1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -32,6 +32,7 @@ #include "cmakeprojectmanager.h" #include "cmakeprojectnodes.h" +#include "cmakebuildconfiguration.h" #include "makestep.h" #include <projectexplorer/project.h> @@ -73,7 +74,9 @@ public: QStringList availableCreationTypes() const; QString displayNameForType(const QString &type) const; - bool create(const QString &type) const; + ProjectExplorer::BuildConfiguration *create(const QString &type) const; + ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const; + ProjectExplorer::BuildConfiguration *restore() const; private: CMakeProject *m_project; @@ -88,6 +91,8 @@ public: CMakeProject(CMakeManager *manager, const QString &filename); ~CMakeProject(); + CMakeBuildConfiguration *activeCMakeBuildConfiguration() const; + virtual QString name() const; virtual Core::IFile *file() const; virtual ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; @@ -97,16 +102,6 @@ public: virtual bool isApplication() const; - //building environment - ProjectExplorer::Environment environment(ProjectExplorer::BuildConfiguration *configuration) const; - ProjectExplorer::Environment baseEnvironment(ProjectExplorer::BuildConfiguration *configuration) const; - void setUserEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff); - QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration) const; - bool useSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration) const; - void setUseSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration, bool b); - - virtual QString buildDirectory(ProjectExplorer::BuildConfiguration *configuration) const; - virtual ProjectExplorer::BuildConfigWidget *createConfigWidget(); virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets(); @@ -114,12 +109,10 @@ public: virtual QStringList files(FilesMode fileMode) const; QStringList targets() const; - QString buildParser(ProjectExplorer::BuildConfiguration *configuration) const; + CMakeTarget targetForTitle(const QString &title); QString sourceDirectory() const; - ProjectExplorer::ToolChain::ToolChainType toolChainType() const; - ProjectExplorer::ToolChain *toolChain(ProjectExplorer::BuildConfiguration *configuration) const; protected: virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer); @@ -134,7 +127,6 @@ private slots: private: bool parseCMakeLists(); - void updateToolChain(const QString &compiler); void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list); void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list); @@ -150,7 +142,6 @@ private: CMakeProjectNode *m_rootNode; QStringList m_files; QList<CMakeTarget> m_targets; - ProjectExplorer::ToolChain *m_toolChain; ProjectExplorer::FileWatcher *m_watcher; bool m_insideFileChanged; QSet<QString> m_watchedFiles; @@ -230,14 +221,14 @@ public: // This is called to set up the config widget before showing it // buildConfiguration is QString::null for the non buildConfiguration specific page - virtual void init(const QString &buildConfiguration); + virtual void init(ProjectExplorer::BuildConfiguration *bc); private slots: void openChangeBuildDirectoryDialog(); private: CMakeProject *m_project; QLineEdit *m_pathLineEdit; QPushButton *m_changeButton; - QString m_buildConfiguration; + CMakeBuildConfiguration *m_buildConfiguration; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index fe516111f6e24d37be03b3d5b24de5ab9cbacfa9..fd898b76754f7ec2126d248a57ac3e5a982061ae 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -10,7 +10,8 @@ HEADERS = cmakeproject.h \ makestep.h \ cmakerunconfiguration.h \ cmakeopenprojectwizard.h \ - cmakebuildenvironmentwidget.h + cmakebuildenvironmentwidget.h \ + cmakebuildconfiguration.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ cmakeprojectmanager.cpp \ @@ -18,7 +19,8 @@ SOURCES = cmakeproject.cpp \ makestep.cpp \ cmakerunconfiguration.cpp \ cmakeopenprojectwizard.cpp \ - cmakebuildenvironmentwidget.cpp + cmakebuildenvironmentwidget.cpp \ + cmakebuildconfiguration.cpp RESOURCES += cmakeproject.qrc FORMS += diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index da290d66a7199aeb1abc66379d29a05ffcb6cff0..30d6f0f3220a180ea9202af1ef2fb3fa7c75d69b 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -30,6 +30,7 @@ #include "cmakerunconfiguration.h" #include "cmakeproject.h" +#include "cmakebuildconfiguration.h" #include "cmakeprojectconstants.h" #include <projectexplorer/environment.h> @@ -58,12 +59,19 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t connect(pro, SIGNAL(activeBuildConfigurationChanged()), this, SIGNAL(baseEnvironmentChanged())); - connect(pro, SIGNAL(environmentChanged(QString)), - this, SIGNAL(baseEnvironmentChanged())); + // TODO +// connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)), +// this, SIGNAL(baseEnvironmentChanged())); } CMakeRunConfiguration::~CMakeRunConfiguration() { + +} + +CMakeProject *CMakeRunConfiguration::cmakeProject() const +{ + return static_cast<CMakeProject *>(project()); } QString CMakeRunConfiguration::type() const @@ -186,7 +194,7 @@ ProjectExplorer::Environment CMakeRunConfiguration::baseEnvironment() const } else if (m_baseEnvironmentBase == CMakeRunConfiguration::SystemEnvironmentBase) { env = ProjectExplorer::Environment::systemEnvironment(); } else if (m_baseEnvironmentBase == CMakeRunConfiguration::BuildEnvironmentBase) { - env = project()->environment(project()->activeBuildConfiguration()); + env = project()->activeBuildConfiguration()->environment(); } return env; } @@ -226,8 +234,8 @@ void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplore ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType() const { - CMakeProject *pro = static_cast<CMakeProject *>(project()); - return pro->toolChainType(); + CMakeBuildConfiguration *bc = cmakeProject()->activeCMakeBuildConfiguration(); + return bc->toolChainType(); } // Configuration widget diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h index 385232d3f408e4e640990733480cca45fda9d867..189b5830b4cef2b12ab40a99edadd3b026ee9f1e 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h @@ -53,6 +53,8 @@ class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfigu public: CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory, const QString &title); virtual ~CMakeRunConfiguration(); + CMakeProject *cmakeProject() const; + virtual QString type() const; virtual QString executable() const; virtual RunMode runMode() const; diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp index 242a7493d260673a831d213fba7b32ca3765ed66..11ae56e0a918b7048d8e5e5fe33acc6d5d59defe 100644 --- a/src/plugins/cmakeprojectmanager/makestep.cpp +++ b/src/plugins/cmakeprojectmanager/makestep.cpp @@ -29,6 +29,7 @@ #include "makestep.h" #include "cmakeprojectconstants.h" #include "cmakeproject.h" +#include "cmakebuildconfiguration.h" #include <projectexplorer/projectexplorer.h> @@ -42,15 +43,14 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; using namespace ProjectExplorer; -MakeStep::MakeStep(CMakeProject *pro, BuildConfiguration *bc) - : AbstractMakeStep(pro, bc), m_pro(pro), m_clean(false), m_futureInterface(0) +MakeStep::MakeStep(BuildConfiguration *bc) + : AbstractMakeStep(bc), m_clean(false), m_futureInterface(0) { m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]"); } MakeStep::MakeStep(MakeStep *bs, BuildConfiguration *bc) : AbstractMakeStep(bs, bc), - m_pro(bs->m_pro), m_clean(bs->m_clean), m_futureInterface(0), m_buildTargets(bs->m_buildTargets), @@ -64,6 +64,11 @@ MakeStep::~MakeStep() } +CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const +{ + return static_cast<CMakeBuildConfiguration *>(buildConfiguration()); +} + void MakeStep::setClean(bool clean) { m_clean = clean; @@ -96,18 +101,18 @@ void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map) bool MakeStep::init() { - BuildConfiguration *bc = buildConfiguration(); - setBuildParser(m_pro->buildParser(bc)); + CMakeBuildConfiguration *bc = cmakeBuildConfiguration(); + setBuildParser(bc->buildParser()); setEnabled(true); - setWorkingDirectory(m_pro->buildDirectory(bc)); + setWorkingDirectory(bc->buildDirectory()); - setCommand(m_pro->toolChain(bc)->makeCommand()); + setCommand(bc->toolChain()->makeCommand()); QStringList arguments = m_buildTargets; arguments << additionalArguments(); setArguments(arguments); - setEnvironment(m_pro->environment(bc)); + setEnvironment(bc->environment()); setIgnoreReturnValue(m_clean); return AbstractMakeStep::init(); @@ -154,11 +159,6 @@ void MakeStep::stdOut(const QString &line) AbstractMakeStep::stdOut(line); } -CMakeProject *MakeStep::project() const -{ - return m_pro; -} - bool MakeStep::buildsTarget(const QString &target) const { return m_buildTargets.contains(target); @@ -206,7 +206,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) fl->addRow(tr("Targets:"), m_targetsList); // TODO update this list also on rescans of the CMakeLists.txt - CMakeProject *pro = m_makeStep->project(); + // TODO shouldn't be accessing project + CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject(); foreach(const QString& target, pro->targets()) { QListWidgetItem *item = new QListWidgetItem(target, m_targetsList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); @@ -255,11 +256,13 @@ void MakeStepConfigWidget::updateDetails() { QStringList arguments = m_makeStep->m_buildTargets; arguments << m_makeStep->additionalArguments(); - m_summaryText = tr("<b>Make:</b> %1 %2") - .arg(m_makeStep->project()->toolChain( - m_makeStep->buildConfiguration()) - ->makeCommand(), - arguments.join(" ")); + + CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration(); + ProjectExplorer::ToolChain *tc = bc->toolChain(); + if (tc) + m_summaryText = tr("<b>Make:</b> %1 %2").arg(tc->makeCommand(), arguments.join(" ")); + else + m_summaryText = tr("<b>Unknown Toolchain</b>"); emit updateSummary(); } @@ -277,12 +280,10 @@ bool MakeStepFactory::canCreate(const QString &name) const return (Constants::MAKESTEP == name); } -BuildStep *MakeStepFactory::create(Project *project, BuildConfiguration *bc, const QString &name) const +BuildStep *MakeStepFactory::create(BuildConfiguration *bc, const QString &name) const { Q_ASSERT(name == Constants::MAKESTEP); - CMakeProject *pro = qobject_cast<CMakeProject *>(project); - Q_ASSERT(pro); - return new MakeStep(pro, bc); + return new MakeStep(bc); } BuildStep *MakeStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) const @@ -290,7 +291,7 @@ BuildStep *MakeStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) const return new MakeStep(static_cast<MakeStep *>(bs), bc); } -QStringList MakeStepFactory::canCreateForProject(Project * /* pro */) const +QStringList MakeStepFactory::canCreateForBuildConfiguration(BuildConfiguration * /* pro */) const { return QStringList(); } diff --git a/src/plugins/cmakeprojectmanager/makestep.h b/src/plugins/cmakeprojectmanager/makestep.h index 43103252511ace561f7346bb68370048c04d71f2..05b7e8ea9a0e911c6459f10c8f9eeb40bfbe09ba 100644 --- a/src/plugins/cmakeprojectmanager/makestep.h +++ b/src/plugins/cmakeprojectmanager/makestep.h @@ -41,7 +41,7 @@ QT_END_NAMESPACE namespace CMakeProjectManager { namespace Internal { -class CMakeProject; +class CMakeBuildConfiguration; class MakeStep : public ProjectExplorer::AbstractMakeStep { @@ -49,9 +49,12 @@ class MakeStep : public ProjectExplorer::AbstractMakeStep friend class MakeStepConfigWidget; // TODO remove // This is for modifying internal data public: - MakeStep(CMakeProject *pro, ProjectExplorer::BuildConfiguration *bc); + MakeStep(ProjectExplorer::BuildConfiguration *bc); MakeStep(MakeStep *bs, ProjectExplorer::BuildConfiguration *bc); ~MakeStep(); + + CMakeBuildConfiguration *cmakeBuildConfiguration() const; + virtual bool init(); virtual void run(QFutureInterface<bool> &fi); @@ -60,7 +63,6 @@ public: virtual QString displayName(); virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; - CMakeProject *project() const; bool buildsTarget(const QString &target) const; void setBuildTarget(const QString &target, bool on); QStringList additionalArguments() const; @@ -77,7 +79,6 @@ protected: // For parsing [ 76%] virtual void stdOut(const QString &line); private: - CMakeProject *m_pro; bool m_clean; QRegExp m_percentProgress; QFutureInterface<bool> *m_futureInterface; @@ -107,9 +108,9 @@ private: class MakeStepFactory : public ProjectExplorer::IBuildStepFactory { virtual bool canCreate(const QString &name) const; - virtual ProjectExplorer::BuildStep *create(ProjectExplorer::Project *pro, ProjectExplorer::BuildConfiguration *bc, const QString &name) const; + virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString &name) const; virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const; - virtual QStringList canCreateForProject(ProjectExplorer::Project *pro) const; + virtual QStringList canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const; virtual QString displayNameForName(const QString &name) const; }; diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 791aa816714b7a8e868c9bcc2807982f334cbdf6..ba45a0699c09fc659e5afaeeaaef39cfd6029f12 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -168,6 +168,7 @@ RESOURCES += core.qrc \ win32 { SOURCES += progressmanager/progressmanager_win.cpp + LIBS += -lole32 } else:macx { OBJECTIVE_SOURCES += progressmanager/progressmanager_mac.mm diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 7418de8cf1bb5f4f8f25072672af5eae34f70c6a..fce083bf60ed3c53c48d13632b6b97376040f8b9 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -50,10 +50,7 @@ ProgressManagerPrivate::ProgressManagerPrivate(QObject *parent) ProgressManagerPrivate::~ProgressManagerPrivate() { -} - -void ProgressManagerPrivate::init() -{ + cleanup(); } void ProgressManagerPrivate::cancelTasks(const QString &type) diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_mac.mm b/src/plugins/coreplugin/progressmanager/progressmanager_mac.mm index 296db9258ed79a0a3e9117c4a3a7a00a4e163f95..9d1a9ec10e6e96f0465d684ae8a7b1ad7278c926 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_mac.mm +++ b/src/plugins/coreplugin/progressmanager/progressmanager_mac.mm @@ -29,6 +29,14 @@ #include "progressmanager_p.h" +void Core::Internal::ProgressManagerPrivate::init() +{ +} + +void Core::Internal::ProgressManagerPrivate::cleanup() +{ +} + #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #import <AppKit/NSDockTile.h> #import <AppKit/NSApplication.h> diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_p.h b/src/plugins/coreplugin/progressmanager/progressmanager_p.h index 80819a36d04a35b26333a6f5258e7265874a8993..e219fb7a7a684472aab08be71ca31c902c7d57d6 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_p.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager_p.h @@ -48,6 +48,7 @@ public: ProgressManagerPrivate(QObject *parent = 0); ~ProgressManagerPrivate(); void init(); + void cleanup(); FutureProgress *addTask(const QFuture<void> &future, const QString &title, const QString &type, ProgressFlags flags); diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp index a427349c0fd8a1c867d0f1dda0ca2836feb56caf..5e324c2bcdc3640754932a0a98978568c500938c 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp @@ -27,8 +27,93 @@ ** **************************************************************************/ +#include <QtCore/QVariant> +#include <QtGui/QMainWindow> + +#include <coreplugin/icore.h> + #include "progressmanager_p.h" +// for windows progress bar +#ifndef __GNUC__ +# include <shobjidl.h> +#endif + +// Windows 7 SDK required +#ifdef __ITaskbarList3_INTERFACE_DEFINED__ + +namespace { + int total = 0; + ITaskbarList3* pITask = 0; +} + +void Core::Internal::ProgressManagerPrivate::init() +{ + CoInitialize(NULL); + HRESULT hRes = CoCreateInstance(CLSID_TaskbarList, + NULL,CLSCTX_INPROC_SERVER, + IID_ITaskbarList3,(LPVOID*) &pITask); + if (FAILED(hRes)) + { + pITask = 0; + CoUninitialize(); + return; + } + + pITask->HrInit(); + return; +} + +void Core::Internal::ProgressManagerPrivate::cleanup() +{ + if (pITask) { + pITask->Release(); + pITask = NULL; + CoUninitialize(); + } +} + + +void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text) +{ + Q_UNUSED(text) +} + +void Core::Internal::ProgressManagerPrivate::setApplicationProgressRange(int min, int max) +{ + total = max-min; +} + +void Core::Internal::ProgressManagerPrivate::setApplicationProgressValue(int value) +{ + if (pITask) { + WId winId = Core::ICore::instance()->mainWindow()->winId(); + pITask->SetProgressValue(winId, value, total); + } +} + +void Core::Internal::ProgressManagerPrivate::setApplicationProgressVisible(bool visible) +{ + if (!pITask) + return; + + WId winId = Core::ICore::instance()->mainWindow()->winId(); + if (visible) + pITask->SetProgressState(winId, TBPF_NORMAL); + else + pITask->SetProgressState(winId, TBPF_NOPROGRESS); +} + +#else + +void Core::Internal::ProgressManagerPrivate::init() +{ +} + +void Core::Internal::ProgressManagerPrivate::cleanup() +{ +} + void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text) { Q_UNUSED(text) @@ -49,3 +134,6 @@ void Core::Internal::ProgressManagerPrivate::setApplicationProgressVisible(bool { Q_UNUSED(visible) } + + +#endif // __ITaskbarList2_INTERFACE_DEFINED__ diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_x11.cpp b/src/plugins/coreplugin/progressmanager/progressmanager_x11.cpp index a427349c0fd8a1c867d0f1dda0ca2836feb56caf..69bc2d0dcd1690a7c1a8ca59b67464f4d3a61fbc 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_x11.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager_x11.cpp @@ -29,6 +29,14 @@ #include "progressmanager_p.h" +void Core::Internal::ProgressManagerPrivate::init() +{ +} + +void Core::Internal::ProgressManagerPrivate::cleanup() +{ +} + void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text) { Q_UNUSED(text) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 465c51a6d0a8241959d8c222d6eaba4758ced901..7e8c06f14faeaf06d0342259e69eb20e77810f89 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -186,19 +186,20 @@ private: } }; -class FindUses: protected ASTVisitor +class FindLocalUses: protected ASTVisitor { Scope *_functionScope; - FindScope findScope; public: - FindUses(TranslationUnit *translationUnit) - : ASTVisitor(translationUnit) + FindLocalUses(TranslationUnit *translationUnit) + : ASTVisitor(translationUnit), hasD(false), hasQ(false) { } // local and external uses. SemanticInfo::LocalUseMap localUses; + bool hasD; + bool hasQ; void operator()(FunctionDefinitionAST *ast) { @@ -218,7 +219,7 @@ protected: if (! (ast && ast->name)) return false; - Identifier *id = ast->name->identifier(); + const Identifier *id = ast->name->identifier(); if (scope) { for (Symbol *member = scope->lookat(id); member; member = member->next()) { @@ -357,6 +358,16 @@ protected: return false; } + virtual bool visit(QtMemberDeclarationAST *ast) + { + if (tokenKind(ast->q_token) == T_Q_D) + hasD = true; + else + hasQ = true; + + return true; + } + virtual bool visit(ExpressionOrDeclarationStatementAST *ast) { accept(ast->declaration); @@ -466,7 +477,7 @@ protected: class FindFunctionDefinitions: protected SymbolVisitor { - Name *_declarationName; + const Name *_declarationName; QList<Function *> *_functions; public: @@ -475,7 +486,7 @@ public: _functions(0) { } - void operator()(Name *declarationName, Scope *globals, + void operator()(const Name *declarationName, Scope *globals, QList<Function *> *functions) { _declarationName = declarationName; @@ -491,8 +502,8 @@ protected: virtual bool visit(Function *function) { - Name *name = function->name(); - if (QualifiedNameId *q = name->asQualifiedNameId()) + const Name *name = function->name(); + if (const QualifiedNameId *q = name->asQualifiedNameId()) name = q->unqualifiedNameId(); if (_declarationName->isEqualTo(name)) @@ -504,19 +515,19 @@ protected: } // end of anonymous namespace -static QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &context) +static const QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &context) { - Name *symbolName = s->name(); + const Name *symbolName = s->name(); if (! symbolName) return 0; // nothing to do. - QVector<Name *> names; + QVector<const Name *> names; for (Scope *scope = s->scope(); scope; scope = scope->enclosingScope()) { if (scope->isClassScope() || scope->isNamespaceScope()) { if (scope->owner() && scope->owner()->name()) { - Name *ownerName = scope->owner()->name(); - if (QualifiedNameId *q = ownerName->asQualifiedNameId()) { + const Name *ownerName = scope->owner()->name(); + if (const QualifiedNameId *q = ownerName->asQualifiedNameId()) { for (unsigned i = 0; i < q->nameCount(); ++i) { names.prepend(q->nameAt(i)); } @@ -527,7 +538,7 @@ static QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext } } - if (QualifiedNameId *q = symbolName->asQualifiedNameId()) { + if (const QualifiedNameId *q = symbolName->asQualifiedNameId()) { for (unsigned i = 0; i < q->nameCount(); ++i) { names.append(q->nameAt(i)); } @@ -929,6 +940,7 @@ void CPPEditor::updateMethodBoxIndex() } void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses, + const SemanticInfo &semanticInfo, QList<QTextEdit::ExtraSelection> *selections) { bool isUnused = false; @@ -951,6 +963,14 @@ void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses, sel.cursor.setPosition(anchor); sel.cursor.setPosition(position, QTextCursor::KeepAnchor); + if (isUnused) { + if (semanticInfo.hasQ && sel.cursor.selectedText() == QLatin1String("q")) + continue; // skip q + + else if (semanticInfo.hasD && sel.cursor.selectedText() == QLatin1String("d")) + continue; // skip d + } + selections->append(sel); } } @@ -1001,27 +1021,28 @@ void CPPEditor::updateUsesNow() semanticRehighlight(); } -static bool isCompatible(Name *name, Name *otherName) +static bool isCompatible(const Name *name, const Name *otherName) { - if (NameId *nameId = name->asNameId()) { - if (TemplateNameId *otherTemplId = otherName->asTemplateNameId()) + if (const NameId *nameId = name->asNameId()) { + if (const TemplateNameId *otherTemplId = otherName->asTemplateNameId()) return nameId->identifier()->isEqualTo(otherTemplId->identifier()); - } else if (TemplateNameId *templId = name->asTemplateNameId()) { - if (NameId *otherNameId = otherName->asNameId()) + } else if (const TemplateNameId *templId = name->asTemplateNameId()) { + if (const NameId *otherNameId = otherName->asNameId()) return templId->identifier()->isEqualTo(otherNameId->identifier()); } return name->isEqualTo(otherName); } -static bool isCompatible(Function *definition, Symbol *declaration, QualifiedNameId *declarationName) +static bool isCompatible(Function *definition, Symbol *declaration, + const QualifiedNameId *declarationName) { Function *declTy = declaration->type()->asFunctionType(); if (! declTy) return false; - Name *definitionName = definition->name(); - if (QualifiedNameId *q = definitionName->asQualifiedNameId()) { + const Name *definitionName = definition->name(); + if (const QualifiedNameId *q = definitionName->asQualifiedNameId()) { if (! isCompatible(q->unqualifiedNameId(), declaration->name())) return false; else if (q->nameCount() > declarationName->nameCount()) @@ -1041,8 +1062,8 @@ static bool isCompatible(Function *definition, Symbol *declaration, QualifiedNam } for (unsigned i = 0; i != q->nameCount(); ++i) { - Name *n = q->nameAt(q->nameCount() - i - 1); - Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); + const Name *n = q->nameAt(q->nameCount() - i - 1); + const Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); if (! isCompatible(n, m)) return false; } @@ -1085,7 +1106,7 @@ void CPPEditor::switchDeclarationDefinition() QList<LookupItem> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol); const LookupContext &context = typeOfExpression.lookupContext(); - QualifiedNameId *q = qualifiedNameIdForSymbol(f, context); + const QualifiedNameId *q = qualifiedNameIdForSymbol(f, context); QList<Symbol *> symbols = context.resolve(q); Symbol *declaration = 0; @@ -1258,11 +1279,11 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol) if (! funTy) return 0; // symbol does not have function type. - Name *name = symbol->name(); + const Name *name = symbol->name(); if (! name) return 0; // skip anonymous functions! - if (QualifiedNameId *q = name->asQualifiedNameId()) + if (const QualifiedNameId *q = name->asQualifiedNameId()) name = q->unqualifiedNameId(); // map from file names to function definitions. @@ -1681,9 +1702,9 @@ void CPPEditor::performQuickFix(int index) { CPPQuickFixCollector *quickFixCollector = CppPlugin::instance()->quickFixCollector(); QuickFixOperationPtr op = m_quickFixes.at(index); - //quickFixCollector->perform(op); - op->createChangeSet(); - setChangeSet(op->changeSet()); + quickFixCollector->perform(op); + //op->createChangeSet(); + //setChangeSet(op->changeSet()); } void CPPEditor::contextMenuEvent(QContextMenuEvent *e) @@ -1869,6 +1890,10 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES)); m_occurrencesUnusedFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_UNUSED)); + m_occurrencesUnusedFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline); + m_occurrencesUnusedFormat.setUnderlineColor(m_occurrencesUnusedFormat.foreground().color()); + m_occurrencesUnusedFormat.clearForeground(); + m_occurrencesUnusedFormat.setToolTip(tr("Unused variable")); m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME)); // only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link @@ -1934,7 +1959,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) int line = 0, column = 0; convertPosition(position(), &line, &column); - QList<QTextEdit::ExtraSelection> allSelections; + QList<QTextEdit::ExtraSelection> unusedSelections; m_renameSelections.clear(); @@ -1953,18 +1978,16 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) } } - if (uses.size() == 1) { + if (uses.size() == 1) // it's an unused declaration - // highlightUses(uses, &allSelections); - } else if (good) { - QList<QTextEdit::ExtraSelection> selections; - highlightUses(uses, &selections); - m_renameSelections += selections; - allSelections += selections; - } + highlightUses(uses, semanticInfo, &unusedSelections); + + else if (good && m_renameSelections.isEmpty()) + highlightUses(uses, semanticInfo, &m_renameSelections); } - setExtraSelections(CodeSemanticsSelection, allSelections); + setExtraSelections(UnusedSymbolSelection, unusedSelections); + setExtraSelections(CodeSemanticsSelection, m_renameSelections); } SemanticHighlighter::Source CPPEditor::currentSource(bool force) @@ -2078,7 +2101,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) FunctionDefinitionUnderCursor functionDefinitionUnderCursor(translationUnit); FunctionDefinitionAST *currentFunctionDefinition = functionDefinitionUnderCursor(ast, source.line, source.column); - FindUses useTable(translationUnit); + FindLocalUses useTable(translationUnit); useTable(currentFunctionDefinition); SemanticInfo semanticInfo; @@ -2086,6 +2109,8 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) semanticInfo.snapshot = snapshot; semanticInfo.doc = doc; semanticInfo.localUses = useTable.localUses; + semanticInfo.hasQ = useTable.hasQ; + semanticInfo.hasD = useTable.hasD; return semanticInfo; } diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 16bf04f94ecf8b0e991017697ea14f4677f0ea23..716240fd3c9bbb2d55180c46c42278a72c981c23 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -79,10 +79,12 @@ public: typedef QHashIterator<CPlusPlus::Symbol *, QList<Use> > LocalUseIterator; SemanticInfo() - : revision(-1) + : revision(-1), hasQ(false), hasD(false) { } int revision; + bool hasQ: 1; + bool hasD: 1; CPlusPlus::Snapshot snapshot; CPlusPlus::Document::Ptr doc; LocalUseMap localUses; @@ -253,6 +255,7 @@ private: SemanticHighlighter::Source currentSource(bool force = false); void highlightUses(const QList<SemanticInfo::Use> &uses, + const SemanticInfo &semanticInfo, QList<QTextEdit::ExtraSelection> *selections); void createToolBar(CPPEditorEditable *editable); diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 6c93ca8ffa5ea5c2e67cdeedc0437312e1d7cea9..3db38f6f7164a4600a23211e36289bab07605da7 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -138,7 +138,7 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint } } -static QString buildHelpId(Symbol *symbol, Name *name) +static QString buildHelpId(Symbol *symbol, const Name *name) { Scope *scope = 0; @@ -161,13 +161,13 @@ static QString buildHelpId(Symbol *symbol, Name *name) Symbol *owner = scope->owner(); if (owner && owner->name() && ! scope->isEnumScope()) { - Name *name = owner->name(); - Identifier *id = 0; + const Name *name = owner->name(); + const Identifier *id = 0; - if (NameId *nameId = name->asNameId()) + if (const NameId *nameId = name->asNameId()) id = nameId->identifier(); - else if (TemplateNameId *nameId = name->asTemplateNameId()) + else if (const TemplateNameId *nameId = name->asTemplateNameId()) id = nameId->identifier(); if (id) @@ -182,7 +182,7 @@ static QString buildHelpId(Symbol *symbol, Name *name) static FullySpecifiedType resolve(const FullySpecifiedType &ty, const LookupContext &context, Symbol **resolvedSymbol, - Name **resolvedName) + const Name **resolvedName) { Control *control = context.control(); @@ -272,8 +272,10 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in if (!doc) return; // nothing to do + QString formatTooltip = edit->extraSelectionTooltip(pos); QTextCursor tc(edit->document()); tc.setPosition(pos); + const unsigned lineNumber = tc.block().blockNumber() + 1; // Find the last symbol up to the cursor position @@ -332,14 +334,14 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in Symbol *lookupSymbol = result.lastVisibleSymbol(); // lookup symbol Symbol *resolvedSymbol = lookupSymbol; - Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0; + const Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0; firstType = resolve(firstType, typeOfExpression.lookupContext(), &resolvedSymbol, &resolvedName); if (resolvedSymbol && resolvedSymbol->scope() && resolvedSymbol->scope()->isClassScope()) { Class *enclosingClass = resolvedSymbol->scope()->owner()->asClass(); - if (Identifier *id = enclosingClass->identifier()) { + if (const Identifier *id = enclosingClass->identifier()) { if (id->isEqualTo(resolvedSymbol->identifier())) resolvedSymbol = enclosingClass; } @@ -392,6 +394,11 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in m_helpEngineNeedsSetup = false; } + + if (!formatTooltip.isEmpty()) { + m_toolTip = formatTooltip; + } + if (!m_toolTip.isEmpty()) m_toolTip = Qt::escape(m_toolTip); diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 37ea378d2e1bcfee6fa0b42e7c94edc8d628f986..a61cfde23ff7fcc6afcbdff77a210d21e7ee5f59 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -192,7 +192,7 @@ protected: return previousItem; } - TextEditor::CompletionItem newCompletionItem(Name *name) + TextEditor::CompletionItem newCompletionItem(const Name *name) { TextEditor::CompletionItem item(_collector); item.text = overview.prettyName(name); @@ -200,25 +200,25 @@ protected: return item; } - virtual void visit(NameId *name) + virtual void visit(const NameId *name) { _item = newCompletionItem(name); } - virtual void visit(TemplateNameId *name) + virtual void visit(const TemplateNameId *name) { _item = newCompletionItem(name); _item.text = QLatin1String(name->identifier()->chars()); } - virtual void visit(DestructorNameId *name) + virtual void visit(const DestructorNameId *name) { _item = newCompletionItem(name); } - virtual void visit(OperatorNameId *name) + virtual void visit(const OperatorNameId *name) { _item = newCompletionItem(name); } - virtual void visit(ConversionNameId *name) + virtual void visit(const ConversionNameId *name) { _item = newCompletionItem(name); } - virtual void visit(QualifiedNameId *name) + virtual void visit(const QualifiedNameId *name) { _item = newCompletionItem(name->unqualifiedNameId()); } }; @@ -890,13 +890,13 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r FullySpecifiedType exprTy = result.type().simplified(); if (Class *klass = exprTy->asClassType()) { - Name *className = klass->name(); + const Name *className = klass->name(); if (! className) continue; // nothing to do for anonymoous classes. for (unsigned i = 0; i < klass->memberCount(); ++i) { Symbol *member = klass->memberAt(i); - Name *memberName = member->name(); + const Name *memberName = member->name(); if (! memberName) continue; // skip anonymous member. @@ -945,7 +945,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r if (functions.isEmpty()) { ResolveExpression resolveExpression(context); ResolveClass resolveClass; - Name *functionCallOp = context.control()->operatorNameId(OperatorNameId::FunctionCallOp); + const Name *functionCallOp = context.control()->operatorNameId(OperatorNameId::FunctionCallOp); foreach (const LookupItem &result, results) { FullySpecifiedType ty = result.type().simplified(); @@ -1092,7 +1092,7 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults, classObjectCandidates.append(klass); else if (NamedType *namedTy = ty->asNamedType()) { - Name *className = namedTy->name(); + const Name *className = namedTy->name(); const QList<Symbol *> classes = resolveClass(className, r, context); foreach (Symbol *c, classes) { diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 9fdc6f883ca7f82b670be28b19ca0d61d68ccb5c..aca2d8c3bff4419b4dd6d5aaa1e863e372913983 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -23,7 +23,7 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** **************************************************************************/ @@ -79,8 +79,8 @@ QList<int> CppFindReferences::references(Symbol *symbol, Document::Ptr doc, const Snapshot& snapshot) const { - Identifier *id = 0; - if (Identifier *symbolId = symbol->identifier()) + const Identifier *id = 0; + if (const Identifier *symbolId = symbol->identifier()) id = doc->control()->findIdentifier(symbolId->chars(), symbolId->size()); QList<int> references; @@ -106,7 +106,7 @@ static void find_helper(QFutureInterface<Usage> &future, QTime tm; tm.start(); - Identifier *symbolId = symbol->identifier(); + const Identifier *symbolId = symbol->identifier(); Q_ASSERT(symbolId != 0); const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); @@ -142,7 +142,7 @@ static void find_helper(QFutureInterface<Usage> &future, if (Document::Ptr previousDoc = snapshot.value(fileName)) { Control *control = previousDoc->control(); - Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size()); + const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size()); if (! id) continue; // skip this document, it's not using symbolId. } @@ -164,7 +164,7 @@ static void find_helper(QFutureInterface<Usage> &future, doc->tokenize(); Control *control = doc->control(); - if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) { + if (const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) { QTime tm; tm.start(); doc->parse(); @@ -202,7 +202,7 @@ void CppFindReferences::findUsages(Symbol *symbol) void CppFindReferences::renameUsages(Symbol *symbol) { - if (Identifier *id = symbol->identifier()) { + if (const Identifier *id = symbol->identifier()) { const QString textToReplace = QString::fromUtf8(id->chars(), id->size()); Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace); diff --git a/src/plugins/cpptools/cppfindreferences.h b/src/plugins/cpptools/cppfindreferences.h index 61ba876546fd9d3320cb9da2ad3d327f51dd7d82..2156a1fa6e63e91cb9b88b34f38aa5ecf70f1a9a 100644 --- a/src/plugins/cpptools/cppfindreferences.h +++ b/src/plugins/cpptools/cppfindreferences.h @@ -23,7 +23,7 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** **************************************************************************/ diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp index ae2c6edc6411ec78ae66eeff2f126e2456c4522f..1e101cb4ef073dd32ddd94e94ca9bd29c39b38df 100644 --- a/src/plugins/cpptools/searchsymbols.cpp +++ b/src/plugins/cpptools/searchsymbols.cpp @@ -95,8 +95,8 @@ bool SearchSymbols::visit(Function *symbol) return false; QString extraScope; - if (Name *name = symbol->name()) { - if (QualifiedNameId *nameId = name->asQualifiedNameId()) { + if (const Name *name = symbol->name()) { + if (const QualifiedNameId *nameId = name->asQualifiedNameId()) { if (nameId->nameCount() > 1) { extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2)); } diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index 08c552dab8b6e2ba6e99145ef79c1473da600669..b538b7fe67578706753db8da04fe9736c42b154f 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -1588,6 +1588,8 @@ QList<Symbol> CdbDebugEngine::moduleSymbols(const QString &moduleName) void CdbDebugEngine::reloadRegisters() { + if (state() != InferiorStopped) + return; const int intBase = 10; if (debugCDB) qDebug() << Q_FUNC_INFO << intBase; diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 077f03dfc6fe6924cc5c3818621381b2efc5ab18..d0713e8c355fe85ad060287e9701fe79c24c1454 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -35,6 +35,7 @@ #include <projectexplorer/environment.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/buildconfiguration.h> #include <utils/qtcassert.h> #include <coreplugin/icore.h> @@ -131,7 +132,7 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, } if (const ProjectExplorer::Project *project = runConfiguration->project()) { m_startParameters->buildDir = - project->buildDirectory(project->activeBuildConfiguration()); + project->activeBuildConfiguration()->buildDirectory(); } m_startParameters->useTerminal = runConfiguration->runMode() == LocalApplicationRunConfiguration::Console; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index b8fa6fa6747962f268b995771f30a5d64583bd76..18c770cb92ab067e6e195fbd3ff911489101b3ec 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -155,9 +155,8 @@ static bool parseConsoleStream(const GdbResponse &response, GdbMi *contents) out = out.left(out.lastIndexOf('"')); // optimization: dumper output never needs real C unquoting out.replace('\\', ""); - out = "dummy={" + out + "}"; - contents->fromString(out); + contents->fromStringMultiple(out); //qDebug() << "CONTENTS" << contents->toString(true); return contents->isValid(); } @@ -2569,6 +2568,8 @@ void GdbEngine::handleStackListThreads(const GdbResponse &response) void GdbEngine::reloadRegisters() { + if (state() != InferiorStopped) + return; if (!m_registerNamesListed) { postCommand(_("-data-list-register-names"), CB(handleRegisterListNames)); m_registerNamesListed = true; @@ -3584,8 +3585,8 @@ void GdbEngine::handleStackFrame(const GdbResponse &response) << out.left(pos); out = out.mid(pos); } - GdbMi all("[" + out + "]"); - //GdbMi all(out); + GdbMi all; + all.fromStringMultiple(out); //qDebug() << "\n\n\nALL: " << all.toString() << "\n"; GdbMi locals = all.findChild("locals"); diff --git a/src/plugins/debugger/gdb/gdbmi.cpp b/src/plugins/debugger/gdb/gdbmi.cpp index ffac5d76d1588b2ef84b94aa22936780d39bca41..639e698d36f39cf0f50cabc7a21156d15309cb0d 100644 --- a/src/plugins/debugger/gdb/gdbmi.cpp +++ b/src/plugins/debugger/gdb/gdbmi.cpp @@ -348,6 +348,13 @@ void GdbMi::fromString(const QByteArray &ba) parseResultOrValue(from, to); } +void GdbMi::fromStringMultiple(const QByteArray &ba) +{ + const char *from = ba.constBegin(); + const char *to = ba.constEnd(); + parseTuple_helper(from, to); +} + GdbMi GdbMi::findChild(const char *name) const { for (int i = 0; i < m_children.size(); ++i) diff --git a/src/plugins/debugger/gdb/gdbmi.h b/src/plugins/debugger/gdb/gdbmi.h index 24295afea662b32d148f929257f61ac342dedf8a..a4ce8375030dea05b26d1e0d72dc37956f8d0f8c 100644 --- a/src/plugins/debugger/gdb/gdbmi.h +++ b/src/plugins/debugger/gdb/gdbmi.h @@ -91,7 +91,6 @@ class GdbMi { public: GdbMi() : m_type(Invalid) {} - explicit GdbMi(const QByteArray &str) { fromString(str); } QByteArray m_name; QByteArray m_data; @@ -126,6 +125,7 @@ public: QByteArray toString(bool multiline = false, int indent = 0) const; void fromString(const QByteArray &str); + void fromStringMultiple(const QByteArray &str); void setStreamOutput(const QByteArray &name, const QByteArray &content); private: diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index f5ef9250e7e52a7fc5a96d6ae91f85c6cc4f7c18..1c07ef499e386e9a3b416f2348288ff0338ba035 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -975,11 +975,8 @@ bool QtDumperHelper::parseQuery(const GdbMi &contents, Debugger debugger) // parse a query bool QtDumperHelper::parseQuery(const char *data, Debugger debugger) { - QByteArray fullData = data; - fullData.insert(0, '{'); - fullData.append(data); - fullData.append('}'); - GdbMi root(fullData); + GdbMi root; + root.fromStringMultiple(QByteArray(data)); if (!root.isValid()) return false; return parseQuery(root, debugger); @@ -1475,11 +1472,8 @@ bool QtDumperHelper::parseValue(const char *data, QList<WatchData> *l) { l->clear(); - QByteArray fullData = data; - fullData.insert(0, '{'); - fullData.append(data); - fullData.append('}'); - GdbMi root(fullData); + GdbMi root; + root.fromStringMultiple(QByteArray(data)); if (!root.isValid()) return false; gbdMiToWatchData(root, GdbMiRecursionContext(), l); diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index 636627c40f876467c40b3ceba6f93c37e9d87bc7..4f08b925faed4b53ed09705d39a2fc00e218652f 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -251,8 +251,8 @@ static bool isCompatible(const Function *definition, const Symbol *declaration, if (! declTy) return false; - Name *definitionName = definition->name(); - if (QualifiedNameId *q = definitionName->asQualifiedNameId()) { + const Name *definitionName = definition->name(); + if (const QualifiedNameId *q = definitionName->asQualifiedNameId()) { if (! isCompatible(q->unqualifiedNameId(), declaration->name())) return false; else if (q->nameCount() > declarationName->nameCount()) @@ -272,8 +272,8 @@ static bool isCompatible(const Function *definition, const Symbol *declaration, } for (unsigned i = 0; i != q->nameCount(); ++i) { - Name *n = q->nameAt(q->nameCount() - i - 1); - Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); + const Name *n = q->nameAt(q->nameCount() - i - 1); + const Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); if (! isCompatible(n, m)) return false; } @@ -291,13 +291,13 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li if (!cppModelManager) return Document::Ptr(); - QVector<Name *> qualifiedName; + QVector<const Name *> qualifiedName; Scope *scope = functionDeclaration->scope(); for (; scope; scope = scope->enclosingScope()) { if (scope->isClassScope() || scope->isNamespaceScope()) { if (scope->owner() && scope->owner()->name()) { - Name *scopeOwnerName = scope->owner()->name(); - if (QualifiedNameId *q = scopeOwnerName->asQualifiedNameId()) { + const Name *scopeOwnerName = scope->owner()->name(); + if (const QualifiedNameId *q = scopeOwnerName->asQualifiedNameId()) { for (unsigned i = 0; i < q->nameCount(); ++i) { qualifiedName.prepend(q->nameAt(i)); @@ -312,7 +312,7 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li qualifiedName.append(functionDeclaration->name()); Control control; - QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size()); + const QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size()); LookupContext context(&control); const Snapshot documents = cppModelManager->snapshot(); foreach (Document::Ptr doc, documents) { @@ -321,13 +321,13 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li visibleScopes = context.expand(visibleScopes); foreach (Scope *visibleScope, visibleScopes) { Symbol *symbol = 0; - if (NameId *nameId = q->unqualifiedNameId()->asNameId()) + if (const NameId *nameId = q->unqualifiedNameId()->asNameId()) symbol = visibleScope->lookat(nameId->identifier()); - else if (DestructorNameId *dtorId = q->unqualifiedNameId()->asDestructorNameId()) + else if (const DestructorNameId *dtorId = q->unqualifiedNameId()->asDestructorNameId()) symbol = visibleScope->lookat(dtorId->identifier()); - else if (TemplateNameId *templNameId = q->unqualifiedNameId()->asTemplateNameId()) + else if (const TemplateNameId *templNameId = q->unqualifiedNameId()->asTemplateNameId()) symbol = visibleScope->lookat(templNameId->identifier()); - else if (OperatorNameId *opId = q->unqualifiedNameId()->asOperatorNameId()) + else if (const OperatorNameId *opId = q->unqualifiedNameId()->asOperatorNameId()) symbol = visibleScope->lookat(opId->kind()); // ### cast operators for (; symbol; symbol = symbol->next()) { diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c1b38ec521cce67930d92fe93c3c06db86c69cc --- /dev/null +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "genericbuildconfiguration.h" +#include "genericproject.h" + +using namespace GenericProjectManager; +using namespace GenericProjectManager::Internal; +using ProjectExplorer::BuildConfiguration; + +GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro) + : BuildConfiguration(pro) +{ + +} + +GenericBuildConfiguration::GenericBuildConfiguration(GenericBuildConfiguration *source) + : BuildConfiguration(source) +{ + +} + +ProjectExplorer::Environment GenericBuildConfiguration::environment() const +{ + return ProjectExplorer::Environment::systemEnvironment(); +} + +QString GenericBuildConfiguration::buildDirectory() const +{ + QString buildDirectory = value("buildDirectory").toString(); + + if (buildDirectory.isEmpty()) { + QFileInfo fileInfo(project()->file()->fileName()); + + buildDirectory = fileInfo.absolutePath(); + } + + return buildDirectory; +} + +GenericProject *GenericBuildConfiguration::genericProject() const +{ + return static_cast<GenericProject *>(project()); +} + diff --git a/src/plugins/qt4projectmanager/embeddedpropertiespage.h b/src/plugins/genericprojectmanager/genericbuildconfiguration.h similarity index 52% rename from src/plugins/qt4projectmanager/embeddedpropertiespage.h rename to src/plugins/genericprojectmanager/genericbuildconfiguration.h index 06342974c00501b4543bd21a28b8eb9bb67e9978..b42d7ae062b8e457f2915f853c8ea24bb50f0aad 100644 --- a/src/plugins/qt4projectmanager/embeddedpropertiespage.h +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.h @@ -27,59 +27,30 @@ ** **************************************************************************/ -#ifndef EMBEDDEDPROPERTIESPAGE_H -#define EMBEDDEDPROPERTIESPAGE_H +#ifndef GENERICBUILDCONFIGURATION_H +#define GENERICBUILDCONFIGURATION_H -#include "ui_embeddedpropertiespage.h" - -#include <projectexplorer/iprojectproperties.h> - -#include <QtCore/QModelIndex> - -namespace ProjectExplorer { -class Project; -} - -namespace Qt4ProjectManager { +#include <projectexplorer/buildconfiguration.h> +namespace GenericProjectManager { namespace Internal { -class EmbeddedPropertiesWidget; +class GenericProject; -class EmbeddedPropertiesPanelFactory : public ProjectExplorer::IPanelFactory -{ -public: - virtual bool supports(ProjectExplorer::Project *project); - ProjectExplorer::IPropertiesPanel *createPanel(ProjectExplorer::Project *project); -}; -class EmbeddedPropertiesPanel : public ProjectExplorer::IPropertiesPanel +class GenericBuildConfiguration : public ProjectExplorer::BuildConfiguration { + Q_OBJECT public: - EmbeddedPropertiesPanel(ProjectExplorer::Project *project); - ~EmbeddedPropertiesPanel(); + GenericBuildConfiguration(GenericProject *pro); + GenericBuildConfiguration(GenericBuildConfiguration *source); - QString name() const; - QWidget *widget() const; - QIcon icon() const; + GenericProject *genericProject() const; -private: - EmbeddedPropertiesWidget *m_widget; - QIcon m_icon; -}; - -class EmbeddedPropertiesWidget : public QWidget -{ - Q_OBJECT -public: - EmbeddedPropertiesWidget(ProjectExplorer::Project *project); - virtual ~EmbeddedPropertiesWidget(); - private: - Ui_EmbeddedPropertiesPage m_ui; - ProjectExplorer::Project *m_pro; + virtual ProjectExplorer::Environment environment() const; + virtual QString buildDirectory() const; }; +} // namespace GenericProjectManager } // namespace Internal -} // namespace Qt4ProjectManager - -#endif // EMBEDDEDPROPERTIESPAGE_H +#endif // GENERICBUILDCONFIGURATION_H diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp index 6fbb3d700f75899c3af9ed3067f9228d5febaf9d..4f10924cce1818e2ba98701fb1526b6e5577011a 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.cpp +++ b/src/plugins/genericprojectmanager/genericmakestep.cpp @@ -31,6 +31,7 @@ #include "genericprojectconstants.h" #include "genericproject.h" #include "ui_genericmakestep.h" +#include "genericbuildconfiguration.h" #include <extensionsystem/pluginmanager.h> #include <projectexplorer/toolchain.h> @@ -47,13 +48,13 @@ using namespace GenericProjectManager; using namespace GenericProjectManager::Internal; -GenericMakeStep::GenericMakeStep(GenericProject *pro, ProjectExplorer::BuildConfiguration *bc) - : AbstractMakeStep(pro, bc), m_pro(pro) +GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildConfiguration *bc) + : AbstractMakeStep(bc) { } GenericMakeStep::GenericMakeStep(GenericMakeStep *bs, ProjectExplorer::BuildConfiguration *bc) - : AbstractMakeStep(bs, bc), m_pro(bs->project()) + : AbstractMakeStep(bs, bc) { m_buildTargets = bs->m_buildTargets; m_makeArguments = bs->m_makeArguments; @@ -64,23 +65,28 @@ GenericMakeStep::~GenericMakeStep() { } +GenericBuildConfiguration *GenericMakeStep::genericBuildConfiguration() const +{ + return static_cast<GenericBuildConfiguration *>(buildConfiguration()); +} + bool GenericMakeStep::init() { - ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); - const QString buildParser = m_pro->buildParser(bc); + GenericBuildConfiguration *bc = genericBuildConfiguration(); + //TODO + const QString buildParser = genericBuildConfiguration()->genericProject()->buildParser(bc); setBuildParser(buildParser); - qDebug() << "*** build parser:" << buildParser; setEnabled(true); Core::VariableManager *vm = Core::VariableManager::instance(); - const QString rawBuildDir = m_pro->buildDirectory(bc); + const QString rawBuildDir = bc->buildDirectory(); const QString buildDir = vm->resolve(rawBuildDir); setWorkingDirectory(buildDir); setCommand(makeCommand()); setArguments(replacedArguments()); - setEnvironment(m_pro->environment(bc)); + setEnvironment(bc->environment()); return AbstractMakeStep::init(); } @@ -119,7 +125,8 @@ QString GenericMakeStep::makeCommand() const { QString command = m_makeCommand; if (command.isEmpty()) { - if (ProjectExplorer::ToolChain *toolChain = m_pro->toolChain()) + GenericProject *pro = genericBuildConfiguration()->genericProject(); + if (ProjectExplorer::ToolChain *toolChain = pro->toolChain()) command = toolChain->makeCommand(); else command = QLatin1String("make"); @@ -152,11 +159,6 @@ bool GenericMakeStep::immutable() const return true; } -GenericProject *GenericMakeStep::project() const -{ - return m_pro; -} - bool GenericMakeStep::buildsTarget(const QString &target) const { return m_buildTargets.contains(target); @@ -184,7 +186,7 @@ GenericMakeStepConfigWidget::GenericMakeStepConfigWidget(GenericMakeStep *makeSt m_ui->setupUi(this); // TODO update this list also on rescans of the GenericLists.txt - GenericProject *pro = m_makeStep->project(); + GenericProject *pro = m_makeStep->genericBuildConfiguration()->genericProject(); foreach (const QString &target, pro->targets()) { QListWidgetItem *item = new QListWidgetItem(target, m_ui->targetsList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); @@ -280,14 +282,11 @@ bool GenericMakeStepFactory::canCreate(const QString &name) const return (Constants::MAKESTEP == name); } -ProjectExplorer::BuildStep *GenericMakeStepFactory::create(ProjectExplorer::Project *project, - ProjectExplorer::BuildConfiguration *bc, +ProjectExplorer::BuildStep *GenericMakeStepFactory::create(ProjectExplorer::BuildConfiguration *bc, const QString &name) const { Q_ASSERT(name == Constants::MAKESTEP); - GenericProject *pro = qobject_cast<GenericProject *>(project); - Q_ASSERT(pro); - return new GenericMakeStep(pro, bc); + return new GenericMakeStep(bc); } ProjectExplorer::BuildStep *GenericMakeStepFactory::clone(ProjectExplorer::BuildStep *bs, @@ -296,7 +295,7 @@ ProjectExplorer::BuildStep *GenericMakeStepFactory::clone(ProjectExplorer::Build return new GenericMakeStep(static_cast<GenericMakeStep*>(bs), bc); } -QStringList GenericMakeStepFactory::canCreateForProject(ProjectExplorer::Project * /* pro */) const +QStringList GenericMakeStepFactory::canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration * /* pro */) const { return QStringList(); } diff --git a/src/plugins/genericprojectmanager/genericmakestep.h b/src/plugins/genericprojectmanager/genericmakestep.h index a9cc5bd18b53162322d6a8acf422347ec27cbead..57a8ee4a11a699e9d895283b6c9488b76762f733 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.h +++ b/src/plugins/genericprojectmanager/genericmakestep.h @@ -43,7 +43,7 @@ QT_END_NAMESPACE namespace GenericProjectManager { namespace Internal { -class GenericProject; +class GenericBuildConfiguration; class GenericMakeStepConfigWidget; struct GenericMakeStepSettings @@ -56,9 +56,11 @@ class GenericMakeStep : public ProjectExplorer::AbstractMakeStep Q_OBJECT friend class GenericMakeStepConfigWidget; // TODO remove again? public: - GenericMakeStep(GenericProject *pro, ProjectExplorer::BuildConfiguration *bc); + GenericMakeStep(ProjectExplorer::BuildConfiguration *bc); GenericMakeStep(GenericMakeStep *bs, ProjectExplorer::BuildConfiguration *bc); ~GenericMakeStep(); + GenericBuildConfiguration *genericBuildConfiguration() const; + virtual bool init(); virtual void run(QFutureInterface<bool> &fi); @@ -67,7 +69,6 @@ public: virtual QString displayName(); virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; - GenericProject *project() const; bool buildsTarget(const QString &target) const; void setBuildTarget(const QString &target, bool on); QStringList replacedArguments() const; @@ -76,7 +77,6 @@ public: virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map); virtual void storeIntoLocalMap(QMap<QString, QVariant> &map); private: - GenericProject *m_pro; QStringList m_buildTargets; QStringList m_makeArguments; QString m_makeCommand; @@ -105,12 +105,11 @@ private: class GenericMakeStepFactory : public ProjectExplorer::IBuildStepFactory { virtual bool canCreate(const QString &name) const; - virtual ProjectExplorer::BuildStep *create(ProjectExplorer::Project *pro, - ProjectExplorer::BuildConfiguration *bc, + virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString &name) const; virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const; - virtual QStringList canCreateForProject(ProjectExplorer::Project *pro) const; + virtual QStringList canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const; virtual QString displayNameForName(const QString &name) const; }; diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index 7775582cc4add8d5a44914c8208bd645b4b8454d..242e04c8c893a575bf36ca39961c74857e780cc7 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -30,6 +30,7 @@ #include "genericproject.h" #include "genericprojectconstants.h" #include "genericmakestep.h" +#include "genericbuildconfiguration.h" #include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorerconstants.h> @@ -131,7 +132,7 @@ QString GenericBuildConfigurationFactory::displayNameForType(const QString & /* return tr("Create"); } -bool GenericBuildConfigurationFactory::create(const QString &type) const +BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &type) const { QTC_ASSERT(type == "Create", return false); //TODO asking for name is duplicated everywhere, but maybe more @@ -145,13 +146,26 @@ bool GenericBuildConfigurationFactory::create(const QString &type) const &ok); if (!ok || buildConfigurationName.isEmpty()) return false; - BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName); + GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project); + bc->setDisplayName(buildConfigurationName); m_project->addBuildConfiguration(bc); // also makes the name unique... - GenericMakeStep *makeStep = new GenericMakeStep(m_project, bc); + GenericMakeStep *makeStep = new GenericMakeStep(bc); bc->insertBuildStep(0, makeStep); makeStep->setBuildTarget("all", /* on = */ true); - return true; + return bc; +} + +BuildConfiguration *GenericBuildConfigurationFactory::clone(BuildConfiguration *source) const +{ + GenericBuildConfiguration *bc = new GenericBuildConfiguration(static_cast<GenericBuildConfiguration *>(source)); + return bc; +} + +BuildConfiguration *GenericBuildConfigurationFactory::restore() const +{ + GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project); + return bc; } //////////////////////////////////////////////////////////////////////////////////// @@ -465,25 +479,6 @@ bool GenericProject::isApplication() const return true; } -ProjectExplorer::Environment GenericProject::environment(BuildConfiguration *configuration) const -{ - Q_UNUSED(configuration) - return ProjectExplorer::Environment::systemEnvironment(); -} - -QString GenericProject::buildDirectory(BuildConfiguration *configuration) const -{ - QString buildDirectory = configuration->value("buildDirectory").toString(); - - if (buildDirectory.isEmpty()) { - QFileInfo fileInfo(m_fileName); - - buildDirectory = fileInfo.absolutePath(); - } - - return buildDirectory; -} - ProjectExplorer::BuildConfigWidget *GenericProject::createConfigWidget() { return new GenericBuildSettingsWidget(this); @@ -518,10 +513,11 @@ bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead Project::restoreSettingsImpl(reader); if (buildConfigurations().isEmpty()) { - ProjectExplorer::BuildConfiguration *bc = new BuildConfiguration("all"); + GenericBuildConfiguration *bc = new GenericBuildConfiguration(this); + bc->setDisplayName("all"); addBuildConfiguration(bc); - GenericMakeStep *makeStep = new GenericMakeStep(this, bc); + GenericMakeStep *makeStep = new GenericMakeStep(bc); bc->insertBuildStep(0, makeStep); makeStep->setBuildTarget("all", /* on = */ true); @@ -574,7 +570,7 @@ void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter //////////////////////////////////////////////////////////////////////////////////// GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project) - : m_project(project) + : m_project(project), m_buildConfiguration(0) { QFormLayout *fl = new QFormLayout(this); fl->setContentsMargins(0, -1, 0, -1); @@ -610,15 +606,15 @@ GenericBuildSettingsWidget::~GenericBuildSettingsWidget() QString GenericBuildSettingsWidget::displayName() const { return tr("Generic Manager"); } -void GenericBuildSettingsWidget::init(const QString &buildConfigurationName) +void GenericBuildSettingsWidget::init(BuildConfiguration *bc) { - m_buildConfiguration = buildConfigurationName; - m_pathChooser->setPath(m_project->buildDirectory(m_project->buildConfiguration(buildConfigurationName))); + m_buildConfiguration = static_cast<GenericBuildConfiguration *>(bc); + m_pathChooser->setPath(m_buildConfiguration->buildDirectory()); } void GenericBuildSettingsWidget::buildDirectoryChanged() { - m_project->buildConfiguration(m_buildConfiguration)->setValue("buildDirectory", m_pathChooser->path()); + m_buildConfiguration->setValue("buildDirectory", m_pathChooser->path()); } void GenericBuildSettingsWidget::toolChainSelected(int index) diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h index 784951aa23a224cd798d7ea93a8db79c6957dbed..eb828b683c672e744725008469d1820a64334ea4 100644 --- a/src/plugins/genericprojectmanager/genericproject.h +++ b/src/plugins/genericprojectmanager/genericproject.h @@ -54,6 +54,7 @@ namespace Internal { class GenericProject; class GenericMakeStep; class GenericProjectFile; +class GenericBuildConfiguration; class GenericBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory { @@ -66,7 +67,9 @@ public: QStringList availableCreationTypes() const; QString displayNameForType(const QString &type) const; - bool create(const QString &type) const; + ProjectExplorer::BuildConfiguration *create(const QString &type) const; + ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const; + ProjectExplorer::BuildConfiguration *restore() const; private: GenericProject *m_project; @@ -93,9 +96,6 @@ public: virtual bool isApplication() const; - virtual ProjectExplorer::Environment environment(ProjectExplorer::BuildConfiguration *configuration) const; - virtual QString buildDirectory(ProjectExplorer::BuildConfiguration *configuration) const; - virtual ProjectExplorer::BuildConfigWidget *createConfigWidget(); virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets(); @@ -193,7 +193,7 @@ public: virtual QString displayName() const; - virtual void init(const QString &buildConfiguration); + virtual void init(ProjectExplorer::BuildConfiguration *bc); private Q_SLOTS: void buildDirectoryChanged(); @@ -202,7 +202,7 @@ private Q_SLOTS: private: GenericProject *m_project; Utils::PathChooser *m_pathChooser; - QString m_buildConfiguration; + GenericBuildConfiguration *m_buildConfiguration; }; } // namespace Internal diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.pro b/src/plugins/genericprojectmanager/genericprojectmanager.pro index a58404176a9c2a66c2eac82bf657cb0ec5001fa5..cc7f6164242d5edc22f55f6c33b375cc7a8a4647 100644 --- a/src/plugins/genericprojectmanager/genericprojectmanager.pro +++ b/src/plugins/genericprojectmanager/genericprojectmanager.pro @@ -10,7 +10,8 @@ HEADERS = genericproject.h \ genericprojectwizard.h \ genericprojectfileseditor.h \ pkgconfigtool.h \ - genericmakestep.h + genericmakestep.h \ + genericbuildconfiguration.h SOURCES = genericproject.cpp \ genericprojectplugin.cpp \ genericprojectmanager.cpp \ @@ -18,8 +19,8 @@ SOURCES = genericproject.cpp \ genericprojectwizard.cpp \ genericprojectfileseditor.cpp \ pkgconfigtool.cpp \ - genericmakestep.cpp + genericmakestep.cpp \ + genericbuildconfiguration.cpp RESOURCES += genericproject.qrc FORMS += genericmakestep.ui - OTHER_FILES += GenericProjectManager.pluginspec diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 9e5fd1a80542e023f48ab9900eeadf04ba5e3c66..d905a538fd9ec28ea61526d06333b3e01f124dc2 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -427,7 +427,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT); a = new QAction(tr("Reset Font Size"), this); - cmd = am->registerAction(a, QLatin1String("Help.ResetFontSize"), + cmd = am->registerAction(a, TextEditor::Constants::RESET_FONT_SIZE, modecontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+0"))); connect(a, SIGNAL(triggered()), m_centralWidget, SLOT(resetZoom())); diff --git a/src/plugins/projectexplorer/abstractmakestep.cpp b/src/plugins/projectexplorer/abstractmakestep.cpp index 56e41862f7884232c05f1bc788cef1fe4ccff71b..6a3573ba83984ff8871a590f6cbae6d47fef863f 100644 --- a/src/plugins/projectexplorer/abstractmakestep.cpp +++ b/src/plugins/projectexplorer/abstractmakestep.cpp @@ -31,6 +31,7 @@ #include "projectexplorerconstants.h" #include "project.h" +#include "buildconfiguration.h" #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -46,8 +47,8 @@ namespace { bool debug = false; } -AbstractMakeStep::AbstractMakeStep(Project *project, BuildConfiguration *bc) - : AbstractProcessStep(project, bc), +AbstractMakeStep::AbstractMakeStep(BuildConfiguration *bc) + : AbstractProcessStep(bc), m_buildParser(0) { } @@ -144,7 +145,7 @@ void AbstractMakeStep::slotAddToTaskWindow(const TaskWindow::Task &task) if (debug) qDebug() << "No success. Trying all files in project ..."; QString fileName = QFileInfo(filePath).fileName(); - foreach (const QString &file, project()->files(ProjectExplorer::Project::AllFiles)) { + foreach (const QString &file, buildConfiguration()->project()->files(ProjectExplorer::Project::AllFiles)) { QFileInfo candidate(file); if (candidate.fileName() == fileName) { if (debug) diff --git a/src/plugins/projectexplorer/abstractmakestep.h b/src/plugins/projectexplorer/abstractmakestep.h index de15f380c25dbeb81e1d94d511acefd414251708..4d8f9268bfa192e9613f2eae586529b209514cb4 100644 --- a/src/plugins/projectexplorer/abstractmakestep.h +++ b/src/plugins/projectexplorer/abstractmakestep.h @@ -46,7 +46,7 @@ class PROJECTEXPLORER_EXPORT AbstractMakeStep : public ProjectExplorer::Abstract { Q_OBJECT public: - AbstractMakeStep(Project * project, BuildConfiguration *bc); + AbstractMakeStep(BuildConfiguration *bc); AbstractMakeStep(AbstractMakeStep *bs, BuildConfiguration *bc); ~AbstractMakeStep(); virtual bool init(); diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 399fd8ab4237922b377e3a6c124123abed33c968..af92a62ec676289eecef5198d771f3d36b7497b2 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -39,8 +39,8 @@ using namespace ProjectExplorer; -AbstractProcessStep::AbstractProcessStep(Project *pro, BuildConfiguration *bc) - : BuildStep(pro, bc), m_timer(0), m_futureInterface(0), m_process(0), m_eventLoop(0) +AbstractProcessStep::AbstractProcessStep(BuildConfiguration *bc) + : BuildStep(bc), m_timer(0), m_futureInterface(0), m_process(0), m_eventLoop(0) { } diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index b1d62a62c5d2557c0b38f027bcc44bf3c3d67c4b..2c725f0b01a30da16e019abed98e7d0fac87c25c 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -65,7 +65,7 @@ class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep { Q_OBJECT public: - AbstractProcessStep(Project *pro, BuildConfiguration *bc); + AbstractProcessStep(BuildConfiguration *bc); AbstractProcessStep(AbstractProcessStep *bs, BuildConfiguration *bc); /// reimplemented from BuildStep::init() /// You need to call this from YourBuildStep::init() diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index a9cbeda862e89db5c552fb10b48e3bacefaddf3a..c2b2cb7d94c9be42c03b33a128bd4ee857337189 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -44,14 +44,14 @@ IBuildStepFactory *findFactory(const QString &name) return 0; } -BuildConfiguration::BuildConfiguration(const QString &name) - : m_name(name) +BuildConfiguration::BuildConfiguration(Project *pro) + : m_project(pro) { - setDisplayName(name); + } -BuildConfiguration::BuildConfiguration(const QString &name, BuildConfiguration *source) - : m_values(source->m_values), m_name(name) +BuildConfiguration::BuildConfiguration(BuildConfiguration *source) + : m_values(source->m_values), m_project(source->m_project) { foreach(BuildStep *originalbs, source->buildSteps()) { IBuildStepFactory *factory = findFactory(originalbs->name()); @@ -71,16 +71,6 @@ BuildConfiguration::~BuildConfiguration() qDeleteAll(m_cleanSteps); } -void BuildConfiguration::setName(const QString &name) -{ - m_name = name; -} - -QString BuildConfiguration::name() const -{ - return m_name; -} - QString BuildConfiguration::displayName() const { QVariant v = value("ProjectExplorer.BuildConfiguration.DisplayName"); @@ -90,7 +80,10 @@ QString BuildConfiguration::displayName() const void BuildConfiguration::setDisplayName(const QString &name) { + if (value("ProjectExplorer.BuildConfiguration.DisplayName").toString() == name) + return; setValue("ProjectExplorer.BuildConfiguration.DisplayName", name); + emit displayNameChanged(); } QVariant BuildConfiguration::value(const QString & key) const @@ -172,6 +165,12 @@ void BuildConfiguration::moveCleanStepUp(int position) m_cleanSteps.swap(position - 1, position); } +Project *BuildConfiguration::project() const +{ + return m_project; +} + + /// // IBuildConfigurationFactory /// diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index 54ec4a690133b491fe63f565dea393fcf7ebe9cd..49a4215493ae2197e0521066aa6721ec18f43fc0 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -31,6 +31,7 @@ #define BUILDCONFIGURATION_H #include "projectexplorer_export.h" +#include "environment.h" #include <QtCore/QHash> #include <QtCore/QString> @@ -50,13 +51,13 @@ class PROJECTEXPLORER_EXPORT BuildConfiguration : public QObject Q_OBJECT public: - BuildConfiguration(const QString &name); - BuildConfiguration(const QString &name, BuildConfiguration *source); - ~BuildConfiguration(); - QString name() const; + // ctors are protected + virtual ~BuildConfiguration(); + QString displayName() const; void setDisplayName(const QString &name); + // TODO remove those QVariant value(const QString &key) const; void setValue(const QString &key, QVariant value); @@ -73,15 +74,26 @@ public: void removeCleanStep(int position); void moveCleanStepUp(int position); -private: - void setName(const QString &name); + Project *project() const; + + virtual Environment environment() const = 0; + virtual QString buildDirectory() const = 0; + +signals: + void environmentChanged(); + void buildDirectoryChanged(); + void displayNameChanged(); +protected: + BuildConfiguration(Project * project); + BuildConfiguration(BuildConfiguration *source); + +private: QList<BuildStep *> m_buildSteps; QList<BuildStep *> m_cleanSteps; QHash<QString, QVariant> m_values; - QString m_name; - friend class Project; // for setName + Project *m_project; }; class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : public QObject @@ -98,12 +110,15 @@ public: virtual QString displayNameForType(const QString &type) const = 0; // creates build configuration(s) for given type and adds them to project - // returns true if build configuration(s) actually have been added - virtual bool create(const QString &type) const = 0; + // if successfull returns the BuildConfiguration that should be shown in the + // project mode for editing + virtual BuildConfiguration *create(const QString &type) const = 0; -// to come: -// restore -// clone + // clones a given BuildConfiguration, should not add it to the project + virtual BuildConfiguration *clone(BuildConfiguration *source) const = 0; + + // restores a BuildConfiguration with the name and adds it to the project + virtual BuildConfiguration *restore() const = 0; signals: void availableCreationTypesChanged(); @@ -111,4 +126,6 @@ signals: } // namespace ProjectExplorer +Q_DECLARE_METATYPE(ProjectExplorer::BuildConfiguration *); + #endif // BUILDCONFIGURATION_H diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index 9b1fc2fe4362b9b7bd850c8ed06bbc419c62ff76..dde844b1fb32539f91f8fa4f50ec9c8281bcf5f5 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -136,7 +136,7 @@ void BuildManager::cancel() this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task))); disconnect(m_currentBuildStep, SIGNAL(addToOutputWindow(QString)), this, SLOT(addToOutputWindow(QString))); - decrementActiveBuildSteps(m_currentBuildStep->project()); + decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->project()); m_progressFutureInterface->setProgressValueAndText(m_progress*100, "Build canceled"); //TODO NBS fix in qtconcurrent clearBuildQueue(); @@ -169,7 +169,7 @@ void BuildManager::emitCancelMessage() void BuildManager::clearBuildQueue() { foreach (BuildStep * bs, m_buildQueue) - decrementActiveBuildSteps(bs->project()); + decrementActiveBuildSteps(bs->buildConfiguration()->project()); m_buildQueue.clear(); m_running = false; @@ -280,13 +280,14 @@ void BuildManager::nextBuildQueue() bool result = m_watcher.result(); if (!result) { // Build Failure - addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1</font>").arg(m_currentBuildStep->project()->name())); + const QString projectName = m_currentBuildStep->buildConfiguration()->project()->name(); + addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1</font>").arg(projectName)); addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName())); // NBS TODO fix in qtconcurrent - m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1").arg(m_currentBuildStep->project()->name())); + m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1").arg(projectName)); } - decrementActiveBuildSteps(m_currentBuildStep->project()); + decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->project()); if (result) nextStep(); else @@ -317,17 +318,18 @@ void BuildManager::nextStep() bool init = m_currentBuildStep->init(); if (!init) { - addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1</font>").arg(m_currentBuildStep->project()->name())); + const QString projectName = m_currentBuildStep->buildConfiguration()->project()->name(); + addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1</font>").arg(projectName)); addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName())); cancel(); return; } - if (m_currentBuildStep->project() != m_previousBuildStepProject) { - const QString projectName = m_currentBuildStep->project()->name(); + if (m_currentBuildStep->buildConfiguration()->project() != m_previousBuildStepProject) { + const QString projectName = m_currentBuildStep->buildConfiguration()->project()->name(); addToOutputWindow(tr("<b>Running build steps for project %2...</b>") .arg(projectName)); - m_previousBuildStepProject = m_currentBuildStep->project(); + m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->project(); } m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep)); } else { @@ -346,23 +348,15 @@ void BuildManager::buildQueueAppend(BuildStep * bs) { m_buildQueue.append(bs); ++m_maxProgress; - incrementActiveBuildSteps(bs->project()); + incrementActiveBuildSteps(bs->buildConfiguration()->project()); } -void BuildManager::buildProjects(const QList<Project *> &projects, const QList<QString> &configurations) +void BuildManager::buildProjects(const QList<BuildConfiguration *> &configurations) { - Q_ASSERT(projects.count() == configurations.count()); - QList<QString>::const_iterator cit = configurations.constBegin(); - QList<Project *>::const_iterator it, end; - end = projects.constEnd(); - - for (it = projects.constBegin(); it != end; ++it, ++cit) { - if (*cit != QString::null) { - BuildConfiguration *bc = (*it)->buildConfiguration(*cit); - QList<BuildStep *> buildSteps = bc->buildSteps(); - foreach (BuildStep *bs, buildSteps) { - buildQueueAppend(bs); - } + foreach(BuildConfiguration *bc, configurations) { + QList<BuildStep *> buildSteps = bc->buildSteps(); + foreach (BuildStep *bs, buildSteps) { + buildQueueAppend(bs); } } if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) @@ -370,20 +364,12 @@ void BuildManager::buildProjects(const QList<Project *> &projects, const QList<Q startBuildQueue(); } -void BuildManager::cleanProjects(const QList<Project *> &projects, const QList<QString> &configurations) +void BuildManager::cleanProjects(const QList<BuildConfiguration *> &configurations) { - Q_ASSERT(projects.count() == configurations.count()); - QList<QString>::const_iterator cit = configurations.constBegin(); - QList<Project *>::const_iterator it, end; - end = projects.constEnd(); - - for (it = projects.constBegin(); it != end; ++it, ++cit) { - if (*cit != QString::null) { - BuildConfiguration *bc = (*it)->buildConfiguration(*cit); - QList<BuildStep *> cleanSteps = bc->cleanSteps(); - foreach (BuildStep *bs, cleanSteps) { - buildQueueAppend(bs); - } + foreach(BuildConfiguration *bc, configurations) { + QList<BuildStep *> cleanSteps = bc->cleanSteps(); + foreach (BuildStep *bs, cleanSteps) { + buildQueueAppend(bs); } } if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) @@ -391,14 +377,14 @@ void BuildManager::cleanProjects(const QList<Project *> &projects, const QList<Q startBuildQueue(); } -void BuildManager::buildProject(Project *p, const QString &configuration) +void BuildManager::buildProject(BuildConfiguration *configuration) { - buildProjects(QList<Project *>() << p, QList<QString>() << configuration); + buildProjects(QList<BuildConfiguration *>() << configuration); } -void BuildManager::cleanProject(Project *p, const QString &configuration) +void BuildManager::cleanProject(BuildConfiguration *configuration) { - cleanProjects(QList<Project *>() << p, QList<QString>() << configuration); + cleanProjects(QList<BuildConfiguration *>() << configuration); } void BuildManager::appendStep(BuildStep *step) diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index 1d2da54b5ec86b3f36e6788e0aa24b22d3ff9d31..47e59ec42b3e1d1d7cf8bd3a37962565697376ae 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -49,6 +49,7 @@ namespace Internal { class BuildStep; class Project; class ProjectExplorerPlugin; +class BuildConfiguration; class PROJECTEXPLORER_EXPORT BuildManager : public QObject @@ -70,10 +71,10 @@ public: void gotoTaskWindow(); //TODO these should take buildconfiguration object - void buildProject(Project *p, const QString &configuration); - void buildProjects(const QList<Project *> &projects, const QList<QString> &configurations); - void cleanProject(Project *p, const QString &configuration); - void cleanProjects(const QList<Project *> &projects, const QList<QString> &configurations); + void buildProject(BuildConfiguration *bc); + void buildProjects(const QList<BuildConfiguration *> &configurations); + void cleanProject(BuildConfiguration *configuration); + void cleanProjects(const QList<BuildConfiguration *> &configurations); bool isBuilding(Project *p); // Append any build step to the list of build steps (currently only used to add the QMakeStep) diff --git a/src/plugins/projectexplorer/buildparserfactory.cpp b/src/plugins/projectexplorer/buildparserfactory.cpp index cb9326d68ba10d9765949269b548a7dc7e3ce2cd..e4b8895eaee2f35c25b5e12a763d199e291a530e 100644 --- a/src/plugins/projectexplorer/buildparserfactory.cpp +++ b/src/plugins/projectexplorer/buildparserfactory.cpp @@ -32,7 +32,6 @@ #include "projectexplorerconstants.h" #include "gccparser.h" #include "msvcparser.h" -#include "qmakeparser.h" using namespace ProjectExplorer::Internal; @@ -65,18 +64,3 @@ ProjectExplorer::IBuildParser * MsvcParserFactory::create(const QString & name) Q_UNUSED(name) return new MsvcParser(); } - -QMakeParserFactory::~QMakeParserFactory() -{ -} - -bool QMakeParserFactory::canCreate(const QString & name) const -{ - return (name == Constants::BUILD_PARSER_QMAKE); -} - -ProjectExplorer::IBuildParser * QMakeParserFactory::create(const QString & name) const -{ - Q_UNUSED(name) - return new QMakeParser(); -} diff --git a/src/plugins/projectexplorer/buildparserfactory.h b/src/plugins/projectexplorer/buildparserfactory.h index f953d63ebf6a2006d82629f3f42645bcf4b4d24c..e29570f2baf2e3d0f0e8f2c964b8ec1bded97a17 100644 --- a/src/plugins/projectexplorer/buildparserfactory.h +++ b/src/plugins/projectexplorer/buildparserfactory.h @@ -55,16 +55,6 @@ public: virtual ProjectExplorer::IBuildParser * create(const QString & name) const; }; -class QMakeParserFactory : public ProjectExplorer::IBuildParserFactory -{ - Q_OBJECT -public: - QMakeParserFactory() {} - virtual ~QMakeParserFactory(); - virtual bool canCreate(const QString & name) const; - virtual ProjectExplorer::IBuildParser * create(const QString & name) const; -}; - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index fac04077b61ddcce688139013e7fcc1d114740f8..e8cc4c355375044e8ec2bd311a0779113505ffa3 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -37,18 +37,21 @@ #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QtCore/QPair> +#include <QtCore/QMargins> +#include <QtCore/QTimer> #include <QtGui/QApplication> +#include <QtGui/QComboBox> #include <QtGui/QInputDialog> #include <QtGui/QLabel> -#include <QtGui/QVBoxLayout> #include <QtGui/QMenu> +#include <QtGui/QPushButton> +#include <QtGui/QVBoxLayout> using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; /// -/// BuildSettingsPanelFactory +// BuildSettingsPanelFactory /// bool BuildSettingsPanelFactory::supports(Project *project) @@ -62,7 +65,7 @@ IPropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project) } /// -/// BuildSettingsPanel +// BuildSettingsPanel /// BuildSettingsPanel::BuildSettingsPanel(Project *project) : @@ -92,74 +95,36 @@ QIcon BuildSettingsPanel::icon() const } /// -// BuildSettingsSubWidgets +// BuildSettingsWidget /// -BuildSettingsSubWidgets::~BuildSettingsSubWidgets() +BuildSettingsWidget::~BuildSettingsWidget() { clear(); } -void BuildSettingsSubWidgets::addWidget(const QString &name, QWidget *widget) -{ - QSpacerItem *item = new QSpacerItem(1, 10, QSizePolicy::Fixed, QSizePolicy::Fixed); - - QLabel *label = new QLabel(this); - label->setText(name); - QFont f = label->font(); - f.setBold(true); - f.setPointSizeF(f.pointSizeF() *1.2); - label->setFont(f); - - layout()->addItem(item); - layout()->addWidget(label); - layout()->addWidget(widget); - - m_spacerItems.append(item); - m_labels.append(label); - m_widgets.append(widget); -} - -void BuildSettingsSubWidgets::clear() -{ - foreach(QSpacerItem *item, m_spacerItems) - layout()->removeItem(item); - qDeleteAll(m_spacerItems); - qDeleteAll(m_widgets); - qDeleteAll(m_labels); - m_widgets.clear(); - m_labels.clear(); - m_spacerItems.clear(); -} - -QList<QWidget *> BuildSettingsSubWidgets::widgets() const +BuildSettingsWidget::BuildSettingsWidget(Project *project) : + m_project(project), + m_buildConfiguration(0), + m_leftMargin(0) { - return m_widgets; + // Provide some time for our contentsmargins to get updated: + QTimer::singleShot(0, this, SLOT(init())); } -BuildSettingsSubWidgets::BuildSettingsSubWidgets(QWidget *parent) - : QWidget(parent) -{ - new QVBoxLayout(this); - layout()->setMargin(0); -} - -/// -/// BuildSettingsWidget -/// - -BuildSettingsWidget::~BuildSettingsWidget() +void BuildSettingsWidget::init() { -} + QMargins margins(contentsMargins()); + m_leftMargin = margins.left(); + margins.setLeft(0); + setContentsMargins(margins); -BuildSettingsWidget::BuildSettingsWidget(Project *project) - : m_project(project) -{ QVBoxLayout *vbox = new QVBoxLayout(this); - vbox->setContentsMargins(0, -1, 0, -1); + vbox->setContentsMargins(0, 0, 0, 0); { // Edit Build Configuration row QHBoxLayout *hbox = new QHBoxLayout(); + hbox->setContentsMargins(m_leftMargin, 0, 0, 0); hbox->addWidget(new QLabel(tr("Edit Build Configuration:"), this)); m_buildConfigurationComboBox = new QComboBox(this); m_buildConfigurationComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); @@ -169,6 +134,8 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) m_addButton->setText(tr("Add")); m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); hbox->addWidget(m_addButton); + m_addButtonMenu = new QMenu(this); + m_addButton->setMenu(m_addButtonMenu); m_removeButton = new QPushButton(this); m_removeButton->setText(tr("Remove")); @@ -182,14 +149,7 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) m_makeActiveLabel->setVisible(false); vbox->addWidget(m_makeActiveLabel); - m_subWidgets = new BuildSettingsSubWidgets(this); - vbox->addWidget(m_subWidgets); - - m_addButtonMenu = new QMenu(this); - m_addButton->setMenu(m_addButtonMenu); - updateAddButtonMenu(); - - m_buildConfiguration = m_project->activeBuildConfiguration()->name(); + m_buildConfiguration = m_project->activeBuildConfiguration(); connect(m_makeActiveLabel, SIGNAL(linkActivated(QString)), this, SLOT(makeActive())); @@ -200,8 +160,9 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) connect(m_removeButton, SIGNAL(clicked()), this, SLOT(deleteConfiguration())); - connect(m_project, SIGNAL(buildConfigurationDisplayNameChanged(const QString &)), - this, SLOT(buildConfigurationDisplayNameChanged(const QString &))); + // TODO update on displayNameChange +// connect(m_project, SIGNAL(buildConfigurationDisplayNameChanged(const QString &)), +// this, SLOT(buildConfigurationDisplayNameChanged(const QString &))); connect(m_project, SIGNAL(activeBuildConfigurationChanged()), this, SLOT(checkMakeActiveLabel())); @@ -209,19 +170,54 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) if (m_project->buildConfigurationFactory()) connect(m_project->buildConfigurationFactory(), SIGNAL(availableCreationTypesChanged()), SLOT(updateAddButtonMenu())); + updateAddButtonMenu(); updateBuildSettings(); } +void BuildSettingsWidget::addSubWidget(const QString &name, QWidget *widget) +{ + widget->setContentsMargins(m_leftMargin, 10, 0, 0); + + QLabel *label = new QLabel(this); + label->setText(name); + QFont f = label->font(); + f.setBold(true); + f.setPointSizeF(f.pointSizeF() * 1.2); + label->setFont(f); + + label->setContentsMargins(m_leftMargin, 10, 0, 0); + + layout()->addWidget(label); + layout()->addWidget(widget); + + m_labels.append(label); + m_subWidgets.append(widget); +} + +void BuildSettingsWidget::clear() +{ + qDeleteAll(m_subWidgets); + m_subWidgets.clear(); + qDeleteAll(m_labels); + m_labels.clear(); + +} + +QList<QWidget *> BuildSettingsWidget::subWidgets() const +{ + return m_subWidgets; +} + void BuildSettingsWidget::makeActive() { - m_project->setActiveBuildConfiguration(m_project->buildConfiguration(m_buildConfiguration)); + m_project->setActiveBuildConfiguration(m_buildConfiguration); } void BuildSettingsWidget::updateAddButtonMenu() { m_addButtonMenu->clear(); m_addButtonMenu->addAction(tr("&Clone Selected"), - this, SLOT(cloneConfiguration())); + this, SLOT(cloneConfiguration())); IBuildConfigurationFactory *factory = m_project->buildConfigurationFactory(); if (factory) { foreach (const QString &type, factory->availableCreationTypes()) { @@ -231,17 +227,6 @@ void BuildSettingsWidget::updateAddButtonMenu() } } -void BuildSettingsWidget::buildConfigurationDisplayNameChanged(const QString &buildConfiguration) -{ - for (int i=0; i<m_buildConfigurationComboBox->count(); ++i) { - if (m_buildConfigurationComboBox->itemData(i).toString() == buildConfiguration) { - m_buildConfigurationComboBox->setItemText(i, m_project->buildConfiguration(buildConfiguration)->displayName()); - break; - } - } -} - - void BuildSettingsWidget::updateBuildSettings() { // TODO save position, entry from combbox @@ -249,26 +234,26 @@ void BuildSettingsWidget::updateBuildSettings() // Delete old tree items bool blocked = m_buildConfigurationComboBox->blockSignals(true); m_buildConfigurationComboBox->clear(); - m_subWidgets->clear(); + clear(); // update buttons m_removeButton->setEnabled(m_project->buildConfigurations().size() > 1); // Add pages BuildConfigWidget *generalConfigWidget = m_project->createConfigWidget(); - m_subWidgets->addWidget(generalConfigWidget->displayName(), generalConfigWidget); + addSubWidget(generalConfigWidget->displayName(), generalConfigWidget); - m_subWidgets->addWidget(tr("Build Steps"), new BuildStepsPage(m_project)); - m_subWidgets->addWidget(tr("Clean Steps"), new BuildStepsPage(m_project, true)); + addSubWidget(tr("Build Steps"), new BuildStepsPage(m_project, false)); + addSubWidget(tr("Clean Steps"), new BuildStepsPage(m_project, true)); QList<BuildConfigWidget *> subConfigWidgets = m_project->subConfigWidgets(); foreach (BuildConfigWidget *subConfigWidget, subConfigWidgets) - m_subWidgets->addWidget(subConfigWidget->displayName(), subConfigWidget); + addSubWidget(subConfigWidget->displayName(), subConfigWidget); // Add tree items - foreach (const BuildConfiguration *bc, m_project->buildConfigurations()) { - m_buildConfigurationComboBox->addItem(bc->displayName(), bc->name()); - if (bc->name() == m_buildConfiguration) + foreach (BuildConfiguration *bc, m_project->buildConfigurations()) { + m_buildConfigurationComboBox->addItem(bc->displayName(), QVariant::fromValue<BuildConfiguration *>(bc)); + if (bc == m_buildConfiguration) m_buildConfigurationComboBox->setCurrentIndex(m_buildConfigurationComboBox->count() - 1); } @@ -276,24 +261,25 @@ void BuildSettingsWidget::updateBuildSettings() // TODO Restore position, entry from combbox // TODO? select entry from combobox ? + activeBuildConfigurationChanged(); } void BuildSettingsWidget::currentIndexChanged(int index) { - m_buildConfiguration = m_buildConfigurationComboBox->itemData(index).toString(); + m_buildConfiguration = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>(); activeBuildConfigurationChanged(); } void BuildSettingsWidget::activeBuildConfigurationChanged() { for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) { - if (m_buildConfigurationComboBox->itemData(i).toString() == m_buildConfiguration) { + if (m_buildConfigurationComboBox->itemData(i).value<BuildConfiguration *>() == m_buildConfiguration) { m_buildConfigurationComboBox->setCurrentIndex(i); break; } } - foreach (QWidget *widget, m_subWidgets->widgets()) { + foreach (QWidget *widget, subWidgets()) { if (BuildConfigWidget *buildStepWidget = qobject_cast<BuildConfigWidget*>(widget)) { buildStepWidget->init(m_buildConfiguration); } @@ -304,10 +290,8 @@ void BuildSettingsWidget::activeBuildConfigurationChanged() void BuildSettingsWidget::checkMakeActiveLabel() { m_makeActiveLabel->setVisible(false); - if (!m_project->activeBuildConfiguration() || m_project->activeBuildConfiguration()->name() != m_buildConfiguration) { - BuildConfiguration *bc = m_project->buildConfiguration(m_buildConfiguration); - QTC_ASSERT(bc, return); - m_makeActiveLabel->setText(tr("<a href=\"#\">Make %1 active.</a>").arg(bc->displayName())); + if (!m_project->activeBuildConfiguration() || m_project->activeBuildConfiguration() != m_buildConfiguration) { + m_makeActiveLabel->setText(tr("<a href=\"#\">Make %1 active.</a>").arg(m_buildConfiguration->displayName())); m_makeActiveLabel->setVisible(true); } } @@ -316,61 +300,56 @@ void BuildSettingsWidget::createConfiguration() { QAction *action = qobject_cast<QAction *>(sender()); const QString &type = action->data().toString(); - if (m_project->buildConfigurationFactory()->create(type)) { - // TODO switching to last buildconfiguration in list might not be what we want - m_buildConfiguration = m_project->buildConfigurations().last()->name(); + BuildConfiguration *bc = m_project->buildConfigurationFactory()->create(type); + if (bc) { + m_buildConfiguration = bc; updateBuildSettings(); } } void BuildSettingsWidget::cloneConfiguration() { - const QString configuration = m_buildConfigurationComboBox->itemData(m_buildConfigurationComboBox->currentIndex()).toString(); - cloneConfiguration(configuration); + const int index = m_buildConfigurationComboBox->currentIndex(); + BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>(); + cloneConfiguration(bc); } void BuildSettingsWidget::deleteConfiguration() { - const QString configuration = m_buildConfigurationComboBox->itemData(m_buildConfigurationComboBox->currentIndex()).toString(); - deleteConfiguration(configuration); + const int index = m_buildConfigurationComboBox->currentIndex(); + BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>(); + deleteConfiguration(bc); } -void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration) +void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfiguration) { - if (sourceConfiguration.isEmpty()) + if (!sourceConfiguration) return; - QString newBuildConfiguration = QInputDialog::getText(this, tr("Clone configuration"), tr("New Configuration Name:")); - if (newBuildConfiguration.isEmpty()) + QString newDisplayName(QInputDialog::getText(this, tr("Clone configuration"), tr("New Configuration Name:"))); + if (newDisplayName.isEmpty()) return; - QString newDisplayName = newBuildConfiguration; QStringList buildConfigurationDisplayNames; foreach(BuildConfiguration *bc, m_project->buildConfigurations()) buildConfigurationDisplayNames << bc->displayName(); newDisplayName = Project::makeUnique(newDisplayName, buildConfigurationDisplayNames); - QStringList buildConfigurationNames; - foreach(BuildConfiguration *bc, m_project->buildConfigurations()) - buildConfigurationNames << bc->name(); - - newBuildConfiguration = Project::makeUnique(newBuildConfiguration, buildConfigurationNames); + m_buildConfiguration = m_project->buildConfigurationFactory()->clone(sourceConfiguration); + m_buildConfiguration->setDisplayName(newDisplayName); + m_project->addBuildConfiguration(m_buildConfiguration); - m_project->copyBuildConfiguration(sourceConfiguration, newBuildConfiguration); - m_project->setDisplayNameFor(m_project->buildConfiguration(newBuildConfiguration), newDisplayName); - - m_buildConfiguration = newBuildConfiguration; updateBuildSettings(); } -void BuildSettingsWidget::deleteConfiguration(const QString &deleteConfiguration) +void BuildSettingsWidget::deleteConfiguration(BuildConfiguration *deleteConfiguration) { - if (deleteConfiguration.isEmpty() || m_project->buildConfigurations().size() <= 1) + if (!deleteConfiguration || m_project->buildConfigurations().size() <= 1) return; - if (m_project->activeBuildConfiguration()->name() == deleteConfiguration) { + if (m_project->activeBuildConfiguration() == deleteConfiguration) { foreach (BuildConfiguration *bc, m_project->buildConfigurations()) { - if (bc->name() != deleteConfiguration) { + if (bc != deleteConfiguration) { m_project->setActiveBuildConfiguration(bc); break; } @@ -378,15 +357,15 @@ void BuildSettingsWidget::deleteConfiguration(const QString &deleteConfiguration } if (m_buildConfiguration == deleteConfiguration) { - foreach (const BuildConfiguration *bc, m_project->buildConfigurations()) { - if (bc->name() != deleteConfiguration) { - m_buildConfiguration = bc->name(); + foreach (BuildConfiguration *bc, m_project->buildConfigurations()) { + if (bc != deleteConfiguration) { + m_buildConfiguration = bc; break; } } } - m_project->removeBuildConfiguration(m_project->buildConfiguration(deleteConfiguration)); + m_project->removeBuildConfiguration(deleteConfiguration); updateBuildSettings(); } diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.h b/src/plugins/projectexplorer/buildsettingspropertiespage.h index 169feeedf7e01145868e4402675acdd0fc1e4dd8..d71b4d2bc373b3572cc63b3f77ef7edcfa54f16e 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.h +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.h @@ -32,34 +32,22 @@ #include "iprojectproperties.h" -#include <QtCore/QHash> -#include <QtGui/QComboBox> -#include <QtGui/QPushButton> -#include <QtGui/QLabel> -#include <QtGui/QGroupBox> -#include <QtGui/QSpacerItem> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE +class QComboBox; +class QLabel; +class QMenu; +class QPushButton; +QT_END_NAMESPACE namespace ProjectExplorer { +class BuildConfiguration; class IBuildStepFactory; namespace Internal { -class BuildSettingsSubWidgets : public QWidget -{ - Q_OBJECT -public: - BuildSettingsSubWidgets(QWidget *parent); - ~BuildSettingsSubWidgets(); - void clear(); - void addWidget(const QString &name, QWidget *widget); - QList<QWidget *> widgets() const; -private: - QList<QWidget *> m_widgets; - QList<QLabel *> m_labels; - QList<QSpacerItem *> m_spacerItems; -}; - class BuildSettingsPanelFactory : public IPanelFactory { public: @@ -92,8 +80,11 @@ public: BuildSettingsWidget(Project *project); ~BuildSettingsWidget(); + void clear(); + void addSubWidget(const QString &name, QWidget *widget); + QList<QWidget *> subWidgets() const; + private slots: - void buildConfigurationDisplayNameChanged(const QString &buildConfiguration); void updateBuildSettings(); void currentIndexChanged(int index); void activeBuildConfigurationChanged(); @@ -105,18 +96,25 @@ private slots: void checkMakeActiveLabel(); void makeActive(); + void init(); + private: - void cloneConfiguration(const QString &toClone); - void deleteConfiguration(const QString &toDelete); + void cloneConfiguration(BuildConfiguration *toClone); + void deleteConfiguration(BuildConfiguration *toDelete); Project *m_project; + BuildConfiguration *m_buildConfiguration; + QPushButton *m_addButton; QPushButton *m_removeButton; QComboBox *m_buildConfigurationComboBox; - BuildSettingsSubWidgets *m_subWidgets; - QString m_buildConfiguration; QMenu *m_addButtonMenu; QLabel *m_makeActiveLabel; + + QList<QWidget *> m_subWidgets; + QList<QLabel *> m_labels; + + int m_leftMargin; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index ef0b07c9ffc6bd103b7064780d66f22df685ec09..9fd6925b5164aec3740485f4dec2c5de130c9949 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -36,15 +36,15 @@ using namespace ProjectExplorer; -BuildStep::BuildStep(Project * pro, BuildConfiguration *bc) - : m_project(pro), m_buildConfiguration(bc) +BuildStep::BuildStep(BuildConfiguration *bc) + : m_buildConfiguration(bc) { } BuildStep::BuildStep(BuildStep *bs, BuildConfiguration *bc) - : m_project(bs->m_project), m_buildConfiguration(bc) + : m_buildConfiguration(bc) { - + Q_UNUSED(bs); } BuildStep::~BuildStep() @@ -68,11 +68,6 @@ void BuildStep::storeIntoLocalMap(QMap<QString, QVariant> &map) Q_UNUSED(map) } -Project *BuildStep::project() const -{ - return m_project; -} - BuildConfiguration *BuildStep::buildConfiguration() const { return m_buildConfiguration; diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index aafb119d24fce92b5fb043464a03b96a662d5768..09fcbf55441b7433fdbb74fc14c55148aa88110c 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -37,8 +37,6 @@ #include <QtCore/QFutureInterface> namespace ProjectExplorer { - -class Project; class BuildConfiguration; /* @@ -71,9 +69,8 @@ class BuildStepConfigWidget; class PROJECTEXPLORER_EXPORT BuildStep : public QObject { Q_OBJECT - friend class Project; //for managing BuildConfigurations protected: - BuildStep(Project *p, BuildConfiguration *bc); + BuildStep(BuildConfiguration *bc); BuildStep(BuildStep *bs, BuildConfiguration *bc); public: @@ -110,7 +107,6 @@ public: virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map); virtual void storeIntoLocalMap(QMap<QString, QVariant> &map); - Project *project() const; BuildConfiguration *buildConfiguration() const; Q_SIGNALS: @@ -120,7 +116,6 @@ Q_SIGNALS: void addToOutputWindow(const QString &string); private: - Project *m_project; BuildConfiguration *m_buildConfiguration; }; @@ -135,10 +130,10 @@ public: /// Called to check wheter this factory can restore the named BuildStep virtual bool canCreate(const QString &name) const = 0; /// Called to restore a buildstep - virtual BuildStep *create(Project *pro, BuildConfiguration *bc, const QString &name) const = 0; + virtual BuildStep *create(BuildConfiguration *bc, const QString &name) const = 0; /// Called by the add BuildStep action to check which BuildSteps could be added /// to the project by this factory, should return a list of names - virtual QStringList canCreateForProject(Project *pro) const = 0; + virtual QStringList canCreateForBuildConfiguration(BuildConfiguration *bc) const = 0; /// Called to convert an internal name to a displayName /// Called to clone a BuildStep @@ -158,7 +153,7 @@ public: virtual QString displayName() const = 0; // This is called to set up the config widget before showing it - virtual void init(const QString &buildConfiguration) = 0; + virtual void init(BuildConfiguration *bc) = 0; }; class PROJECTEXPLORER_EXPORT BuildStepConfigWidget diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index 6c2a3c0f011b5900e9b3b77e7e51dc0b337b51f9..5e7a0e99baf83cba67de7bfe259f404d28881098 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -28,13 +28,14 @@ **************************************************************************/ #include "buildstepspage.h" -#include "project.h" #include "buildconfiguration.h" #include <coreplugin/coreconstants.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> +#include <QtCore/QSignalMapper> + #include <QtGui/QLabel> #include <QtGui/QPushButton> #include <QtGui/QMenu> @@ -47,40 +48,11 @@ using namespace ProjectExplorer::Internal; BuildStepsPage::BuildStepsPage(Project *project, bool clean) : BuildConfigWidget(), - m_pro(project), - m_clean(clean) + m_clean(clean), + m_addButton(0), + m_leftMargin(-1) { - m_vbox = new QVBoxLayout(this); - m_vbox->setContentsMargins(0, 0, 0, 0); - m_vbox->setSpacing(0); - - m_noStepsLabel = new QLabel(tr("No Build Steps"), this); - m_vbox->addWidget(m_noStepsLabel); - - QHBoxLayout *hboxLayout = new QHBoxLayout(); - m_addButton = new QPushButton(this); - m_addButton->setText(clean ? tr("Add clean step") : tr("Add build step")); - m_addButton->setMenu(new QMenu(this)); - hboxLayout->addWidget(m_addButton); - - m_removeButton = new QPushButton(this); - m_removeButton->setText(clean ? tr("Remove clean step") : tr("Remove build step")); - m_removeButton->setMenu(new QMenu(this)); - hboxLayout->addWidget(m_removeButton); - hboxLayout->addStretch(10); - -#ifdef Q_OS_MAC - m_addButton->setAttribute(Qt::WA_MacSmallSize); - m_removeButton->setAttribute(Qt::WA_MacSmallSize); -#endif - - m_vbox->addLayout(hboxLayout); - - connect(m_addButton->menu(), SIGNAL(aboutToShow()), - this, SLOT(updateAddBuildStepMenu())); - - connect(m_removeButton->menu(), SIGNAL(aboutToShow()), - this, SLOT(updateRemoveBuildStepMenu())); + Q_UNUSED(project); } BuildStepsPage::~BuildStepsPage() @@ -110,18 +82,21 @@ QString BuildStepsPage::displayName() const return m_clean ? tr("Clean Steps") : tr("Build Steps"); } -void BuildStepsPage::init(const QString &buildConfiguration) +void BuildStepsPage::init(BuildConfiguration *bc) { + QTC_ASSERT(bc, return); + + setupUi(); + foreach(BuildStepsWidgetStruct s, m_buildSteps) { delete s.widget; delete s.detailsWidget; } m_buildSteps.clear(); - m_configuration = buildConfiguration; - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); + m_configuration = bc; - const QList<BuildStep *> &steps = m_clean ? bc->cleanSteps() : bc->buildSteps(); + const QList<BuildStep *> &steps = m_clean ? m_configuration->cleanSteps() : m_configuration->buildSteps(); int i = 0; foreach (BuildStep *bs, steps) { addBuildStepWidget(i, bs); @@ -143,8 +118,8 @@ void BuildStepsPage::updateAddBuildStepMenu() QMap<QString, QPair<QString, IBuildStepFactory *> > map; //Build up a list of possible steps and save map the display names to the (internal) name and factories. QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); - foreach (IBuildStepFactory * factory, factories) { - QStringList names = factory->canCreateForProject(m_pro); + foreach (IBuildStepFactory *factory, factories) { + QStringList names = factory->canCreateForBuildConfiguration(m_configuration); foreach (const QString &name, names) { map.insert(factory->displayNameForName(name), QPair<QString, IBuildStepFactory *>(name, factory)); } @@ -188,138 +163,144 @@ void BuildStepsPage::addBuildStepWidget(int pos, BuildStep *step) s.upButton->setIconSize(QSize(10, 10)); s.downButton->setIconSize(QSize(10, 10)); #endif + s.removeButton = new QPushButton(this); + s.removeButton->setText(QChar('X')); + s.removeButton->setMaximumHeight(22); + s.removeButton->setMaximumWidth(22); + // layout QWidget *toolWidget = new QWidget(s.detailsWidget); toolWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - s.hbox = new QHBoxLayout(toolWidget); - s.hbox->setMargin(0); - s.hbox->setSpacing(0); - s.hbox->addWidget(s.upButton); - s.hbox->addWidget(s.downButton); + QHBoxLayout *hbox = new QHBoxLayout(); + toolWidget->setLayout(hbox); + hbox->setMargin(0); + hbox->setSpacing(0); + hbox->addWidget(s.upButton); + hbox->addWidget(s.downButton); + hbox->addWidget(s.removeButton); + s.detailsWidget->setToolWidget(toolWidget); + const int leftMargin(qMax(m_leftMargin - toolWidget->width(), 0)); + s.detailsWidget->setContentsMargins(leftMargin, 0, 0, 1); + m_buildSteps.insert(pos, s); + m_vbox->insertWidget(pos, s.detailsWidget); connect(s.widget, SIGNAL(updateSummary()), this, SLOT(updateSummary())); connect(s.upButton, SIGNAL(clicked()), - this, SLOT(upBuildStep())); + m_upMapper, SLOT(map())); connect(s.downButton, SIGNAL(clicked()), - this, SLOT(downBuildStep())); + m_downMapper, SLOT(map())); + connect(s.removeButton, SIGNAL(clicked()), + m_removeMapper, SLOT(map())); } void BuildStepsPage::addBuildStep() { if (QAction *action = qobject_cast<QAction *>(sender())) { - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); QPair<QString, IBuildStepFactory *> pair = m_addBuildStepHash.value(action); - BuildStep *newStep = pair.second->create(m_pro, bc, pair.first); - int pos = m_clean ? bc->cleanSteps().count() : bc->buildSteps().count(); - m_clean ? bc->insertCleanStep(pos, newStep) : bc->insertBuildStep(pos, newStep); + BuildStep *newStep = pair.second->create(m_configuration, pair.first); + int pos = m_clean ? m_configuration->cleanSteps().count() : m_configuration->buildSteps().count(); + m_clean ? m_configuration->insertCleanStep(pos, newStep) : m_configuration->insertBuildStep(pos, newStep); addBuildStepWidget(pos, newStep); const BuildStepsWidgetStruct s = m_buildSteps.at(pos); s.widget->init(); s.detailsWidget->setSummaryText(s.widget->summaryText()); + s.detailsWidget->setExpanded(true); } + updateBuildStepButtonsState(); } -void BuildStepsPage::updateRemoveBuildStepMenu() +void BuildStepsPage::stepMoveUp(int pos) { - QMenu *menu = m_removeButton->menu(); - menu->clear(); - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); - const QList<BuildStep *> &steps = m_clean ? bc->cleanSteps() : bc->buildSteps(); - foreach(BuildStep *step, steps) { - QAction *action = menu->addAction(step->displayName()); - if (step->immutable()) - action->setEnabled(false); - connect(action, SIGNAL(triggered()), - this, SLOT(removeBuildStep())); - } -} + m_clean ? m_configuration->moveCleanStepUp(pos) : m_configuration->moveBuildStepUp(pos); + + m_vbox->insertWidget(pos - 1, m_buildSteps.at(pos).detailsWidget); + + m_buildSteps.swap(pos - 1, pos); -void BuildStepsPage::removeBuildStep() -{ - QAction *action = qobject_cast<QAction *>(sender()); - if (action) { - int pos = m_removeButton->menu()->actions().indexOf(action); - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); - const QList<BuildStep *> &steps = m_clean ? bc->cleanSteps() : bc->buildSteps(); - if (steps.at(pos)->immutable()) - return; - - BuildStepsWidgetStruct s = m_buildSteps.at(pos); - delete s.widget; - delete s.detailsWidget; - m_buildSteps.removeAt(pos); - m_clean ? bc->removeCleanStep(pos) : bc->removeBuildStep(pos); - } updateBuildStepButtonsState(); } -void BuildStepsPage::upBuildStep() +void BuildStepsPage::stepMoveDown(int pos) { - int pos = -1; - QToolButton *tb = qobject_cast<QToolButton *>(sender()); - if (!tb) - return; + stepMoveUp(pos + 1); +} - for (int i=0; i<m_buildSteps.count(); ++i) { - if (m_buildSteps.at(i).upButton == tb) { - pos = i; - break; - } - } - if (pos == -1) - return; +void BuildStepsPage::stepRemove(int pos) +{ + BuildStepsWidgetStruct s = m_buildSteps.at(pos); + delete s.widget; + delete s.detailsWidget; + m_buildSteps.removeAt(pos); + m_clean ? m_configuration->removeCleanStep(pos) : m_configuration->removeBuildStep(pos); - stepMoveUp(pos); updateBuildStepButtonsState(); } -void BuildStepsPage::downBuildStep() +void BuildStepsPage::setupUi() { - int pos = -1; - QToolButton *tb = qobject_cast<QToolButton *>(sender()); - if (!tb) + if (0 != m_addButton) return; - for (int i=0; i<m_buildSteps.count(); ++i) { - if (m_buildSteps.at(i).downButton == tb) { - pos = i; - break; - } - } - if (pos == -1) - return; + QMargins margins(contentsMargins()); + m_leftMargin = margins.left(); + margins.setLeft(0); + setContentsMargins(margins); + + m_upMapper = new QSignalMapper(this); + connect(m_upMapper, SIGNAL(mapped(int)), + this, SLOT(stepMoveUp(int))); + m_downMapper = new QSignalMapper(this); + connect(m_downMapper, SIGNAL(mapped(int)), + this, SLOT(stepMoveDown(int))); + m_removeMapper = new QSignalMapper(this); + connect(m_removeMapper, SIGNAL(mapped(int)), + this, SLOT(stepRemove(int))); - stepMoveUp(pos + 1); - updateBuildStepButtonsState(); -} + m_vbox = new QVBoxLayout(this); + m_vbox->setContentsMargins(0, 0, 0, 0); + m_vbox->setSpacing(0); -void BuildStepsPage::stepMoveUp(int pos) -{ - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); - m_clean ? bc->moveCleanStepUp(pos) : bc->moveBuildStepUp(pos); + m_noStepsLabel = new QLabel(tr("No Build Steps"), this); + m_noStepsLabel->setContentsMargins(m_leftMargin, 0, 0, 0); + m_vbox->addWidget(m_noStepsLabel); - m_vbox->insertWidget(pos - 1, m_buildSteps.at(pos).detailsWidget); + QHBoxLayout *hboxLayout = new QHBoxLayout(); + hboxLayout->setContentsMargins(m_leftMargin, 4, 0, 0); + m_addButton = new QPushButton(this); + m_addButton->setText(m_clean ? tr("Add clean step") : tr("Add build step")); + m_addButton->setMenu(new QMenu(this)); + hboxLayout->addWidget(m_addButton); - BuildStepsWidgetStruct tmp = m_buildSteps.at(pos -1); - m_buildSteps[pos -1] = m_buildSteps.at(pos); - m_buildSteps[pos] = tmp; + hboxLayout->addStretch(10); + +#ifdef Q_OS_MAC + m_addButton->setAttribute(Qt::WA_MacSmallSize); +#endif + + m_vbox->addLayout(hboxLayout); + + connect(m_addButton->menu(), SIGNAL(aboutToShow()), + this, SLOT(updateAddBuildStepMenu())); } void BuildStepsPage::updateBuildStepButtonsState() { - BuildConfiguration *bc = m_pro->buildConfiguration(m_configuration); - const QList<BuildStep *> &steps = m_clean ? bc->cleanSteps() : bc->buildSteps(); - for(int i=0; i<m_buildSteps.count(); ++i) { + const QList<BuildStep *> &steps = m_clean ? m_configuration->cleanSteps() : m_configuration->buildSteps(); + for(int i = 0; i < m_buildSteps.count(); ++i) { BuildStepsWidgetStruct s = m_buildSteps.at(i); - s.upButton->setEnabled((i>0) && !(steps.at(i)->immutable() && steps.at(i - 1))); - s.downButton->setEnabled((i + 1< steps.count()) && !(steps.at(i)->immutable() && steps.at(i + 1)->immutable())); + s.removeButton->setEnabled(!steps.at(i)->immutable()); + m_removeMapper->setMapping(s.removeButton, i); + s.upButton->setEnabled((i > 0) && !(steps.at(i)->immutable() && steps.at(i - 1))); + m_upMapper->setMapping(s.upButton, i); + s.downButton->setEnabled((i + 1 < steps.count()) && !(steps.at(i)->immutable() && steps.at(i + 1)->immutable())); + m_downMapper->setMapping(s.downButton, i); } } diff --git a/src/plugins/projectexplorer/buildstepspage.h b/src/plugins/projectexplorer/buildstepspage.h index b6c7e0ac099aa53cc35d2d610e1629eeadd97b6b..09cf70a0772659f0b5a8f6082e08254bdf93c87b 100644 --- a/src/plugins/projectexplorer/buildstepspage.h +++ b/src/plugins/projectexplorer/buildstepspage.h @@ -34,18 +34,17 @@ #include <utils/detailswidget.h> QT_BEGIN_NAMESPACE -class QTreeWidgetItem; -class QHBoxLayout; class QPushButton; -class QAbstractButton; class QToolButton; class QLabel; class QVBoxLayout; +class QSignalMapper; QT_END_NAMESPACE namespace ProjectExplorer { class Project; +class BuildConfiguration; namespace Internal { @@ -59,7 +58,7 @@ struct BuildStepsWidgetStruct Utils::DetailsWidget *detailsWidget; QToolButton *upButton; QToolButton *downButton; - QHBoxLayout *hbox; + QPushButton *removeButton; }; class BuildStepsPage : public BuildConfigWidget @@ -71,35 +70,37 @@ public: virtual ~BuildStepsPage(); QString displayName() const; - void init(const QString &buildConfiguration); + void init(BuildConfiguration *bc); private slots: void updateAddBuildStepMenu(); void addBuildStep(); - void updateRemoveBuildStepMenu(); - void removeBuildStep(); - void upBuildStep(); - void downBuildStep(); void updateSummary(); + void stepMoveUp(int pos); + void stepMoveDown(int pos); + void stepRemove(int pos); private: - void stepMoveUp(int pos); + void setupUi(); void updateBuildStepButtonsState(); void addBuildStepWidget(int pos, BuildStep *step); - Project *m_pro; - QString m_configuration; + BuildConfiguration * m_configuration; QHash<QAction *, QPair<QString, ProjectExplorer::IBuildStepFactory *> > m_addBuildStepHash; bool m_clean; - QList<QHBoxLayout *> m_titleLayouts; QList<BuildStepsWidgetStruct> m_buildSteps; QVBoxLayout *m_vbox; QLabel *m_noStepsLabel; QPushButton *m_addButton; - QPushButton *m_removeButton; + + QSignalMapper *m_upMapper; + QSignalMapper *m_downMapper; + QSignalMapper *m_removeMapper; + + int m_leftMargin; }; } // Internal diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 8d6852d90b8a7d31bebd2fecc4c885bd9c875bf4..d48750f6e6e1def9846dc3cb910af3c23407ec36 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -35,6 +35,7 @@ #include <coreplugin/icore.h> #include <projectexplorer/debugginghelper.h> +#include <projectexplorer/buildconfiguration.h> #include <utils/detailswidget.h> #include <utils/pathchooser.h> @@ -251,8 +252,9 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro) connect(pro, SIGNAL(activeBuildConfigurationChanged()), this, SIGNAL(baseEnvironmentChanged())); - connect(pro, SIGNAL(environmentChanged(QString)), - this, SIGNAL(baseEnvironmentChanged())); +// TODO +// connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)), +// this, SIGNAL(baseEnvironmentChanged())); } @@ -279,7 +281,7 @@ QString CustomExecutableRunConfiguration::executable() const { QString exec; if (QDir::isRelativePath(m_executable)) { - Environment env = project()->environment(project()->activeBuildConfiguration()); + Environment env = project()->activeBuildConfiguration()->environment(); exec = env.searchInPath(m_executable); } else { exec = m_executable; @@ -328,7 +330,7 @@ QString CustomExecutableRunConfiguration::baseWorkingDirectory() const QString CustomExecutableRunConfiguration::workingDirectory() const { QString wd = m_workingDirectory; - QString bd = project()->buildDirectory(project()->activeBuildConfiguration()); + QString bd = project()->activeBuildConfiguration()->buildDirectory(); return wd.replace("$BUILDDIR", QDir::cleanPath(bd)); } @@ -345,7 +347,7 @@ ProjectExplorer::Environment CustomExecutableRunConfiguration::baseEnvironment() } else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::SystemEnvironmentBase) { env = ProjectExplorer::Environment::systemEnvironment(); } else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::BuildEnvironmentBase) { - env = project()->environment(project()->activeBuildConfiguration()); + env = project()->activeBuildConfiguration()->environment(); } return env; } diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index eab3735146c5f0e5edba26d3d91c24f858bc8be3..d579ebe9511022a9dea0fc5f36064172d5f4c512 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -30,6 +30,7 @@ #include "processstep.h" #include "buildstep.h" #include "project.h" +#include "buildconfiguration.h" #include <coreplugin/ifile.h> #include <utils/qtcassert.h> @@ -45,8 +46,8 @@ static const char * const PROCESS_WORKINGDIRECTORY = "abstractProcess.workingDir static const char * const PROCESS_ARGUMENTS = "abstractProcess.arguments"; static const char * const PROCESS_ENABLED = "abstractProcess.enabled"; -ProcessStep::ProcessStep(Project *pro, BuildConfiguration *bc) - : AbstractProcessStep(pro, bc) +ProcessStep::ProcessStep(BuildConfiguration *bc) + : AbstractProcessStep(bc) { } @@ -64,12 +65,12 @@ ProcessStep::ProcessStep(ProcessStep *bs, BuildConfiguration *bc) bool ProcessStep::init() { - setEnvironment(project()->environment(buildConfiguration())); + setEnvironment(buildConfiguration()->environment()); QString wd = workingDirectory(); if (wd.isEmpty()) wd = "$BUILDDIR"; - AbstractProcessStep::setWorkingDirectory(wd.replace("$BUILDDIR", project()->buildDirectory(buildConfiguration()))); + AbstractProcessStep::setWorkingDirectory(wd.replace("$BUILDDIR", buildConfiguration()->buildDirectory())); AbstractProcessStep::setCommand(m_command); AbstractProcessStep::setEnabled(m_enabled); AbstractProcessStep::setArguments(m_arguments); @@ -200,10 +201,10 @@ bool ProcessStepFactory::canCreate(const QString &name) const return name == "projectexplorer.processstep"; } -BuildStep *ProcessStepFactory::create(Project *pro, BuildConfiguration *bc, const QString &name) const +BuildStep *ProcessStepFactory::create(BuildConfiguration *bc, const QString &name) const { Q_UNUSED(name) - return new ProcessStep(pro, bc); + return new ProcessStep(bc); } BuildStep *ProcessStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) const @@ -211,9 +212,9 @@ BuildStep *ProcessStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) cons return new ProcessStep(static_cast<ProcessStep *>(bs), bc); } -QStringList ProcessStepFactory::canCreateForProject(Project *pro) const +QStringList ProcessStepFactory::canCreateForBuildConfiguration(BuildConfiguration *bc) const { - Q_UNUSED(pro) + Q_UNUSED(bc) return QStringList()<<"projectexplorer.processstep"; } QString ProcessStepFactory::displayNameForName(const QString &name) const diff --git a/src/plugins/projectexplorer/processstep.h b/src/plugins/projectexplorer/processstep.h index 7b64a07af0baccd0ae76b4950890752c8238887d..801ba25894576cfd5fca296cdb358386f96b5ac6 100644 --- a/src/plugins/projectexplorer/processstep.h +++ b/src/plugins/projectexplorer/processstep.h @@ -45,9 +45,9 @@ class ProcessStepFactory : public IBuildStepFactory public: ProcessStepFactory(); virtual bool canCreate(const QString &name) const; - virtual BuildStep *create(Project *pro, BuildConfiguration *bc, const QString &name) const; + virtual BuildStep *create(BuildConfiguration *bc, const QString &name) const; virtual BuildStep *clone(BuildStep *bs, BuildConfiguration *bc) const; - virtual QStringList canCreateForProject(Project *pro) const; + virtual QStringList canCreateForBuildConfiguration(BuildConfiguration *pro) const; virtual QString displayNameForName(const QString &name) const; }; @@ -55,7 +55,7 @@ class ProcessStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT public: - ProcessStep(Project *pro, BuildConfiguration *bc); + ProcessStep(BuildConfiguration *bc); ProcessStep(ProcessStep *bs, BuildConfiguration *bc); virtual bool init(); virtual void run(QFutureInterface<bool> &); diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index e8c0b31c8443c6de3057cb51731d72d2fe216213..941cd1806fa70a542db28041379920a632192eb8 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -74,15 +74,6 @@ QString Project::makeUnique(const QString &preferedName, const QStringList &used void Project::addBuildConfiguration(BuildConfiguration *configuration) { - QStringList buildConfigurationNames; - foreach (const BuildConfiguration *bc, buildConfigurations()) - buildConfigurationNames << bc->name(); - - // Check that the internal name is not taken and use a different one otherwise - QString configurationName = configuration->name(); - configurationName = makeUnique(configurationName, buildConfigurationNames); - configuration->setName(configurationName); - // Check that we don't have a configuration with the same displayName QString configurationDisplayName = configuration->displayName(); QStringList displayNames; @@ -94,7 +85,7 @@ void Project::addBuildConfiguration(BuildConfiguration *configuration) // add it m_buildConfigurationValues.push_back(configuration); - emit addedBuildConfiguration(this, configuration->name()); + emit addedBuildConfiguration(this, configuration); } void Project::removeBuildConfiguration(BuildConfiguration *configuration) @@ -105,21 +96,10 @@ void Project::removeBuildConfiguration(BuildConfiguration *configuration) m_buildConfigurationValues.removeOne(configuration); - emit removedBuildConfiguration(this, configuration->name()); + emit removedBuildConfiguration(this, configuration); delete configuration; } -void Project::copyBuildConfiguration(const QString &source, const QString &dest) -{ - BuildConfiguration *sourceConfiguration = buildConfiguration(source); - if (!sourceConfiguration) - return; - - m_buildConfigurationValues.push_back(new BuildConfiguration(dest, sourceConfiguration)); - - emit addedBuildConfiguration(this, dest); -} - QList<BuildConfiguration *> Project::buildConfigurations() const { return m_buildConfigurationValues; @@ -144,7 +124,7 @@ bool Project::restoreSettings() if (!restoreSettingsImpl(reader)) return false; - if (m_activeBuildConfiguration.isEmpty() && !m_buildConfigurationValues.isEmpty()) + if (m_activeBuildConfiguration && !m_buildConfigurationValues.isEmpty()) setActiveBuildConfiguration(m_buildConfigurationValues.at(0)); if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty()) @@ -159,47 +139,48 @@ QList<BuildConfigWidget*> Project::subConfigWidgets() void Project::saveSettingsImpl(PersistentSettingsWriter &writer) { - writer.saveValue("activebuildconfiguration", m_activeBuildConfiguration); - //save m_values - writer.saveValue("project", m_values); + const QList<BuildConfiguration *> bcs = buildConfigurations(); + + // For compability with older versions the "name" is saved as a string instead of a number + writer.saveValue("activebuildconfiguration", QString::number(bcs.indexOf(m_activeBuildConfiguration))); //save buildsettings QStringList buildConfigurationNames; - foreach (const BuildConfiguration *bc, buildConfigurations()) { - QMap<QString, QVariant> temp = bc->toMap(); - writer.saveValue("buildConfiguration-" + bc->name(), temp); - buildConfigurationNames << bc->name(); + for(int i=0; i < bcs.size(); ++i) { + QMap<QString, QVariant> temp = bcs.at(i)->toMap(); + writer.saveValue("buildConfiguration-" + QString::number(i), temp); + buildConfigurationNames << QString::number(i); } writer.saveValue("buildconfigurations", buildConfigurationNames); // save each buildstep/buildConfiguration combination - foreach (const BuildConfiguration *bc, buildConfigurations()) { + for(int i=0; i < bcs.size(); ++i) { QStringList buildStepNames; - foreach (BuildStep *buildStep, bc->buildSteps()) + foreach (BuildStep *buildStep, bcs.at(i)->buildSteps()) buildStepNames << buildStep->name(); - writer.saveValue("buildconfiguration-" + bc->name() + "-buildsteps", buildStepNames); + writer.saveValue("buildconfiguration-" + QString::number(i) + "-buildsteps", buildStepNames); int buildstepnr = 0; - foreach (BuildStep *buildStep, bc->buildSteps()) { + foreach (BuildStep *buildStep, bcs.at(i)->buildSteps()) { QMap<QString, QVariant> temp; buildStep->storeIntoLocalMap(temp); - writer.saveValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr), temp); + writer.saveValue("buildconfiguration-" + QString::number(i) + "-buildstep" + QString().setNum(buildstepnr), temp); ++buildstepnr; } } // save each cleanstep/buildConfiguration combination - foreach (const BuildConfiguration *bc, buildConfigurations()) { + for(int i=0; i < bcs.size(); ++i) { QStringList cleanStepNames; - foreach (BuildStep *cleanStep, bc->cleanSteps()) + foreach (BuildStep *cleanStep, bcs.at(i)->cleanSteps()) cleanStepNames << cleanStep->name(); - writer.saveValue("buildconfiguration-" + bc->name() + "-cleansteps", cleanStepNames); + writer.saveValue("buildconfiguration-" + QString::number(i) + "-cleansteps", cleanStepNames); int cleanstepnr = 0; - foreach (BuildStep *cleanStep, bc->cleanSteps()) { + foreach (BuildStep *cleanStep, bcs.at(i)->cleanSteps()) { QMap<QString, QVariant> temp; cleanStep->storeIntoLocalMap(temp); - writer.saveValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr), temp); + writer.saveValue("buildconfiguration-" + QString::number(i) + "-cleanstep" + QString().setNum(cleanstepnr), temp); ++cleanstepnr; } } @@ -223,24 +204,21 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer) bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) { - m_activeBuildConfiguration = reader.restoreValue("activebuildconfiguration").toString(); - - m_values = reader.restoreValue("project").toMap(); - const QList<IBuildStepFactory *> buildStepFactories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); // restoring BuldConfigurations from settings const QStringList buildConfigurationNames = reader.restoreValue("buildconfigurations").toStringList(); + foreach (const QString &buildConfigurationName, buildConfigurationNames) { - BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName); - addBuildConfiguration(bc); + BuildConfiguration *bc = buildConfigurationFactory()->restore(); + QMap<QString, QVariant> temp = reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap(); bc->setValuesFromMap(temp); // Restore build steps - QVariant buildStepsValueVariant = reader.restoreValue("buildconfiguration-" + bc->name() + "-buildsteps"); + QVariant buildStepsValueVariant = reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildsteps"); if(buildStepsValueVariant.isValid()) { int pos = 0; QStringList buildStepNames = buildStepsValueVariant.toStringList(); @@ -249,7 +227,7 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) BuildStep *buildStep = 0; foreach (IBuildStepFactory *factory, buildStepFactories) { if (factory->canCreate(buildStepName)) { - buildStep = factory->create(this, bc, buildStepName); + buildStep = factory->create(bc, buildStepName); break; } } @@ -259,7 +237,7 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) QMap<QString, QVariant> buildStepValues = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap(); buildStep->restoreFromGlobalMap(buildStepValues); buildStepValues = - reader.restoreValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr)).toMap(); + reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr)).toMap(); buildStep->restoreFromLocalMap(buildStepValues); bc->insertBuildStep(pos, buildStep); ++pos; @@ -267,7 +245,7 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) } } // Restore clean steps - QVariant cleanStepsValueVariant = reader.restoreValue("buildconfiguration-" + bc->name() + "-cleansteps"); + QVariant cleanStepsValueVariant = reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleansteps"); if(cleanStepsValueVariant.isValid()) { int pos = 0; QStringList cleanStepNames = cleanStepsValueVariant.toStringList(); @@ -276,7 +254,7 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) BuildStep *cleanStep = 0; foreach (IBuildStepFactory *factory, buildStepFactories) { if (factory->canCreate(cleanStepName)) { - cleanStep = factory->create(this, bc, cleanStepName); + cleanStep = factory->create(bc, cleanStepName); break; } } @@ -286,13 +264,26 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) QMap<QString, QVariant> buildStepValues = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap(); cleanStep->restoreFromGlobalMap(buildStepValues); buildStepValues = - reader.restoreValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr)).toMap(); + reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr)).toMap(); cleanStep->restoreFromLocalMap(buildStepValues); bc->insertCleanStep(pos, cleanStep); ++pos; } } } + addBuildConfiguration(bc); + } + + // Set Active Configuration + { // Try restoring the active configuration + QString activeConfigurationName = reader.restoreValue("activebuildconfiguration").toString(); + int index = buildConfigurationNames.indexOf(activeConfigurationName); + if (index != -1) + m_activeBuildConfiguration = buildConfigurations().at(index); + else if (!buildConfigurations().isEmpty()) + m_activeBuildConfiguration = buildConfigurations().at(0); + else + m_activeBuildConfiguration = 0; } //Build Settings @@ -313,13 +304,14 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) } } if (factory) { - foreach(BuildConfiguration *bc, buildConfigurations()) { - buildStep = factory->create(this, bc, buildStepName); - bc->insertBuildStep(pos, buildStep); + const QList<BuildConfiguration *> &bcs = buildConfigurations(); + for(int i = 0; i < bcs.size(); ++i) { + buildStep = factory->create(bcs.at(i), buildStepName); + bcs.at(i)->insertBuildStep(pos, buildStep); QMap<QString, QVariant> buildStepValues = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap(); buildStep->restoreFromGlobalMap(buildStepValues); buildStepValues = - reader.restoreValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr)).toMap(); + reader.restoreValue("buildconfiguration-" + QString::number(i) + "-buildstep" + QString().setNum(buildstepnr)).toMap(); buildStep->restoreFromLocalMap(buildStepValues); } ++pos; @@ -345,13 +337,14 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) } if (factory) { - foreach(BuildConfiguration *bc, buildConfigurations()) { - cleanStep = factory->create(this, bc, cleanStepName); - bc->insertCleanStep(pos, cleanStep); + const QList<BuildConfiguration *> &bcs = buildConfigurations(); + for (int i = 0; i < bcs.size(); ++i) { + cleanStep = factory->create(bcs.at(i), cleanStepName); + bcs.at(i)->insertCleanStep(pos, cleanStep); QMap<QString, QVariant> cleanStepValues = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap(); cleanStep->restoreFromGlobalMap(cleanStepValues); QMap<QString, QVariant> buildStepValues = - reader.restoreValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr)).toMap(); + reader.restoreValue("buildconfiguration-" + QString::number(i) + "-cleanstep" + QString().setNum(cleanstepnr)).toMap(); cleanStep->restoreFromLocalMap(buildStepValues); } ++pos; @@ -392,38 +385,15 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader) return true; } -void Project::setValue(const QString &name, const QVariant & value) -{ - m_values.insert(name, value); -} - -QVariant Project::value(const QString &name) const -{ - QMap<QString, QVariant>::const_iterator it = - m_values.find(name); - if (it != m_values.constEnd()) - return it.value(); - else - return QVariant(); -} - -BuildConfiguration *Project::buildConfiguration(const QString &name) const -{ - for (int i = 0; i != m_buildConfigurationValues.size(); ++i) - if (m_buildConfigurationValues.at(i)->name() == name) - return m_buildConfigurationValues.at(i); - return 0; -} - BuildConfiguration *Project::activeBuildConfiguration() const { - return buildConfiguration(m_activeBuildConfiguration); //TODO + return m_activeBuildConfiguration; } void Project::setActiveBuildConfiguration(BuildConfiguration *configuration) { - if (m_activeBuildConfiguration != configuration->name() && m_buildConfigurationValues.contains(configuration)) { - m_activeBuildConfiguration = configuration->name(); + if (m_activeBuildConfiguration != configuration && m_buildConfigurationValues.contains(configuration)) { + m_activeBuildConfiguration = configuration; emit activeBuildConfigurationChanged(); } } @@ -483,23 +453,6 @@ EditorConfiguration *Project::editorConfiguration() const return m_editorConfiguration; } -void Project::setDisplayNameFor(BuildConfiguration *configuration, const QString &displayName) -{ - if (configuration->displayName() == displayName) - return; - QString dn = displayName; - QStringList displayNames; - foreach (BuildConfiguration *bc, m_buildConfigurationValues) { - if (bc != configuration) - displayNames << bc->displayName(); - } - dn = makeUnique(displayName, displayNames); - - configuration->setDisplayName(displayName); - - emit buildConfigurationDisplayNameChanged(configuration->name()); -} - QByteArray Project::predefinedMacros(const QString &) const { return QByteArray(); diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 6ad90351f4f51be2e0527fd01eaa13d8947bcedd..8e1ea86383d34a219ee08aec79f0871b311524b2 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -86,19 +86,13 @@ public: // Build configuration void addBuildConfiguration(BuildConfiguration *configuration); void removeBuildConfiguration(BuildConfiguration *configuration); - void copyBuildConfiguration(const QString &source, const QString &dest); - BuildConfiguration *buildConfiguration(const QString & name) const; + QList<BuildConfiguration *> buildConfigurations() const; - // remove and add "QString uniqueConfigurationDisplayName(const QString &proposedName) const" instead - void setDisplayNameFor(BuildConfiguration *configuration, const QString &displayName); BuildConfiguration *activeBuildConfiguration() const; void setActiveBuildConfiguration(BuildConfiguration *configuration); virtual IBuildConfigurationFactory *buildConfigurationFactory() const = 0; - void setValue(const QString &name, const QVariant &value); - QVariant value(const QString &name) const; - // Running QList<RunConfiguration *> runConfigurations() const; void addRunConfiguration(RunConfiguration* runConfiguration); @@ -109,9 +103,6 @@ public: EditorConfiguration *editorConfiguration() const; - virtual Environment environment(BuildConfiguration *configuration) const = 0; - virtual QString buildDirectory(BuildConfiguration *configuration) const = 0; - void saveSettings(); bool restoreSettings(); @@ -132,7 +123,6 @@ public: static QString makeUnique(const QString &preferedName, const QStringList &usedNames); signals: void fileListChanged(); - void buildDirectoryChanged(); // TODO clean up signal names // might be better to also have @@ -146,12 +136,8 @@ signals: void removedRunConfiguration(ProjectExplorer::Project *p, const QString &name); void addedRunConfiguration(ProjectExplorer::Project *p, const QString &name); - void removedBuildConfiguration(ProjectExplorer::Project *p, const QString &name); - void addedBuildConfiguration(ProjectExplorer::Project *p, const QString &name); - - // This signal is jut there for updating the tree list in the buildsettings wizard - void buildConfigurationDisplayNameChanged(const QString &buildConfiguration); - void environmentChanged(const QString &buildConfiguration); + void removedBuildConfiguration(ProjectExplorer::Project *p, ProjectExplorer::BuildConfiguration *bc); + void addedBuildConfiguration(ProjectExplorer::Project *p, ProjectExplorer::BuildConfiguration *bc); protected: /* This method is called when the project .user file is saved. Simply call @@ -173,9 +159,8 @@ protected: virtual bool restoreSettingsImpl(PersistentSettingsReader &reader); private: - QMap<QString, QVariant> m_values; QList<BuildConfiguration *> m_buildConfigurationValues; - QString m_activeBuildConfiguration; + BuildConfiguration *m_activeBuildConfiguration; QList<RunConfiguration *> m_runConfigurations; RunConfiguration* m_activeRunConfiguration; EditorConfiguration *m_editorConfiguration; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 1693c398df759b4883b89b43d4716bc07ae339dd..c15c303e3aea1fb6e7f621034ee95a4552cd31cd 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -307,7 +307,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // Build parsers addAutoReleasedObject(new GccParserFactory); addAutoReleasedObject(new MsvcParserFactory); - addAutoReleasedObject(new QMakeParserFactory); // Settings page addAutoReleasedObject(new ProjectExplorerSettingsPage); @@ -1424,20 +1423,7 @@ void ProjectExplorerPlugin::buildProjectOnly() qDebug() << "ProjectExplorerPlugin::buildProjectOnly"; if (saveModifiedFiles()) - buildManager()->buildProject(d->m_currentProject, d->m_currentProject->activeBuildConfiguration()->name()); -} - -static QStringList configurations(const QList<Project *> &projects) -{ - QStringList result; - foreach (const Project * pro, projects) { - if (BuildConfiguration *bc = pro->activeBuildConfiguration()) { - result << bc->name(); - } else { - result << QString::null; - } - } - return result; + buildManager()->buildProject(d->m_currentProject->activeBuildConfiguration()); } void ProjectExplorerPlugin::buildProject() @@ -1446,8 +1432,11 @@ void ProjectExplorerPlugin::buildProject() qDebug() << "ProjectExplorerPlugin::buildProject"; if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(d->m_currentProject); - d->m_buildManager->buildProjects(projects, configurations(projects)); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, d->m_session->projectOrder(d->m_currentProject)) + configurations << pro->activeBuildConfiguration(); + + d->m_buildManager->buildProjects(configurations); } } @@ -1457,8 +1446,10 @@ void ProjectExplorerPlugin::buildSession() qDebug() << "ProjectExplorerPlugin::buildSession"; if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(); - d->m_buildManager->buildProjects(projects, configurations(projects)); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, d->m_session->projectOrder()) + configurations << pro->activeBuildConfiguration(); + d->m_buildManager->buildProjects(configurations); } } @@ -1468,8 +1459,8 @@ void ProjectExplorerPlugin::rebuildProjectOnly() qDebug() << "ProjectExplorerPlugin::rebuildProjectOnly"; if (saveModifiedFiles()) { - d->m_buildManager->cleanProject(d->m_currentProject, d->m_currentProject->activeBuildConfiguration()->name()); - d->m_buildManager->buildProject(d->m_currentProject, d->m_currentProject->activeBuildConfiguration()->name()); + d->m_buildManager->cleanProject(d->m_currentProject->activeBuildConfiguration()); + d->m_buildManager->buildProject(d->m_currentProject->activeBuildConfiguration()); } } @@ -1479,11 +1470,13 @@ void ProjectExplorerPlugin::rebuildProject() qDebug() << "ProjectExplorerPlugin::rebuildProject"; if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(d->m_currentProject); - const QStringList configs = configurations(projects); + const QList<Project *> &projects = d->m_session->projectOrder(d->m_currentProject); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, projects) + configurations << pro->activeBuildConfiguration(); - d->m_buildManager->cleanProjects(projects, configs); - d->m_buildManager->buildProjects(projects, configs); + d->m_buildManager->cleanProjects(configurations); + d->m_buildManager->buildProjects(configurations); } } @@ -1494,10 +1487,12 @@ void ProjectExplorerPlugin::rebuildSession() if (saveModifiedFiles()) { const QList<Project *> & projects = d->m_session->projectOrder(); - const QStringList configs = configurations(projects); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, projects) + configurations << pro->activeBuildConfiguration(); - d->m_buildManager->cleanProjects(projects, configs); - d->m_buildManager->buildProjects(projects, configs); + d->m_buildManager->cleanProjects(configurations); + d->m_buildManager->buildProjects(configurations); } } @@ -1507,7 +1502,7 @@ void ProjectExplorerPlugin::cleanProjectOnly() qDebug() << "ProjectExplorerPlugin::cleanProjectOnly"; if (saveModifiedFiles()) - d->m_buildManager->cleanProject(d->m_currentProject, d->m_currentProject->activeBuildConfiguration()->name()); + d->m_buildManager->cleanProject(d->m_currentProject->activeBuildConfiguration()); } void ProjectExplorerPlugin::cleanProject() @@ -1517,7 +1512,10 @@ void ProjectExplorerPlugin::cleanProject() if (saveModifiedFiles()) { const QList<Project *> & projects = d->m_session->projectOrder(d->m_currentProject); - d->m_buildManager->cleanProjects(projects, configurations(projects)); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, projects) + configurations << pro->activeBuildConfiguration(); + d->m_buildManager->cleanProjects(configurations); } } @@ -1528,21 +1526,24 @@ void ProjectExplorerPlugin::cleanSession() if (saveModifiedFiles()) { const QList<Project *> & projects = d->m_session->projectOrder(); - d->m_buildManager->cleanProjects(projects, configurations(projects)); + QList<BuildConfiguration *> configurations; + foreach (Project *pro, projects) + configurations << pro->activeBuildConfiguration(); + d->m_buildManager->cleanProjects(configurations); } } void ProjectExplorerPlugin::runProject() { - runProjectImpl(startupProject()); + runProjectImpl(startupProject(), ProjectExplorer::Constants::RUNMODE); } void ProjectExplorerPlugin::runProjectContextMenu() { - runProjectImpl(d->m_currentProject); + runProjectImpl(d->m_currentProject, ProjectExplorer::Constants::RUNMODE); } -void ProjectExplorerPlugin::runProjectImpl(Project *pro) +void ProjectExplorerPlugin::runProjectImpl(Project *pro, QString mode) { if (!pro) return; @@ -1553,16 +1554,21 @@ void ProjectExplorerPlugin::runProjectImpl(Project *pro) return; } if (saveModifiedFiles()) { - d->m_runMode = ProjectExplorer::Constants::RUNMODE; + d->m_runMode = mode; d->m_delayedRunConfiguration = pro->activeRunConfiguration(); const QList<Project *> & projects = d->m_session->projectOrder(pro); - d->m_buildManager->buildProjects(projects, configurations(projects)); + QList<BuildConfiguration *> configurations; + foreach(Project *pro, projects) + configurations << pro->activeBuildConfiguration(); + d->m_buildManager->buildProjects(configurations); + + updateRunAction(); } } else { // TODO this ignores RunConfiguration::isEnabled() if (saveModifiedFiles()) - executeRunConfiguration(pro->activeRunConfiguration(), ProjectExplorer::Constants::RUNMODE); + executeRunConfiguration(pro->activeRunConfiguration(), mode); } } @@ -1572,25 +1578,7 @@ void ProjectExplorerPlugin::debugProject() if (!pro || d->m_debuggingRunControl ) return; - if (d->m_projectExplorerSettings.buildBeforeRun && pro->hasBuildSettings()) { - if (!pro->activeRunConfiguration()->isEnabled()) { - if (!showBuildConfigDialog()) - return; - } - if (saveModifiedFiles()) { - d->m_runMode = ProjectExplorer::Constants::DEBUGMODE; - d->m_delayedRunConfiguration = pro->activeRunConfiguration(); - - const QList<Project *> & projects = d->m_session->projectOrder(pro); - d->m_buildManager->buildProjects(projects, configurations(projects)); - - updateRunAction(); - } - } else { - // TODO this ignores RunConfiguration::isEnabled() - if (saveModifiedFiles()) - executeRunConfiguration(pro->activeRunConfiguration(), ProjectExplorer::Constants::DEBUGMODE); - } + runProjectImpl(pro, ProjectExplorer::Constants::DEBUGMODE); } bool ProjectExplorerPlugin::showBuildConfigDialog() @@ -1965,14 +1953,14 @@ void ProjectExplorerPlugin::populateBuildConfigurationMenu() d->m_buildConfigurationMenu->clear(); if (Project *pro = d->m_currentProject) { const BuildConfiguration *activeBC = pro->activeBuildConfiguration(); - foreach (const BuildConfiguration *bc, pro->buildConfigurations()) { + foreach (BuildConfiguration *bc, pro->buildConfigurations()) { QString displayName = bc->displayName(); QAction *act = new QAction(displayName, d->m_buildConfigurationActionGroup); if (debug) - qDebug() << "BuildConfiguration " << bc->name() << "active: " << activeBC->name(); + qDebug() << "BuildConfiguration " << bc->displayName() << "active: " << activeBC->displayName(); act->setCheckable(true); act->setChecked(bc == activeBC); - act->setData(bc->name()); + act->setData(QVariant::fromValue(bc)); d->m_buildConfigurationMenu->addAction(act); } d->m_buildConfigurationMenu->setEnabled(true); @@ -1986,8 +1974,7 @@ void ProjectExplorerPlugin::buildConfigurationMenuTriggered(QAction *action) if (debug) qDebug() << "ProjectExplorerPlugin::buildConfigurationMenuTriggered"; - d->m_currentProject->setActiveBuildConfiguration(d->m_currentProject->buildConfiguration( - action->data().toString())); + d->m_currentProject->setActiveBuildConfiguration(action->data().value<BuildConfiguration *>()); } void ProjectExplorerPlugin::populateRunConfigurationMenu() @@ -2136,9 +2123,6 @@ Internal::ProjectExplorerSettings ProjectExplorerPlugin::projectExplorerSettings return d->m_projectExplorerSettings; } -// ---------- BuildConfigDialog ----------- -Q_DECLARE_METATYPE(BuildConfiguration*); - BuildConfigDialog::BuildConfigDialog(Project *project, QWidget *parent) : QDialog(parent), m_project(project) @@ -2173,7 +2157,7 @@ BuildConfigDialog::BuildConfigDialog(Project *project, QWidget *parent) RunConfiguration *activeRun = m_project->activeRunConfiguration(); foreach (BuildConfiguration *config, m_project->buildConfigurations()) { if (activeRun->isEnabled(config)) { - m_configCombo->addItem(config->name(), qVariantFromValue(config)); + m_configCombo->addItem(config->displayName(), QVariant::fromValue(config)); } } if (m_configCombo->count() == 0) { diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index b8ea2d8d8b837a5adb326c24bab5a12eb85f1179..10dc691e737d57ce939d07a8c95769df1f9b625b 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -215,7 +215,7 @@ private slots: void currentModeChanged(Core::IMode *mode); private: - void runProjectImpl(Project *pro); + void runProjectImpl(Project *pro, QString mode); void executeRunConfiguration(RunConfiguration *, const QString &mode); bool showBuildConfigDialog(); diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 8aaba10473a2d5b7b19963d514011543b22008a0..325f624a321b4a4a99e6388511b13fb5a04b7773 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -66,7 +66,6 @@ HEADERS += projectexplorer.h \ projectexplorersettingspage.h \ projectwelcomepage.h \ projectwelcomepagewidget.h \ - qmakeparser.h \ baseprojectwizarddialog.h SOURCES += projectexplorer.cpp \ projectwindow.cpp \ @@ -121,7 +120,6 @@ SOURCES += projectexplorer.cpp \ projectwelcomepage.cpp \ projectwelcomepagewidget.cpp \ corelistenercheckingforrunningbuild.cpp \ - qmakeparser.cpp \ baseprojectwizarddialog.cpp FORMS += processstep.ui \ editorsettingspropertiespage.ui \ diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 262cc513675317fa404799437194688d36386136..958391e6371011e45f6075ef899d05084e701c53 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -179,7 +179,6 @@ const char * const FORM_MIMETYPE = "application/x-designer"; const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource"; // build parsers -const char * const BUILD_PARSER_QMAKE = "BuildParser.QMake"; const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC"; const char * const BUILD_PARSER_GCC = "BuildParser.Gcc"; const char * const BUILD_PARSER_RVCT = "BuildParser.Rvct"; diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 5fc16bafc32279903254c6db04b36421dc7746c2..b7be977809a0844e3f61cd26f78d13f4631dcc64 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -44,28 +44,28 @@ #include <coreplugin/icore.h> #include <coreplugin/ifile.h> #include <extensionsystem/pluginmanager.h> +#include <utils/qtcassert.h> #include <utils/styledbar.h> #include <utils/stylehelper.h> -#include <QtCore/QDebug> #include <QtGui/QApplication> #include <QtGui/QBoxLayout> #include <QtGui/QComboBox> #include <QtGui/QScrollArea> -#include <QtGui/QTabWidget> -#include <QtGui/QTreeWidget> -#include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QPainter> #include <QtGui/QPaintEvent> #include <QtGui/QMenu> - using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; namespace { const int ICON_SIZE(64); + +const int ABOVE_HEADING_MARGIN(10); +const int ABOVE_CONTENTS_MARGIN(4); +const int BELOW_CONTENTS_MARGIN(16); } /// @@ -84,8 +84,9 @@ public: } void paintEvent(QPaintEvent *e) { + Q_UNUSED(e); QPainter p(this); - p.fillRect(e->rect(), QBrush(Utils::StyleHelper::borderColor())); + p.fillRect(contentsRect(), QBrush(Utils::StyleHelper::borderColor())); } }; @@ -94,7 +95,7 @@ public: /// PanelsWidget::Panel::Panel(QWidget * w) : - iconLabel(0), lineWidget(0), nameLabel(0), panelWidget(w), spacer(0) + iconLabel(0), lineWidget(0), nameLabel(0), panelWidget(w) { } PanelsWidget::Panel::~Panel() @@ -103,7 +104,6 @@ PanelsWidget::Panel::~Panel() delete lineWidget; delete nameLabel; // do not delete panelWidget, we do not own it! - delete spacer; } /// @@ -118,16 +118,10 @@ PanelsWidget::PanelsWidget(QWidget *parent) : // side of the screen. m_root->setMaximumWidth(800); // The layout holding the individual panels: - m_layout = new QGridLayout; - m_layout->setColumnMinimumWidth(0, ICON_SIZE); - - // A helper layout to glue some stretch to the button of - // the panel layout: - QVBoxLayout * vbox = new QVBoxLayout; - vbox->addLayout(m_layout); - vbox->addStretch(10); - - m_root->setLayout(vbox); + m_layout = new QGridLayout(m_root); + m_layout->setColumnMinimumWidth(0, ICON_SIZE + 4); + m_layout->setSpacing(0); + m_layout->setRowStretch(0, 10); // Add horizontal space to the left of our widget: QHBoxLayout *hbox = new QHBoxLayout; @@ -155,15 +149,17 @@ PanelsWidget::~PanelsWidget() * Add a widget into the grid layout of the PanelsWidget. * * ... - * +--------+-------------------------------------------+ - * | | widget | - * +--------+-------------------------------------------+ + * +--------+-------------------------------------------+ ABOVE_CONTENTS_MARGIN + * | widget (with contentsmargins adjusted!) | + * +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN */ void PanelsWidget::addWidget(QWidget *widget) { - Panel *p = new Panel(widget); - m_layout->addWidget(widget, m_layout->rowCount(), 1); - m_panels.append(p); + QTC_ASSERT(widget, return); + + const int row(m_layout->rowCount() - 1); + m_layout->setRowStretch(row, 0); + addPanelWidget(new Panel(widget), row); } /* @@ -171,52 +167,49 @@ void PanelsWidget::addWidget(QWidget *widget) * layout of the PanelsWidget. * * ... - * +--------+-------------------------------------------+ - * | | spacer | - * +--------+-------------------------------------------+ + * +--------+-------------------------------------------+ ABOVE_HEADING_MARGIN * | icon | name | * + +-------------------------------------------+ - * | | Line | - * + +-------------------------------------------+ - * | | widget | - * +--------+-------------------------------------------+ + * | | line | + * +--------+-------------------------------------------+ ABOVE_CONTENTS_MARGIN + * | widget (with contentsmargins adjusted!) | + * +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN */ void PanelsWidget::addWidget(const QString &name, QWidget *widget, const QIcon & icon) { - Panel *p = new Panel(widget); + QTC_ASSERT(widget, return); - // spacer: - const int spacerRow(m_layout->rowCount()); - p->spacer = new QSpacerItem(1, 10, QSizePolicy::Fixed, QSizePolicy::Fixed); - m_layout->addItem(p->spacer, spacerRow, 1); + Panel *p = new Panel(widget); // icon: - const int headerRow(spacerRow + 1); + const int headerRow(m_layout->rowCount() - 1); + m_layout->setRowStretch(headerRow, 0); + if (!icon.isNull()) { p->iconLabel = new QLabel(m_root); p->iconLabel->setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE)); - m_layout->addWidget(p->iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter); + p->iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0); + m_layout->addWidget(p->iconLabel, headerRow, 0, 2, 1, Qt::AlignTop | Qt::AlignHCenter); } // name: p->nameLabel = new QLabel(m_root); p->nameLabel->setText(name); + p->nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0); QFont f = p->nameLabel->font(); f.setBold(true); f.setPointSizeF(f.pointSizeF() * 1.4); p->nameLabel->setFont(f); - m_layout->addWidget(p->nameLabel, headerRow, 1); + m_layout->addWidget(p->nameLabel, headerRow, 1, 1, 1, Qt::AlignBottom | Qt::AlignLeft); // line: const int lineRow(headerRow + 1); p->lineWidget = new OnePixelBlackLine(m_root); m_layout->addWidget(p->lineWidget, lineRow, 1); - // widget: + // add the widget: const int widgetRow(lineRow + 1); - m_layout->addWidget(p->panelWidget, widgetRow, 1); - - m_panels.append(p); + addPanelWidget(p, widgetRow); } QWidget *PanelsWidget::rootWidget() const @@ -235,13 +228,24 @@ void PanelsWidget::clear() m_layout->removeWidget(p->nameLabel); if (p->panelWidget) m_layout->removeWidget(p->panelWidget); - if (p->spacer) - m_layout->removeItem(p->spacer); delete p; } m_panels.clear(); } +void PanelsWidget::addPanelWidget(Panel *panel, int row) +{ + panel->panelWidget->setContentsMargins(m_layout->columnMinimumWidth(0), + ABOVE_CONTENTS_MARGIN, 0, + BELOW_CONTENTS_MARGIN); + m_layout->addWidget(panel->panelWidget, row, 0, 1, 2); + + const int stretchRow(row + 1); + m_layout->setRowStretch(stretchRow, 10); + + m_panels.append(panel); +} + //// // ActiveConfigurationWidget //// @@ -512,7 +516,7 @@ BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *pare //m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); foreach(const BuildConfiguration *buildConfiguration, p->buildConfigurations()) - m_comboBox->addItem(buildConfiguration->displayName(), buildConfiguration->name()); + m_comboBox->addItem(buildConfiguration->displayName(), buildConfiguration); if (p->buildConfigurations().count() == 1) { m_label->setText(m_comboBox->itemText(0)); setCurrentWidget(m_label); @@ -522,14 +526,15 @@ BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *pare if (index != -1) m_comboBox->setCurrentIndex(index); - connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)), - this, SLOT(nameChanged(QString))); + // TODO +// connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)), + // this, SLOT(nameChanged(ProjectExplorer::BuildConfiguration *))); connect(p, SIGNAL(activeBuildConfigurationChanged()), this, SLOT(activeConfigurationChanged())); - connect(p, SIGNAL(addedBuildConfiguration(ProjectExplorer::Project *, QString)), - this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, QString))); - connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, QString)), - this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, QString))); + connect(p, SIGNAL(addedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)), + this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *))); + connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)), + this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *))); connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(changedIndex(int))); } @@ -539,28 +544,28 @@ BuildConfigurationComboBox::~BuildConfigurationComboBox() } -void BuildConfigurationComboBox::nameChanged(const QString &buildConfiguration) +void BuildConfigurationComboBox::nameChanged(BuildConfiguration *bc) { - int index = nameToIndex(buildConfiguration); + const int index(buildConfigurationToIndex(bc)); if (index == -1) return; - const QString &displayName = m_project->buildConfiguration(buildConfiguration)->displayName(); + const QString &displayName = bc->displayName(); m_comboBox->setItemText(index, displayName); if (m_comboBox->count() == 1) m_label->setText(displayName); } -int BuildConfigurationComboBox::nameToIndex(const QString &buildConfiguration) +int BuildConfigurationComboBox::buildConfigurationToIndex(BuildConfiguration *bc) { for (int i=0; i < m_comboBox->count(); ++i) - if (m_comboBox->itemData(i) == buildConfiguration) + if (m_comboBox->itemData(i).value<BuildConfiguration *>() == bc) return i; return -1; } void BuildConfigurationComboBox::activeConfigurationChanged() { - int index = nameToIndex(m_project->activeBuildConfiguration()->name()); + const int index(buildConfigurationToIndex(m_project->activeBuildConfiguration())); if (index == -1) return; ignoreIndexChange = true; @@ -568,20 +573,26 @@ void BuildConfigurationComboBox::activeConfigurationChanged() ignoreIndexChange = false; } -void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,const QString &buildConfiguration) +void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *project, + BuildConfiguration *bc) { + Q_UNUSED(project); ignoreIndexChange = true; - m_comboBox->addItem(m_project->buildConfiguration(buildConfiguration)->displayName(), buildConfiguration); + m_comboBox->addItem(bc->displayName(), QVariant::fromValue(bc)); if (m_comboBox->count() == 2) setCurrentWidget(m_comboBox); ignoreIndexChange = false; } -void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration) +void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Project *project, + BuildConfiguration * bc) { + Q_UNUSED(project); ignoreIndexChange = true; - int index = nameToIndex(buildConfiguration); + const int index(buildConfigurationToIndex(bc)); + if (index == -1) + return; m_comboBox->removeItem(index); if (m_comboBox->count() == 1) { m_label->setText(m_comboBox->itemText(0)); @@ -594,8 +605,7 @@ void BuildConfigurationComboBox::changedIndex(int newIndex) { if (newIndex == -1) return; - m_project->setActiveBuildConfiguration( - m_project->buildConfiguration(m_comboBox->itemData(newIndex).toString())); + m_project->setActiveBuildConfiguration(m_comboBox->itemData(newIndex).value<BuildConfiguration *>()); } /// @@ -719,19 +729,13 @@ ProjectWindow::ProjectWindow(QWidget *parent) m_panelsWidget = new PanelsWidget(this); viewLayout->addWidget(m_panelsWidget); - // Run and build configuration selection area: + // Run and build configuration selection panel: m_activeConfigurationWidget = new ActiveConfigurationWidget(m_panelsWidget->rootWidget()); - // Spacer and line: - m_spacerBetween = new QWidget(m_panelsWidget->rootWidget()); - QVBoxLayout *spacerVbox = new QVBoxLayout(m_spacerBetween); - spacerVbox->setMargin(0); - m_spacerBetween->setLayout(spacerVbox); - spacerVbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed)); - spacerVbox->addWidget(new OnePixelBlackLine(m_spacerBetween)); - spacerVbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed)); + // Spacer and line panel: + m_spacerBetween = new OnePixelBlackLine(m_panelsWidget->rootWidget()); - // Project chooser: + // Project chooser panel: m_projectChooser = new QWidget(m_panelsWidget->rootWidget()); QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser); hbox->setMargin(0); diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index a99e9fb66c6bb1d5e935bed0614b517fd0017894..558dbc7bb152cf42c714d510712940c83eb62272 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -30,32 +30,26 @@ #ifndef PROJECTWINDOW_H #define PROJECTWINDOW_H -#include <QtGui/QWidget> -#include <QtGui/QScrollArea> -#include <QtGui/QComboBox> #include <QtCore/QPair> -#include <QtGui/QStackedWidget> -#include <QtGui/QPushButton> -#include <QtGui/QToolButton> +#include <QtCore/QMap> +#include <QtGui/QComboBox> #include <QtGui/QLabel> +#include <QtGui/QPushButton> +#include <QtGui/QScrollArea> +#include <QtGui/QStackedWidget> +#include <QtGui/QWidget> QT_BEGIN_NAMESPACE class QLabel; class QGridLayout; -class QModelIndex; -class QTabWidget; -class QHBoxLayout; -class QComboBox; class QMenu; -class QSpacerItem; QT_END_NAMESPACE namespace ProjectExplorer { class IPropertiesPanel; class Project; -class ProjectExplorerPlugin; -class SessionManager; +class BuildConfiguration; namespace Internal { @@ -78,17 +72,18 @@ private: struct Panel { // This does not take ownership of widget! - explicit Panel(QWidget * widget); + explicit Panel(QWidget *widget); ~Panel(); QLabel *iconLabel; QWidget *lineWidget; QLabel *nameLabel; QWidget *panelWidget; - QSpacerItem *spacer; }; QList<Panel *> m_panels; + void addPanelWidget(Panel *panel, int row); + QGridLayout *m_layout; QWidget *m_root; }; @@ -100,13 +95,15 @@ public: BuildConfigurationComboBox(ProjectExplorer::Project *p, QWidget *parent = 0); ~BuildConfigurationComboBox(); private slots: - void nameChanged(const QString &buildConfiguration); + void nameChanged(BuildConfiguration *bc); void activeConfigurationChanged(); - void addedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration); - void removedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration); + void addedBuildConfiguration(ProjectExplorer::Project *project, + BuildConfiguration *bc); + void removedBuildConfiguration(ProjectExplorer::Project *project, + BuildConfiguration *bc); void changedIndex(int newIndex); private: - int nameToIndex(const QString &buildConfiguration); + int buildConfigurationToIndex(BuildConfiguration *bc); bool ignoreIndexChange; ProjectExplorer::Project *m_project; QComboBox *m_comboBox; diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 8dcb7c238d2131c1c8583d552e5a577975c82577..8fb3b897d51be1a58c996a363cdab581ac550fa0 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -853,7 +853,6 @@ Project *SessionManager::projectForFile(const QString &fileName) const foreach (Project *p, projectList) if (p != currentProject && projectContainsFile(p, fileName)) return p; - return 0; } diff --git a/src/plugins/qmleditor/qmleditor.cpp b/src/plugins/qmleditor/qmleditor.cpp index 8b25ce5a61e6814c84f2eb9a3051adefe915a388..498c2e4cd5ed7bde0897680ce97b10fb4bdd7f3b 100644 --- a/src/plugins/qmleditor/qmleditor.cpp +++ b/src/plugins/qmleditor/qmleditor.cpp @@ -666,7 +666,7 @@ static int blockStartState(const QTextBlock &block) return state & 0xff; } -void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedChar) +void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar /*typedChar*/) { TextEditor::TabSettings ts = tabSettings(); diff --git a/src/plugins/qmleditor/qmlexpressionundercursor.cpp b/src/plugins/qmleditor/qmlexpressionundercursor.cpp index 4bb17bdeb66e72f1cb0cbbc9a69e1d7ac5e66b3f..2c7ee0b3bad157ca77e2de6b959be6f281f12f7e 100644 --- a/src/plugins/qmleditor/qmlexpressionundercursor.cpp +++ b/src/plugins/qmleditor/qmlexpressionundercursor.cpp @@ -104,7 +104,7 @@ namespace QmlEditor { } protected: - virtual bool visit(Block *ast) + virtual bool visit(Block * /*ast*/) { // TODO // if (_pos > ast->lbraceToken.end() && _pos < ast->rbraceToken.offset) { diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index d8df516d8881ba3fd7fe3d246c04d1cf02c40830..89ebeaf584cbaa40d3cd4efa6bba0edfcb7a40fb 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -162,12 +162,6 @@ QStringList QmlProject::convertToAbsoluteFiles(const QStringList &paths) const QStringList QmlProject::files() const { return m_files; } -QString QmlProject::buildParser(BuildConfiguration *configuration) const -{ - Q_UNUSED(configuration) - return QString(); -} - QString QmlProject::name() const { return m_projectName; @@ -198,18 +192,6 @@ bool QmlProject::hasBuildSettings() const return false; } -ProjectExplorer::Environment QmlProject::environment(BuildConfiguration *configuration) const -{ - Q_UNUSED(configuration) - return ProjectExplorer::Environment::systemEnvironment(); -} - -QString QmlProject::buildDirectory(BuildConfiguration *configuration) const -{ - Q_UNUSED(configuration) - return QString(); -} - ProjectExplorer::BuildConfigWidget *QmlProject::createConfigWidget() { return 0; diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 1a8e660daeb5c8b195d5e45f783df3639cdd9651..9cbb23a37eb176c73148401e98e9367a0f3f3968 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -71,9 +71,6 @@ public: virtual bool isApplication() const; virtual bool hasBuildSettings() const; - virtual ProjectExplorer::Environment environment(ProjectExplorer::BuildConfiguration *configuration) const; - virtual QString buildDirectory(ProjectExplorer::BuildConfiguration *configuration) const; - virtual ProjectExplorer::BuildConfigWidget *createConfigWidget(); virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets(); @@ -81,7 +78,6 @@ public: virtual QStringList files(FilesMode fileMode) const; QStringList targets() const; - QString buildParser(ProjectExplorer::BuildConfiguration *configuration) const; enum RefreshOptions { Files = 0x01, diff --git a/src/plugins/qt4projectmanager/embeddedpropertiespage.cpp b/src/plugins/qt4projectmanager/embeddedpropertiespage.cpp deleted file mode 100644 index 2fa903fe3ab799ac8a97916d26af92b2f38beae9..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/embeddedpropertiespage.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "embeddedpropertiespage.h" -#include "qt4project.h" - -#include <QFileInfo> -#include <QDir> - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; -using namespace Qt4ProjectManager::Internal; - -/// -/// EmbeddedPropertiesPanelFactory -/// - -bool EmbeddedPropertiesPanelFactory::supports(Project *project) -{ -#ifdef Q_OS_WIN - Qt4Project *pro = qobject_cast<Qt4Project *>(project); - if (pro) { - return true; - } -#else - Q_UNUSED(project) -#endif - return false; -} - -ProjectExplorer::IPropertiesPanel *EmbeddedPropertiesPanelFactory::createPanel( - ProjectExplorer::Project *project) -{ - return new EmbeddedPropertiesPanel(project); -} - -/// -/// EmbeddedPropertiesPanel -/// - -EmbeddedPropertiesPanel::EmbeddedPropertiesPanel(ProjectExplorer::Project *project) : - m_widget(new EmbeddedPropertiesWidget(project)), - m_icon(":/projectexplorer/images/rebuild.png") -{ -} - -EmbeddedPropertiesPanel::~EmbeddedPropertiesPanel() -{ - delete m_widget; -} - -QString EmbeddedPropertiesPanel::name() const -{ - return QApplication::tr("Embedded Linux"); -} - -QWidget *EmbeddedPropertiesPanel::widget() const -{ - return m_widget; -} - -QIcon EmbeddedPropertiesPanel::icon() const -{ - return m_icon; -} - -/// -/// EmbeddedPropertiesWidget -/// - -EmbeddedPropertiesWidget::EmbeddedPropertiesWidget(ProjectExplorer::Project *project) - : QWidget() -{ - m_ui.setupUi(this); - -#ifdef Q_OS_WIN - m_ui.virtualBoxCheckbox->setChecked(project->value("useVBOX").toBool()); - - // Find all skins - QString skin = QFileInfo(project->value("VNCSkin").toString()).fileName(); - QStringList skins; - - QDir skinDir = QApplication::applicationDirPath(); - skinDir.cdUp(); - if (skinDir.cd("qtembeddedtools") && skinDir.cd("qsimplevnc")) { - skins = skinDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ); - } - m_ui.skinComboBox->clear(); - m_ui.skinComboBox->addItems(skins); - if (!skin.isEmpty()) { - int index = m_ui.skinComboBox->findText(skin); - if (index != -1) - m_ui.skinComboBox->setCurrentIndex(index); - } -#else - Q_UNUSED(project) -#endif - //TODO readd finish code - /* - project->setValue("useVBOX", m_ui.virtualBoxCheckbox->isChecked()); - - //Skin - QDir skinDir = QApplication::applicationDirPath(); - skinDir.cdUp(); - skinDir.cd("qtembeddedtools"); - skinDir.cd("qsimplevnc"); - project->setValue("VNCSkin", skinDir.absolutePath() + "/" + m_ui.skinComboBox->currentText() + "/" + m_ui.skinComboBox->currentText()); - - */ -} - -EmbeddedPropertiesWidget::~EmbeddedPropertiesWidget() -{ -} - diff --git a/src/plugins/qt4projectmanager/embeddedpropertiespage.ui b/src/plugins/qt4projectmanager/embeddedpropertiespage.ui deleted file mode 100644 index f4f42aa80cbde5c848f8f567b215ce29d4eaddcb..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/embeddedpropertiespage.ui +++ /dev/null @@ -1,46 +0,0 @@ -<ui version="4.0" > - <class>EmbeddedPropertiesPage</class> - <widget class="QWidget" name="EmbeddedPropertiesPage" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>649</width> - <height>302</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout" > - <item> - <layout class="QFormLayout" name="formLayout" > - <property name="fieldGrowthPolicy" > - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="1" > - <widget class="QCheckBox" name="virtualBoxCheckbox" > - <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> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="skinLabel" > - <property name="text" > - <string>Skin:</string> - </property> - <property name="alignment" > - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QComboBox" name="skinComboBox" /> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qt4projectmanager/externaleditors.cpp b/src/plugins/qt4projectmanager/externaleditors.cpp index 142bef7f501daa58ed36c5889d493cdeb950db89..b165315f5dfbc85cee7e3c7655ba4a5d7c689811 100644 --- a/src/plugins/qt4projectmanager/externaleditors.cpp +++ b/src/plugins/qt4projectmanager/externaleditors.cpp @@ -2,6 +2,7 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" #include "qtversionmanager.h" +#include "qt4buildconfiguration.h" #include <utils/synchronousprocess.h> #include <projectexplorer/projectexplorer.h> @@ -99,7 +100,8 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, const Qt4Project *project = qt4ProjectFor(fileName); // Get the binary either from the current Qt version of the project or Path if (project) { - const QtVersion *qtVersion= project->qtVersion(project->activeBuildConfiguration()); + Qt4BuildConfiguration *qt4bc = project->activeQt4BuildConfiguration(); + const QtVersion *qtVersion= qt4bc->qtVersion(); data->binary = (qtVersion->*commandAccessor)(); data->workingDirectory = QFileInfo(project->file()->fileName()).absolutePath(); } else { diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index 6ec95cbba1e7f00f016206a9d08cf9db368e6035..beb2fbc45e758bb1ddfb90bbc436adefb6f53d2c 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -30,6 +30,7 @@ #include "makestep.h" #include "qt4project.h" +#include "qt4buildconfiguration.h" #include "qt4projectmanagerconstants.h" #include <projectexplorer/projectexplorerconstants.h> @@ -44,8 +45,8 @@ using ExtensionSystem::PluginManager; using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; -MakeStep::MakeStep(Qt4Project * project, ProjectExplorer::BuildConfiguration *bc) - : AbstractMakeStep(project, bc), m_clean(false) +MakeStep::MakeStep(ProjectExplorer::BuildConfiguration *bc) + : AbstractMakeStep(bc), m_clean(false) { } @@ -53,7 +54,7 @@ MakeStep::MakeStep(Qt4Project * project, ProjectExplorer::BuildConfiguration *bc MakeStep::MakeStep(MakeStep *bs, ProjectExplorer::BuildConfiguration *bc) : AbstractMakeStep(bs, bc), m_clean(bs->m_clean), - m_makeargs(bs->m_makeargs), + m_userArgs(bs->m_userArgs), m_makeCmd(bs->m_makeCmd) { @@ -64,6 +65,11 @@ MakeStep::~MakeStep() } +Qt4BuildConfiguration *MakeStep::qt4BuildConfiguration() const +{ + return static_cast<Qt4BuildConfiguration *>(buildConfiguration()); +} + void MakeStep::setClean(bool clean) { m_clean = clean; @@ -78,7 +84,7 @@ void MakeStep::restoreFromGlobalMap(const QMap<QString, QVariant> &map) void MakeStep::restoreFromLocalMap(const QMap<QString, QVariant> &map) { - m_makeargs = map.value("makeargs").toStringList(); + m_userArgs = map.value("makeargs").toStringList(); m_makeCmd = map.value("makeCmd").toString(); if (map.value("clean").isValid() && map.value("clean").toBool()) m_clean = true; @@ -87,7 +93,7 @@ void MakeStep::restoreFromLocalMap(const QMap<QString, QVariant> &map) void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map) { - map["makeargs"] = m_makeargs; + map["makeargs"] = m_userArgs; map["makeCmd"] = m_makeCmd; if (m_clean) map["clean"] = true; @@ -96,15 +102,14 @@ void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map) bool MakeStep::init() { - ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); - Environment environment = project()->environment(bc); + Qt4BuildConfiguration *bc = qt4BuildConfiguration(); + Environment environment = bc->environment(); setEnvironment(environment); - Qt4Project *qt4project = qobject_cast<Qt4Project *>(project()); - QString workingDirectory = qt4project->buildDirectory(bc); + QString workingDirectory = bc->buildDirectory(); setWorkingDirectory(workingDirectory); - QString makeCmd = qt4project->makeCommand(bc); + QString makeCmd = bc->makeCommand(); if (!m_makeCmd.isEmpty()) makeCmd = m_makeCmd; if (!QFileInfo(makeCmd).isAbsolute()) { @@ -123,17 +128,17 @@ bool MakeStep::init() // we should stop the clean queue // That is mostly so that rebuild works on a alrady clean project setIgnoreReturnValue(m_clean); - QStringList args = m_makeargs; + QStringList args = m_userArgs; if (!m_clean) { - if (!qt4project->defaultMakeTarget(bc).isEmpty()) - args << qt4project->defaultMakeTarget(bc); + if (!bc->defaultMakeTarget().isEmpty()) + args << bc->defaultMakeTarget(); } // -w option enables "Enter"/"Leaving directory" messages, which we need for detecting the // absolute file path // FIXME doing this without the user having a way to override this is rather bad // so we only do it for unix and if the user didn't override the make command // but for now this is the least invasive change - ProjectExplorer::ToolChain *toolchain = qt4project->toolChain(bc); + ProjectExplorer::ToolChain *toolchain = bc->toolChain(); ProjectExplorer::ToolChain::ToolChainType type = ProjectExplorer::ToolChain::UNKNOWN; if (toolchain) @@ -163,7 +168,7 @@ bool MakeStep::init() void MakeStep::run(QFutureInterface<bool> & fi) { - if (qobject_cast<Qt4Project *>(project())->rootProjectNode()->projectType() == ScriptTemplate) { + if (qt4BuildConfiguration()->qt4Project()->rootProjectNode()->projectType() == ScriptTemplate) { fi.reportResult(true); return; } @@ -191,19 +196,19 @@ ProjectExplorer::BuildStepConfigWidget *MakeStep::createConfigWidget() return new MakeStepConfigWidget(this); } -QStringList MakeStep::makeArguments() +QStringList MakeStep::userArguments() { - return m_makeargs; + return m_userArgs; } -void MakeStep::setMakeArguments(const QStringList &arguments) +void MakeStep::setUserArguments(const QStringList &arguments) { - m_makeargs = arguments; - emit changed(); + m_userArgs = arguments; + emit userArgumentsChanged(); } MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) - : BuildStepConfigWidget(), m_makeStep(makeStep) + : BuildStepConfigWidget(), m_makeStep(makeStep), m_ignoreChange(false) { m_ui.setupUi(this); connect(m_ui.makeLineEdit, SIGNAL(textEdited(QString)), @@ -211,9 +216,9 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) connect(m_ui.makeArgumentsLineEdit, SIGNAL(textEdited(QString)), this, SLOT(makeArgumentsLineEditTextEdited())); - connect(makeStep, SIGNAL(changed()), - this, SLOT(update())); - connect(makeStep->project(), SIGNAL(buildDirectoryChanged()), + connect(makeStep, SIGNAL(userArgumentsChanged()), + this, SLOT(userArgumentsChanged())); + connect(makeStep->buildConfiguration(), SIGNAL(buildDirectoryChanged()), this, SLOT(updateDetails())); connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()), @@ -224,22 +229,20 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) void MakeStepConfigWidget::updateMakeOverrideLabel() { - Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_makeStep->project()); - m_ui.makeLabel->setText(tr("Override %1:").arg(qt4project-> - makeCommand(m_makeStep->buildConfiguration()))); + Qt4BuildConfiguration *qt4bc = m_makeStep->qt4BuildConfiguration(); + m_ui.makeLabel->setText(tr("Override %1:").arg(qt4bc->makeCommand())); } void MakeStepConfigWidget::updateDetails() { - Qt4Project *pro = static_cast<Qt4Project *>(m_makeStep->project()); - ProjectExplorer::BuildConfiguration *bc = m_makeStep->buildConfiguration(); - QString workingDirectory = pro->buildDirectory(bc); + Qt4BuildConfiguration *bc = m_makeStep->qt4BuildConfiguration(); + QString workingDirectory = bc->buildDirectory(); - QString makeCmd = pro->makeCommand(bc); + QString makeCmd = bc->makeCommand(); if (!m_makeStep->m_makeCmd.isEmpty()) makeCmd = m_makeStep->m_makeCmd; if (!QFileInfo(makeCmd).isAbsolute()) { - Environment environment = pro->environment(bc); + Environment environment = bc->environment(); // Try to detect command in environment QString tmp = environment.searchInPath(makeCmd); if (tmp == QString::null) { @@ -254,9 +257,9 @@ void MakeStepConfigWidget::updateDetails() // FIXME doing this without the user having a way to override this is rather bad // so we only do it for unix and if the user didn't override the make command // but for now this is the least invasive change - QStringList args = m_makeStep->makeArguments(); + QStringList args = m_makeStep->userArguments(); ProjectExplorer::ToolChain::ToolChainType t = ProjectExplorer::ToolChain::UNKNOWN; - ProjectExplorer::ToolChain *toolChain = pro->toolChain(bc); + ProjectExplorer::ToolChain *toolChain = bc->toolChain(); if (toolChain) t = toolChain->type(); if (t != ProjectExplorer::ToolChain::MSVC && t != ProjectExplorer::ToolChain::WINCE) { @@ -278,9 +281,11 @@ QString MakeStepConfigWidget::displayName() const return m_makeStep->displayName(); } -void MakeStepConfigWidget::update() +void MakeStepConfigWidget::userArgumentsChanged() { - init(); + const QStringList &makeArguments = m_makeStep->userArguments(); + m_ui.makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments)); + updateDetails(); } void MakeStepConfigWidget::init() @@ -290,7 +295,7 @@ void MakeStepConfigWidget::init() const QString &makeCmd = m_makeStep->m_makeCmd; m_ui.makeLineEdit->setText(makeCmd); - const QStringList &makeArguments = m_makeStep->makeArguments(); + const QStringList &makeArguments = m_makeStep->userArguments(); m_ui.makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments)); updateDetails(); } @@ -303,8 +308,10 @@ void MakeStepConfigWidget::makeLineEditTextEdited() void MakeStepConfigWidget::makeArgumentsLineEditTextEdited() { - m_makeStep->setMakeArguments( + m_ignoreChange = true; + m_makeStep->setUserArguments( ProjectExplorer::Environment::parseCombinedArgString(m_ui.makeArgumentsLineEdit->text())); + m_ignoreChange = false; updateDetails(); } @@ -325,10 +332,10 @@ bool MakeStepFactory::canCreate(const QString & name) const return (name == Constants::MAKESTEP); } -ProjectExplorer::BuildStep *MakeStepFactory::create(ProjectExplorer::Project *pro, ProjectExplorer::BuildConfiguration *bc, const QString & name) const +ProjectExplorer::BuildStep *MakeStepFactory::create(ProjectExplorer::BuildConfiguration *bc, const QString & name) const { Q_UNUSED(name) - return new MakeStep(static_cast<Qt4Project *>(pro), bc); + return new MakeStep(bc); } ProjectExplorer::BuildStep *MakeStepFactory::clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const @@ -336,9 +343,9 @@ ProjectExplorer::BuildStep *MakeStepFactory::clone(ProjectExplorer::BuildStep *b return new MakeStep(static_cast<MakeStep *>(bs), bc); } -QStringList MakeStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const +QStringList MakeStepFactory::canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *pro) const { - if (qobject_cast<Qt4Project *>(pro)) + if (qobject_cast<Qt4BuildConfiguration *>(pro)) return QStringList() << Constants::MAKESTEP; else return QStringList(); diff --git a/src/plugins/qt4projectmanager/makestep.h b/src/plugins/qt4projectmanager/makestep.h index f605120bc605ee8ba004f74ae7868cfa57d2c794..db70e16a0e05be71ec76f407583be35e763769f2 100644 --- a/src/plugins/qt4projectmanager/makestep.h +++ b/src/plugins/qt4projectmanager/makestep.h @@ -43,8 +43,9 @@ class Project; } namespace Qt4ProjectManager { - namespace Internal { +class Qt4BuildConfiguration; + class MakeStepFactory : public ProjectExplorer::IBuildStepFactory { Q_OBJECT @@ -52,12 +53,12 @@ public: MakeStepFactory(); virtual ~MakeStepFactory(); bool canCreate(const QString & name) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::Project * pro, ProjectExplorer::BuildConfiguration *bc, const QString & name) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString & name) const; ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const; - QStringList canCreateForProject(ProjectExplorer::Project *pro) const; + QStringList canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const; QString displayNameForName(const QString &name) const; }; -} +} //namespace Internal class Qt4Project; @@ -67,17 +68,20 @@ class MakeStep : public ProjectExplorer::AbstractMakeStep friend class MakeStepConfigWidget; // TODO remove this // used to access internal stuff public: - MakeStep(Qt4Project * project, ProjectExplorer::BuildConfiguration *bc); + MakeStep(ProjectExplorer::BuildConfiguration *bc); MakeStep(MakeStep *bs, ProjectExplorer::BuildConfiguration *bc); ~MakeStep(); + + Internal::Qt4BuildConfiguration *qt4BuildConfiguration() const; + virtual bool init(); virtual void run(QFutureInterface<bool> &); virtual QString name(); virtual QString displayName(); virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; - QStringList makeArguments(); - void setMakeArguments(const QStringList &arguments); + QStringList userArguments(); + void setUserArguments(const QStringList &arguments); virtual void restoreFromGlobalMap(const QMap<QString, QVariant> &map); @@ -87,10 +91,10 @@ public: virtual void storeIntoLocalMap(QMap<QString, QVariant> &map); signals: - void changed(); + void userArgumentsChanged(); private: bool m_clean; - QStringList m_makeargs; + QStringList m_userArgs; QString m_makeCmd; }; @@ -105,13 +109,14 @@ public: private slots: void makeLineEditTextEdited(); void makeArgumentsLineEditTextEdited(); - void update(); void updateMakeOverrideLabel(); void updateDetails(); + void userArgumentsChanged(); private: Ui::MakeStep m_ui; MakeStep *m_makeStep; QString m_summaryText; + bool m_ignoreChange; }; } // Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index 3eae813b041788bc06da3fd9aa8d8c00214017fc..04d46cb2ca5e13e3571bc6153bd6194228959361 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -33,6 +33,7 @@ #include "qt4projectmanager.h" #include "qmakestep.h" #include "makestep.h" +#include "qt4buildconfiguration.h" #include <extensionsystem/pluginmanager.h> @@ -66,9 +67,9 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W QPair<QtVersion::QmakeBuildConfigs, QStringList> result = QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig()); m_importBuildConfig = result.first; - m_additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second); + m_additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second); - QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, m_importVersion); + QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArgumentList(result.second, directory, m_importVersion); QString versionSpec = m_importVersion->mkspec(); // Compare mkspecs and add to additional arguments diff --git a/src/plugins/projectexplorer/qmakeparser.cpp b/src/plugins/qt4projectmanager/qmakeparser.cpp similarity index 71% rename from src/plugins/projectexplorer/qmakeparser.cpp rename to src/plugins/qt4projectmanager/qmakeparser.cpp index 4425835f4e7c627a6cec0ccb5ff51b0902170159..767b86921af18888ca8112d25c909c07b917aa18 100644 --- a/src/plugins/projectexplorer/qmakeparser.cpp +++ b/src/plugins/qt4projectmanager/qmakeparser.cpp @@ -28,10 +28,28 @@ **************************************************************************/ #include "qmakeparser.h" -#include "projectexplorerconstants.h" -#include "taskwindow.h" +#include "qt4projectmanagerconstants.h" +#include <projectexplorer/taskwindow.h> +#include <projectexplorer/projectexplorerconstants.h> -using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; +using ProjectExplorer::TaskWindow; + +QMakeParserFactory::~QMakeParserFactory() +{ +} + +bool QMakeParserFactory::canCreate(const QString & name) const +{ + return (name == Constants::BUILD_PARSER_QMAKE); +} + +ProjectExplorer::IBuildParser * QMakeParserFactory::create(const QString & name) const +{ + Q_UNUSED(name) + return new QMakeParser(); +} QMakeParser::QMakeParser() { @@ -39,7 +57,7 @@ QMakeParser::QMakeParser() QString QMakeParser::name() const { - return QLatin1String(ProjectExplorer::Constants::BUILD_PARSER_QMAKE); + return QLatin1String(Qt4ProjectManager::Constants::BUILD_PARSER_QMAKE); } void QMakeParser::stdOutput(const QString & line) @@ -57,7 +75,7 @@ void QMakeParser::stdError(const QString & line) lne /* description */, QString() /* filename */, -1 /* linenumber */, - Constants::TASK_CATEGORY_BUILDSYSTEM)); + ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); return; } } diff --git a/src/plugins/projectexplorer/qmakeparser.h b/src/plugins/qt4projectmanager/qmakeparser.h similarity index 79% rename from src/plugins/projectexplorer/qmakeparser.h rename to src/plugins/qt4projectmanager/qmakeparser.h index 5d5a1b02bb7a1b341dd18715f6c79396e22a9f63..e3bdf950a9d48ddc212b73adfe934747b0e7fe34 100644 --- a/src/plugins/projectexplorer/qmakeparser.h +++ b/src/plugins/qt4projectmanager/qmakeparser.h @@ -30,11 +30,23 @@ #ifndef QMAKEPARSER_H #define QMAKEPARSER_H -#include "ibuildparser.h" +#include <projectexplorer/ibuildparser.h> #include <QtCore/QRegExp> -namespace ProjectExplorer { +namespace Qt4ProjectManager { +namespace Internal { + +class QMakeParserFactory : public ProjectExplorer::IBuildParserFactory +{ + Q_OBJECT +public: + QMakeParserFactory() {} + virtual ~QMakeParserFactory(); + virtual bool canCreate(const QString & name) const; + virtual ProjectExplorer::IBuildParser * create(const QString & name) const; +}; + class QMakeParser : public ProjectExplorer::IBuildParser { @@ -48,6 +60,7 @@ public: private: }; +} // namesapce Interanal } // namespace ProjectExplorer #endif // QMAKEPARSER_H diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 9b91f4c8dc0558d9a1870ed2a13c6ff6b05e7a0a..ab5d39075c2546efdf7f77fbb9580bd4f5a92115 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -34,12 +34,11 @@ #include "qt4projectmanager.h" #include "makestep.h" #include "qtversionmanager.h" +#include "qt4buildconfiguration.h" #include <coreplugin/icore.h> #include <utils/qtcassert.h> -#include <projectexplorer/projectexplorerconstants.h> - #include <QFileDialog> #include <QDir> #include <QFile> @@ -49,16 +48,15 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; using namespace ProjectExplorer; -QMakeStep::QMakeStep(Qt4Project *project, ProjectExplorer::BuildConfiguration *bc) - : AbstractMakeStep(project, bc), m_pro(project), m_forced(false) +QMakeStep::QMakeStep(ProjectExplorer::BuildConfiguration *bc) + : AbstractMakeStep(bc), m_forced(false) { } QMakeStep::QMakeStep(QMakeStep *bs, ProjectExplorer::BuildConfiguration *bc) : AbstractMakeStep(bs, bc), - m_pro(bs->m_pro), m_forced(false), - m_qmakeArgs(bs->m_qmakeArgs) + m_userArgs(bs->m_userArgs) { } @@ -67,26 +65,31 @@ QMakeStep::~QMakeStep() { } -QStringList QMakeStep::arguments() +Qt4BuildConfiguration *QMakeStep::qt4BuildConfiguration() const +{ + return static_cast<Qt4BuildConfiguration *>(buildConfiguration()); +} + +QStringList QMakeStep::allArguments() { - QStringList additonalArguments = m_qmakeArgs; - ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); + QStringList additonalArguments = m_userArgs; + Qt4BuildConfiguration *bc = qt4BuildConfiguration(); QStringList arguments; - arguments << project()->file()->fileName(); + arguments << buildConfiguration()->project()->file()->fileName(); arguments << "-r"; if (!additonalArguments.contains("-spec")) - arguments << "-spec" << m_pro->qtVersion(bc)->mkspec(); + arguments << "-spec" << bc->qtVersion()->mkspec(); #ifdef Q_OS_WIN - ToolChain::ToolChainType type = m_pro->toolChainType(bc); + ToolChain::ToolChainType type = bc->toolChainType(); if (type == ToolChain::GCC_MAEMO) arguments << QLatin1String("-unix"); #endif if (bc->value("buildConfiguration").isValid()) { QStringList configarguments; - QtVersion::QmakeBuildConfigs defaultBuildConfiguration = m_pro->qtVersion(bc)->defaultBuildConfig(); + QtVersion::QmakeBuildConfigs defaultBuildConfiguration = bc->qtVersion()->defaultBuildConfig(); QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()); if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll)) configarguments << "CONFIG-=debug_and_release"; @@ -110,8 +113,8 @@ QStringList QMakeStep::arguments() bool QMakeStep::init() { - ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); - const QtVersion *qtVersion = m_pro->qtVersion(bc); + Qt4BuildConfiguration *qt4bc = qt4BuildConfiguration(); + const QtVersion *qtVersion = qt4bc->qtVersion(); if (!qtVersion->isValid()) { #if defined(Q_WS_MAC) @@ -122,8 +125,8 @@ bool QMakeStep::init() return false; } - QStringList args = arguments(); - QString workingDirectory = m_pro->buildDirectory(bc); + QStringList args = allArguments(); + QString workingDirectory = qt4bc->buildDirectory(); QString program = qtVersion->qmakeCommand(); @@ -132,7 +135,7 @@ bool QMakeStep::init() if (QDir(workingDirectory).exists(QLatin1String("Makefile"))) { QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory); if (qtVersion->qmakeCommand() == qmakePath) { - m_needToRunQMake = !m_pro->compareBuildConfigurationToImportFrom(bc, workingDirectory); + m_needToRunQMake = !qt4bc->compareToImportFrom(workingDirectory); } } @@ -145,15 +148,16 @@ bool QMakeStep::init() setWorkingDirectory(workingDirectory); setCommand(program); setArguments(args); - setEnvironment(m_pro->environment(bc)); + setEnvironment(qt4bc->environment()); - setBuildParser(ProjectExplorer::Constants::BUILD_PARSER_QMAKE); + setBuildParser(Qt4ProjectManager::Constants::BUILD_PARSER_QMAKE); return AbstractMakeStep::init(); } void QMakeStep::run(QFutureInterface<bool> &fi) { - if (qobject_cast<Qt4Project *>(project())->rootProjectNode()->projectType() == ScriptTemplate) { + Qt4Project *pro = qt4BuildConfiguration()->qt4Project(); + if (pro->rootProjectNode()->projectType() == ScriptTemplate) { fi.reportResult(true); return; } @@ -210,40 +214,40 @@ bool QMakeStep::processFinished(int exitCode, QProcess::ExitStatus status) return result; } -void QMakeStep::setQMakeArguments(const QStringList &arguments) +void QMakeStep::setUserArguments(const QStringList &arguments) { - m_qmakeArgs = arguments; - emit changed(); + m_userArgs = arguments; + emit userArgumentsChanged(); } -QStringList QMakeStep::qmakeArguments() +QStringList QMakeStep::userArguments() { - return m_qmakeArgs; + return m_userArgs; } void QMakeStep::restoreFromLocalMap(const QMap<QString, QVariant> &map) { - m_qmakeArgs = map.value("qmakeArgs").toStringList(); + m_userArgs = map.value("qmakeArgs").toStringList(); AbstractProcessStep::restoreFromLocalMap(map); } void QMakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map) { - map["qmakeArgs"] = m_qmakeArgs; + map["qmakeArgs"] = m_userArgs; AbstractProcessStep::storeIntoLocalMap(map); } QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) - : BuildStepConfigWidget(), m_step(step) + : BuildStepConfigWidget(), m_step(step), m_ignoreChange(false) { m_ui.setupUi(this); connect(m_ui.qmakeAdditonalArgumentsLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(qmakeArgumentsLineEditTextEdited())); connect(m_ui.buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(buildConfigurationChanged())); - connect(step, SIGNAL(changed()), - this, SLOT(update())); - connect(step->project(), SIGNAL(qtVersionChanged(ProjectExplorer::BuildConfiguration *)), - this, SLOT(qtVersionChanged(ProjectExplorer::BuildConfiguration *))); + connect(step, SIGNAL(userArgumentsChanged()), + this, SLOT(userArgumentsChanged())); + connect(step->buildConfiguration(), SIGNAL(qtVersionChanged()), + this, SLOT(qtVersionChanged())); } QString QMakeStepConfigWidget::summaryText() const @@ -251,29 +255,28 @@ QString QMakeStepConfigWidget::summaryText() const return m_summaryText; } -void QMakeStepConfigWidget::qtVersionChanged(ProjectExplorer::BuildConfiguration *bc) +void QMakeStepConfigWidget::qtVersionChanged() { - if (bc == m_step->buildConfiguration()) { - updateTitleLabel(); - updateEffectiveQMakeCall(); - } + updateTitleLabel(); + updateEffectiveQMakeCall(); } void QMakeStepConfigWidget::updateTitleLabel() { - Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_step->project()); - const QtVersion *qtVersion = qt4project->qtVersion(m_step->buildConfiguration()); + Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration(); + const QtVersion *qtVersion = qt4bc->qtVersion(); if (!qtVersion) { m_summaryText = tr("<b>QMake:</b> No Qt version set. QMake can not be run."); emit updateSummary(); return; } - QStringList args = m_step->arguments(); + QStringList args = m_step->allArguments(); // We don't want the full path to the .pro file - int index = args.indexOf(m_step->project()->file()->fileName()); + const QString projectFileName = m_step->buildConfiguration()->project()->file()->fileName(); + int index = args.indexOf(projectFileName); if (index != -1) - args[index] = QFileInfo(m_step->project()->file()->fileName()).fileName(); + args[index] = QFileInfo(projectFileName).fileName(); // And we only use the .pro filename not the full path QString program = QFileInfo(qtVersion->qmakeCommand()).fileName(); @@ -284,10 +287,12 @@ void QMakeStepConfigWidget::updateTitleLabel() void QMakeStepConfigWidget::qmakeArgumentsLineEditTextEdited() { - m_step->setQMakeArguments( + m_ignoreChange = true; + m_step->setUserArguments( ProjectExplorer::Environment::parseCombinedArgString(m_ui.qmakeAdditonalArgumentsLineEdit->text())); + m_ignoreChange = false; - static_cast<Qt4Project *>(m_step->project())->invalidateCachedTargetInformation(); + m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation(); updateTitleLabel(); updateEffectiveQMakeCall(); } @@ -303,12 +308,12 @@ void QMakeStepConfigWidget::buildConfigurationChanged() buildConfiguration = buildConfiguration & ~QtVersion::DebugBuild; } bc->setValue("buildConfiguration", int(buildConfiguration)); - static_cast<Qt4Project *>(m_step->project())->invalidateCachedTargetInformation(); + m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation(); updateTitleLabel(); updateEffectiveQMakeCall(); // TODO if exact parsing is the default, we need to update the code model // and all the Qt4ProFileNodes - //static_cast<Qt4Project *>(m_step->project())->update(); + // m_step->qt4Project()->update(); } QString QMakeStepConfigWidget::displayName() const @@ -316,14 +321,19 @@ QString QMakeStepConfigWidget::displayName() const return m_step->displayName(); } -void QMakeStepConfigWidget::update() +void QMakeStepConfigWidget::userArgumentsChanged() { - init(); + if (m_ignoreChange) + return; + QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments()); + m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs); + updateTitleLabel(); + updateEffectiveQMakeCall(); } void QMakeStepConfigWidget::init() { - QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->qmakeArguments()); + QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments()); m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs); ProjectExplorer::BuildConfiguration *bc = m_step->buildConfiguration(); bool debug = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()) & QtVersion::DebugBuild; @@ -334,11 +344,11 @@ void QMakeStepConfigWidget::init() void QMakeStepConfigWidget::updateEffectiveQMakeCall() { - Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_step->project()); - const QtVersion *qtVersion = qt4project->qtVersion(m_step->buildConfiguration()); + Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration(); + const QtVersion *qtVersion = qt4bc->qtVersion(); if (qtVersion) { QString program = QFileInfo(qtVersion->qmakeCommand()).fileName(); - m_ui.qmakeArgumentsEdit->setPlainText(program + QLatin1Char(' ') + ProjectExplorer::Environment::joinArgumentList(m_step->arguments())); + m_ui.qmakeArgumentsEdit->setPlainText(program + QLatin1Char(' ') + ProjectExplorer::Environment::joinArgumentList(m_step->allArguments())); } else { m_ui.qmakeArgumentsEdit->setPlainText(tr("No valid Qt version set.")); } @@ -361,10 +371,10 @@ bool QMakeStepFactory::canCreate(const QString & name) const return (name == Constants::QMAKESTEP); } -ProjectExplorer::BuildStep *QMakeStepFactory::create(ProjectExplorer::Project * pro, BuildConfiguration *bc, const QString & name) const +ProjectExplorer::BuildStep *QMakeStepFactory::create(BuildConfiguration *bc, const QString & name) const { Q_UNUSED(name) - return new QMakeStep(static_cast<Qt4Project *>(pro), bc); + return new QMakeStep(bc); } ProjectExplorer::BuildStep *QMakeStepFactory::clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const @@ -372,9 +382,12 @@ ProjectExplorer::BuildStep *QMakeStepFactory::clone(ProjectExplorer::BuildStep * return new QMakeStep(static_cast<QMakeStep *>(bs), bc); } -QStringList QMakeStepFactory::canCreateForProject(ProjectExplorer::Project *) const +QStringList QMakeStepFactory::canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const { - return QStringList() << Constants::QMAKESTEP; + if (Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(bc)) + if (!qt4bc->qmakeStep()) + return QStringList() << Constants::QMAKESTEP; + return QStringList(); } QString QMakeStepFactory::displayNameForName(const QString &name) const diff --git a/src/plugins/qt4projectmanager/qmakestep.h b/src/plugins/qt4projectmanager/qmakestep.h index 71ff893e793b7dfb96320107a915c685e957c267..c6a4a37b95dbaa5d1c8fcfaa4ce37c4fbfcecdc1 100644 --- a/src/plugins/qt4projectmanager/qmakestep.h +++ b/src/plugins/qt4projectmanager/qmakestep.h @@ -43,8 +43,11 @@ class Project; } namespace Qt4ProjectManager { +class Qt4Project; namespace Internal { +class Qt4BuildConfiguration; + class QMakeStepFactory : public ProjectExplorer::IBuildStepFactory { Q_OBJECT @@ -52,55 +55,52 @@ public: QMakeStepFactory(); virtual ~QMakeStepFactory(); bool canCreate(const QString & name) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::Project * pro, ProjectExplorer::BuildConfiguration *bc, const QString & name) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString & name) const; ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const; - QStringList canCreateForProject(ProjectExplorer::Project *pro) const; + QStringList canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const; QString displayNameForName(const QString &name) const; }; -} -class Qt4Project; +} // namespace Internal class QMakeStep : public ProjectExplorer::AbstractMakeStep { Q_OBJECT - friend class Qt4Project; // TODO remove - // Currently used to access qmakeArgs public: - QMakeStep(Qt4Project * project, ProjectExplorer::BuildConfiguration *bc); + QMakeStep(ProjectExplorer::BuildConfiguration *bc); QMakeStep(QMakeStep *bs, ProjectExplorer::BuildConfiguration *bc); ~QMakeStep(); + Internal::Qt4BuildConfiguration *qt4BuildConfiguration() const; virtual bool init(); virtual void run(QFutureInterface<bool> &); virtual QString name(); virtual QString displayName(); virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; - QStringList arguments(); void setForced(bool b); bool forced(); - QStringList qmakeArguments(); - void setQMakeArguments(const QStringList &arguments); + QStringList allArguments(); + QStringList userArguments(); + void setUserArguments(const QStringList &arguments); virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map); virtual void storeIntoLocalMap(QMap<QString, QVariant> &map); signals: - void changed(); + void userArgumentsChanged(); protected: virtual void processStartupFailed(); virtual bool processFinished(int exitCode, QProcess::ExitStatus status); private: - Qt4Project *m_pro; // last values QStringList m_lastEnv; bool m_forced; bool m_needToRunQMake; // set in init(), read in run() - QStringList m_qmakeArgs; + QStringList m_userArgs; }; @@ -115,14 +115,15 @@ public: private slots: void qmakeArgumentsLineEditTextEdited(); void buildConfigurationChanged(); - void update(); - void qtVersionChanged(ProjectExplorer::BuildConfiguration *bc); + void userArgumentsChanged(); + void qtVersionChanged(); private: void updateTitleLabel(); void updateEffectiveQMakeCall(); Ui::QMakeStep m_ui; QMakeStep *m_step; QString m_summaryText; + bool m_ignoreChange; }; } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp index 5027ebd331474cc33c78b1617268e6bc2e9e460c..6c89388f490037855d20cf27e3364dff5b3fb99e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp @@ -34,6 +34,7 @@ #include "maemotoolchain.h" #include "profilereader.h" #include "qt4project.h" +#include "qt4buildconfiguration.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -260,11 +261,6 @@ MaemoRunConfiguration::MaemoRunConfiguration(Project *project, connect(project, SIGNAL(activeBuildConfigurationChanged()), this, SLOT(invalidateCachedTargetInformation())); - connect(project, SIGNAL(targetInformationChanged()), this, - SLOT(invalidateCachedSimulatorInformation())); - connect(project, SIGNAL(activeBuildConfigurationChanged()), this, - SLOT(invalidateCachedSimulatorInformation())); - qemu = new QProcess(this); connect(qemu, SIGNAL(error(QProcess::ProcessError)), &dumper, SLOT(printToStream(QProcess::ProcessError))); @@ -296,10 +292,9 @@ Qt4Project *MaemoRunConfiguration::project() const bool MaemoRunConfiguration::isEnabled() const { - Qt4Project *qt4Project = qobject_cast<Qt4Project*>(project()); - QTC_ASSERT(qt4Project, return false); - ToolChain::ToolChainType type = - qt4Project->toolChainType(qt4Project->activeBuildConfiguration()); + Qt4BuildConfiguration *qt4bc = project()->activeQt4BuildConfiguration(); + QTC_ASSERT(qt4bc, return false); + ToolChain::ToolChainType type = qt4bc->toolChainType(); return type == ToolChain::GCC_MAEMO; } @@ -355,8 +350,8 @@ void MaemoRunConfiguration::wasDeployed() bool MaemoRunConfiguration::hasDebuggingHelpers() const { - return project()->qtVersion(project()->activeBuildConfiguration()) - ->hasDebuggingHelper(); + Qt4BuildConfiguration *qt4bc = project()->activeQt4BuildConfiguration(); + return qt4bc->qtVersion()->hasDebuggingHelper(); } bool MaemoRunConfiguration::debuggingHelpersNeedDeployment() const @@ -411,10 +406,10 @@ const QString MaemoRunConfiguration::cmd(const QString &cmdName) const const MaemoToolChain *MaemoRunConfiguration::toolchain() const { - Qt4Project *qt4Project = qobject_cast<Qt4Project *>(project()); - QTC_ASSERT(qt4Project != 0, return 0); + Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(project()->activeBuildConfiguration()); + QTC_ASSERT(qt4bc, return 0); MaemoToolChain *tc = dynamic_cast<MaemoToolChain *>( - qt4Project->toolChain(qt4Project->activeBuildConfiguration()) ); + qt4bc->toolChain() ); QTC_ASSERT(tc != 0, return 0); return tc; } @@ -429,7 +424,7 @@ const QString MaemoRunConfiguration::gdbCmd() const QString MaemoRunConfiguration::maddeRoot() const { if (const MaemoToolChain *tc = toolchain()) - tc->maddeRoot(); + return tc->maddeRoot(); return QString(); } @@ -447,8 +442,8 @@ const QStringList MaemoRunConfiguration::arguments() const const QString MaemoRunConfiguration::dumperLib() const { - return project()->qtVersion(project()->activeBuildConfiguration())-> - debuggingHelperLibrary(); + Qt4BuildConfiguration *qt4bc = project()->activeQt4BuildConfiguration(); + return qt4bc->qtVersion()->debuggingHelperLibrary(); } QString MaemoRunConfiguration::executable() const @@ -543,7 +538,8 @@ void MaemoRunConfiguration::updateTarget() m_executable = QString::null; m_cachedTargetInformationValid = true; - if (Qt4Project *qt4Project = static_cast<Qt4Project *>(project())) { + if (Qt4Project *qt4Project = project()) { + Qt4BuildConfiguration *qt4bc = qt4Project->activeQt4BuildConfiguration(); Qt4PriFileNode * priFileNode = qt4Project->rootProjectNode() ->findProFileFor(m_proFilePath); if (!priFileNode) { @@ -551,8 +547,7 @@ void MaemoRunConfiguration::updateTarget() return; } - QtVersion *qtVersion = - qt4Project->qtVersion(qt4Project->activeBuildConfiguration()); + QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = priFileNode->createProFileReader(); reader->setCumulative(false); reader->setQtVersion(qtVersion); @@ -600,8 +595,7 @@ void MaemoRunConfiguration::updateTarget() QFileInfo(project()->file()->fileName()).absoluteDir(); QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path()); - QDir baseBuildDirectory = - project()->buildDirectory(project()->activeBuildConfiguration()); + QDir baseBuildDirectory = qt4bc->buildDirectory(); QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir); if (!reader->contains("DESTDIR")) { @@ -1137,11 +1131,10 @@ const QString AbstractMaemoRunControl::targetCmdLinePrefix() const bool AbstractMaemoRunControl::setProcessEnvironment(QProcess &process) { QTC_ASSERT(runConfig, return false); - Qt4Project *qt4Project = qobject_cast<Qt4Project *>(runConfig->project()); - QTC_ASSERT(qt4Project, return false); + Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(runConfig->project()->activeBuildConfiguration()); + QTC_ASSERT(qt4bc, return false); Environment env = Environment::systemEnvironment(); - qt4Project->toolChain(qt4Project->activeBuildConfiguration()) - ->addToEnvironment(env); + qt4bc->toolChain()->addToEnvironment(env); process.setEnvironment(env.toStringList()); return true; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 58e4b625a29239e01dd1de4a213052cc55b68fc2..cefe094fab0b35539baa5159b3459eb6d1768980 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -37,9 +37,11 @@ #include "s60runconfigbluetoothstarter.h" #include "bluetoothlistener_gui.h" #include "serialdevicelister.h" +#include "qt4buildconfiguration.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> +#include <coreplugin/progressmanager/progressmanager.h> #include <utils/qtcassert.h> #include <utils/pathchooser.h> #include <projectexplorer/projectexplorerconstants.h> @@ -54,10 +56,18 @@ #include <QtGui/QMainWindow> using namespace ProjectExplorer; +using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; enum { debug = 0 }; +static const int PROGRESS_PACKAGECREATED = 100; +static const int PROGRESS_PACKAGESIGNED = 200; +static const int PROGRESS_DEPLOYBASE = 200; +static const int PROGRESS_PACKAGEDEPLOYED = 300; +static const int PROGRESS_PACKAGEINSTALLED = 400; +static const int PROGRESS_MAX = 400; + // Format information about a file static QString lsFile(const QString &f) { @@ -98,6 +108,11 @@ S60DeviceRunConfiguration::~S60DeviceRunConfiguration() { } +Qt4Project *S60DeviceRunConfiguration::qt4Project() const +{ + return static_cast<Qt4Project *>(project()); +} + QString S60DeviceRunConfiguration::type() const { return QLatin1String("Qt4ProjectManager.DeviceRunConfiguration"); @@ -106,21 +121,22 @@ QString S60DeviceRunConfiguration::type() const ProjectExplorer::ToolChain::ToolChainType S60DeviceRunConfiguration::toolChainType( ProjectExplorer::BuildConfiguration *configuration) const { - if (const Qt4Project *pro = qobject_cast<const Qt4Project*>(project())) - return pro->toolChainType(configuration); + if (Qt4BuildConfiguration *bc = qobject_cast<Qt4BuildConfiguration *>(configuration)) + return bc->toolChainType(); return ProjectExplorer::ToolChain::INVALID; } ProjectExplorer::ToolChain::ToolChainType S60DeviceRunConfiguration::toolChainType() const { - if (const Qt4Project *pro = qobject_cast<const Qt4Project*>(project())) - return pro->toolChainType(pro->activeBuildConfiguration()); + if (Qt4BuildConfiguration *bc = qobject_cast<Qt4BuildConfiguration *>(project()->activeBuildConfiguration())) + return bc->toolChainType(); return ProjectExplorer::ToolChain::INVALID; } bool S60DeviceRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *configuration) const { - const ToolChain::ToolChainType type = toolChainType(configuration); + Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(configuration); + const ToolChain::ToolChainType type = qt4bc->toolChainType(); return type == ToolChain::GCCE || type == ToolChain::RVCT_ARMV5 || type == ToolChain::RVCT_ARMV6; } @@ -243,9 +259,8 @@ QString S60DeviceRunConfiguration::packageFileName() const QString S60DeviceRunConfiguration::localExecutableFileName() const { - Qt4Project *qt4project = qobject_cast<Qt4Project *>(project()); - S60Devices::Device device = S60Manager::instance()->deviceForQtVersion( - qt4project->qtVersion(qt4project->activeBuildConfiguration())); + Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(project()->activeBuildConfiguration()); + S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(qt4bc->qtVersion()); QString localExecutable = device.epocRoot; localExecutable += QString::fromLatin1("/epoc32/release/%1/%2/%3.exe") @@ -258,15 +273,15 @@ void S60DeviceRunConfiguration::updateTarget() { if (m_cachedTargetInformationValid) return; - Qt4Project *pro = static_cast<Qt4Project *>(project()); - Qt4PriFileNode * priFileNode = static_cast<Qt4Project *>(project())->rootProjectNode()->findProFileFor(m_proFilePath); + Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration(); + Qt4PriFileNode * priFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath); if (!priFileNode) { m_baseFileName = QString::null; m_cachedTargetInformationValid = true; emit targetInformationChanged(); return; } - QtVersion *qtVersion = pro->qtVersion(pro->activeBuildConfiguration()); + QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = priFileNode->createProFileReader(); reader->setCumulative(false); reader->setQtVersion(qtVersion); @@ -274,7 +289,7 @@ void S60DeviceRunConfiguration::updateTarget() // Find out what flags we pass on to qmake, this code is duplicated in the qmake step QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig(); QtVersion::QmakeBuildConfigs projectBuildConfiguration = - QtVersion::QmakeBuildConfigs(pro->activeBuildConfiguration()->value("buildConfiguration").toInt()); + QtVersion::QmakeBuildConfigs(qt4bc->value("buildConfiguration").toInt()); QStringList addedUserConfigArguments; QStringList removedUserConfigArguments; if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll)) @@ -297,7 +312,7 @@ void S60DeviceRunConfiguration::updateTarget() // Extract data const QDir baseProjectDirectory = QFileInfo(project()->file()->fileName()).absoluteDir(); const QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path()); - const QDir baseBuildDirectory = project()->buildDirectory(project()->activeBuildConfiguration()); + const QDir baseBuildDirectory = qt4bc->buildDirectory(); const QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir); // Directory @@ -319,7 +334,7 @@ void S60DeviceRunConfiguration::updateTarget() m_packageTemplateFileName = QDir::cleanPath( m_workingDir + QLatin1Char('/') + m_targetName + QLatin1String("_template.pkg")); - switch (pro->toolChainType(pro->activeBuildConfiguration())) { + switch (qt4bc->toolChainType()) { case ToolChain::GCCE: case ToolChain::GCCE_GNUPOC: m_platform = QLatin1String("gcce"); @@ -407,7 +422,10 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfigurat m_makesis(new QProcess(this)), m_signsis(0), m_launcher(0) -{ +{ + // connect for automatically reporting the "finished deploy" state to the progress manager + connect(this, SIGNAL(finished()), this, SLOT(reportDeployFinished())); + connect(m_makesis, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError())); connect(m_makesis, SIGNAL(readyReadStandardOutput()), @@ -417,10 +435,10 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfigurat connect(m_makesis, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(makesisProcessFinished())); - Qt4Project *project = qobject_cast<Qt4Project *>(runConfiguration->project()); - QTC_ASSERT(project, return); - S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration); + + Qt4BuildConfiguration *activeBuildConf = s60runConfig->qt4Project()->activeQt4BuildConfiguration(); + QTC_ASSERT(s60runConfig, return); m_toolChain = s60runConfig->toolChainType(); m_serialPortName = s60runConfig->serialPortName(); @@ -432,18 +450,17 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfigurat m_symbianTarget = s60runConfig->symbianTarget(); m_packageTemplateFile = s60runConfig->packageTemplateFileName(); m_workingDirectory = QFileInfo(m_baseFileName).absolutePath(); - m_qtDir = project->qtVersion(project->activeBuildConfiguration())->versionInfo().value("QT_INSTALL_DATA"); + m_qtDir = activeBuildConf->qtVersion()->versionInfo().value("QT_INSTALL_DATA"); m_useCustomSignature = (s60runConfig->signingMode() == S60DeviceRunConfiguration::SignCustom); m_customSignaturePath = s60runConfig->customSignaturePath(); m_customKeyPath = s60runConfig->customKeyPath(); - ProjectExplorer::BuildConfiguration *const activeBuildConf = project->activeBuildConfiguration(); - const S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(project->qtVersion(activeBuildConf)); + const S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(activeBuildConf->qtVersion()); switch (m_toolChain) { case ProjectExplorer::ToolChain::GCCE_GNUPOC: case ProjectExplorer::ToolChain::RVCT_ARMV6_GNUPOC: { // 'sis' is a make target here. Set up with correct environment - ProjectExplorer::ToolChain *toolchain = project->toolChain(activeBuildConf); + ProjectExplorer::ToolChain *toolchain = activeBuildConf->toolChain(); m_makesisTool = toolchain->makeCommand(); m_toolsDirectory = device.epocRoot + QLatin1String("/epoc32/tools"); ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment(); @@ -484,6 +501,13 @@ S60DeviceRunControlBase::~S60DeviceRunControlBase() void S60DeviceRunControlBase::start() { + m_deployProgress = new QFutureInterface<void>; + Core::ICore::instance()->progressManager()->addTask(m_deployProgress->future(), + tr("Deploying"), + QLatin1String("Symbian.Deploy")); + m_deployProgress->setProgressRange(0, PROGRESS_MAX); + m_deployProgress->setProgressValue(0); + m_deployProgress->reportStarted(); emit started(); if (m_serialPortName.isEmpty()) { error(this, tr("There is no device plugged in.")); @@ -603,6 +627,7 @@ void S60DeviceRunControlBase::makesisProcessFinished() emit finished(); return; } + m_deployProgress->setProgressValue(PROGRESS_PACKAGECREATED); switch (m_toolChain) { case ProjectExplorer::ToolChain::GCCE_GNUPOC: case ProjectExplorer::ToolChain::RVCT_ARMV6_GNUPOC: @@ -644,6 +669,7 @@ void S60DeviceRunControlBase::signsisProcessFinished() stop(); emit finished(); } else { + m_deployProgress->setProgressValue(PROGRESS_PACKAGESIGNED); startDeployment(); } } @@ -659,6 +685,7 @@ void S60DeviceRunControlBase::startDeployment() connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(printCloseFileFailed(QString,QString))); connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice())); connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(printInstallFailed(QString,QString))); + connect(m_launcher, SIGNAL(installingFinished()), this, SLOT(printInstallingFinished())); connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int))); connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int))); @@ -727,14 +754,23 @@ void S60DeviceRunControlBase::printCopyingNotice() void S60DeviceRunControlBase::printCopyProgress(int progress) { - emit addToOutputWindow(this, tr("%1% copied.").arg(progress)); + m_deployProgress->setProgressValue(PROGRESS_DEPLOYBASE + progress); } void S60DeviceRunControlBase::printInstallingNotice() { + m_deployProgress->setProgressValue(PROGRESS_PACKAGEDEPLOYED); emit addToOutputWindow(this, tr("Installing application...")); } +void S60DeviceRunControlBase::printInstallingFinished() +{ + m_deployProgress->setProgressValue(PROGRESS_PACKAGEINSTALLED); + m_deployProgress->reportFinished(); + delete m_deployProgress; + m_deployProgress = 0; +} + void S60DeviceRunControlBase::printInstallFailed(const QString &filename, const QString &errorMessage) { emit addToOutputWindow(this, tr("Could not install from package %1 on device: %2").arg(filename, errorMessage)); @@ -747,6 +783,15 @@ void S60DeviceRunControlBase::launcherFinished() handleLauncherFinished(); } +void S60DeviceRunControlBase::reportDeployFinished() +{ + if (m_deployProgress) { + m_deployProgress->reportFinished(); + delete m_deployProgress; + m_deployProgress = 0; + } +} + QMessageBox *S60DeviceRunControlBase::createTrkWaitingMessageBox(const QString &port, QWidget *parent) { const QString title = QCoreApplication::translate("Qt4ProjectManager::Internal::S60DeviceRunControlBase", diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 10464514ca6b3ca1c856b87d900ea48a3db56b12..8eac205640f3588bb56c181cd82c26f061af9b10 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -36,6 +36,7 @@ #include <projectexplorer/toolchain.h> #include <QtCore/QProcess> +#include <QtCore/QFutureInterface> QT_BEGIN_NAMESPACE class QMessageBox; @@ -47,6 +48,8 @@ namespace Debugger { } namespace Qt4ProjectManager { +class Qt4Project; + namespace Internal { class S60DeviceRunConfiguration : public ProjectExplorer::RunConfiguration @@ -61,6 +64,8 @@ public: explicit S60DeviceRunConfiguration(ProjectExplorer::Project *project, const QString &proFilePath); ~S60DeviceRunConfiguration(); + Qt4Project *qt4Project() const; + QString type() const; bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const; QWidget *configurationWidget(); @@ -172,9 +177,11 @@ private slots: void printCopyProgress(int progress); void printInstallingNotice(); void printInstallFailed(const QString &filename, const QString &errorMessage); + void printInstallingFinished(); void launcherFinished(); void slotLauncherStateChanged(int); void slotWaitingForTrkClosed(); + void reportDeployFinished(); private: bool createPackageFileFromTemplate(QString *errorMessage); @@ -203,6 +210,7 @@ private: QString m_makesisTool; QString m_packageFile; + QFutureInterface<void> *m_deployProgress; trk::Launcher *m_launcher; }; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp index 5c3c2c48023e28818c8e2d51d4394cb86f9cac65..eb63185f30bd8dad39912853267b9db7f744fc1e 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp @@ -34,6 +34,7 @@ #include "profilereader.h" #include "s60manager.h" #include "s60devices.h" +#include "qt4buildconfiguration.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -47,6 +48,7 @@ #include <QtGui/QLineEdit> using namespace ProjectExplorer; +using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; // ======== S60EmulatorRunConfiguration @@ -71,6 +73,11 @@ S60EmulatorRunConfiguration::~S60EmulatorRunConfiguration() { } +Qt4Project *S60EmulatorRunConfiguration::qt4Project() const +{ + return static_cast<Qt4Project *>(project()); +} + QString S60EmulatorRunConfiguration::type() const { return "Qt4ProjectManager.EmulatorRunConfiguration"; @@ -78,9 +85,9 @@ QString S60EmulatorRunConfiguration::type() const bool S60EmulatorRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *configuration) const { - Qt4Project *pro = qobject_cast<Qt4Project*>(project()); - QTC_ASSERT(pro, return false); - ToolChain::ToolChainType type = pro->toolChainType(configuration); + Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(configuration); + QTC_ASSERT(qt4bc, return false); + ToolChain::ToolChainType type = qt4bc->toolChainType(); return type == ToolChain::WINSCW; } @@ -113,23 +120,22 @@ void S60EmulatorRunConfiguration::updateTarget() { if (m_cachedTargetInformationValid) return; - Qt4Project *pro = static_cast<Qt4Project *>(project()); - Qt4PriFileNode * priFileNode = static_cast<Qt4Project *>(project())->rootProjectNode()->findProFileFor(m_proFilePath); + Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration(); + Qt4PriFileNode * priFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath); if (!priFileNode) { m_executable = QString::null; m_cachedTargetInformationValid = true; emit targetInformationChanged(); return; } - QtVersion *qtVersion = pro->qtVersion(pro->activeBuildConfiguration()); + QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = priFileNode->createProFileReader(); reader->setCumulative(false); reader->setQtVersion(qtVersion); // Find out what flags we pass on to qmake, this code is duplicated in the qmake step QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig(); - QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration() - ->value("buildConfiguration").toInt()); + QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(qt4bc->value("buildConfiguration").toInt()); QStringList addedUserConfigArguments; QStringList removedUserConfigArguments; if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll)) @@ -282,8 +288,7 @@ S60EmulatorRunControl::S60EmulatorRunControl(S60EmulatorRunConfiguration *runCon { // stuff like the EPOCROOT and EPOCDEVICE env variable Environment env = Environment::systemEnvironment(); - Project *project = runConfiguration->project(); - static_cast<Qt4Project *>(project)->toolChain(project->activeBuildConfiguration())->addToEnvironment(env); + runConfiguration->qt4Project()->activeQt4BuildConfiguration()->toolChain()->addToEnvironment(env); m_applicationLauncher.setEnvironment(env.toStringList()); m_executable = runConfiguration->executable(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h index 1650a0e710dd1c99b01af62c1ae200e099c372f4..64c8cdfce936b18f0d7ffee2181d0bff43f7fe2f 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h @@ -45,6 +45,8 @@ namespace Utils { } namespace Qt4ProjectManager { +class Qt4Project; + namespace Internal { class S60EmulatorRunConfiguration : public ProjectExplorer::RunConfiguration @@ -54,6 +56,8 @@ public: S60EmulatorRunConfiguration(ProjectExplorer::Project *project, const QString &proFilePath); ~S60EmulatorRunConfiguration(); + Qt4Project *qt4Project() const; + QString type() const; bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const; QWidget *configurationWidget(); diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c12d4056a2ffb6e082ae34840d80aab48209e184 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp @@ -0,0 +1,404 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "qt4buildconfiguration.h" +#include "qt4project.h" + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; +using namespace ProjectExplorer; + +namespace { + bool debug = false; +} + +namespace { + const char * const KEY_QT_VERSION_ID = "QtVersionId"; +} + +Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro) + : BuildConfiguration(pro) +{ + +} + +Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BuildConfiguration *source) + : BuildConfiguration(source) +{ + +} + +Qt4BuildConfiguration::~Qt4BuildConfiguration() +{ + +} + +Qt4Project *Qt4BuildConfiguration::qt4Project() const +{ + return static_cast<Qt4Project *>(project()); +} + +ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const +{ + Environment env = useSystemEnvironment() ? Environment::systemEnvironment() : Environment(); + qtVersion()->addToEnvironment(env); + ToolChain *tc = toolChain(); + if (tc) + tc->addToEnvironment(env); + return env; +} + +ProjectExplorer::Environment Qt4BuildConfiguration::environment() const +{ + Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +void Qt4BuildConfiguration::setUseSystemEnvironment(bool b) +{ + if (useSystemEnvironment() == b) + return; + setValue("clearSystemEnvironment", !b); + emit environmentChanged(); +} + +bool Qt4BuildConfiguration::useSystemEnvironment() const +{ + bool b = !(value("clearSystemEnvironment").isValid() + && value("clearSystemEnvironment").toBool()); + return b; +} + +QList<ProjectExplorer::EnvironmentItem> Qt4BuildConfiguration::userEnvironmentChanges() const +{ + return EnvironmentItem::fromStringList(value("userEnvironmentChanges").toStringList()); +} + +void Qt4BuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + QStringList list = EnvironmentItem::toStringList(diff); + if (list == value("userEnvironmentChanges").toStringList()) + return; + setValue("userEnvironmentChanges", list); + emit environmentChanged(); +} + +QString Qt4BuildConfiguration::buildDirectory() const +{ + QString workingDirectory; + if (value("useShadowBuild").toBool()) + workingDirectory = value("buildDirectory").toString(); + if (workingDirectory.isEmpty()) + workingDirectory = QFileInfo(project()->file()->fileName()).absolutePath(); + return workingDirectory; +} + +ProjectExplorer::ToolChain *Qt4BuildConfiguration::toolChain() const +{ + ToolChain::ToolChainType tct = toolChainType(); + return qtVersion()->toolChain(tct); +} + +QString Qt4BuildConfiguration::makeCommand() const +{ + ToolChain *tc = toolChain(); + return tc ? tc->makeCommand() : "make"; +} + +#ifdef QTCREATOR_WITH_S60 +static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfig buildConfig, + const QString &type) +{ + QString rc = (buildConfig & QtVersion::DebugBuild) ? + QLatin1String("debug-") : QLatin1String("release-"); + rc += type; + return rc; +} +#endif + +QString Qt4BuildConfiguration::defaultMakeTarget() const +{ +#ifdef QTCREATOR_WITH_S60 + ToolChain *tc = toolChain(); + if (!tc) + return QString::null; + const QtVersion::QmakeBuildConfig buildConfig + = QtVersion::QmakeBuildConfig(value("buildConfiguration").toInt()); + + switch (tc->type()) { + case ToolChain::GCCE: + case ToolChain::GCCE_GNUPOC: + return symbianMakeTarget(buildConfig, QLatin1String("gcce")); + case ToolChain::RVCT_ARMV5: + return symbianMakeTarget(buildConfig, QLatin1String("armv5")); + case ToolChain::RVCT_ARMV6: + case ToolChain::RVCT_ARMV6_GNUPOC: + return symbianMakeTarget(buildConfig, QLatin1String("armv6")); + default: + break; + } +#else + +#endif + return QString::null; +} + +QString Qt4BuildConfiguration::qtDir() const +{ + QtVersion *version = qtVersion(); + if (version) + return version->versionInfo().value("QT_INSTALL_DATA"); + return QString::null; +} + +QtVersion *Qt4BuildConfiguration::qtVersion() const +{ + return QtVersionManager::instance()->version(qtVersionId()); +} + +int Qt4BuildConfiguration::qtVersionId() const +{ + QtVersionManager *vm = QtVersionManager::instance(); + if (debug) + qDebug()<<"Looking for qtVersion ID of "<<displayName(); + int id = 0; + QVariant vid = value(KEY_QT_VERSION_ID); + if (vid.isValid()) { + id = vid.toInt(); + if (vm->version(id)->isValid()) { + return id; + } else { + const_cast<Qt4BuildConfiguration *>(this)->setValue(KEY_QT_VERSION_ID, 0); + return 0; + } + } else { + // Backward compatibilty, we might have just the name: + QString vname = value("QtVersion").toString(); + if (debug) + qDebug()<<" Backward compatibility reading QtVersion"<<vname; + if (!vname.isEmpty()) { + const QList<QtVersion *> &versions = vm->versions(); + foreach (const QtVersion * const version, versions) { + if (version->name() == vname) { + if (debug) + qDebug()<<"found name in versions"; + const_cast<Qt4BuildConfiguration *>(this)->setValue(KEY_QT_VERSION_ID, version->uniqueId()); + return version->uniqueId(); + } + } + } + } + if (debug) + qDebug()<<" using qtversion with id ="<<id; + // Nothing found, reset to default + const_cast<Qt4BuildConfiguration *>(this)->setValue(KEY_QT_VERSION_ID, id); + return id; +} + +void Qt4BuildConfiguration::setQtVersion(int id) +{ + setValue(KEY_QT_VERSION_ID, id); + emit qtVersionChanged(); + qt4Project()->updateActiveRunConfiguration(); +} + +void Qt4BuildConfiguration::setToolChainType(ProjectExplorer::ToolChain::ToolChainType type) +{ + setValue("ToolChain", (int)type); + qt4Project()->updateActiveRunConfiguration(); +} + +ProjectExplorer::ToolChain::ToolChainType Qt4BuildConfiguration::toolChainType() const +{ + ToolChain::ToolChainType originalType = ToolChain::ToolChainType(value("ToolChain").toInt()); + ToolChain::ToolChainType type = originalType; + const QtVersion *version = qtVersion(); + if (!version->possibleToolChainTypes().contains(type)) { + // Oh no the saved type is not valid for this qt version + // use default tool chain + type = version->defaultToolchainType(); + const_cast<Qt4BuildConfiguration *>(this)->setToolChainType(type); + } + return type; +} + + +QMakeStep *Qt4BuildConfiguration::qmakeStep() const +{ + QMakeStep *qs = 0; + foreach(BuildStep *bs, buildSteps()) + if ((qs = qobject_cast<QMakeStep *>(bs)) != 0) + return qs; + return 0; +} + +MakeStep *Qt4BuildConfiguration::makeStep() const +{ + MakeStep *qs = 0; + foreach(BuildStep *bs, buildSteps()) + if ((qs = qobject_cast<MakeStep *>(bs)) != 0) + return qs; + return 0; +} + +// returns true if both are equal +bool Qt4BuildConfiguration::compareToImportFrom(const QString &workingDirectory) +{ + QMakeStep *qs = qmakeStep(); + if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) { + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory); + QtVersion *version = qtVersion(); + if (version->qmakeCommand() == qmakePath) { + // same qtversion + QPair<QtVersion::QmakeBuildConfigs, QStringList> result = + QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig()); + if (QtVersion::QmakeBuildConfig(value("buildConfiguration").toInt()) == result.first) { + // The QMake Build Configuration are the same, + // now compare arguments lists + // we have to compare without the spec/platform cmd argument + // and compare that on its own + QString actualSpec = extractSpecFromArgumentList(qs->userArguments(), workingDirectory, version); + if (actualSpec.isEmpty()) { + // Easy one the user has choosen not to override the settings + actualSpec = version->mkspec(); + } + + + QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version); + QStringList actualArgs = removeSpecFromArgumentList(qs->userArguments()); + QStringList parsedArgs = removeSpecFromArgumentList(result.second); + + if (debug) { + qDebug()<<"Actual args:"<<actualArgs; + qDebug()<<"Parsed args:"<<parsedArgs; + qDebug()<<"Actual spec:"<<actualSpec; + qDebug()<<"Parsed spec:"<<parsedSpec; + } + + if (actualArgs == parsedArgs) { + // Specs match exactly + if (actualSpec == parsedSpec) + return true; + // Actual spec is the default one +// qDebug()<<"AS vs VS"<<actualSpec<<version->mkspec(); + if ((actualSpec == version->mkspec() || actualSpec == "default") + && (parsedSpec == version->mkspec() || parsedSpec == "default" || parsedSpec.isEmpty())) + return true; + } + } + } + } + return false; +} + +// We match -spec and -platfrom separetly +// We ignore -cache, because qmake contained a bug that it didn't +// mention the -cache in the Makefile +// That means changing the -cache option in the additional arguments +// does not automatically rerun qmake. Alas, we could try more +// intelligent matching for -cache, but i guess people rarely +// do use that. + +QStringList Qt4BuildConfiguration::removeSpecFromArgumentList(const QStringList &old) +{ + if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache")) + return old; + QStringList newList; + bool ignoreNext = false; + foreach(const QString &item, old) { + if (ignoreNext) { + ignoreNext = false; + } else if (item == "-spec" || item == "-platform" || item == "-cache") { + ignoreNext = true; + } else { + newList << item; + } + } + return newList; +} + +QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version) +{ + int index = list.indexOf("-spec"); + if (index == -1) + index = list.indexOf("-platform"); + if (index == -1) + return QString(); + + ++index; + + if (index >= list.length()) + return QString(); + + QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS"); + if (baseMkspecDir.isEmpty()) + baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs"; + + QString parsedSpec = QDir::cleanPath(list.at(index)); +#ifdef Q_OS_WIN + baseMkspecDir = baseMkspecDir.toLower(); + parsedSpec = parsedSpec.toLower(); +#endif + // if the path is relative it can be + // relative to the working directory (as found in the Makefiles) + // or relatively to the mkspec directory + // if it is the former we need to get the canonical form + // for the other one we don't need to do anything + if (QFileInfo(parsedSpec).isRelative()) { + if(QFileInfo(directory + "/" + parsedSpec).exists()) { + parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec); +#ifdef Q_OS_WIN + parsedSpec = parsedSpec.toLower(); +#endif + } else { + parsedSpec = baseMkspecDir + "/" + parsedSpec; + } + } + + QFileInfo f2(parsedSpec); + while (f2.isSymLink()) { + parsedSpec = f2.symLinkTarget(); + f2.setFile(parsedSpec); + } + + if (parsedSpec.startsWith(baseMkspecDir)) { + parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1); + } else { + QString sourceMkSpecPath = version->sourcePath() + "/mkspecs"; + if (parsedSpec.startsWith(sourceMkSpecPath)) { + parsedSpec = parsedSpec.mid(sourceMkSpecPath.length() + 1); + } + } +#ifdef Q_OS_WIN + parsedSpec = parsedSpec.toLower(); +#endif + return parsedSpec; + +} diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.h b/src/plugins/qt4projectmanager/qt4buildconfiguration.h new file mode 100644 index 0000000000000000000000000000000000000000..378876ed93039aa5ae5cd6f6555bb206fe2ac183 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.h @@ -0,0 +1,108 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef QT4BUILDCONFIGURATION_H +#define QT4BUILDCONFIGURATION_H + +#include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/toolchain.h> + +namespace Qt4ProjectManager { + +class Qt4Project; +class QtVersion; +class QMakeStep; +class MakeStep; + +namespace Internal { + +class Qt4BuildConfiguration : public ProjectExplorer::BuildConfiguration +{ + Q_OBJECT +public: + Qt4BuildConfiguration(Qt4Project *pro); + // copy ctor + Qt4BuildConfiguration(Qt4BuildConfiguration *source); + ~Qt4BuildConfiguration(); + + Qt4Project *qt4Project() const; + + ProjectExplorer::Environment environment() const; + ProjectExplorer::Environment baseEnvironment() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + bool useSystemEnvironment() const; + void setUseSystemEnvironment(bool b); + + virtual QString buildDirectory() const; + + // returns the qtdir (depends on the current QtVersion) + QString qtDir() const; + //returns the qtVersion, if the project is set to use the default qt version, then + // that is returned + // to check wheter the project uses the default qt version use qtVersionId + QtVersion *qtVersion() const; + + // returns the id of the qt version, if the project is using the default qt version + // this function returns 0 + int qtVersionId() const; + //returns the name of the qt version, might be QString::Null, which means default qt version + // qtVersion is in general the better method to use + QString qtVersionName() const; + + void setQtVersion(int id); + + ProjectExplorer::ToolChain *toolChain() const; + void setToolChainType(ProjectExplorer::ToolChain::ToolChainType type); + ProjectExplorer::ToolChain::ToolChainType toolChainType() const; + + + // Those functions are used in a few places. + // The drawback is that we shouldn't actually depend on them beeing always there + // That is generally the stuff that is asked should normally be transfered to + // Qt4Project * + // So that we can later enable people to build qt4projects the way they would like + QMakeStep *qmakeStep() const; + MakeStep *makeStep() const; + + QString makeCommand() const; + QString defaultMakeTarget() const; + + bool compareToImportFrom(const QString &workingDirectory); + static QStringList removeSpecFromArgumentList(const QStringList &old); + static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version); + +signals: + void qtVersionChanged(); +}; + +} // namespace Qt4ProjectManager +} // namespace Internal + +#endif // QT4BUILDCONFIGURATION_H diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp index 2edd8cfeb77c455d4ec94c407be89a8fafa7e226..998ae3591bf6f52f06eea38c2658f1a03569bce3 100644 --- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp @@ -29,6 +29,7 @@ #include "qt4buildenvironmentwidget.h" #include "qt4project.h" +#include "qt4buildconfiguration.h" #include <projectexplorer/environmenteditmodel.h> @@ -42,7 +43,7 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project) - : BuildConfigWidget(), m_pro(project) + : BuildConfigWidget(), m_pro(project), m_buildConfiguration(0) { QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); @@ -65,28 +66,25 @@ QString Qt4BuildEnvironmentWidget::displayName() const return tr("Build Environment"); } -void Qt4BuildEnvironmentWidget::init(const QString &buildConfiguration) +void Qt4BuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc) { if (debug) qDebug() << "Qt4BuildConfigWidget::init()"; - m_buildConfiguration = buildConfiguration; - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfiguration); - m_clearSystemEnvironmentCheckBox->setChecked(!m_pro->useSystemEnvironment(bc)); - m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc)); - m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(bc)); + m_buildConfiguration = static_cast<Qt4BuildConfiguration *>(bc); + m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment()); + m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); + m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges()); m_buildEnvironmentWidget->updateButtons(); } void Qt4BuildEnvironmentWidget::environmentModelUserChangesUpdated() { - m_pro->setUserEnvironmentChanges(m_pro->buildConfiguration(m_buildConfiguration), - m_buildEnvironmentWidget->userChanges()); + m_buildConfiguration->setUserEnvironmentChanges(m_buildEnvironmentWidget->userChanges()); } void Qt4BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked) { - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - m_pro->setUseSystemEnvironment(bc, !checked); - m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc)); + m_buildConfiguration->setUseSystemEnvironment(!checked); + m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); } diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h index c6c9d259e007cdbd958d177ce868d5d52a2c9ce3..304649c044954b80c7276fb9dd9066f133a7877b 100644 --- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h +++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h @@ -45,6 +45,8 @@ namespace Qt4ProjectManager { class Qt4Project; namespace Internal { +class Qt4BuildConfiguration; + class Qt4BuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget { Q_OBJECT @@ -53,7 +55,7 @@ public: Qt4BuildEnvironmentWidget(Qt4Project *project); QString displayName() const; - void init(const QString &buildConfiguration); + void init(ProjectExplorer::BuildConfiguration *bc); private slots: void environmentModelUserChangesUpdated(); @@ -63,7 +65,7 @@ private: ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget; QCheckBox *m_clearSystemEnvironmentCheckBox; Qt4Project *m_pro; - QString m_buildConfiguration; + Qt4BuildConfiguration *m_buildConfiguration; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 70c7029251c910b6403a4184eeef158e4d473114..550e7593772f7b7cf2d639f46fb3f3622982770e 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -35,6 +35,7 @@ #include "qt4project.h" #include "qt4projectmanager.h" #include "qtuicodemodelsupport.h" +#include "qt4buildconfiguration.h" #include <projectexplorer/nodesvisitor.h> #include <projectexplorer/filewatcher.h> @@ -1101,7 +1102,9 @@ ProFileReader *Qt4PriFileNode::createProFileReader() const connect(reader, SIGNAL(errorFound(QString)), m_project, SLOT(proFileParseError(QString))); - QtVersion *version = m_project->qtVersion(m_project->activeBuildConfiguration()); + Qt4BuildConfiguration *qt4bc = m_project->activeQt4BuildConfiguration(); + + QtVersion *version = qt4bc->qtVersion(); if (version->isValid()) reader->setQtVersion(version); @@ -1202,7 +1205,7 @@ QString Qt4PriFileNode::buildDir() const { const QDir srcDirRoot = QFileInfo(m_project->rootProjectNode()->path()).absoluteDir(); const QString relativeDir = srcDirRoot.relativeFilePath(m_projectDir); - return QDir(m_project->buildDirectory(m_project->activeBuildConfiguration())).absoluteFilePath(relativeDir); + return QDir(m_project->activeBuildConfiguration()->buildDirectory()).absoluteFilePath(relativeDir); } /* diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 4f23d4bbbab8f96554890ddb4cb4e813d47de563..78f830c9b1c108932ad1073b8e6bc9a3d47fde94 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -41,6 +41,8 @@ #include "qt4projectmanagerconstants.h" #include "projectloadwizard.h" #include "qtversionmanager.h" +#include "qt4buildconfiguration.h" +#include "qt4buildconfiguration.h" #ifdef QTCREATOR_WITH_S60 #include "qt-s60/gccetoolchain.h" @@ -67,10 +69,6 @@ using namespace ProjectExplorer; enum { debug = 0 }; -namespace { - const char * const KEY_QT_VERSION_ID = "QtVersionId"; -} - namespace Qt4ProjectManager { namespace Internal { @@ -269,7 +267,7 @@ QString Qt4BuildConfigurationFactory::displayNameForType(const QString &type) co return QString(); } -bool Qt4BuildConfigurationFactory::create(const QString &type) const +BuildConfiguration *Qt4BuildConfigurationFactory::create(const QString &type) const { QTC_ASSERT(m_versions.contains(type), return false); const VersionInfo &info = m_versions.value(type); @@ -289,10 +287,24 @@ bool Qt4BuildConfigurationFactory::create(const QString &type) const m_project->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName), version, (version->defaultBuildConfig() | QtVersion::DebugBuild)); + BuildConfiguration *bc = m_project->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName), version, (version->defaultBuildConfig() & ~QtVersion::DebugBuild)); - return true; + return bc; +} + +BuildConfiguration *Qt4BuildConfigurationFactory::clone(BuildConfiguration *source) const +{ + Qt4BuildConfiguration *oldbc = static_cast<Qt4BuildConfiguration *>(source); + Qt4BuildConfiguration *newbc = new Qt4BuildConfiguration(oldbc); + return newbc; +} + +BuildConfiguration *Qt4BuildConfigurationFactory::restore() const +{ + Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(m_project); + return bc; } /*! @@ -323,9 +335,14 @@ Qt4Project::~Qt4Project() delete m_projectFiles; } +Qt4BuildConfiguration *Qt4Project::activeQt4BuildConfiguration() const +{ + return static_cast<Qt4BuildConfiguration *>(activeBuildConfiguration()); +} + void Qt4Project::defaultQtVersionChanged() { - if (qtVersionId(activeBuildConfiguration()) == 0) + if (activeQt4BuildConfiguration()->qtVersionId() == 0) m_rootProjectNode->update(); } @@ -333,9 +350,10 @@ void Qt4Project::qtVersionsChanged() { QtVersionManager *vm = QtVersionManager::instance(); foreach (BuildConfiguration *bc, buildConfigurations()) { - if (!vm->version(qtVersionId(bc))->isValid()) { - setQtVersion(bc, 0); - if (bc == activeBuildConfiguration()) + Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(bc); + if (!vm->version(qt4bc->qtVersionId())->isValid()) { + qt4bc->setQtVersion(0); + if (qt4bc == activeBuildConfiguration()) m_rootProjectNode->update(); } } @@ -365,8 +383,9 @@ bool Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader) // or if not, is reset to the default foreach (BuildConfiguration *bc, buildConfigurations()) { - qtVersionId(bc); - toolChainType(bc); + Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(bc); + qt4bc->qtVersionId(); + qt4bc->toolChainType(); } m_rootProjectNode = new Qt4ProFileNode(this, m_fileInfo->fileName(), this); @@ -436,40 +455,42 @@ ProjectExplorer::IBuildConfigurationFactory *Qt4Project::buildConfigurationFacto return m_buildConfigurationFactory; } -void Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVersion *qtversion, +Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString displayName, QtVersion *qtversion, QtVersion::QmakeBuildConfigs qmakeBuildConfiguration, QStringList additionalArguments) { bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild; // Add the buildconfiguration - ProjectExplorer::BuildConfiguration *bc = new ProjectExplorer::BuildConfiguration(buildConfigurationName); + Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this); + bc->setDisplayName(displayName); addBuildConfiguration(bc); - QMakeStep *qmakeStep = new QMakeStep(this, bc); + QMakeStep *qmakeStep = new QMakeStep(bc); bc->insertBuildStep(0, qmakeStep); - MakeStep *makeStep = new MakeStep(this, bc); + MakeStep *makeStep = new MakeStep(bc); bc->insertBuildStep(1, makeStep); - MakeStep* cleanStep = new MakeStep(this, bc); + MakeStep* cleanStep = new MakeStep(bc); cleanStep->setClean(true); bc->insertCleanStep(0, cleanStep); if (!additionalArguments.isEmpty()) - qmakeStep->m_qmakeArgs = additionalArguments; + qmakeStep->setUserArguments(additionalArguments); // set some options for qmake and make if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets - makeStep->setMakeArguments(QStringList() << (debug ? "debug" : "release")); + makeStep->setUserArguments(QStringList() << (debug ? "debug" : "release")); bc->setValue("buildConfiguration", int(qmakeBuildConfiguration)); // Finally set the qt version bool defaultQtVersion = (qtversion == 0); if (defaultQtVersion) - setQtVersion(bc, 0); + bc->setQtVersion(0); else - setQtVersion(bc, qtversion->uniqueId()); + bc->setQtVersion(qtversion->uniqueId()); + return bc; } namespace { @@ -499,61 +520,13 @@ void Qt4Project::scheduleUpdateCodeModel(Qt4ProjectManager::Internal::Qt4ProFile m_proFilesForCodeModelUpdate.append(pro); } -ProjectExplorer::ToolChain *Qt4Project::toolChain(BuildConfiguration *configuration) const -{ - ToolChain::ToolChainType tct = toolChainType(configuration); - return qtVersion(configuration)->toolChain(tct); -} - -QString Qt4Project::makeCommand(BuildConfiguration *configuration) const -{ - ToolChain *tc = toolChain(configuration); - return tc ? tc->makeCommand() : "make"; -} - -#ifdef QTCREATOR_WITH_S60 -static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfig buildConfig, - const QString &type) -{ - QString rc = (buildConfig & QtVersion::DebugBuild) ? - QLatin1String("debug-") : QLatin1String("release-"); - rc += type; - return rc; -} -#endif - -QString Qt4Project::defaultMakeTarget(BuildConfiguration *configuration) const -{ -#ifdef QTCREATOR_WITH_S60 - ToolChain *tc = toolChain(configuration); - if (!tc) - return QString::null; - const QtVersion::QmakeBuildConfig buildConfig - = QtVersion::QmakeBuildConfig(activeBuildConfiguration()->value("buildConfiguration").toInt()); - - switch (tc->type()) { - case ToolChain::GCCE: - case ToolChain::GCCE_GNUPOC: - return symbianMakeTarget(buildConfig, QLatin1String("gcce")); - case ToolChain::RVCT_ARMV5: - return symbianMakeTarget(buildConfig, QLatin1String("armv5")); - case ToolChain::RVCT_ARMV6: - case ToolChain::RVCT_ARMV6_GNUPOC: - return symbianMakeTarget(buildConfig, QLatin1String("armv6")); - default: - break; - } -#else - Q_UNUSED(configuration); -#endif - return QString::null; -} - void Qt4Project::updateCodeModel() { if (debug) qDebug()<<"Qt4Project::updateCodeModel()"; + Qt4BuildConfiguration *activeBC = activeQt4BuildConfiguration(); + CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance() ->getObject<CppTools::CppModelManagerInterface>(); @@ -565,7 +538,7 @@ void Qt4Project::updateCodeModel() QStringList predefinedFrameworkPaths; QByteArray predefinedMacros; - ToolChain *tc = toolChain(activeBuildConfiguration()); + ToolChain *tc = activeBC->toolChain(); QList<HeaderPath> allHeaderPaths; if (tc) { predefinedMacros = tc->predefinedMacros(); @@ -584,7 +557,7 @@ void Qt4Project::updateCodeModel() predefinedIncludePaths.append(headerPath.path()); } - const QHash<QString, QString> versionInfo = qtVersion(activeBuildConfiguration())->versionInfo(); + const QHash<QString, QString> versionInfo = activeBC->qtVersion()->versionInfo(); const QString newQtIncludePath = versionInfo.value(QLatin1String("QT_INSTALL_HEADERS")); predefinedIncludePaths.append(newQtIncludePath); @@ -669,7 +642,7 @@ void Qt4Project::updateCodeModel() } // Add mkspec directory - info.includes.append(qtVersion(activeBuildConfiguration())->mkspecPath()); + info.includes.append(activeBC->qtVersion()->mkspecPath()); info.frameworkPaths = allFrameworkPaths; @@ -683,7 +656,7 @@ void Qt4Project::updateCodeModel() } // Add mkspec directory - allIncludePaths.append(qtVersion(activeBuildConfiguration())->mkspecPath()); + allIncludePaths.append(activeBC->qtVersion()->mkspecPath()); // Dump things out // This is debugging output... @@ -766,7 +739,6 @@ QStringList Qt4Project::frameworkPaths(const QString &fileName) const // */ void Qt4Project::update() { - // TODO Maybe remove this method completely? m_rootProjectNode->update(); //updateCodeModel(); } @@ -841,126 +813,6 @@ Qt4ProFileNode *Qt4Project::rootProjectNode() const return m_rootProjectNode; } -QString Qt4Project::buildDirectory(BuildConfiguration *configuration) const -{ - QString workingDirectory; - if (configuration->value("useShadowBuild").toBool()) - workingDirectory = configuration->value("buildDirectory").toString(); - if (workingDirectory.isEmpty()) - workingDirectory = QFileInfo(file()->fileName()).absolutePath(); - return workingDirectory; -} - -ProjectExplorer::Environment Qt4Project::baseEnvironment(BuildConfiguration *configuration) const -{ - Environment env = useSystemEnvironment(configuration) ? Environment::systemEnvironment() : Environment(); - qtVersion(configuration)->addToEnvironment(env); - ToolChain *tc = toolChain(configuration); - if (tc) - tc->addToEnvironment(env); - return env; -} - -ProjectExplorer::Environment Qt4Project::environment(BuildConfiguration *configuration) const -{ - Environment env = baseEnvironment(configuration); - env.modify(userEnvironmentChanges(configuration)); - return env; -} - -void Qt4Project::setUseSystemEnvironment(BuildConfiguration *configuration, bool b) -{ - if (useSystemEnvironment(configuration) == b) - return; - configuration->setValue("clearSystemEnvironment", !b); - emit environmentChanged(configuration->name()); -} - -bool Qt4Project::useSystemEnvironment(BuildConfiguration *configuration) const -{ - bool b = !(configuration->value("clearSystemEnvironment").isValid() - && configuration->value("clearSystemEnvironment").toBool()); - return b; -} - -QList<ProjectExplorer::EnvironmentItem> Qt4Project::userEnvironmentChanges(BuildConfiguration *configuration) const -{ - return EnvironmentItem::fromStringList(configuration->value("userEnvironmentChanges").toStringList()); -} - -void Qt4Project::setUserEnvironmentChanges(BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff) -{ - QStringList list = EnvironmentItem::toStringList(diff); - if (list == configuration->value("userEnvironmentChanges").toStringList()) - return; - configuration->setValue("userEnvironmentChanges", list); - emit environmentChanged(configuration->name()); -} - -QString Qt4Project::qtDir(BuildConfiguration *configuration) const -{ - QtVersion *version = qtVersion(configuration); - if (version) - return version->versionInfo().value("QT_INSTALL_DATA"); - return QString::null; -} - -QtVersion *Qt4Project::qtVersion(BuildConfiguration *configuration) const -{ - return QtVersionManager::instance()->version(qtVersionId(configuration)); -} - -int Qt4Project::qtVersionId(BuildConfiguration *configuration) const -{ - QtVersionManager *vm = QtVersionManager::instance(); - if (debug) - qDebug()<<"Looking for qtVersion ID of "<<configuration->name(); - int id = 0; - QVariant vid = configuration->value(KEY_QT_VERSION_ID); - if (vid.isValid()) { - id = vid.toInt(); - if (vm->version(id)->isValid()) { - return id; - } else { - configuration->setValue(KEY_QT_VERSION_ID, 0); - return 0; - } - } else { - // Backward compatibilty, we might have just the name: - QString vname = configuration->value("QtVersion").toString(); - if (debug) - qDebug()<<" Backward compatibility reading QtVersion"<<vname; - if (!vname.isEmpty()) { - const QList<QtVersion *> &versions = vm->versions(); - foreach (const QtVersion * const version, versions) { - if (version->name() == vname) { - if (debug) - qDebug()<<"found name in versions"; - configuration->setValue(KEY_QT_VERSION_ID, version->uniqueId()); - return version->uniqueId(); - } - } - } - } - if (debug) - qDebug()<<" using qtversion with id ="<<id; - // Nothing found, reset to default - configuration->setValue(KEY_QT_VERSION_ID, id); - return id; -} - -void Qt4Project::setQtVersion(BuildConfiguration *configuration, int id) -{ - configuration->setValue(KEY_QT_VERSION_ID, id); - emit qtVersionChanged(configuration); - updateActiveRunConfiguration(); -} - -void Qt4Project::setToolChainType(BuildConfiguration *configuration, ProjectExplorer::ToolChain::ToolChainType type) -{ - configuration->setValue("ToolChain", (int)type); - updateActiveRunConfiguration(); -} void Qt4Project::updateActiveRunConfiguration() { @@ -968,76 +820,7 @@ void Qt4Project::updateActiveRunConfiguration() emit targetInformationChanged(); } -ProjectExplorer::ToolChain::ToolChainType Qt4Project::toolChainType(BuildConfiguration *configuration) const -{ - ToolChain::ToolChainType originalType = ToolChain::ToolChainType(configuration->value("ToolChain").toInt()); - ToolChain::ToolChainType type = originalType; - const QtVersion *version = qtVersion(configuration); - if (!version->possibleToolChainTypes().contains(type)) // use default tool chain - type = version->defaultToolchainType(); - if (type != originalType) - const_cast<Qt4Project *>(this)->setToolChainType(configuration, type); - return type; -} - -QString Qt4Project::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version) -{ - int index = list.indexOf("-spec"); - if (index == -1) - index = list.indexOf("-platform"); - if (index == -1) - return QString(); - - ++index; - - if (index >= list.length()) - return QString(); - - QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS"); - if (baseMkspecDir.isEmpty()) - baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs"; - - QString parsedSpec = QDir::cleanPath(list.at(index)); -#ifdef Q_OS_WIN - baseMkspecDir = baseMkspecDir.toLower(); - parsedSpec = parsedSpec.toLower(); -#endif - // if the path is relative it can be - // relative to the working directory (as found in the Makefiles) - // or relatively to the mkspec directory - // if it is the former we need to get the canonical form - // for the other one we don't need to do anything - if (QFileInfo(parsedSpec).isRelative()) { - if(QFileInfo(directory + "/" + parsedSpec).exists()) { - parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec); -#ifdef Q_OS_WIN - parsedSpec = parsedSpec.toLower(); -#endif - } else { - parsedSpec = baseMkspecDir + "/" + parsedSpec; - } - } - - QFileInfo f2(parsedSpec); - while (f2.isSymLink()) { - parsedSpec = f2.symLinkTarget(); - f2.setFile(parsedSpec); - } - - if (parsedSpec.startsWith(baseMkspecDir)) { - parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1); - } else { - QString sourceMkSpecPath = version->sourcePath() + "/mkspecs"; - if (parsedSpec.startsWith(sourceMkSpecPath)) { - parsedSpec = parsedSpec.mid(sourceMkSpecPath.length() + 1); - } - } -#ifdef Q_OS_WIN - parsedSpec = parsedSpec.toLower(); -#endif - return parsedSpec; -} BuildConfigWidget *Qt4Project::createConfigWidget() { @@ -1167,24 +950,6 @@ void Qt4Project::proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *nod } } -QMakeStep *Qt4Project::qmakeStep(ProjectExplorer::BuildConfiguration *bc) const -{ - QMakeStep *qs = 0; - foreach(BuildStep *bs, bc->buildSteps()) - if ((qs = qobject_cast<QMakeStep *>(bs)) != 0) - return qs; - return 0; -} - -MakeStep *Qt4Project::makeStep(ProjectExplorer::BuildConfiguration *bc) const -{ - MakeStep *qs = 0; - foreach(BuildStep *bs, bc->buildSteps()) - if ((qs = qobject_cast<MakeStep *>(bs)) != 0) - return qs; - return 0; -} - bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path) { if (root->path() == path) @@ -1225,88 +990,6 @@ void Qt4Project::invalidateCachedTargetInformation() emit targetInformationChanged(); } -void Qt4Project::emitBuildDirectoryChanged() -{ - emit buildDirectoryChanged(); -} - -// We match -spec and -platfrom separetly -// We ignore -cache, because qmake contained a bug that it didn't -// mention the -cache in the Makefile -// That means changing the -cache option in the additional arguments -// does not automatically rerun qmake. Alas, we could try more -// intelligent matching for -cache, but i guess people rarely -// do use that. - -QStringList Qt4Project::removeSpecFromArgumentList(const QStringList &old) -{ - if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache")) - return old; - QStringList newList; - bool ignoreNext = false; - foreach(const QString &item, old) { - if (ignoreNext) { - ignoreNext = false; - } else if (item == "-spec" || item == "-platform" || item == "-cache") { - ignoreNext = true; - } else { - newList << item; - } - } - return newList; -} - -// returns true if both are equal -bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *bc, const QString &workingDirectory) -{ - QMakeStep *qs = qmakeStep(bc); - if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) { - QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory); - QtVersion *version = qtVersion(bc); - if (version->qmakeCommand() == qmakePath) { - // same qtversion - QPair<QtVersion::QmakeBuildConfigs, QStringList> result = - QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig()); - if (QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()) == result.first) { - // The QMake Build Configuration are the same, - // now compare arguments lists - // we have to compare without the spec/platform cmd argument - // and compare that on its own - QString actualSpec = extractSpecFromArgumentList(qs->m_qmakeArgs, workingDirectory, version); - if (actualSpec.isEmpty()) { - // Easy one the user has choosen not to override the settings - actualSpec = version->mkspec(); - } - - - QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version); - QStringList actualArgs = removeSpecFromArgumentList(qs->m_qmakeArgs); - QStringList parsedArgs = removeSpecFromArgumentList(result.second); - - if (debug) { - qDebug()<<"Actual args:"<<actualArgs; - qDebug()<<"Parsed args:"<<parsedArgs; - qDebug()<<"Actual spec:"<<actualSpec; - qDebug()<<"Parsed spec:"<<parsedSpec; - } - - if (actualArgs == parsedArgs) { - // Specs match exactly - if (actualSpec == parsedSpec) - return true; - // Actual spec is the default one -// qDebug()<<"AS vs VS"<<actualSpec<<version->mkspec(); - if ((actualSpec == version->mkspec() || actualSpec == "default") - && (parsedSpec == version->mkspec() || parsedSpec == "default" || parsedSpec.isEmpty())) - return true; - } - } - } - } - return false; -} - - /*! Handle special case were a subproject of the qt directory is opened, and qt was configured to be built as a shadow build -> also build in the sub- diff --git a/src/plugins/qt4projectmanager/qt4project.h b/src/plugins/qt4projectmanager/qt4project.h index d5529125b7648615e7e32a4f28ffa51c548e9c79..189c999bc4fb5baff0f529bc7f960e9debe685ab 100644 --- a/src/plugins/qt4projectmanager/qt4project.h +++ b/src/plugins/qt4projectmanager/qt4project.h @@ -73,6 +73,7 @@ namespace Internal { class GCCPreprocessor; struct Qt4ProjectFiles; class Qt4ProjectConfigWidget; + class Qt4BuildConfiguration; class CodeModelInfo { @@ -130,7 +131,9 @@ public: QStringList availableCreationTypes() const; QString displayNameForType(const QString &type) const; - bool create(const QString &type) const; + ProjectExplorer::BuildConfiguration *create(const QString &type) const; + ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const; + ProjectExplorer::BuildConfiguration *restore() const; void update(); @@ -155,16 +158,18 @@ public: explicit Qt4Project(Qt4Manager *manager, const QString &proFile); virtual ~Qt4Project(); + Internal::Qt4BuildConfiguration *activeQt4BuildConfiguration() const; + QString name() const; Core::IFile *file() const; ProjectExplorer::IProjectManager *projectManager() const; Qt4Manager *qt4ProjectManager() const; ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; - void addQt4BuildConfiguration(QString buildConfigurationName, - QtVersion *qtversion, - QtVersion::QmakeBuildConfigs qmakeBuildConfiguration, - QStringList additionalArguments = QStringList()); + Internal::Qt4BuildConfiguration *addQt4BuildConfiguration(QString displayName, + QtVersion *qtversion, + QtVersion::QmakeBuildConfigs qmakeBuildConfiguration, + QStringList additionalArguments = QStringList()); QList<Core::IFile *> dependencies(); //NBS remove QList<ProjectExplorer::Project *>dependsOn(); @@ -175,70 +180,31 @@ public: virtual QStringList files(FilesMode fileMode) const; - //building environment - ProjectExplorer::Environment environment(ProjectExplorer::BuildConfiguration *configuration) const; - ProjectExplorer::Environment baseEnvironment(ProjectExplorer::BuildConfiguration *configuration) const; - void setUserEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff); - QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration) const; - bool useSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration) const; - void setUseSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration, bool b); - - virtual QString buildDirectory(ProjectExplorer::BuildConfiguration *configuration) const; // returns the CONFIG variable from the .pro file QStringList qmakeConfig() const; - // returns the qtdir (depends on the current QtVersion) - QString qtDir(ProjectExplorer::BuildConfiguration *configuration) const; - //returns the qtVersion, if the project is set to use the default qt version, then - // that is returned - // to check wheter the project uses the default qt version use qtVersionId - QtVersion *qtVersion(ProjectExplorer::BuildConfiguration *configuration) const; - - // returns the id of the qt version, if the project is using the default qt version - // this function returns 0 - int qtVersionId(ProjectExplorer::BuildConfiguration *configuration) const; - //returns the name of the qt version, might be QString::Null, which means default qt version - // qtVersion is in general the better method to use - QString qtVersionName(ProjectExplorer::BuildConfiguration *configuration) const; - - ProjectExplorer::ToolChain *toolChain(ProjectExplorer::BuildConfiguration *configuration) const; - void setToolChainType(ProjectExplorer::BuildConfiguration *configuration, ProjectExplorer::ToolChain::ToolChainType type); - ProjectExplorer::ToolChain::ToolChainType toolChainType(ProjectExplorer::BuildConfiguration *configuration) const; ProjectExplorer::BuildConfigWidget *createConfigWidget(); QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets(); - void setQtVersion(ProjectExplorer::BuildConfiguration *configuration, int id); - QList<Internal::Qt4ProFileNode *> applicationProFiles() const; - // Those functions are used in a few places. - // The drawback is that we shouldn't actually depend on them beeing always there - // That is generally the stuff that is asked should normally be transfered to - // Qt4Project * - // So that we can later enable people to build qt4projects the way they would like - QMakeStep *qmakeStep(ProjectExplorer::BuildConfiguration *bc) const; - MakeStep *makeStep(ProjectExplorer::BuildConfiguration *bc) const; void notifyChanged(const QString &name); - QString makeCommand(ProjectExplorer::BuildConfiguration *configuration) const; - QString defaultMakeTarget(ProjectExplorer::BuildConfiguration *configuration) const; - // Is called by qmakestep qt4configurationwidget if the settings change // Informs all Qt4RunConfigurations that their cached values are now invalid // the Qt4RunConfigurations will update as soon as asked + + // TODO remove void invalidateCachedTargetInformation(); virtual QByteArray predefinedMacros(const QString &fileName) const; virtual QStringList includePaths(const QString &fileName) const; virtual QStringList frameworkPaths(const QString &fileName) const; - bool compareBuildConfigurationToImportFrom(ProjectExplorer::BuildConfiguration *configuration, const QString &workingDirectory); - - static QStringList removeSpecFromArgumentList(const QStringList &old); - static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version); + // TODO can i remove this? + void updateActiveRunConfiguration(); signals: void targetInformationChanged(); - void qtVersionChanged(ProjectExplorer::BuildConfiguration *); public slots: void update(); @@ -268,17 +234,12 @@ private: static void findProFile(const QString& fileName, Internal::Qt4ProFileNode *root, QList<Internal::Qt4ProFileNode *> &list); static bool hasSubNode(Internal::Qt4PriFileNode *root, const QString &path); - // called by Qt4ProjectConfigWidget - // TODO remove once there's a setBuildDirectory call - void emitBuildDirectoryChanged(); - QList<Internal::Qt4ProFileNode *> m_applicationProFileChange; ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const; void addDefaultBuild(); static QString qmakeVarName(ProjectExplorer::FileType type); - void updateActiveRunConfiguration(); Qt4Manager *m_manager; Internal::Qt4ProFileNode *m_rootProjectNode; diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index a309cc7e628d156c3cfcb80446877637a1bae1d1..13ac7cb6d6c68eba10fc770ebf74555ca18f43f7 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -34,6 +34,7 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" #include "qt4projectmanager.h" +#include "qt4buildconfiguration.h" #include "ui_qt4projectconfigwidget.h" #include <coreplugin/icore.h> @@ -53,8 +54,9 @@ using namespace Qt4ProjectManager::Internal; Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project) : BuildConfigWidget(), - m_pro(project) + m_buildConfiguration(0) { + Q_UNUSED(project); QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); m_detailsContainer = new Utils::DetailsWidget(this); @@ -111,10 +113,9 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget() void Qt4ProjectConfigWidget::updateDetails() { - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - QtVersion *version = m_pro->qtVersion(bc); + QtVersion *version = m_buildConfiguration->qtVersion(); QString versionString; - if (m_pro->qtVersionId(bc) == 0) { + if (m_buildConfiguration->qtVersionId() == 0) { versionString = tr("Default Qt Version (%1)").arg(version->name()); } else if(version){ versionString = version->name(); @@ -126,8 +127,8 @@ void Qt4ProjectConfigWidget::updateDetails() "with tool chain <b>%2</b><br>" "building in <b>%3</b>") .arg(versionString, - ProjectExplorer::ToolChain::toolChainName(m_pro->toolChainType(bc)), - QDir::toNativeSeparators(m_pro->buildDirectory(bc)))); + ProjectExplorer::ToolChain::toolChainName(m_buildConfiguration->toolChainType()), + QDir::toNativeSeparators(m_buildConfiguration->buildDirectory()))); } void Qt4ProjectConfigWidget::manageQtVersions() @@ -142,22 +143,21 @@ QString Qt4ProjectConfigWidget::displayName() const return tr("General"); } -void Qt4ProjectConfigWidget::init(const QString &buildConfiguration) +void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc) { if (debug) - qDebug() << "Qt4ProjectConfigWidget::init() for"<<buildConfiguration; + qDebug() << "Qt4ProjectConfigWidget::init() for"<<bc->displayName(); - m_buildConfiguration = buildConfiguration; - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfiguration); - m_ui->nameLineEdit->setText(bc->displayName()); + m_buildConfiguration = static_cast<Qt4BuildConfiguration *>(bc); + m_ui->nameLineEdit->setText(m_buildConfiguration->displayName()); setupQtVersionsComboBox(); - bool shadowBuild = bc->value("useShadowBuild").toBool(); + bool shadowBuild = m_buildConfiguration->value("useShadowBuild").toBool(); m_ui->shadowBuildCheckBox->setChecked(shadowBuild); m_ui->shadowBuildDirEdit->setEnabled(shadowBuild); m_browseButton->setEnabled(shadowBuild); - m_ui->shadowBuildDirEdit->setPath(m_pro->buildDirectory(bc)); + m_ui->shadowBuildDirEdit->setPath(m_buildConfiguration->buildDirectory()); updateImportLabel(); updateToolChainCombo(); updateDetails(); @@ -165,13 +165,12 @@ void Qt4ProjectConfigWidget::init(const QString &buildConfiguration) void Qt4ProjectConfigWidget::changeConfigName(const QString &newName) { - m_pro->setDisplayNameFor( - m_pro->buildConfiguration(m_buildConfiguration), newName); + m_buildConfiguration->setDisplayName(newName); } void Qt4ProjectConfigWidget::setupQtVersionsComboBox() { - if (m_buildConfiguration.isEmpty()) // not yet initialized + if (!m_buildConfiguration) // not yet initialized return; disconnect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)), @@ -182,7 +181,7 @@ void Qt4ProjectConfigWidget::setupQtVersionsComboBox() m_ui->qtVersionComboBox->clear(); m_ui->qtVersionComboBox->addItem(tr("Default Qt Version (%1)").arg(vm->defaultVersion()->name()), 0); - int qtVersionId = m_pro->qtVersionId(m_pro->buildConfiguration(m_buildConfiguration)); + int qtVersionId = m_buildConfiguration->qtVersionId(); if (qtVersionId == 0) { m_ui->qtVersionComboBox->setCurrentIndex(0); @@ -206,7 +205,7 @@ void Qt4ProjectConfigWidget::setupQtVersionsComboBox() void Qt4ProjectConfigWidget::onBeforeBeforeShadowBuildDirBrowsed() { - QString initialDirectory = QFileInfo(m_pro->file()->fileName()).absolutePath(); + QString initialDirectory = QFileInfo(m_buildConfiguration->project()->file()->fileName()).absolutePath(); if (!initialDirectory.isEmpty()) m_ui->shadowBuildDirEdit->setInitialBrowsePathBackup(initialDirectory); } @@ -216,14 +215,13 @@ void Qt4ProjectConfigWidget::shadowBuildCheckBoxClicked(bool checked) m_ui->shadowBuildDirEdit->setEnabled(checked); m_browseButton->setEnabled(checked); bool b = m_ui->shadowBuildCheckBox->isChecked(); - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - bc->setValue("useShadowBuild", b); + m_buildConfiguration->setValue("useShadowBuild", b); if (b) - bc->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path()); + m_buildConfiguration->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path()); else - bc->setValue("buildDirectory", QVariant(QString::null)); + m_buildConfiguration->setValue("buildDirectory", QVariant(QString::null)); updateDetails(); - m_pro->invalidateCachedTargetInformation(); + m_buildConfiguration->qt4Project()->invalidateCachedTargetInformation(); updateImportLabel(); } @@ -232,10 +230,9 @@ void Qt4ProjectConfigWidget::updateImportLabel() bool visible = false; // we only show if we actually have a qmake and makestep - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - if (m_pro->qmakeStep(bc) && m_pro->makeStep(bc)) { - QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(m_pro->buildDirectory(bc)); - QtVersion *version = m_pro->qtVersion(bc); + if (m_buildConfiguration->qmakeStep() && m_buildConfiguration->makeStep()) { + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(m_buildConfiguration->buildDirectory()); + QtVersion *version = m_buildConfiguration->qtVersion(); // check that there's a makefile if (!qmakePath.isEmpty()) { // and that the qmake path is different from the current version @@ -244,7 +241,7 @@ void Qt4ProjectConfigWidget::updateImportLabel() visible = true; } else { // check that the qmake flags, arguments match - visible = !m_pro->compareBuildConfigurationToImportFrom(bc, m_pro->buildDirectory(bc)); + visible = !m_buildConfiguration->compareToImportFrom(m_buildConfiguration->buildDirectory()); } } else { visible = false; @@ -256,25 +253,23 @@ void Qt4ProjectConfigWidget::updateImportLabel() void Qt4ProjectConfigWidget::shadowBuildLineEditTextChanged() { - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - if (bc->value("buildDirectory").toString() == m_ui->shadowBuildDirEdit->path()) + if (m_buildConfiguration->value("buildDirectory").toString() == m_ui->shadowBuildDirEdit->path()) return; - bc->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path()); + m_buildConfiguration->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path()); // if the directory already exists // check if we have a build in there and // offer to import it updateImportLabel(); - m_pro->invalidateCachedTargetInformation(); + m_buildConfiguration->qt4Project()->invalidateCachedTargetInformation(); updateDetails(); } void Qt4ProjectConfigWidget::importLabelClicked() { - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - if (!m_pro->qmakeStep(bc) || !m_pro->makeStep(bc)) + if (!m_buildConfiguration->qmakeStep() || !m_buildConfiguration->makeStep()) return; - QString directory = m_pro->buildDirectory(bc); + QString directory = m_buildConfiguration->buildDirectory(); if (!directory.isEmpty()) { QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(directory); if (!qmakePath.isEmpty()) { @@ -288,8 +283,8 @@ void Qt4ProjectConfigWidget::importLabelClicked() QPair<QtVersion::QmakeBuildConfigs, QStringList> result = QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig()); QtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first; - QStringList additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second); - QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, version); + QStringList additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second); + QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArgumentList(result.second, directory, version); QString versionSpec = version->mkspec(); if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") { // using the default spec, don't modify additional arguments @@ -299,19 +294,19 @@ void Qt4ProjectConfigWidget::importLabelClicked() } // So we got all the information now apply it... - m_pro->setQtVersion(bc, version->uniqueId()); + m_buildConfiguration->setQtVersion(version->uniqueId()); // Combo box will be updated at the end - QMakeStep *qmakeStep = m_pro->qmakeStep(bc); - qmakeStep->setQMakeArguments(additionalArguments); - MakeStep *makeStep = m_pro->makeStep(bc); + QMakeStep *qmakeStep = m_buildConfiguration->qmakeStep(); + qmakeStep->setUserArguments(additionalArguments); + MakeStep *makeStep = m_buildConfiguration->makeStep(); - bc->setValue("buildConfiguration", int(qmakeBuildConfig)); + m_buildConfiguration->setValue("buildConfiguration", int(qmakeBuildConfig)); // Adjust command line arguments, this is ugly as hell // If we are switching to BuildAll we want "release" in there and no "debug" // or "debug" in there and no "release" // If we are switching to not BuildAl we want neither "release" nor "debug" in there - QStringList makeCmdArguments = makeStep->makeArguments(); + QStringList makeCmdArguments = makeStep->userArguments(); bool debug = qmakeBuildConfig & QtVersion::DebugBuild; if (qmakeBuildConfig & QtVersion::BuildAll) { makeCmdArguments.removeAll(debug ? "release" : "debug"); @@ -321,7 +316,7 @@ void Qt4ProjectConfigWidget::importLabelClicked() makeCmdArguments.removeAll("debug"); makeCmdArguments.removeAll("release"); } - makeStep->setMakeArguments(makeCmdArguments); + makeStep->setUserArguments(makeCmdArguments); } } setupQtVersionsComboBox(); @@ -341,10 +336,10 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString QtVersionManager *vm = QtVersionManager::instance(); bool isValid = vm->version(newQtVersion)->isValid(); m_ui->invalidQtWarningLabel->setVisible(!isValid); - if (newQtVersion != m_pro->qtVersionId(m_pro->buildConfiguration(m_buildConfiguration))) { - m_pro->setQtVersion(m_pro->buildConfiguration(m_buildConfiguration), newQtVersion); + if (newQtVersion != m_buildConfiguration->qtVersionId()) { + m_buildConfiguration->setQtVersion(newQtVersion); updateToolChainCombo(); - m_pro->update(); + m_buildConfiguration->qt4Project()->update(); } updateDetails(); } @@ -352,20 +347,19 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString void Qt4ProjectConfigWidget::updateToolChainCombo() { m_ui->toolChainComboBox->clear(); - ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration); - QList<ProjectExplorer::ToolChain::ToolChainType> toolchains = m_pro->qtVersion(bc)->possibleToolChainTypes(); + QList<ProjectExplorer::ToolChain::ToolChainType> toolchains = m_buildConfiguration->qtVersion()->possibleToolChainTypes(); using namespace ProjectExplorer; foreach (ToolChain::ToolChainType toolchain, toolchains) { m_ui->toolChainComboBox->addItem(ToolChain::toolChainName(toolchain), qVariantFromValue(toolchain)); } m_ui->toolChainComboBox->setEnabled(toolchains.size() > 1); - setToolChain(toolchains.indexOf(m_pro->toolChainType(bc))); + setToolChain(toolchains.indexOf(m_buildConfiguration->toolChainType())); } void Qt4ProjectConfigWidget::selectToolChain(int index) { setToolChain(index); - m_pro->update(); + m_buildConfiguration->qt4Project()->update(); } void Qt4ProjectConfigWidget::setToolChain(int index) @@ -373,7 +367,7 @@ void Qt4ProjectConfigWidget::setToolChain(int index) ProjectExplorer::ToolChain::ToolChainType selectedToolChainType = m_ui->toolChainComboBox->itemData(index, Qt::UserRole).value<ProjectExplorer::ToolChain::ToolChainType>(); - m_pro->setToolChainType(m_pro->buildConfiguration(m_buildConfiguration), selectedToolChainType); + m_buildConfiguration->setToolChainType(selectedToolChainType); if (m_ui->toolChainComboBox->currentIndex() != index) m_ui->toolChainComboBox->setCurrentIndex(index); updateDetails(); diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.h b/src/plugins/qt4projectmanager/qt4projectconfigwidget.h index 5590c29fd64616de521c7cb55605d454765d5937..2f6171a9ad723d96114ae78d6e064b49e4165f07 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.h +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.h @@ -39,6 +39,7 @@ namespace Qt4ProjectManager { class Qt4Project; namespace Internal { +class Qt4BuildConfiguration; namespace Ui { class Qt4ProjectConfigWidget; @@ -52,7 +53,7 @@ public: ~Qt4ProjectConfigWidget(); QString displayName() const; - void init(const QString &buildConfiguration); + void init(ProjectExplorer::BuildConfiguration *bc); private slots: void changeConfigName(const QString &newName); @@ -72,8 +73,7 @@ private: void setToolChain(int index); Ui::Qt4ProjectConfigWidget *m_ui; QAbstractButton *m_browseButton; - Qt4Project *m_pro; - QString m_buildConfiguration; + Qt4BuildConfiguration *m_buildConfiguration; Utils::DetailsWidget *m_detailsContainer; }; diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index b30e3fe8c05e614aaaaeb15fa082751a13607ca0..aafdecbb6ae58d974cbec240f74b6ea0084cd0de 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -28,7 +28,6 @@ HEADERS += qt4projectmanagerplugin.h \ qt4projectmanagerconstants.h \ makestep.h \ qmakestep.h \ - embeddedpropertiespage.h \ qt4runconfiguration.h \ qtmodulesinfo.h \ qt4projectconfigwidget.h \ @@ -39,7 +38,9 @@ HEADERS += qt4projectmanagerplugin.h \ qtuicodemodelsupport.h \ externaleditors.h \ gettingstartedwelcomepagewidget.h \ - gettingstartedwelcomepage.h + gettingstartedwelcomepage.h \ + qt4buildconfiguration.h \ + qmakeparser.h SOURCES += qt4projectmanagerplugin.cpp \ qt4projectmanager.cpp \ qt4project.cpp \ @@ -63,7 +64,6 @@ SOURCES += qt4projectmanagerplugin.cpp \ wizards/qtwizard.cpp \ makestep.cpp \ qmakestep.cpp \ - embeddedpropertiespage.cpp \ qt4runconfiguration.cpp \ qtmodulesinfo.cpp \ qt4projectconfigwidget.cpp \ @@ -74,11 +74,12 @@ SOURCES += qt4projectmanagerplugin.cpp \ qtuicodemodelsupport.cpp \ externaleditors.cpp \ gettingstartedwelcomepagewidget.cpp \ - gettingstartedwelcomepage.cpp + gettingstartedwelcomepage.cpp \ + qt4buildconfiguration.cpp \ + qmakeparser.cpp FORMS += makestep.ui \ qmakestep.ui \ qt4projectconfigwidget.ui \ - embeddedpropertiespage.ui \ qtversionmanager.ui \ showbuildlog.ui \ gettingstartedwelcomepagewidget.ui diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index 19c033a0eeecfd415adf1493bf86a2edda72d671..6af9bbb0f6ab2eb18a79c8368d9dc76607bc931b 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -77,6 +77,9 @@ const char * const QT_SETTINGS_CATEGORY = "L.Qt4"; const char * const QT_SETTINGS_TR_CATEGORY = QT_TRANSLATE_NOOP("Qt4ProjectManager", "Qt4"); const char * const QTVERSION_SETTINGS_PAGE_ID = "Qt Versions"; const char * const QTVERSION_SETTINGS_PAGE_NAME = QT_TRANSLATE_NOOP("Qt4ProjectManager", "Qt Versions"); + +// BuildParser +const char * const BUILD_PARSER_QMAKE = "BuildParser.QMake"; } // namespace Constants } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index 9471e3d1f30c8a8ce4dffd830d56b7fe2b4a8dd2..040691c56a0e3b23b95b99b3a3b251b1f4c1f75c 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -38,7 +38,6 @@ #include "profileeditorfactory.h" #include "qt4projectmanagerconstants.h" #include "qt4project.h" -#include "embeddedpropertiespage.h" #include "qt4runconfiguration.h" #include "profilereader.h" #include "qtversionmanager.h" @@ -46,6 +45,7 @@ #include "externaleditors.h" #include "gettingstartedwelcomepage.h" #include "gettingstartedwelcomepagewidget.h" +#include "qmakeparser.h" #ifdef QTCREATOR_WITH_S60 #include "qt-s60/s60manager.h" @@ -150,6 +150,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * addAutoReleasedObject(new QMakeStepFactory); addAutoReleasedObject(new MakeStepFactory); + addAutoReleasedObject(new QMakeParserFactory); addAutoReleasedObject(new Qt4RunConfigurationFactory); diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index 40759947d647c0648fbf2e0144565fb8531bb7d3..c6ef301676f6c93fd3af248df57310e788f3ab16 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -33,6 +33,7 @@ #include "profilereader.h" #include "qt4nodes.h" #include "qt4project.h" +#include "qt4buildconfiguration.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -80,14 +81,20 @@ Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFile connect(pro, SIGNAL(activeBuildConfigurationChanged()), this, SIGNAL(baseEnvironmentChanged())); - connect(pro, SIGNAL(environmentChanged(QString)), - this, SIGNAL(baseEnvironmentChanged())); +// TODO +// connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)), +// this, SIGNAL(baseEnvironmentChanged())); } Qt4RunConfiguration::~Qt4RunConfiguration() { } +Qt4Project *Qt4RunConfiguration::qt4Project() const +{ + return static_cast<Qt4Project *>(project()); +} + QString Qt4RunConfiguration::type() const { return "Qt4ProjectManager.Qt4RunConfiguration"; @@ -96,9 +103,9 @@ QString Qt4RunConfiguration::type() const bool Qt4RunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *configuration) const { #if defined(QTCREATOR_WITH_S60) || defined(QTCREATOR_WITH_MAEMO) - Qt4Project *pro = qobject_cast<Qt4Project*>(project()); - QTC_ASSERT(pro, return false); - ProjectExplorer::ToolChain::ToolChainType type = pro->toolChainType(configuration); + Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(configuration); + QTC_ASSERT(qt4bc, return false); + ProjectExplorer::ToolChain::ToolChainType type = qt4bc->toolChainType(); #ifdef QTCREATOR_WITH_S60 if (type == ProjectExplorer::ToolChain::WINSCW || type == ProjectExplorer::ToolChain::GCCE @@ -479,7 +486,7 @@ ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const } else if (m_baseEnvironmentBase == Qt4RunConfiguration::SystemEnvironmentBase) { env = ProjectExplorer::Environment::systemEnvironment(); } else if (m_baseEnvironmentBase == Qt4RunConfiguration::BuildEnvironmentBase) { - env = project()->environment(project()->activeBuildConfiguration()); + env = project()->activeBuildConfiguration()->environment(); } if (m_isUsingDyldImageSuffix) { env.set("DYLD_IMAGE_SUFFIX", "_debug"); @@ -554,8 +561,8 @@ void Qt4RunConfiguration::updateTarget() if (m_cachedTargetInformationValid) return; //qDebug()<<"updateTarget"; - Qt4Project *pro = static_cast<Qt4Project *>(project()); - Qt4PriFileNode * priFileNode = static_cast<Qt4Project *>(project())->rootProjectNode()->findProFileFor(m_proFilePath); + Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration(); + Qt4PriFileNode * priFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath); if (!priFileNode) { m_workingDir = QString::null; m_executable = QString::null; @@ -565,11 +572,11 @@ void Qt4RunConfiguration::updateTarget() } ProFileReader *reader = priFileNode->createProFileReader(); reader->setCumulative(false); - reader->setQtVersion(pro->qtVersion(pro->activeBuildConfiguration())); + reader->setQtVersion(qt4bc->qtVersion()); // Find out what flags we pass on to qmake, this code is duplicated in the qmake step - QtVersion::QmakeBuildConfigs defaultBuildConfiguration = pro->qtVersion(pro->activeBuildConfiguration())->defaultBuildConfig(); - QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()->value("buildConfiguration").toInt()); + QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qt4bc->qtVersion()->defaultBuildConfig(); + QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(qt4bc->value("buildConfiguration").toInt()); QStringList addedUserConfigArguments; QStringList removedUserConfigArguments; if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll)) @@ -592,7 +599,7 @@ void Qt4RunConfiguration::updateTarget() // Extract data QDir baseProjectDirectory = QFileInfo(project()->file()->fileName()).absoluteDir(); QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path()); - QDir baseBuildDirectory = project()->buildDirectory(project()->activeBuildConfiguration()); + QDir baseBuildDirectory = project()->activeBuildConfiguration()->buildDirectory(); QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir); //qDebug()<<relSubDir<<baseDir; @@ -653,8 +660,7 @@ void Qt4RunConfiguration::invalidateCachedTargetInformation() QString Qt4RunConfiguration::dumperLibrary() const { - Qt4Project *pro = qobject_cast<Qt4Project *>(project()); - QtVersion *version = pro->qtVersion(pro->activeBuildConfiguration()); + QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion(); if (version) return version->debuggingHelperLibrary(); else @@ -663,8 +669,7 @@ QString Qt4RunConfiguration::dumperLibrary() const QStringList Qt4RunConfiguration::dumperLibraryLocations() const { - Qt4Project *pro = qobject_cast<Qt4Project *>(project()); - QtVersion *version = pro->qtVersion(pro->activeBuildConfiguration()); + QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion(); if (version) return version->debuggingHelperLibraryLocations(); else @@ -685,8 +690,8 @@ Qt4RunConfiguration::BaseEnvironmentBase Qt4RunConfiguration::baseEnvironmentBas } ProjectExplorer::ToolChain::ToolChainType Qt4RunConfiguration::toolChainType() const { - Qt4Project *pro = qobject_cast<Qt4Project *>(project()); - return pro->toolChainType(pro->activeBuildConfiguration()); + Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration(); + return qt4bc->toolChainType(); } /// diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.h b/src/plugins/qt4projectmanager/qt4runconfiguration.h index 9fddd5efa2ec2877f3948ff25453e9f531fde4b0..ce16df7c16a3dfecc3c600e85b577a64ab217294 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.h +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.h @@ -65,6 +65,8 @@ public: Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath); virtual ~Qt4RunConfiguration(); + Qt4Project *qt4Project() const; + virtual QString type() const; virtual bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const; virtual QWidget *configurationWidget(); diff --git a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp index 62a0f1755352b9d56e910237178a447c2ef16982..029028a2542e10ed806d8d39b1c38c0672faa49e 100644 --- a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp +++ b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp @@ -1,4 +1,5 @@ #include "qtuicodemodelsupport.h" +#include "qt4buildconfiguration.h" #include "qt4project.h" #include <designer/formwindoweditor.h> @@ -88,9 +89,10 @@ void Qt4UiCodeModelSupport::setFileName(const QString &name) bool Qt4UiCodeModelSupport::runUic(const QString &ui) const { + Qt4BuildConfiguration *qt4bc = m_project->activeQt4BuildConfiguration(); QProcess uic; - uic.setEnvironment(m_project->environment(m_project->activeBuildConfiguration()).toStringList()); - uic.start(m_project->qtVersion(m_project->activeBuildConfiguration())->uicCommand(), QStringList(), QIODevice::ReadWrite); + uic.setEnvironment(m_project->activeBuildConfiguration()->environment().toStringList()); + uic.start(qt4bc->qtVersion()->uicCommand(), QStringList(), QIODevice::ReadWrite); uic.waitForStarted(); uic.write(ui.toUtf8()); uic.closeWriteChannel(); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 625bb8bee562e45b57fc5d80ade256e9da3154c3..3a8c5e9437c10864a6d81b89990e1ceb9f3629d7 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -177,6 +177,7 @@ BaseTextEditor::BaseTextEditor(QWidget *parent) d->m_overlay = new TextEditorOverlay(this); d->m_searchResultOverlay = new TextEditorOverlay(this); + d->m_searchResultUnderlay = new TextEditorOverlay(this); d->setupDocumentSignals(d->m_document); d->setupDocumentSignals(d->m_document); @@ -230,6 +231,10 @@ BaseTextEditor::BaseTextEditor(QWidget *parent) slotCursorPositionChanged(); setFrameStyle(QFrame::NoFrame); + d->m_delayedUpdateTimer = new QTimer(this); + d->m_delayedUpdateTimer->setSingleShot(true); + connect(d->m_delayedUpdateTimer, SIGNAL(timeout()), viewport(), SLOT(update())); + connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(currentEditorChanged(Core::IEditor*))); } @@ -1822,7 +1827,9 @@ QTextBlock BaseTextEditor::collapsedBlockAt(const QPoint &pos, QRect *box) const return QTextBlock(); } -void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block) +void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block, + TextEditorOverlay *overlay, + QVector<QTextLayout::FormatRange> *selections ) { if (m_searchExpr.isEmpty()) return; @@ -1843,9 +1850,19 @@ void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block) if (m_findScope.isNull() || (block.position() + idx >= m_findScope.selectionStart() && block.position() + idx + l <= m_findScope.selectionEnd())) { - m_searchResultOverlay->addOverlaySelection(block.position() + idx, - block.position() + idx + l, - m_searchResultFormat.background().color()); + if (selections) { + QTextLayout::FormatRange selection; + selection.start = idx; + selection.length = l; + selection.format = m_searchResultFormat; + selections->append(selection); + } + + overlay->addOverlaySelection(block.position() + idx, + block.position() + idx + l, + m_searchResultFormat.background().color().darker(120), + QColor()); + } } } @@ -2075,6 +2092,8 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QPen cursor_pen; d->m_searchResultOverlay->clear(); + d->m_searchResultUnderlay->clear(); + while (block.isValid()) { QRectF r = blockBoundingRect(block).translated(offset); @@ -2169,7 +2188,9 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) selections.append(o); } } - d->highlightSearchResults(block); + + d->highlightSearchResults(block, d->m_searchResultUnderlay, &selections); + d->m_searchResultOverlay->m_selections.append(d->m_searchResultUnderlay->m_selections); selections += prioritySelections; bool drawCursor = ((editable || true) // we want the cursor in read-only mode @@ -2191,6 +2212,12 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) } } + if (d->m_searchResultUnderlay && !d->m_searchExpr.isEmpty()) { + d->m_searchResultUnderlay->fill(&painter, + d->m_searchResultFormat.background().color(), + e->rect()); + d->m_searchResultUnderlay->clear(); + } layout->draw(&painter, offset, selections, er); @@ -2208,6 +2235,9 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) cursor_pen = painter.pen(); } + } else if (r.bottom() >= er.top()-10 && r.top() <= er.bottom()+10) { + // search result overlays can cover adjacent blocks + d->highlightSearchResults(block, d->m_searchResultOverlay); } offset.ry() += r.height(); @@ -2421,11 +2451,13 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) painter.drawLine(QPointF(lineX, 0), QPointF(lineX, viewport()->height())); } - if (d->m_searchResultOverlay) - d->m_searchResultOverlay->paint(&painter, e->rect()); - if (d->m_overlay && d->m_overlay->isVisible()) d->m_overlay->paint(&painter, e->rect()); + + if (d->m_searchResultOverlay && !d->m_searchExpr.isEmpty()) + d->m_searchResultOverlay->paint(&painter, e->rect()); +// d->m_searchResultOverlay->paintInverted(&painter, e->rect(), d->m_searchResultFormat.background().color()); + // draw the cursor last, on top of everything @@ -3411,14 +3443,8 @@ void BaseTextEditor::wheelEvent(QWheelEvent *e) void BaseTextEditor::zoomIn(int range) { - d->clearVisibleCollapsedBlock(); - QFont f = font(); - const int newSize = f.pointSize() + range; - if (newSize <= 0) - return; - emit requestFontSize(newSize); -// f.setPointSize(newSize); -// setFont(f); + d->clearVisibleCollapsedBlock(); + emit requestFontZoom(range*10); } void BaseTextEditor::zoomOut(int range) @@ -3426,6 +3452,11 @@ void BaseTextEditor::zoomOut(int range) zoomIn(-range); } +void BaseTextEditor::zoomReset() +{ + emit requestZoomReset(); +} + bool BaseTextEditor::isElectricCharacter(const QChar &) const { return false; @@ -3935,9 +3966,9 @@ void BaseTextEditor::highlightSearchResults(const QString &txt, Find::IFindSuppo d->m_searchExpr.setCaseSensitivity((findFlags & Find::IFindSupport::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive); d->m_findFlags = findFlags; - viewport()->update(); -} + d->m_delayedUpdateTimer->start(10); +} void BaseTextEditor::setFindScope(const QTextCursor &scope) { @@ -4180,6 +4211,14 @@ void BaseTextEditor::changeEvent(QEvent *e) } } +void BaseTextEditor::focusOutEvent(QFocusEvent *e) +{ + QPlainTextEdit::focusOutEvent(e); + if (viewport()->cursor().shape() == Qt::BlankCursor) + viewport()->setCursor(Qt::IBeamCursor); +} + + void BaseTextEditor::maybeSelectLine() { QTextCursor cursor = textCursor(); @@ -4239,6 +4278,21 @@ QList<QTextEdit::ExtraSelection> BaseTextEditor::extraSelections(ExtraSelectionK return d->m_extraSelections[kind]; } +QString BaseTextEditor::extraSelectionTooltip(int pos) const +{ + QList<QTextEdit::ExtraSelection> all; + for (int i = 0; i < NExtraSelectionKinds; ++i) { + const QList<QTextEdit::ExtraSelection> &sel = d->m_extraSelections[i]; + for (int j = 0; j < sel.size(); ++j) { + const QTextEdit::ExtraSelection &s = sel.at(j); + if (s.cursor.selectionStart() <= pos + && s.cursor.selectionEnd() >= pos + && !s.format.toolTip().isEmpty()) + return s.format.toolTip(); + } + } + return QString(); +} // the blocks list must be sorted void BaseTextEditor::setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange> &blocks) diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index a9495b747e86d1a20d05caf93a3467205a76505f..6c135b86f3caf6904c41cc37b20954c1d729732a 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -382,6 +382,7 @@ public slots: void zoomIn(int range = 1); void zoomOut(int range = 1); + void zoomReset(); void cutLine(); void deleteLine(); @@ -417,6 +418,7 @@ protected: void keyPressEvent(QKeyEvent *e); void wheelEvent(QWheelEvent *e); void changeEvent(QEvent *e); + void focusOutEvent(QFocusEvent *e); void showEvent(QShowEvent *); @@ -471,12 +473,14 @@ public: ParenthesesMatchingSelection, CodeWarningsSelection, CodeSemanticsSelection, - OtherSelection, + UnusedSymbolSelection, FakeVimSelection, + OtherSelection, NExtraSelectionKinds }; void setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections); QList<QTextEdit::ExtraSelection> extraSelections(ExtraSelectionKind kind) const; + QString extraSelectionTooltip(int pos) const; struct BlockRange { @@ -577,7 +581,8 @@ protected slots: virtual void slotUpdateBlockNotify(const QTextBlock &); signals: - void requestFontSize(int pointSize); + void requestFontZoom(int zoom); + void requestZoomReset(); void requestBlockUpdate(const QTextBlock &); void requestAutoCompletion(TextEditor::ITextEditable *editor, bool forced); void requestQuickFix(TextEditor::ITextEditable *editor); diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index f7c7ed3a6b84126529c5282c37f2cdcff77a85b3..39bb0dfedbc5978c7dfc584a3ecf2c953e1d454e 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -189,6 +189,7 @@ public: TextEditorOverlay *m_overlay; TextEditorOverlay *m_searchResultOverlay; + TextEditorOverlay *m_searchResultUnderlay; QBasicTimer collapsedBlockTimer; int visibleCollapsedBlockNumber; @@ -222,7 +223,10 @@ public: QTextCharFormat m_searchScopeFormat; QTextCharFormat m_currentLineFormat; QTextCharFormat m_currentLineNumberFormat; - void highlightSearchResults(const QTextBlock &block); + void highlightSearchResults(const QTextBlock &block, + TextEditorOverlay *overlay, + QVector<QTextLayout::FormatRange> *selections = 0); + QTimer *m_delayedUpdateTimer; BaseTextEditorEditable *m_editable; diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 0906a9016fddf81defb000f26e5969c4d48e0013..aca646ccf93c0885326cfb979c13fa59a978f4b4 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -40,7 +40,7 @@ static const char * const showWrapColumnKey = "ShowWrapColumn"; static const char * const wrapColumnKey = "WrapColumn"; static const char * const visualizeWhitespaceKey = "VisualizeWhitespace"; static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers"; -static const char * const highlightCurrentLineKey = "HighlightCurrentLineKey"; +static const char * const highlightCurrentLineKey = "HighlightCurrentLine2Key"; static const char * const highlightBlocksKey = "HighlightBlocksKey"; static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey"; static const char * const mouseNavigationKey = "MouseNavigation"; @@ -56,7 +56,7 @@ DisplaySettings::DisplaySettings() : m_wrapColumn(80), m_visualizeWhitespace(false), m_displayFoldingMarkers(true), - m_highlightCurrentLine(true), + m_highlightCurrentLine(false), m_highlightBlocks(false), m_animateMatchingParentheses(true), m_mouseNavigation(true), diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index 8631645a4859bc3bd077c42412414b254c0e39be..cf14545c8f72d01d884b24df171c5f7db833f93f 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -39,6 +39,7 @@ static const char *fontFamilyKey = "FontFamily"; static const char *fontSizeKey = "FontSize"; +static const char *fontZoomKey= "FontZoom"; static const char *antialiasKey = "FontAntialias"; static const char *schemeFileNameKey = "ColorScheme"; @@ -65,6 +66,7 @@ namespace TextEditor { FontSettings::FontSettings() : m_family(defaultFixedFontFamily()), m_fontSize(DEFAULT_FONT_SIZE), + m_fontZoom(100), m_antialias(DEFAULT_ANTIALIAS) { } @@ -73,6 +75,7 @@ void FontSettings::clear() { m_family = defaultFixedFontFamily(); m_fontSize = DEFAULT_FONT_SIZE; + m_fontZoom = 100; m_antialias = DEFAULT_ANTIALIAS; m_scheme.clear(); } @@ -87,6 +90,9 @@ void FontSettings::toSettings(const QString &category, if (m_fontSize != DEFAULT_FONT_SIZE || s->contains(QLatin1String(fontSizeKey))) s->setValue(QLatin1String(fontSizeKey), m_fontSize); + if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey))) + s->setValue(QLatin1String(fontZoomKey), m_fontZoom); + if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey))) s->setValue(QLatin1String(antialiasKey), m_antialias); @@ -110,6 +116,7 @@ bool FontSettings::fromSettings(const QString &category, m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString(); m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt(); + m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt(); m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool(); if (s->contains(group + QLatin1String(schemeFileNameKey))) { @@ -144,6 +151,7 @@ bool FontSettings::equals(const FontSettings &f) const return m_family == f.m_family && m_schemeFileName == f.m_schemeFileName && m_fontSize == f.m_fontSize + && m_fontZoom == f.m_fontZoom && m_antialias == f.m_antialias && m_scheme == f.m_scheme; } @@ -160,7 +168,7 @@ QTextCharFormat FontSettings::toTextCharFormat(const QString &category) const if (category == textCategory) { tf.setFontFamily(m_family); - tf.setFontPointSize(m_fontSize); + tf.setFontPointSize(m_fontSize * m_fontZoom / 100); tf.setFontStyleStrategy(m_antialias ? QFont::PreferAntialias : QFont::NoAntialias); } @@ -213,6 +221,19 @@ void FontSettings::setFontSize(int size) m_fontSize = size; } +/** + * Returns the configured font zoom factor in percent. + */ +int FontSettings::fontZoom() const +{ + return m_fontZoom; +} + +void FontSettings::setFontZoom(int zoom) +{ + m_fontZoom = zoom; +} + /** * Returns the configured antialiasing behavior. */ diff --git a/src/plugins/texteditor/fontsettings.h b/src/plugins/texteditor/fontsettings.h index 38ffa2d66e2a7098881cf57e55f562d109c5e9c5..88f27883296b67c52c107542b58fc7cce978c405 100644 --- a/src/plugins/texteditor/fontsettings.h +++ b/src/plugins/texteditor/fontsettings.h @@ -78,6 +78,9 @@ public: int fontSize() const; void setFontSize(int size); + int fontZoom() const; + void setFontZoom(int zoom); + QFont font() const { return QFont(family(), fontSize()); } @@ -105,6 +108,7 @@ private: QString m_family; QString m_schemeFileName; int m_fontSize; + int m_fontZoom; bool m_antialias; ColorScheme m_scheme; }; diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 18880da65f615a5bc786ae5ecf7540e9ead4e7e2..1795158a6eb29cc4b0f7e89e8da4209ab5925766 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -258,7 +258,7 @@ QColor FormatDescription::foreground() const return m_format.foreground(); } } else if (m_name == QLatin1String(Constants::C_OCCURRENCES_UNUSED)) { - return Qt::lightGray; + return Qt::darkYellow; } else if (m_name == QLatin1String(Constants::C_PARENTHESES)) { return QColor(Qt::red); } @@ -360,6 +360,7 @@ QWidget *FontSettingsPage::createPage(QWidget *parent) d_ptr->ui.familyComboBox->setCurrentIndex(idx); d_ptr->ui.antialias->setChecked(d_ptr->m_value.antialias()); + d_ptr->ui.zoomSpinBox->setValue(d_ptr->m_value.fontZoom()); d_ptr->ui.schemeEdit->setFormatDescriptions(d_ptr->m_descriptions); d_ptr->ui.schemeEdit->setBaseFont(d_ptr->m_value.font()); @@ -367,10 +368,12 @@ QWidget *FontSettingsPage::createPage(QWidget *parent) connect(d_ptr->ui.familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString))); connect(d_ptr->ui.sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString))); + connect(d_ptr->ui.zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged())); connect(d_ptr->ui.schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int))); connect(d_ptr->ui.copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme())); connect(d_ptr->ui.deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme())); + updatePointSizes(); refreshColorSchemeList(); d_ptr->m_lastValue = d_ptr->m_value; @@ -421,6 +424,11 @@ void FontSettingsPage::fontSizeSelected(const QString &sizeString) } } +void FontSettingsPage::fontZoomChanged() +{ + d_ptr->m_value.setFontZoom(d_ptr->ui.zoomSpinBox->value()); +} + void FontSettingsPage::colorSchemeSelected(int index) { bool readOnly = true; diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index 89f4522fbdb79cd98c5132964fb0a8c7cd32a338..4e555c263be30afd0adfbf9c2400ff8e987ca5d5 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -111,6 +111,7 @@ private slots: void delayedChange(); void fontFamilySelected(const QString &family); void fontSizeSelected(const QString &sizeString); + void fontZoomChanged(); void colorSchemeSelected(int index); void copyColorScheme(); void copyColorScheme(const QString &name); diff --git a/src/plugins/texteditor/fontsettingspage.ui b/src/plugins/texteditor/fontsettingspage.ui index cb7f5d1fb6a5cf5d2f83dce2934fe3ad7700eede..bef6cc789a9f6bd2bd8bd618eefabac77417f7ba 100644 --- a/src/plugins/texteditor/fontsettingspage.ui +++ b/src/plugins/texteditor/fontsettingspage.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>344</width> + <width>402</width> <height>306</height> </rect> </property> @@ -84,9 +84,12 @@ <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> <property name="sizeHint" stdset="0"> <size> - <width>40</width> + <width>20</width> <height>20</height> </size> </property> @@ -99,6 +102,45 @@ </property> </widget> </item> + <item row="0" column="7"> + <widget class="QSpinBox" name="zoomSpinBox"> + <property name="suffix"> + <string>%</string> + </property> + <property name="minimum"> + <number>10</number> + </property> + <property name="maximum"> + <number>300</number> + </property> + <property name="singleStep"> + <number>10</number> + </property> + <property name="value"> + <number>100</number> + </property> + </widget> + </item> + <item row="0" column="8"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="6"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Zoom:</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 9da54ddc10c28b88b459d7d0df7fb6159ec5e9ec..e586a54cb3fcec3e761e3d291053d2b7ae2d7354 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -73,6 +73,7 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context, m_selectEncodingAction(0), m_increaseFontSizeAction(0), m_decreaseFontSizeAction(0), + m_resetFontSizeAction(0), m_gotoBlockStartAction(0), m_gotoBlockEndAction(0), m_gotoBlockStartWithSelectionAction(0), @@ -221,6 +222,12 @@ void TextEditorActionHandler::createActions() connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize())); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); + m_resetFontSizeAction = new QAction(tr("Reset Font Size"), this); + command = am->registerAction(m_resetFontSizeAction, Constants::RESET_FONT_SIZE, m_contextId); + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+0"))); + connect(m_resetFontSizeAction, SIGNAL(triggered()), this, SLOT(resetFontSize())); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); + m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this); command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+["))); @@ -422,6 +429,7 @@ FUNCTION(collapse) FUNCTION(expand) FUNCTION2(increaseFontSize, zoomIn) FUNCTION2(decreaseFontSize, zoomOut) +FUNCTION2(resetFontSize, zoomReset) FUNCTION(selectEncoding) FUNCTION(gotoBlockStart) FUNCTION(gotoBlockEnd) diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index ca9a878ca1e544646f3228cb1d1454aaabb0b871..661932e98d24ead7105a633cd8de791ff5334c25 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -104,6 +104,7 @@ private slots: void selectEncoding(); void increaseFontSize(); void decreaseFontSize(); + void resetFontSize(); void gotoBlockStart(); void gotoBlockEnd(); void gotoBlockStartWithSelection(); @@ -139,6 +140,7 @@ private: QAction *m_selectEncodingAction; QAction *m_increaseFontSizeAction; QAction *m_decreaseFontSizeAction; + QAction *m_resetFontSizeAction; QAction *m_gotoBlockStartAction; QAction *m_gotoBlockEndAction; QAction *m_gotoBlockStartWithSelectionAction; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index c2818dd21f9f34f0d91946da367d089d4cbc1a72..d21b4f8c2e1a8fd24e269ae069314b8a65b0b1bd 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -49,6 +49,7 @@ const char * const UN_COLLAPSE_ALL = "TextEditor.UnCollapseAll"; const char * const AUTO_INDENT_SELECTION = "TextEditor.AutoIndentSelection"; const char * const INCREASE_FONT_SIZE = "TextEditor.IncreaseFontSize"; const char * const DECREASE_FONT_SIZE = "TextEditor.DecreaseFontSize"; +const char * const RESET_FONT_SIZE = "TextEditor.ResetFontSize"; const char * const GOTO_BLOCK_START = "TextEditor.GotoBlockStart"; const char * const GOTO_BLOCK_START_WITH_SELECTION = "TextEditor.GotoBlockStartWithSelection"; const char * const GOTO_BLOCK_END = "TextEditor.GotoBlockEnd"; diff --git a/src/plugins/texteditor/texteditoroverlay.cpp b/src/plugins/texteditor/texteditoroverlay.cpp index 5c9d621a836b6ee6bd53fe382605d6485d9e4c20..1e3065ca3e38ecc051ca439ce461c4cd10d78d89 100644 --- a/src/plugins/texteditor/texteditoroverlay.cpp +++ b/src/plugins/texteditor/texteditoroverlay.cpp @@ -36,7 +36,8 @@ void TextEditorOverlay::clear() update(); } -void TextEditorOverlay::addOverlaySelection(int begin, int end, const QColor &color, bool lockSize) +void TextEditorOverlay::addOverlaySelection(int begin, int end, + const QColor &fg, const QColor &bg, bool lockSize) { if (end < begin) return; @@ -44,7 +45,8 @@ void TextEditorOverlay::addOverlaySelection(int begin, int end, const QColor &co QTextDocument *document = m_editor->document(); OverlaySelection selection; - selection.m_color = color; + selection.m_fg = fg; + selection.m_bg = bg; selection.m_cursor_begin = QTextCursor(document); selection.m_cursor_begin.setPosition(begin); @@ -60,9 +62,10 @@ void TextEditorOverlay::addOverlaySelection(int begin, int end, const QColor &co } -void TextEditorOverlay::addOverlaySelection(const QTextCursor &cursor, const QColor &color, bool lockSize) +void TextEditorOverlay::addOverlaySelection(const QTextCursor &cursor, + const QColor &fg, const QColor &bg, bool lockSize) { - addOverlaySelection(cursor.selectionStart(), cursor.selectionEnd(), color, lockSize); + addOverlaySelection(cursor.selectionStart(), cursor.selectionEnd(), fg, bg, lockSize); } QRect TextEditorOverlay::rect() const @@ -70,20 +73,21 @@ QRect TextEditorOverlay::rect() const return m_viewport->rect(); } -void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, const QColor &color) +QPainterPath TextEditorOverlay::createSelectionPath(const QTextCursor &begin, const QTextCursor &end, + const QRect &clip) { if (begin.isNull() || end.isNull() || begin.position() > end.position()) - return; + return QPainterPath(); QPointF offset = m_editor->contentOffset(); QRect viewportRect = rect(); QTextDocument *document = m_editor->document(); - if (m_editor->blockBoundingGeometry(begin.block()).translated(offset).top() > viewportRect.bottom() + 10 - || m_editor->blockBoundingGeometry(end.block()).translated(offset).bottom() < viewportRect.top() - 10 + if (m_editor->blockBoundingGeometry(begin.block()).translated(offset).top() > clip.bottom() + 10 + || m_editor->blockBoundingGeometry(end.block()).translated(offset).bottom() < clip.top() - 10 ) - return; // nothing of the selection is visible + return QPainterPath(); // nothing of the selection is visible QTextBlock block = begin.block(); @@ -154,11 +158,12 @@ void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &beg if (selection.isEmpty()) - return; + return QPainterPath(); QVector<QPointF> points; const int margin = m_borderWidth/2; + const int extra = 0; points += (selection.at(0).topLeft() + selection.at(0).topRight()) / 2 + QPointF(0, -margin); points += selection.at(0).topRight() + QPointF(margin+1, -margin); @@ -178,8 +183,8 @@ void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &beg } points += selection.at(selection.count()-1).topRight() + QPointF(margin+1, 0); - points += selection.at(selection.count()-1).bottomRight() + QPointF(margin+1, margin+1); - points += selection.at(selection.count()-1).bottomLeft() + QPointF(-margin, margin+1); + points += selection.at(selection.count()-1).bottomRight() + QPointF(margin+1, margin+extra); + points += selection.at(selection.count()-1).bottomLeft() + QPointF(-margin, margin+extra); points += selection.at(selection.count()-1).topLeft() + QPointF(-margin, 0); for(int i = selection.count()-2; i > 0; --i) { @@ -188,11 +193,11 @@ void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &beg selection.at(i).left(), selection.at(i+1).left()) - margin; - points += QPointF(x, selection.at(i).bottom()+1); + points += QPointF(x, selection.at(i).bottom()+extra); points += QPointF(x, selection.at(i).top()); } - points += selection.at(0).bottomLeft() + QPointF(-margin, 1); + points += selection.at(0).bottomLeft() + QPointF(-margin, extra); points += selection.at(0).topLeft() + QPointF(-margin, -margin); @@ -223,21 +228,60 @@ void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &beg previous = points.at(i); } path.closeSubpath(); + path.translate(offset); + return path; +} + +void TextEditorOverlay::paintSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, + const QColor &fg, const QColor &bg) +{ + if (begin.isNull() || end.isNull() || begin.position() > end.position()) + return; + + QPainterPath path = createSelectionPath(begin, end, m_editor->viewport()->rect()); painter->save(); - QPen pen(color, m_borderWidth); + QColor penColor = fg; + penColor.setAlpha(220); + QPen pen(penColor, m_borderWidth); painter->translate(-.5, -.5); - QColor brush = color; - brush.setAlpha(30); + + QRectF pathRect = path.controlPointRect(); + + if (bg.isValid()) { + QLinearGradient linearGrad(pathRect.topLeft(), pathRect.bottomLeft()); + QColor col1 = fg.lighter(150); + col1.setAlpha(20); + QColor col2 = fg; + col2.setAlpha(80); + linearGrad.setColorAt(0, col1); + linearGrad.setColorAt(1, col2); + painter->setBrush(QBrush(linearGrad)); + } else { + painter->setBrush(QBrush()); + } + painter->setRenderHint(QPainter::Antialiasing); pen.setJoinStyle(Qt::RoundJoin); painter->setPen(pen); - painter->setBrush(brush); - path.translate(offset); painter->drawPath(path); painter->restore(); } +void TextEditorOverlay::fillSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, + const QColor &color) +{ + if (begin.isNull() || end.isNull() || begin.position() > end.position()) + return; + + QPainterPath path = createSelectionPath(begin, end, m_editor->viewport()->rect()); + + painter->save(); + painter->translate(-.5, -.5); + painter->setRenderHint(QPainter::Antialiasing); + painter->fillPath(path, color); + painter->restore(); +} void TextEditorOverlay::paint(QPainter *painter, const QRect &clip) { @@ -252,10 +296,89 @@ void TextEditorOverlay::paint(QPainter *painter, const QRect &clip) paintSelection(painter, selection.m_cursor_begin, selection.m_cursor_end, - selection.m_color + selection.m_fg, + selection.m_bg ); } } +void TextEditorOverlay::fill(QPainter *painter, const QColor &color, const QRect &clip) +{ + Q_UNUSED(clip); + for (int i = 0; i < m_selections.size(); ++i) { + const OverlaySelection &selection = m_selections.at(i); + if (selection.m_fixedLength >= 0 + && selection.m_cursor_end.position() - selection.m_cursor_begin.position() + != selection.m_fixedLength) + continue; + + fillSelection(painter, + selection.m_cursor_begin, + selection.m_cursor_end, + color + ); + } +} + +void TextEditorOverlay::paintInverted(QPainter *painter, const QRect &clip, const QColor &color) +{ + QPainterPath path; + for (int i = 0; i < m_selections.size(); ++i) { + const OverlaySelection &selection = m_selections.at(i); + if (selection.m_fixedLength >= 0 + && selection.m_cursor_end.position() - selection.m_cursor_begin.position() + != selection.m_fixedLength) + continue; + path.addPath(createSelectionPath(selection.m_cursor_begin, selection.m_cursor_end, clip)); + } + + QRect viewportRect = m_editor->viewport()->rect(); + QColor background = Qt::black; + background.setAlpha(30); + + if (path.isEmpty()) { + painter->fillRect(viewportRect, background); + return; + } + +// QPainterPath all; +// all.addRect(viewportRect); +// QPainterPath inversion = all.subtracted(path); + + painter->save(); + QColor penColor = color; + penColor.setAlpha(220); + QPen pen(penColor, m_borderWidth); + QColor brush = color; + brush.setAlpha(30); + painter->translate(-.5, -.5); + +// painter->setRenderHint(QPainter::Antialiasing); + //pen.setJoinStyle(Qt::RoundJoin); + painter->setPen(pen); + painter->setBrush(QBrush()); + painter->drawPath(path); + + painter->translate(.5, .5); + + QPixmap shadow(clip.size()); + shadow.fill(background); + QPainter pmp(&shadow); + pmp.translate(-.5, -.5); + pmp.setRenderHint(QPainter::Antialiasing); + pmp.setCompositionMode(QPainter::CompositionMode_Source); + path.translate(-clip.topLeft()); + pen.setColor(Qt::transparent); + pmp.setPen(pen); + pmp.setBrush(Qt::transparent); + pmp.drawPath(path); + pmp.end(); + + painter->drawPixmap(clip.topLeft(), shadow); + +// painter->fillPath(inversion, background); + painter->restore(); +} + diff --git a/src/plugins/texteditor/texteditoroverlay.h b/src/plugins/texteditor/texteditoroverlay.h index 6516b69bca971826f140a0b67c9cd56abdad6a03..798367764348bc84c730e408f1af8381601420d2 100644 --- a/src/plugins/texteditor/texteditoroverlay.h +++ b/src/plugins/texteditor/texteditoroverlay.h @@ -11,7 +11,8 @@ struct TEXTEDITOR_EXPORT OverlaySelection { OverlaySelection():m_fixedLength(-1){} QTextCursor m_cursor_begin; QTextCursor m_cursor_end; - QColor m_color; + QColor m_fg; + QColor m_bg; int m_fixedLength; }; @@ -21,7 +22,9 @@ Q_OBJECT BaseTextEditor *m_editor; QWidget *m_viewport; +public: QList<OverlaySelection> m_selections; +private: bool m_visible; int m_borderWidth; @@ -31,6 +34,9 @@ public: QRect rect() const; void paint(QPainter *painter, const QRect &clip); + void fill(QPainter *painter, const QColor &color, const QRect &clip); + + void paintInverted(QPainter *painter, const QRect &clip, const QColor &color); bool isVisible() const { return m_visible; } void setVisible(bool b); @@ -40,13 +46,17 @@ public: void update(); void clear(); - void addOverlaySelection(const QTextCursor &cursor, const QColor &color, bool lockSize = false); - void addOverlaySelection(int begin, int end, const QColor &color, bool lockSize = false); + void addOverlaySelection(const QTextCursor &cursor, const QColor &fg, const QColor &bg, bool lockSize = false); + void addOverlaySelection(int begin, int end, const QColor &fg, const QColor &bg, bool lockSize = false); inline bool isEmpty() const { return m_selections.isEmpty(); } private: - void paintSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, const QColor &color); + QPainterPath createSelectionPath(const QTextCursor &begin, const QTextCursor &end, const QRect& clip); + void paintSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, + const QColor &fg, const QColor &bg); + void fillSelection(QPainter *painter, const QTextCursor &begin, const QTextCursor &end, + const QColor &color); }; diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index 5e6f5ae091996f5a7db5ee0625b7db2a44030776..ea2b6e0168f2e709d437870fae4307c05d3d1d1e 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -187,7 +187,8 @@ void TextEditorPlugin::invokeQuickFix() void TextEditorPlugin::updateSearchResultsFont(const FontSettings &settings) { if (m_searchResultWindow) - m_searchResultWindow->setTextEditorFont(QFont(settings.family(), settings.fontSize())); + m_searchResultWindow->setTextEditorFont(QFont(settings.family(), + settings.fontSize() * settings.fontZoom() / 100)); } Q_EXPORT_PLUGIN(TextEditorPlugin) diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 66e71706a7a63d691064bca7915f9ab6bfe98ce8..52ab3bb24add7cf843a6ddc89c7991e7e2cf263e 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -170,8 +170,10 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor) connect(this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings))); - connect(editor, SIGNAL(requestFontSize(int)), - this, SLOT(fontSizeRequested(int))); + connect(editor, SIGNAL(requestFontZoom(int)), + this, SLOT(fontZoomRequested(int))); + connect(editor, SIGNAL(requestZoomReset()), + this, SLOT(zoomResetRequested())); // Apply current settings (tab settings depend on font settings) editor->setFontSettings(fontSettings()); @@ -181,10 +183,17 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor) } -void TextEditorSettings::fontSizeRequested(int pointSize) +void TextEditorSettings::fontZoomRequested(int zoom) { FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings()); - fs.setFontSize(pointSize); + fs.setFontZoom(qMax(10, fs.fontZoom() + zoom)); + m_fontSettingsPage->saveSettings(); +} + +void TextEditorSettings::zoomResetRequested() +{ + FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings()); + fs.setFontZoom(100); m_fontSettingsPage->saveSettings(); } diff --git a/src/plugins/texteditor/texteditorsettings.h b/src/plugins/texteditor/texteditorsettings.h index de3ff07bd2bfad1078d649a3e3e8bbc22ac9bbb1..14912d69562028c2b01f95e52bae5138a56d6b47 100644 --- a/src/plugins/texteditor/texteditorsettings.h +++ b/src/plugins/texteditor/texteditorsettings.h @@ -74,7 +74,8 @@ signals: void displaySettingsChanged(const TextEditor::DisplaySettings &); private slots: - void fontSizeRequested(int pointSize); + void fontZoomRequested(int pointSize); + void zoomResetRequested(); private: FontSettingsPage *m_fontSettingsPage; diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index b4b1f1a3efbe88367c745023c713f6fd5bc702eb..e901b67e92d34e754874f244229cac957c25bfb3 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -246,7 +246,21 @@ unsigned QtMethodAST::lastToken() const return method_token + 1; } +unsigned QtMemberDeclarationAST::firstToken() const +{ + return q_token; +} +unsigned QtMemberDeclarationAST::lastToken() const +{ + if (rparen_token) + return rparen_token + 1; + else if (type_id) + return type_id->lastToken(); + else if (lparen_token) + return lparen_token + 1; + return q_token + 1; +} unsigned BinaryExpressionAST::firstToken() const { diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index eb6473128162f5a939bf9e177cfbedf94e59f02a..47342c2e04554e9d649b2303ab0ceaf87eb92f5e 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -246,6 +246,7 @@ public: virtual PostfixDeclaratorAST *asPostfixDeclarator() { return 0; } virtual PostfixExpressionAST *asPostfixExpression() { return 0; } virtual PtrOperatorAST *asPtrOperator() { return 0; } + virtual QtMemberDeclarationAST *asQtMemberDeclaration() { return 0; } virtual QtMethodAST *asQtMethod() { return 0; } virtual QualifiedNameAST *asQualifiedName() { return 0; } virtual ReferenceAST *asReference() { return 0; } @@ -302,7 +303,7 @@ public: class CPLUSPLUS_EXPORT NameAST: public ExpressionAST { public: // annotations - Name *name; + const Name *name; public: virtual NameAST *asName() { return this; } @@ -341,7 +342,7 @@ public: class CPLUSPLUS_EXPORT ObjCSelectorAST: public AST { public: // annotation - Name *selector_name; + const Name *selector_name; public: virtual ObjCSelectorAST *asObjCSelector() { return this; } @@ -582,6 +583,25 @@ protected: virtual bool match0(AST *, ASTMatcher *); }; +class CPLUSPLUS_EXPORT QtMemberDeclarationAST: public StatementAST +{ +public: + unsigned q_token; + unsigned lparen_token; + ExpressionAST *type_id; + unsigned rparen_token; + +public: + virtual QtMemberDeclarationAST *asQtMemberDeclaration() { return this; } + + virtual unsigned firstToken() const; + virtual unsigned lastToken() const; + +protected: + virtual void accept0(ASTVisitor *visitor); + virtual bool match0(AST *, ASTMatcher *); +}; + class CPLUSPLUS_EXPORT BinaryExpressionAST: public ExpressionAST { public: diff --git a/src/shared/cplusplus/ASTMatch0.cpp b/src/shared/cplusplus/ASTMatch0.cpp index 7c4ff19ae6e5afc81ad6b08740f72376f287409d..e16c0788080f0b8e08d6b74d580365545358fb7b 100644 --- a/src/shared/cplusplus/ASTMatch0.cpp +++ b/src/shared/cplusplus/ASTMatch0.cpp @@ -128,6 +128,14 @@ bool QtMethodAST::match0(AST *pattern, ASTMatcher *matcher) return false; } +bool QtMemberDeclarationAST::match0(AST *pattern, ASTMatcher *matcher) +{ + if (QtMemberDeclarationAST *_other = pattern->asQtMemberDeclaration()) + return matcher->match(this, _other); + + return false; +} + bool BinaryExpressionAST::match0(AST *pattern, ASTMatcher *matcher) { if (BinaryExpressionAST *_other = pattern->asBinaryExpression()) diff --git a/src/shared/cplusplus/ASTMatcher.cpp b/src/shared/cplusplus/ASTMatcher.cpp index 9ded92f8ef98f8d77597c09e49eead70974da247..b7920f767f4395fbf2a046abdb73f2f58dd32546 100644 --- a/src/shared/cplusplus/ASTMatcher.cpp +++ b/src/shared/cplusplus/ASTMatcher.cpp @@ -274,6 +274,25 @@ bool ASTMatcher::match(QtMethodAST *node, QtMethodAST *pattern) return true; } +bool ASTMatcher::match(QtMemberDeclarationAST *node, QtMemberDeclarationAST *pattern) +{ + (void) node; + (void) pattern; + + pattern->q_token = node->q_token; + + pattern->lparen_token = node->lparen_token; + + if (! pattern->type_id) + pattern->type_id = node->type_id; + else if (! AST::match(node->type_id, pattern->type_id, this)) + return false; + + pattern->rparen_token = node->rparen_token; + + return true; +} + bool ASTMatcher::match(BinaryExpressionAST *node, BinaryExpressionAST *pattern) { (void) node; diff --git a/src/shared/cplusplus/ASTMatcher.h b/src/shared/cplusplus/ASTMatcher.h index f299dc51bbddb88c7c6fb8ff7749ff6fe3858797..c3490ac69be4f60ff8f1aa1dd102d76991ada103 100644 --- a/src/shared/cplusplus/ASTMatcher.h +++ b/src/shared/cplusplus/ASTMatcher.h @@ -135,6 +135,7 @@ public: virtual bool match(UsingDirectiveAST *node, UsingDirectiveAST *pattern); virtual bool match(WhileStatementAST *node, WhileStatementAST *pattern); virtual bool match(QtMethodAST *node, QtMethodAST *pattern); + virtual bool match(QtMemberDeclarationAST *node, QtMemberDeclarationAST *pattern); virtual bool match(ObjCClassDeclarationAST *node, ObjCClassDeclarationAST *pattern); virtual bool match(ObjCClassForwardDeclarationAST *node, ObjCClassForwardDeclarationAST *pattern); virtual bool match(ObjCProtocolDeclarationAST *node, ObjCProtocolDeclarationAST *pattern); diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index 6e26f772b2401b6b90bfb5e9e1181e76b9769c1c..877dd8df743ef74181c108784d51cf6600d89a13 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -131,6 +131,14 @@ void QtMethodAST::accept0(ASTVisitor *visitor) visitor->endVisit(this); } +void QtMemberDeclarationAST::accept0(ASTVisitor *visitor) +{ + if (visitor->visit(this)) { + accept(type_id, visitor); + } + visitor->endVisit(this); +} + void BinaryExpressionAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { diff --git a/src/shared/cplusplus/ASTVisitor.cpp b/src/shared/cplusplus/ASTVisitor.cpp index 9281efdf2b92b8cf85730df335687962989482f3..4f93c06d0a491e32204a47944aee63238098ae8c 100644 --- a/src/shared/cplusplus/ASTVisitor.cpp +++ b/src/shared/cplusplus/ASTVisitor.cpp @@ -89,28 +89,28 @@ int ASTVisitor::tokenKind(unsigned index) const const char *ASTVisitor::spell(unsigned index) const { return translationUnit()->spell(index); } -Identifier *ASTVisitor::identifier(unsigned index) const +const Identifier *ASTVisitor::identifier(unsigned index) const { return translationUnit()->identifier(index); } -Literal *ASTVisitor::literal(unsigned index) const +const Literal *ASTVisitor::literal(unsigned index) const { return translationUnit()->literal(index); } -NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const +const NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const { return translationUnit()->numericLiteral(index); } -StringLiteral *ASTVisitor::stringLiteral(unsigned index) const +const StringLiteral *ASTVisitor::stringLiteral(unsigned index) const { return translationUnit()->stringLiteral(index); } void ASTVisitor::getPosition(unsigned offset, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { translationUnit()->getPosition(offset, line, column, fileName); } void ASTVisitor::getTokenPosition(unsigned index, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { translationUnit()->getTokenPosition(index, line, column, fileName); } void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const diff --git a/src/shared/cplusplus/ASTVisitor.h b/src/shared/cplusplus/ASTVisitor.h index 0a42b6f4d4e62b5989beb6bb176019164f694967..d4ebdcc81abfaedae65c15b45b39e9dc3cc71021 100644 --- a/src/shared/cplusplus/ASTVisitor.h +++ b/src/shared/cplusplus/ASTVisitor.h @@ -72,20 +72,20 @@ public: const Token &tokenAt(unsigned index) const; int tokenKind(unsigned index) const; const char *spell(unsigned index) const; - Identifier *identifier(unsigned index) const; - Literal *literal(unsigned index) const; - NumericLiteral *numericLiteral(unsigned index) const; - StringLiteral *stringLiteral(unsigned index) const; + const Identifier *identifier(unsigned index) const; + const Literal *literal(unsigned index) const; + const NumericLiteral *numericLiteral(unsigned index) const; + const StringLiteral *stringLiteral(unsigned index) const; void getPosition(unsigned offset, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void getTokenPosition(unsigned index, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const; void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const; @@ -198,6 +198,7 @@ public: virtual bool visit(UsingDirectiveAST *) { return true; } virtual bool visit(WhileStatementAST *) { return true; } virtual bool visit(QtMethodAST *) { return true; } + virtual bool visit(QtMemberDeclarationAST *) { return true; } // ObjC++ virtual bool visit(ObjCClassDeclarationAST *) { return true; } @@ -323,6 +324,7 @@ public: virtual void endVisit(UsingDirectiveAST *) { } virtual void endVisit(WhileStatementAST *) { } virtual void endVisit(QtMethodAST *) { } + virtual void endVisit(QtMemberDeclarationAST *) { } // ObjC++ virtual void endVisit(ObjCClassDeclarationAST *) { } diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index 18f1987d5e99b6a5024bc887cbaa2a83f4545fe1..cefdfdc3815c9e719c2f3920c6059a42a54f28d9 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -162,6 +162,7 @@ class PostfixAST; class PostfixDeclaratorAST; class PostfixExpressionAST; class PtrOperatorAST; +class QtMemberDeclarationAST; class QtMethodAST; class QualifiedNameAST; class ReferenceAST; diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index d7d7029fa21a1d01dbf0f2b796cd0c4326597c26..426a7d9de2bfcde6a26045910e75ec5b5d858ea8 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -153,7 +153,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) if (elab_type_spec->name) sourceLocation = elab_type_spec->name->firstToken(); - Name *name = semantic()->check(elab_type_spec->name, _scope); + const Name *name = semantic()->check(elab_type_spec->name, _scope); ForwardClassDeclaration *symbol = control()->newForwardClassDeclaration(sourceLocation, name); @@ -172,7 +172,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) List<Declaration *> **decl_it = &ast->symbols; for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) { - Name *name = 0; + const Name *name = 0; FullySpecifiedType declTy = semantic()->check(it->value, qualTy, _scope, &name); @@ -268,7 +268,7 @@ bool CheckDeclaration::visit(ExceptionDeclarationAST *ast) FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType qualTy = ty.qualifiedType(); - Name *name = 0; + const Name *name = 0; FullySpecifiedType declTy = semantic()->check(ast->declarator, qualTy, _scope, &name); @@ -293,7 +293,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) { FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope); FullySpecifiedType qualTy = ty.qualifiedType(); - Name *name = 0; + const Name *name = 0; FullySpecifiedType funTy = semantic()->check(ast->declarator, qualTy, _scope, &name); if (! (funTy && funTy->isFunctionType())) { @@ -378,8 +378,9 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast) bool CheckDeclaration::visit(NamespaceAST *ast) { - Identifier *id = identifier(ast->identifier_token); - Name *namespaceName = control()->nameId(id); + const Name *namespaceName = 0; + if (const Identifier *id = identifier(ast->identifier_token)) + namespaceName = control()->nameId(id); unsigned sourceLocation = ast->firstToken(); @@ -411,7 +412,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast) sourceLocation = ast->firstToken(); } - Name *argName = 0; + const Name *argName = 0; FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(), _scope, &argName); @@ -445,7 +446,7 @@ bool CheckDeclaration::visit(TypenameTypeParameterAST *ast) if (ast->name) sourceLocation = ast->name->firstToken(); - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type ast->symbol = arg; _scope->enterSymbol(arg); @@ -458,7 +459,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast) if (ast->name) sourceLocation = ast->name->firstToken(); - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type ast->symbol = arg; _scope->enterSymbol(arg); @@ -467,7 +468,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast) bool CheckDeclaration::visit(UsingAST *ast) { - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); unsigned sourceLocation = ast->firstToken(); if (ast->name) @@ -481,7 +482,7 @@ bool CheckDeclaration::visit(UsingAST *ast) bool CheckDeclaration::visit(UsingDirectiveAST *ast) { - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); unsigned sourceLocation = ast->firstToken(); if (ast->name) @@ -510,7 +511,7 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast) else declarationLocation = sourceLocation; - Name *protocolName = semantic()->check(it->value, _scope); + const Name *protocolName = semantic()->check(it->value, _scope); ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName); fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset); fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -533,7 +534,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast) else sourceLocation = ast->firstToken(); - Name *protocolName = semantic()->check(ast->name, _scope); + const Name *protocolName = semantic()->check(ast->name, _scope); ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, protocolName); protocol->setStartOffset(tokenAt(ast->firstToken()).offset); protocol->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -541,7 +542,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast) if (ast->protocol_refs && ast->protocol_refs->identifier_list) { for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { NameAST* name = iter->value; - Name *protocolName = semantic()->check(name, _scope); + const Name *protocolName = semantic()->check(name, _scope); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); protocol->addProtocol(baseProtocol); } @@ -571,7 +572,7 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast) else declarationLocation = sourceLocation; - Name *className = semantic()->check(it->value, _scope); + const Name *className = semantic()->check(it->value, _scope); ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className); fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset); fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -594,7 +595,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast) else sourceLocation = ast->firstToken(); - Name *className = semantic()->check(ast->class_name, _scope); + const Name *className = semantic()->check(ast->class_name, _scope); ObjCClass *klass = control()->newObjCClass(sourceLocation, className); klass->setStartOffset(tokenAt(ast->firstToken()).offset); klass->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -603,12 +604,12 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast) klass->setInterface(ast->interface_token != 0); if (ast->category_name) { - Name *categoryName = semantic()->check(ast->category_name, _scope); + const Name *categoryName = semantic()->check(ast->category_name, _scope); klass->setCategoryName(categoryName); } if (ast->superclass) { - Name *superClassName = semantic()->check(ast->superclass, _scope); + const Name *superClassName = semantic()->check(ast->superclass, _scope); ObjCBaseClass *superKlass = control()->newObjCBaseClass(ast->superclass->firstToken(), superClassName); klass->setBaseClass(superKlass); } @@ -616,7 +617,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast) if (ast->protocol_refs && ast->protocol_refs->identifier_list) { for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { NameAST* name = iter->value; - Name *protocolName = semantic()->check(name, _scope); + const Name *protocolName = semantic()->check(name, _scope); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); klass->addProtocol(baseProtocol); } @@ -711,14 +712,14 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast) } int propAttrs = ObjCPropertyDeclaration::None; - Name *getterName = 0, *setterName = 0; + const Name *getterName = 0, *setterName = 0; for (ObjCPropertyAttributeListAST *iter= ast->property_attribute_list; iter; iter = iter->next) { ObjCPropertyAttributeAST *attrAst = iter->value; if (!attrAst) continue; - Identifier *attrId = identifier(attrAst->attribute_identifier_token); + const Identifier *attrId = identifier(attrAst->attribute_identifier_token); if (attrId == control()->objcGetterId()) { if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) { getterName = semantic()->check(attrAst->method_selector, _scope); diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp index 9f283811059c4ad9c33e97d23872836fd4c5a255..7af4e02268af7ff64c5fc04b61cab505478feba8 100644 --- a/src/shared/cplusplus/CheckDeclarator.cpp +++ b/src/shared/cplusplus/CheckDeclarator.cpp @@ -70,12 +70,12 @@ CheckDeclarator::~CheckDeclarator() FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator, const FullySpecifiedType &type, Scope *scope, - Name **name) + const Name **name) { FullySpecifiedType previousType = switchFullySpecifiedType(type); Scope *previousScope = switchScope(scope); DeclaratorAST *previousDeclarator = switchDeclarator(declarator); - Name **previousName = switchName(name); + const Name **previousName = switchName(name); accept(declarator); (void) switchName(previousName); (void) switchDeclarator(previousDeclarator); @@ -124,9 +124,9 @@ Scope *CheckDeclarator::switchScope(Scope *scope) return previousScope; } -Name **CheckDeclarator::switchName(Name **name) +const Name **CheckDeclarator::switchName(const Name **name) { - Name **previousName = _name; + const Name **previousName = _name; _name = name; return previousName; } @@ -149,7 +149,7 @@ bool CheckDeclarator::visit(DeclaratorAST *ast) bool CheckDeclarator::visit(DeclaratorIdAST *ast) { - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); if (_name) *_name = name; return false; @@ -219,7 +219,7 @@ bool CheckDeclarator::visit(ArrayDeclaratorAST *ast) bool CheckDeclarator::visit(PointerToMemberAST *ast) { - Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope); + const Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope); PointerToMemberType *ptrTy = control()->pointerToMemberType(memberName, _fullySpecifiedType); FullySpecifiedType ty(ptrTy); _fullySpecifiedType = ty; diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h index 1b9e14cb813bb735158bec2c54af4cacd6c88c5b..81d6c0e4f5c48d79d4d1a08cccc6e5a9b89d8536 100644 --- a/src/shared/cplusplus/CheckDeclarator.h +++ b/src/shared/cplusplus/CheckDeclarator.h @@ -65,7 +65,7 @@ public: FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type, Scope *scope, - Name **name); + const Name **name); FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, @@ -78,7 +78,7 @@ protected: DeclaratorAST *switchDeclarator(DeclaratorAST *declarator); FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type); Scope *switchScope(Scope *scope); - Name **switchName(Name **name); + const Name **switchName(const Name **name); using ASTVisitor::visit; @@ -102,7 +102,7 @@ protected: private: DeclaratorAST *_declarator; Scope *_scope; - Name **_name; + const Name **_name; FullySpecifiedType _fullySpecifiedType; }; diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp index ad1bb3a46e599c26c1591bbb4eea090c8cf9054d..f8da07534c59942131230e59ebece213ecff701d 100644 --- a/src/shared/cplusplus/CheckExpression.cpp +++ b/src/shared/cplusplus/CheckExpression.cpp @@ -120,7 +120,7 @@ bool CheckExpression::visit(CastExpressionAST *ast) bool CheckExpression::visit(ConditionAST *ast) { FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope); - Name *name = 0; + const Name *name = 0; FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), _scope, &name); Declaration *decl = control()->newDeclaration(ast->declarator->firstToken(), name); @@ -302,8 +302,7 @@ bool CheckExpression::visit(ThrowExpressionAST *ast) bool CheckExpression::visit(TypeIdAST *ast) { FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope); - FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), - _scope); + FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), _scope); _fullySpecifiedType = declTy; return false; } @@ -316,7 +315,7 @@ bool CheckExpression::visit(UnaryExpressionAST *ast) bool CheckExpression::visit(QtMethodAST *ast) { - Name *name = 0; + const Name *name = 0; Scope dummy; FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(), &dummy, &name); diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp index 63a1885128a7668905845c4a9ee86da3d8b5cffa..11688aba4816ba558fe38a1834a83a0475782701 100644 --- a/src/shared/cplusplus/CheckName.cpp +++ b/src/shared/cplusplus/CheckName.cpp @@ -69,9 +69,9 @@ CheckName::CheckName(Semantic *semantic) CheckName::~CheckName() { } -Name *CheckName::check(NameAST *name, Scope *scope) +const Name *CheckName::check(NameAST *name, Scope *scope) { - Name *previousName = switchName(0); + const Name *previousName = switchName(0); Scope *previousScope = switchScope(scope); accept(name); @@ -82,12 +82,12 @@ Name *CheckName::check(NameAST *name, Scope *scope) return switchName(previousName); } -Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope) +const Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope) { - Name *previousName = switchName(0); + const Name *previousName = switchName(0); Scope *previousScope = switchScope(scope); - std::vector<Name *> names; + std::vector<const Name *> names; for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) { NestedNameSpecifierAST *nested_name_specifier = it->value; names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope)); @@ -100,9 +100,9 @@ Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, S return switchName(previousName); } -Name *CheckName::check(ObjCSelectorAST *args, Scope *scope) +const Name *CheckName::check(ObjCSelectorAST *args, Scope *scope) { - Name *previousName = switchName(0); + const Name *previousName = switchName(0); Scope *previousScope = switchScope(scope); accept(args); @@ -113,7 +113,7 @@ Name *CheckName::check(ObjCSelectorAST *args, Scope *scope) void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope) { - Name *previousName = switchName(0); + const Name *previousName = switchName(0); Scope *previousScope = switchScope(scope); accept(arg); @@ -122,9 +122,9 @@ void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope) (void) switchName(previousName); } -Name *CheckName::switchName(Name *name) +const Name *CheckName::switchName(const Name *name) { - Name *previousName = _name; + const Name *previousName = _name; _name = name; return previousName; } @@ -138,14 +138,13 @@ Scope *CheckName::switchScope(Scope *scope) bool CheckName::visit(QualifiedNameAST *ast) { - std::vector<Name *> names; + std::vector<const Name *> names; for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) { NestedNameSpecifierAST *nested_name_specifier = it->value; names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope)); } names.push_back(semantic()->check(ast->unqualified_name, _scope)); - _name = control()->qualifiedNameId(&names[0], names.size(), - ast->global_scope_token != 0); + _name = control()->qualifiedNameId(&names[0], names.size(), ast->global_scope_token != 0); ast->name = _name; return false; @@ -343,7 +342,7 @@ bool CheckName::visit(ConversionFunctionIdAST *ast) bool CheckName::visit(SimpleNameAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); _name = control()->nameId(id); ast->name = _name; return false; @@ -351,7 +350,7 @@ bool CheckName::visit(SimpleNameAST *ast) bool CheckName::visit(DestructorNameAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); _name = control()->destructorNameId(id); ast->name = _name; return false; @@ -359,7 +358,7 @@ bool CheckName::visit(DestructorNameAST *ast) bool CheckName::visit(TemplateIdAST *ast) { - Identifier *id = identifier(ast->identifier_token); + const Identifier *id = identifier(ast->identifier_token); std::vector<FullySpecifiedType> templateArguments; for (TemplateArgumentListAST *it = ast->template_argument_list; it; it = it->next) { @@ -379,9 +378,9 @@ bool CheckName::visit(TemplateIdAST *ast) bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast) { if (ast->name_token) { - std::vector<Name *> names; - Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token)); - NameId *nameId = control()->nameId(id); + std::vector<const Name *> names; + const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token)); + const NameId *nameId = control()->nameId(id); names.push_back(nameId); _name = control()->selectorNameId(&names[0], names.size(), false); ast->selector_name = _name; @@ -392,11 +391,11 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast) bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast) { - std::vector<Name *> names; + std::vector<const Name *> names; for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) { if (it->value->name_token) { - Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token)); - NameId *nameId = control()->nameId(id); + const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token)); + const NameId *nameId = control()->nameId(id); names.push_back(nameId); } else { // we have an incomplete name due, probably due to error recovery. So, back out completely @@ -420,7 +419,7 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast) type = semantic()->check(ast->type_name, _scope); if (ast->param_name_token) { - Identifier *id = identifier(ast->param_name_token); + const Identifier *id = identifier(ast->param_name_token); _name = control()->nameId(id); ast->name = _name; diff --git a/src/shared/cplusplus/CheckName.h b/src/shared/cplusplus/CheckName.h index 7f86d751671bef6d880e655f45c7a2f6f99076c6..1484cb7848e4145074a5adde049432189e498da7 100644 --- a/src/shared/cplusplus/CheckName.h +++ b/src/shared/cplusplus/CheckName.h @@ -61,13 +61,13 @@ public: CheckName(Semantic *semantic); virtual ~CheckName(); - Name *check(NameAST *name, Scope *scope); - Name *check(NestedNameSpecifierListAST *name, Scope *scope); - Name *check(ObjCSelectorAST *args, Scope *scope); + const Name *check(NameAST *name, Scope *scope); + const Name *check(NestedNameSpecifierListAST *name, Scope *scope); + const Name *check(ObjCSelectorAST *args, Scope *scope); void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope); protected: - Name *switchName(Name *name); + const Name *switchName(const Name *name); Scope *switchScope(Scope *scope); using ASTVisitor::visit; @@ -85,7 +85,7 @@ protected: virtual bool visit(ObjCMessageArgumentDeclarationAST *ast); private: - Name *_name; + const Name *_name; Scope *_scope; }; diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp index c7604c5ee665d7c96b419a37693c65d7d4e29257..03b2d53d97d483f197b02815f29b63e93852b7b0 100644 --- a/src/shared/cplusplus/CheckSpecifier.cpp +++ b/src/shared/cplusplus/CheckSpecifier.cpp @@ -312,7 +312,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast) if (ast->name) sourceLocation = ast->name->firstToken(); - Name *className = semantic()->check(ast->name, _scope); + const Name *className = semantic()->check(ast->name, _scope); Class *klass = control()->newClass(sourceLocation, className); klass->setStartOffset(tokenAt(ast->firstToken()).offset); klass->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -330,7 +330,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast) for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) { BaseSpecifierAST *base = it->value; - Name *baseClassName = semantic()->check(base->name, _scope); + const Name *baseClassName = semantic()->check(base->name, _scope); BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName); base->symbol = baseClass; if (base->virtual_token) @@ -359,14 +359,14 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast) bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast) { - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); _fullySpecifiedType.setType(control()->namedType(name)); return false; } bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast) { - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); _fullySpecifiedType.setType(control()->namedType(name)); return false; } @@ -377,7 +377,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast) if (ast->name) sourceLocation = ast->name->firstToken(); - Name *name = semantic()->check(ast->name, _scope); + const Name *name = semantic()->check(ast->name, _scope); Enum *e = control()->newEnum(sourceLocation, name); e->setStartOffset(tokenAt(ast->firstToken()).offset); e->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -386,10 +386,10 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast) _fullySpecifiedType.setType(e); for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) { EnumeratorAST *enumerator = it->value; - Identifier *id = identifier(enumerator->identifier_token); + const Identifier *id = identifier(enumerator->identifier_token); if (! id) continue; - NameId *enumeratorName = control()->nameId(id); + const NameId *enumeratorName = control()->nameId(id); Declaration *decl = control()->newDeclaration(enumerator->firstToken(), enumeratorName); e->addMember(decl); @@ -403,7 +403,7 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast) return false; } -bool CheckSpecifier::visit(AttributeSpecifierAST *ast) +bool CheckSpecifier::visit(AttributeSpecifierAST * /*ast*/) { return false; } diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index 1273f816105719285e1b870ae309aa4543801ed2..ec9f6590e294261267bc4e0202b800c80a57d0c1 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -54,6 +54,9 @@ #include "CoreTypes.h" #include "Control.h" #include "Symbols.h" +#include "Names.h" +#include "Literals.h" +#include <string> using namespace CPlusPlus; @@ -151,7 +154,7 @@ bool CheckStatement::visit(ForeachStatementAST *ast) Scope *previousScope = switchScope(block->members()); if (ast->type_specifier_list && ast->declarator) { FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); - Name *name = 0; + const Name *name = 0; ty = semantic()->check(ast->declarator, ty, _scope, &name); unsigned location = ast->declarator->firstToken(); if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator) @@ -180,7 +183,7 @@ bool CheckStatement::visit(ObjCFastEnumerationAST *ast) Scope *previousScope = switchScope(block->members()); if (ast->type_specifier_list && ast->declarator) { FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); - Name *name = 0; + const Name *name = 0; ty = semantic()->check(ast->declarator, ty, _scope, &name); unsigned location = ast->declarator->firstToken(); if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator) @@ -307,4 +310,35 @@ bool CheckStatement::visit(WhileStatementAST *ast) return false; } +bool CheckStatement::visit(QtMemberDeclarationAST *ast) +{ + const Name *name = 0; + + if (tokenKind(ast->q_token) == T_Q_D) + name = control()->nameId(control()->findOrInsertIdentifier("d")); + else + name = control()->nameId(control()->findOrInsertIdentifier("q")); + + FullySpecifiedType declTy = semantic()->check(ast->type_id, _scope); + + if (tokenKind(ast->q_token) == T_Q_D) { + if (NamedType *namedTy = declTy->asNamedType()) { + if (const NameId *nameId = namedTy->name()->asNameId()) { + std::string privateClass; + privateClass += nameId->identifier()->chars(); + privateClass += "Private"; + + const Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(), + privateClass.size())); + declTy.setType(control()->namedType(privName)); + } + } + } + + Declaration *symbol = control()->newDeclaration(/*generated*/ 0, name); + symbol->setType(control()->pointerType(declTy)); + + _scope->enterSymbol(symbol); + return false; +} diff --git a/src/shared/cplusplus/CheckStatement.h b/src/shared/cplusplus/CheckStatement.h index 6bd0c868ab9e9bbac0c1eccb32d5c156030934b4..e31d507a5efb35d581c097577890a6c939f7bac2 100644 --- a/src/shared/cplusplus/CheckStatement.h +++ b/src/shared/cplusplus/CheckStatement.h @@ -88,6 +88,7 @@ protected: virtual bool visit(TryBlockStatementAST *ast); virtual bool visit(CatchClauseAST *ast); virtual bool visit(WhileStatementAST *ast); + virtual bool visit(QtMemberDeclarationAST *ast); private: StatementAST *_statement; diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp index 4e6ea089b8c27bc3c1b6f5d3f8a9eead5d8cbd9c..f03384274a9052f4bff1ec33718ec8d218385383 100644 --- a/src/shared/cplusplus/Control.cpp +++ b/src/shared/cplusplus/Control.cpp @@ -55,27 +55,170 @@ #include "Names.h" #include "Array.h" #include "TypeMatcher.h" -#include <map> // ### replace me with LiteralTable +#include <map> +#include <set> using namespace CPlusPlus; +namespace { + +template <typename _Tp> +struct Compare; + +template <> struct Compare<IntegerType> +{ + bool operator()(const IntegerType &ty, const IntegerType &otherTy) const + { return ty.kind() < otherTy.kind(); } +}; + +template <> struct Compare<FloatType> +{ + bool operator()(const FloatType &ty, const FloatType &otherTy) const + { return ty.kind() < otherTy.kind(); } +}; + +template <> struct Compare<PointerToMemberType> +{ + bool operator()(const PointerToMemberType &ty, const PointerToMemberType &otherTy) const + { + if (ty.memberName() < otherTy.memberName()) + return true; + + else if (ty.memberName() == otherTy.memberName()) + return ty.elementType() < otherTy.elementType(); + + return false; + } +}; + +template <> struct Compare<PointerType> +{ + bool operator()(const PointerType &ty, const PointerType &otherTy) const + { + return ty.elementType() < otherTy.elementType(); + } +}; + +template <> struct Compare<ReferenceType> +{ + bool operator()(const ReferenceType &ty, const ReferenceType &otherTy) const + { + return ty.elementType() < otherTy.elementType(); + } +}; + +template <> struct Compare<NamedType> +{ + bool operator()(const NamedType &ty, const NamedType &otherTy) const + { + return ty.name() < otherTy.name(); + } +}; + +template <> struct Compare<ArrayType> +{ + bool operator()(const ArrayType &ty, const ArrayType &otherTy) const + { + if (ty.size() < otherTy.size()) + return true; + + else if (ty.size() == otherTy.size()) + return ty.elementType() < otherTy.elementType(); + + return false; + } +}; + +template <> struct Compare<NameId> +{ + bool operator()(const NameId &name, const NameId &otherName) const + { + return name.identifier() < otherName.identifier(); + } +}; + +template <> struct Compare<DestructorNameId> +{ + bool operator()(const DestructorNameId &name, const DestructorNameId &otherName) const + { + return name.identifier() < otherName.identifier(); + } +}; + +template <> struct Compare<OperatorNameId> +{ + bool operator()(const OperatorNameId &name, const OperatorNameId &otherName) const + { + return name.kind() < otherName.kind(); + } +}; + +template <> struct Compare<ConversionNameId> +{ + bool operator()(const ConversionNameId &name, const ConversionNameId &otherName) const + { + return name.type() < otherName.type(); + } +}; +template <> struct Compare<TemplateNameId> +{ + bool operator()(const TemplateNameId &name, const TemplateNameId &otherName) const + { + const Identifier *id = name.identifier(); + const Identifier *otherId = otherName.identifier(); + + if (id == otherId) + return std::lexicographical_compare(name.firstTemplateArgument(), name.lastTemplateArgument(), + otherName.firstTemplateArgument(), otherName.lastTemplateArgument()); + + return id < otherId; + } +}; +template <> struct Compare<QualifiedNameId> +{ + bool operator()(const QualifiedNameId &name, const QualifiedNameId &otherName) const + { + if (name.isGlobal() == otherName.isGlobal()) + return std::lexicographical_compare(name.firstName(), name.lastName(), + otherName.firstName(), otherName.lastName()); + + return name.isGlobal() < otherName.isGlobal(); + } +}; + +template <> struct Compare<SelectorNameId> +{ + bool operator()(const SelectorNameId &name, const SelectorNameId &otherName) const + { + if (name.hasArguments() == otherName.hasArguments()) + return std::lexicographical_compare(name.firstName(), name.lastName(), + otherName.firstName(), otherName.lastName()); + + return name.hasArguments() < otherName.hasArguments(); + } +}; + + +template <typename _Tp> +class Table: public std::set<_Tp, Compare<_Tp> > +{ +public: + _Tp *intern(const _Tp &element) + { return const_cast<_Tp *>(&*insert(element).first); } +}; + +} // end of anonymous namespace + template <typename _Iterator> -static void delete_map_entries(_Iterator first, _Iterator last) +static void delete_array_entries(_Iterator first, _Iterator last) { for (; first != last; ++first) - delete first->second; + delete *first; } -template <typename _Map> -static void delete_map_entries(const _Map &m) -{ delete_map_entries(m.begin(), m.end()); } - template <typename _Array> static void delete_array_entries(const _Array &a) -{ - for (unsigned i = 0; i < a.size(); ++i) - delete a.at(i); -} +{ delete_array_entries(a.begin(), a.end()); } class Control::Data { @@ -88,199 +231,87 @@ public: ~Data() { - // names - delete_map_entries(nameIds); - delete_map_entries(destructorNameIds); - delete_map_entries(operatorNameIds); - delete_map_entries(conversionNameIds); - delete_map_entries(qualifiedNameIds); - delete_map_entries(templateNameIds); - - // types - delete_array_entries(integerTypes); - delete_array_entries(floatTypes); - delete_array_entries(pointerToMemberTypes); - delete_array_entries(pointerTypes); - delete_array_entries(referenceTypes); - delete_array_entries(arrayTypes); - delete_array_entries(namedTypes); - // symbols delete_array_entries(symbols); } - NameId *findOrInsertNameId(Identifier *id) + const NameId *findOrInsertNameId(const Identifier *id) { if (! id) return 0; - std::map<Identifier *, NameId *>::iterator it = nameIds.lower_bound(id); - if (it == nameIds.end() || it->first != id) - it = nameIds.insert(it, std::make_pair(id, new NameId(id))); - return it->second; + + return nameIds.intern(NameId(id)); } - TemplateNameId *findOrInsertTemplateNameId(Identifier *id, - const std::vector<FullySpecifiedType> &templateArguments) + template <typename _Iterator> + const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id, _Iterator first, _Iterator last) { - if (! id) - return 0; - const TemplateNameIdKey key(id, templateArguments); - std::map<TemplateNameIdKey, TemplateNameId *>::iterator it = - templateNameIds.lower_bound(key); - if (it == templateNameIds.end() || it->first != key) { - const FullySpecifiedType *args = 0; - if (templateArguments.size()) - args = &templateArguments[0]; - TemplateNameId *templ = new TemplateNameId(id, args, - templateArguments.size()); - it = templateNameIds.insert(it, std::make_pair(key, templ)); - } - return it->second; - } - - DestructorNameId *findOrInsertDestructorNameId(Identifier *id) + return templateNameIds.intern(TemplateNameId(id, first, last)); + } + + const DestructorNameId *findOrInsertDestructorNameId(const Identifier *id) { - if (! id) - return 0; - std::map<Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id); - if (it == destructorNameIds.end() || it->first != id) - it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id))); - return it->second; + return destructorNameIds.intern(DestructorNameId(id)); } - OperatorNameId *findOrInsertOperatorNameId(int kind) + const OperatorNameId *findOrInsertOperatorNameId(int kind) { - const int key(kind); - std::map<int, OperatorNameId *>::iterator it = operatorNameIds.lower_bound(key); - if (it == operatorNameIds.end() || it->first != key) - it = operatorNameIds.insert(it, std::make_pair(key, new OperatorNameId(kind))); - return it->second; + return operatorNameIds.intern(OperatorNameId(kind)); } - ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type) + const ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type) { - std::map<FullySpecifiedType, ConversionNameId *>::iterator it = - conversionNameIds.lower_bound(type); - if (it == conversionNameIds.end() || it->first != type) - it = conversionNameIds.insert(it, std::make_pair(type, new ConversionNameId(type))); - return it->second; + return conversionNameIds.intern(ConversionNameId(type)); } - QualifiedNameId *findOrInsertQualifiedNameId(const std::vector<Name *> &names, bool isGlobal) + template <typename _Iterator> + const QualifiedNameId *findOrInsertQualifiedNameId(_Iterator first, _Iterator last, bool isGlobal) { - const QualifiedNameIdKey key(names, isGlobal); - std::map<QualifiedNameIdKey, QualifiedNameId *>::iterator it = - qualifiedNameIds.lower_bound(key); - if (it == qualifiedNameIds.end() || it->first != key) { - QualifiedNameId *name = new QualifiedNameId(&names[0], names.size(), isGlobal); - it = qualifiedNameIds.insert(it, std::make_pair(key, name)); - } - return it->second; + return qualifiedNameIds.intern(QualifiedNameId(first, last, isGlobal)); } - SelectorNameId *findOrInsertSelectorNameId(const std::vector<Name *> &names, bool hasArguments) + template <typename _Iterator> + const SelectorNameId *findOrInsertSelectorNameId(_Iterator first, _Iterator last, bool hasArguments) { - const SelectorNameIdKey key(names, hasArguments); - std::map<SelectorNameIdKey, SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key); - if (it == selectorNameIds.end() || it->first != key) - it = selectorNameIds.insert(it, std::make_pair(key, new SelectorNameId(&names[0], names.size(), hasArguments))); - return it->second; + return selectorNameIds.intern(SelectorNameId(first, last, hasArguments)); } IntegerType *findOrInsertIntegerType(int kind) { - for (unsigned i = 0; i < integerTypes.size(); ++i) { - IntegerType *ty = integerTypes.at(i); - - if (ty->kind() == kind) - return ty; - } - - IntegerType *ty = new IntegerType(kind); - integerTypes.push_back(ty); - return ty; + return integerTypes.intern(IntegerType(kind)); } FloatType *findOrInsertFloatType(int kind) { - for (unsigned i = 0; i < floatTypes.size(); ++i) { - FloatType *ty = floatTypes.at(i); - - if (ty->kind() == kind) - return ty; - } - - FloatType *ty = new FloatType(kind); - floatTypes.push_back(ty); - return ty; + return floatTypes.intern(FloatType(kind)); } - PointerToMemberType *findOrInsertPointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) + PointerToMemberType *findOrInsertPointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType) { - for (unsigned i = 0; i < pointerToMemberTypes.size(); ++i) { - PointerToMemberType *ty = pointerToMemberTypes.at(i); - if (ty->elementType().match(elementType, &matcher) && matcher.isEqualTo(ty->memberName(), memberName)) - return ty; - } - - PointerToMemberType *ty = new PointerToMemberType(memberName, elementType); - pointerToMemberTypes.push_back(ty); - return ty; + return pointerToMemberTypes.intern(PointerToMemberType(memberName, elementType)); } PointerType *findOrInsertPointerType(const FullySpecifiedType &elementType) { - for (unsigned i = 0; i < pointerTypes.size(); ++i) { - PointerType *ty = pointerTypes.at(i); - if (ty->elementType().match(elementType, &matcher)) - return ty; - } - - PointerType *ty = new PointerType(elementType); - pointerTypes.push_back(ty); - return ty; + return pointerTypes.intern(PointerType(elementType)); } ReferenceType *findOrInsertReferenceType(const FullySpecifiedType &elementType) { - for (unsigned i = 0; i < referenceTypes.size(); ++i) { - ReferenceType *ty = referenceTypes.at(i); - if (ty->elementType().match(elementType, &matcher)) - return ty; - } - - ReferenceType *ty = new ReferenceType(elementType); - referenceTypes.push_back(ty); - return ty; + return referenceTypes.intern(ReferenceType(elementType)); } ArrayType *findOrInsertArrayType(const FullySpecifiedType &elementType, unsigned size) { - for (unsigned i = 0; i < arrayTypes.size(); ++i) { - ArrayType *ty = arrayTypes.at(i); - if (ty->size() == size && ty->elementType().match(elementType, &matcher)) - return ty; - } - - ArrayType *ty = new ArrayType(elementType, size); - arrayTypes.push_back(ty); - return ty; + return arrayTypes.intern(ArrayType(elementType, size)); } - NamedType *findOrInsertNamedType(Name *name) + NamedType *findOrInsertNamedType(const Name *name) { - for (unsigned i = 0; i < namedTypes.size(); ++i) { - NamedType *ty = namedTypes.at(i); - if (matcher.isEqualTo(ty->name(), name)) - return ty; - } - - NamedType *ty = new NamedType(name); - namedTypes.push_back(ty); - return ty; + return namedTypes.intern(NamedType(name)); } - Declaration *newDeclaration(unsigned sourceLocation, Name *name) + Declaration *newDeclaration(unsigned sourceLocation, const Name *name) { Declaration *declaration = new Declaration(translationUnit, sourceLocation, name); @@ -288,7 +319,7 @@ public: return declaration; } - Argument *newArgument(unsigned sourceLocation, Name *name) + Argument *newArgument(unsigned sourceLocation, const Name *name) { Argument *argument = new Argument(translationUnit, sourceLocation, name); @@ -296,7 +327,7 @@ public: return argument; } - Function *newFunction(unsigned sourceLocation, Name *name) + Function *newFunction(unsigned sourceLocation, const Name *name) { Function *function = new Function(translationUnit, sourceLocation, name); @@ -304,7 +335,7 @@ public: return function; } - BaseClass *newBaseClass(unsigned sourceLocation, Name *name) + BaseClass *newBaseClass(unsigned sourceLocation, const Name *name) { BaseClass *baseClass = new BaseClass(translationUnit, sourceLocation, name); @@ -319,7 +350,7 @@ public: return block; } - Class *newClass(unsigned sourceLocation, Name *name) + Class *newClass(unsigned sourceLocation, const Name *name) { Class *klass = new Class(translationUnit, sourceLocation, name); @@ -327,7 +358,7 @@ public: return klass; } - Namespace *newNamespace(unsigned sourceLocation, Name *name) + Namespace *newNamespace(unsigned sourceLocation, const Name *name) { Namespace *ns = new Namespace(translationUnit, sourceLocation, name); @@ -335,7 +366,7 @@ public: return ns; } - UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name) + UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name) { UsingNamespaceDirective *u = new UsingNamespaceDirective(translationUnit, sourceLocation, name); @@ -343,7 +374,7 @@ public: return u; } - ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name) + ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name) { ForwardClassDeclaration *c = new ForwardClassDeclaration(translationUnit, sourceLocation, name); @@ -351,63 +382,63 @@ public: return c; } - ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name) + ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name) { ObjCBaseClass *c = new ObjCBaseClass(translationUnit, sourceLocation, name); symbols.push_back(c); return c; } - ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name) + ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name) { ObjCBaseProtocol *p = new ObjCBaseProtocol(translationUnit, sourceLocation, name); symbols.push_back(p); return p; } - ObjCClass *newObjCClass(unsigned sourceLocation, Name *name) + ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name) { ObjCClass *c = new ObjCClass(translationUnit, sourceLocation, name); symbols.push_back(c); return c; } - ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name) + ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name) { ObjCForwardClassDeclaration *fwd = new ObjCForwardClassDeclaration(translationUnit, sourceLocation, name); symbols.push_back(fwd); return fwd; } - ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name) + ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name) { ObjCProtocol *p = new ObjCProtocol(translationUnit, sourceLocation, name); symbols.push_back(p); return p; } - ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name) + ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name) { ObjCForwardProtocolDeclaration *fwd = new ObjCForwardProtocolDeclaration(translationUnit, sourceLocation, name); symbols.push_back(fwd); return fwd; } - ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name) + ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name) { ObjCMethod *method = new ObjCMethod(translationUnit, sourceLocation, name); symbols.push_back(method); return method; } - ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name) + ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name) { ObjCPropertyDeclaration *decl = new ObjCPropertyDeclaration(translationUnit, sourceLocation, name); symbols.push_back(decl); return decl; } - Enum *newEnum(unsigned sourceLocation, Name *name) + Enum *newEnum(unsigned sourceLocation, const Name *name) { Enum *e = new Enum(translationUnit, sourceLocation, name); @@ -415,7 +446,7 @@ public: return e; } - UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name) + UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name) { UsingDeclaration *u = new UsingDeclaration(translationUnit, sourceLocation, name); @@ -423,75 +454,6 @@ public: return u; } - struct TemplateNameIdKey { - Identifier *id; - std::vector<FullySpecifiedType> templateArguments; - - TemplateNameIdKey(Identifier *id, const std::vector<FullySpecifiedType> &templateArguments) - : id(id), templateArguments(templateArguments) - { } - - bool operator == (const TemplateNameIdKey &other) const - { return id == other.id && templateArguments == other.templateArguments; } - - bool operator != (const TemplateNameIdKey &other) const - { return ! operator==(other); } - - bool operator < (const TemplateNameIdKey &other) const - { - if (id == other.id) - return std::lexicographical_compare(templateArguments.begin(), - templateArguments.end(), - other.templateArguments.begin(), - other.templateArguments.end()); - return id < other.id; - } - }; - - struct QualifiedNameIdKey { - std::vector<Name *> names; - bool isGlobal; - - QualifiedNameIdKey(const std::vector<Name *> &names, bool isGlobal) : - names(names), isGlobal(isGlobal) - { } - - bool operator == (const QualifiedNameIdKey &other) const - { return isGlobal == other.isGlobal && names == other.names; } - - bool operator != (const QualifiedNameIdKey &other) const - { return ! operator==(other); } - - bool operator < (const QualifiedNameIdKey &other) const - { - if (isGlobal == other.isGlobal) - return std::lexicographical_compare(names.begin(), names.end(), - other.names.begin(), other.names.end()); - return isGlobal < other.isGlobal; - } - }; - - struct SelectorNameIdKey { - std::vector<Name *> _names; - bool _hasArguments; - - SelectorNameIdKey(const std::vector<Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {} - - bool operator==(const SelectorNameIdKey &other) const - { return _names == other._names && _hasArguments == other._hasArguments; } - - bool operator!=(const SelectorNameIdKey &other) const - { return !operator==(other); } - - bool operator<(const SelectorNameIdKey &other) const - { - if (_hasArguments == other._hasArguments) - return std::lexicographical_compare(_names.begin(), _names.end(), other._names.begin(), other._names.end()); - else - return _hasArguments < other._hasArguments; - } - }; - Control *control; TranslationUnit *translationUnit; DiagnosticClient *diagnosticClient; @@ -505,36 +467,36 @@ public: // ### replace std::map with lookup tables. ASAP! // names - std::map<Identifier *, NameId *> nameIds; - std::map<Identifier *, DestructorNameId *> destructorNameIds; - std::map<int, OperatorNameId *> operatorNameIds; - std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds; - std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds; - std::map<QualifiedNameIdKey, QualifiedNameId *> qualifiedNameIds; - std::map<SelectorNameIdKey, SelectorNameId *> selectorNameIds; + Table<NameId> nameIds; + Table<DestructorNameId> destructorNameIds; + Table<OperatorNameId> operatorNameIds; + Table<ConversionNameId> conversionNameIds; + Table<TemplateNameId> templateNameIds; + Table<QualifiedNameId> qualifiedNameIds; + Table<SelectorNameId> selectorNameIds; // types VoidType voidType; - Array<IntegerType *> integerTypes; - Array<FloatType *> floatTypes; - Array<PointerToMemberType *> pointerToMemberTypes; - Array<PointerType *> pointerTypes; - Array<ReferenceType *> referenceTypes; - Array<ArrayType *> arrayTypes; - Array<NamedType *> namedTypes; + Table<IntegerType> integerTypes; + Table<FloatType> floatTypes; + Table<PointerToMemberType> pointerToMemberTypes; + Table<PointerType> pointerTypes; + Table<ReferenceType> referenceTypes; + Table<ArrayType> arrayTypes; + Table<NamedType> namedTypes; // symbols - Array<Symbol *> symbols; + std::vector<Symbol *> symbols; // ObjC context keywords: - Identifier *objcGetterId; - Identifier *objcSetterId; - Identifier *objcReadwriteId; - Identifier *objcReadonlyId; - Identifier *objcAssignId; - Identifier *objcRetainId; - Identifier *objcCopyId; - Identifier *objcNonatomicId; + const Identifier *objcGetterId; + const Identifier *objcSetterId; + const Identifier *objcReadwriteId; + const Identifier *objcReadonlyId; + const Identifier *objcAssignId; + const Identifier *objcRetainId; + const Identifier *objcCopyId; + const Identifier *objcNonatomicId; }; Control::Control() @@ -570,13 +532,13 @@ DiagnosticClient *Control::diagnosticClient() const void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient) { d->diagnosticClient = diagnosticClient; } -Identifier *Control::findIdentifier(const char *chars, unsigned size) const +const Identifier *Control::findIdentifier(const char *chars, unsigned size) const { return d->identifiers.findLiteral(chars, size); } -Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size) +const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size) { return d->identifiers.findOrInsertLiteral(chars, size); } -Identifier *Control::findOrInsertIdentifier(const char *chars) +const Identifier *Control::findOrInsertIdentifier(const char *chars) { unsigned length = std::strlen(chars); return findOrInsertIdentifier(chars, length); @@ -600,58 +562,55 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const Control::NumericLiteralIterator Control::lastNumericLiteral() const { return d->numericLiterals.end(); } -StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size) +const StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size) { return d->stringLiterals.findOrInsertLiteral(chars, size); } -StringLiteral *Control::findOrInsertStringLiteral(const char *chars) +const StringLiteral *Control::findOrInsertStringLiteral(const char *chars) { unsigned length = std::strlen(chars); return findOrInsertStringLiteral(chars, length); } -NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size) +const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size) { return d->numericLiterals.findOrInsertLiteral(chars, size); } -NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars) +const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars) { unsigned length = std::strlen(chars); return findOrInsertNumericLiteral(chars, length); } -NameId *Control::nameId(Identifier *id) +const NameId *Control::nameId(const Identifier *id) { return d->findOrInsertNameId(id); } -TemplateNameId *Control::templateNameId(Identifier *id, - FullySpecifiedType *const args, - unsigned argv) +const TemplateNameId *Control::templateNameId(const Identifier *id, + const FullySpecifiedType *const args, + unsigned argv) { - std::vector<FullySpecifiedType> templateArguments(args, args + argv); - return d->findOrInsertTemplateNameId(id, templateArguments); + return d->findOrInsertTemplateNameId(id, args, args + argv); } -DestructorNameId *Control::destructorNameId(Identifier *id) +const DestructorNameId *Control::destructorNameId(const Identifier *id) { return d->findOrInsertDestructorNameId(id); } -OperatorNameId *Control::operatorNameId(int kind) +const OperatorNameId *Control::operatorNameId(int kind) { return d->findOrInsertOperatorNameId(kind); } -ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type) +const ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type) { return d->findOrInsertConversionNameId(type); } -QualifiedNameId *Control::qualifiedNameId(Name *const *names, - unsigned nameCount, - bool isGlobal) +const QualifiedNameId *Control::qualifiedNameId(const Name *const *names, + unsigned nameCount, + bool isGlobal) { - std::vector<Name *> classOrNamespaceNames(names, names + nameCount); - return d->findOrInsertQualifiedNameId(classOrNamespaceNames, isGlobal); + return d->findOrInsertQualifiedNameId(names, names + nameCount, isGlobal); } -SelectorNameId *Control::selectorNameId(Name *const *names, - unsigned nameCount, - bool hasArguments) +const SelectorNameId *Control::selectorNameId(const Name *const *names, + unsigned nameCount, + bool hasArguments) { - std::vector<Name *> selectorNames(names, names + nameCount); - return d->findOrInsertSelectorNameId(selectorNames, hasArguments); + return d->findOrInsertSelectorNameId(names, names + nameCount, hasArguments); } @@ -664,7 +623,7 @@ IntegerType *Control::integerType(int kind) FloatType *Control::floatType(int kind) { return d->findOrInsertFloatType(kind); } -PointerToMemberType *Control::pointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) +PointerToMemberType *Control::pointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType) { return d->findOrInsertPointerToMemberType(memberName, elementType); } PointerType *Control::pointerType(const FullySpecifiedType &elementType) @@ -676,88 +635,88 @@ ReferenceType *Control::referenceType(const FullySpecifiedType &elementType) ArrayType *Control::arrayType(const FullySpecifiedType &elementType, unsigned size) { return d->findOrInsertArrayType(elementType, size); } -NamedType *Control::namedType(Name *name) +NamedType *Control::namedType(const Name *name) { return d->findOrInsertNamedType(name); } -Argument *Control::newArgument(unsigned sourceLocation, Name *name) +Argument *Control::newArgument(unsigned sourceLocation, const Name *name) { return d->newArgument(sourceLocation, name); } -Function *Control::newFunction(unsigned sourceLocation, Name *name) +Function *Control::newFunction(unsigned sourceLocation, const Name *name) { return d->newFunction(sourceLocation, name); } -Namespace *Control::newNamespace(unsigned sourceLocation, Name *name) +Namespace *Control::newNamespace(unsigned sourceLocation, const Name *name) { return d->newNamespace(sourceLocation, name); } -BaseClass *Control::newBaseClass(unsigned sourceLocation, Name *name) +BaseClass *Control::newBaseClass(unsigned sourceLocation, const Name *name) { return d->newBaseClass(sourceLocation, name); } -Class *Control::newClass(unsigned sourceLocation, Name *name) +Class *Control::newClass(unsigned sourceLocation, const Name *name) { return d->newClass(sourceLocation, name); } -Enum *Control::newEnum(unsigned sourceLocation, Name *name) +Enum *Control::newEnum(unsigned sourceLocation, const Name *name) { return d->newEnum(sourceLocation, name); } Block *Control::newBlock(unsigned sourceLocation) { return d->newBlock(sourceLocation); } -Declaration *Control::newDeclaration(unsigned sourceLocation, Name *name) +Declaration *Control::newDeclaration(unsigned sourceLocation, const Name *name) { return d->newDeclaration(sourceLocation, name); } UsingNamespaceDirective *Control::newUsingNamespaceDirective(unsigned sourceLocation, - Name *name) + const Name *name) { return d->newUsingNamespaceDirective(sourceLocation, name); } -UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, Name *name) +UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, const Name *name) { return d->newUsingDeclaration(sourceLocation, name); } ForwardClassDeclaration *Control::newForwardClassDeclaration(unsigned sourceLocation, - Name *name) + const Name *name) { return d->newForwardClassDeclaration(sourceLocation, name); } -ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, Name *name) +ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, const Name *name) { return d->newObjCBaseClass(sourceLocation, name); } -ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, Name *name) +ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, const Name *name) { return d->newObjCBaseProtocol(sourceLocation, name); } -ObjCClass *Control::newObjCClass(unsigned sourceLocation, Name *name) +ObjCClass *Control::newObjCClass(unsigned sourceLocation, const Name *name) { return d->newObjCClass(sourceLocation, name); } -ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name) +ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name) { return d->newObjCForwardClassDeclaration(sourceLocation, name); } -ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, Name *name) +ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, const Name *name) { return d->newObjCProtocol(sourceLocation, name); } -ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name) +ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name) { return d->newObjCForwardProtocolDeclaration(sourceLocation, name); } -ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name) +ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, const Name *name) { return d->newObjCMethod(sourceLocation, name); } -ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name) +ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name) { return d->newObjCPropertyDeclaration(sourceLocation, name); } -Identifier *Control::objcGetterId() const +const Identifier *Control::objcGetterId() const { return d->objcGetterId; } -Identifier *Control::objcSetterId() const +const Identifier *Control::objcSetterId() const { return d->objcSetterId; } -Identifier *Control::objcReadwriteId() const +const Identifier *Control::objcReadwriteId() const { return d->objcReadwriteId; } -Identifier *Control::objcReadonlyId() const +const Identifier *Control::objcReadonlyId() const { return d->objcReadonlyId; } -Identifier *Control::objcAssignId() const +const Identifier *Control::objcAssignId() const { return d->objcAssignId; } -Identifier *Control::objcRetainId() const +const Identifier *Control::objcRetainId() const { return d->objcRetainId; } -Identifier *Control::objcCopyId() const +const Identifier *Control::objcCopyId() const { return d->objcCopyId; } -Identifier *Control::objcNonatomicId() const +const Identifier *Control::objcNonatomicId() const { return d->objcNonatomicId; } diff --git a/src/shared/cplusplus/Control.h b/src/shared/cplusplus/Control.h index 53203f832f3172d7a3337fc8f61bfb14fa83a6cc..4881b416e8e0cf6e7a4eca9c127d4925c84a6075 100644 --- a/src/shared/cplusplus/Control.h +++ b/src/shared/cplusplus/Control.h @@ -66,30 +66,30 @@ public: void setDiagnosticClient(DiagnosticClient *diagnosticClient); /// Returns the canonical name id. - NameId *nameId(Identifier *id); + const NameId *nameId(const Identifier *id); /// Returns the canonical template name id. - TemplateNameId *templateNameId(Identifier *id, - FullySpecifiedType *const args = 0, - unsigned argc = 0); + const TemplateNameId *templateNameId(const Identifier *id, + const FullySpecifiedType *const args = 0, + unsigned argc = 0); /// Returns the canonical destructor name id. - DestructorNameId *destructorNameId(Identifier *id); + const DestructorNameId *destructorNameId(const Identifier *id); /// Returns the canonical operator name id. - OperatorNameId *operatorNameId(int operatorId); + const OperatorNameId *operatorNameId(int operatorId); /// Returns the canonical conversion name id. - ConversionNameId *conversionNameId(const FullySpecifiedType &type); + const ConversionNameId *conversionNameId(const FullySpecifiedType &type); /// Returns the canonical qualified name id. - QualifiedNameId *qualifiedNameId(Name *const *names, - unsigned nameCount, - bool isGlobal = false); + const QualifiedNameId *qualifiedNameId(const Name *const *names, + unsigned nameCount, + bool isGlobal = false); - SelectorNameId *selectorNameId(Name *const *names, - unsigned nameCount, - bool hasArguments); + const SelectorNameId *selectorNameId(const Name *const *names, + unsigned nameCount, + bool hasArguments); /// Returns a Type object of type VoidType. VoidType *voidType(); @@ -101,7 +101,7 @@ public: FloatType *floatType(int floatId); /// Returns a Type object of type PointertoMemberType. - PointerToMemberType *pointerToMemberType(Name *memberName, + PointerToMemberType *pointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType); /// Returns a Type object of type PointerType. @@ -114,76 +114,75 @@ public: ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0); /// Returns a Type object of type NamedType. - NamedType *namedType(Name *name); + NamedType *namedType(const Name *name); /// Creates a new Declaration symbol. - Declaration *newDeclaration(unsigned sourceLocation, Name *name); + Declaration *newDeclaration(unsigned sourceLocation, const Name *name); /// Creates a new Argument symbol. - Argument *newArgument(unsigned sourceLocation, Name *name = 0); + Argument *newArgument(unsigned sourceLocation, const Name *name = 0); /// Creates a new Function symbol. - Function *newFunction(unsigned sourceLocation, Name *name = 0); + Function *newFunction(unsigned sourceLocation, const Name *name = 0); /// Creates a new Namespace symbol. - Namespace *newNamespace(unsigned sourceLocation, Name *name = 0); + Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0); /// Creates a new BaseClass symbol. - BaseClass *newBaseClass(unsigned sourceLocation, Name *name = 0); + BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0); /// Creates a new Class symbol. - Class *newClass(unsigned sourceLocation, Name *name = 0); + Class *newClass(unsigned sourceLocation, const Name *name = 0); /// Creates a new Enum symbol. - Enum *newEnum(unsigned sourceLocation, Name *name = 0); + Enum *newEnum(unsigned sourceLocation, const Name *name = 0); /// Creates a new Block symbol. Block *newBlock(unsigned sourceLocation); /// Creates a new UsingNamespaceDirective symbol. - UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name = 0); + UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0); /// Creates a new UsingDeclaration symbol. - UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name = 0); + UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0); /// Creates a new ForwardClassDeclaration symbol. - ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name = 0); + ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0); - ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name); - ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name); + ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name); + ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name); /// Creates a new Objective-C class symbol. - ObjCClass *newObjCClass(unsigned sourceLocation, Name *name = 0); + ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0); /// Creates a new Objective-C class forward declaration symbol. - ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name = 0); + ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0); /// Creates a new Objective-C protocol symbol. - ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name = 0); + ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0); /// Creates a new Objective-C protocol forward declaration symbol. - ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name = 0); + ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0); /// Creates a new Objective-C method symbol. - ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name = 0); + ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0); /// Creates a new Objective-C @property declaration symbol. - ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name); + ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name); // Objective-C specific context keywords. - Identifier *objcGetterId() const; - Identifier *objcSetterId() const; - Identifier *objcReadwriteId() const; - Identifier *objcReadonlyId() const; - Identifier *objcAssignId() const; - Identifier *objcRetainId() const; - Identifier *objcCopyId() const; - Identifier *objcNonatomicId() const; - - Identifier *findIdentifier(const char *chars, unsigned size) const; - - Identifier *findOrInsertIdentifier(const char *chars, unsigned size); - Identifier *findOrInsertIdentifier(const char *chars); + const Identifier *objcGetterId() const; + const Identifier *objcSetterId() const; + const Identifier *objcReadwriteId() const; + const Identifier *objcReadonlyId() const; + const Identifier *objcAssignId() const; + const Identifier *objcRetainId() const; + const Identifier *objcCopyId() const; + const Identifier *objcNonatomicId() const; + + const Identifier *findIdentifier(const char *chars, unsigned size) const; + const Identifier *findOrInsertIdentifier(const char *chars, unsigned size); + const Identifier *findOrInsertIdentifier(const char *chars); typedef const Identifier *const *IdentifierIterator; typedef const StringLiteral *const *StringLiteralIterator; @@ -198,11 +197,11 @@ public: NumericLiteralIterator firstNumericLiteral() const; NumericLiteralIterator lastNumericLiteral() const; - StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size); - StringLiteral *findOrInsertStringLiteral(const char *chars); + const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size); + const StringLiteral *findOrInsertStringLiteral(const char *chars); - NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size); - NumericLiteral *findOrInsertNumericLiteral(const char *chars); + const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size); + const NumericLiteral *findOrInsertNumericLiteral(const char *chars); private: class Data; diff --git a/src/shared/cplusplus/CoreTypes.cpp b/src/shared/cplusplus/CoreTypes.cpp index 9bdd17a827f0a3fac2e275d53d62320646024b32..43d9f8bab00e79b43383456c7d5df7c35469e90d 100644 --- a/src/shared/cplusplus/CoreTypes.cpp +++ b/src/shared/cplusplus/CoreTypes.cpp @@ -90,7 +90,7 @@ bool VoidType::matchType0(const Type *otherType, TypeMatcher *matcher) const return false; } -PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) +PointerToMemberType::PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType) : _memberName(memberName), _elementType(elementType) { } @@ -98,7 +98,7 @@ PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedT PointerToMemberType::~PointerToMemberType() { } -Name *PointerToMemberType::memberName() const +const Name *PointerToMemberType::memberName() const { return _memberName; } FullySpecifiedType PointerToMemberType::elementType() const @@ -275,14 +275,14 @@ FullySpecifiedType ArrayType::elementType() const unsigned ArrayType::size() const { return _size; } -NamedType::NamedType(Name *name) +NamedType::NamedType(const Name *name) : _name(name) { } NamedType::~NamedType() { } -Name *NamedType::name() const +const Name *NamedType::name() const { return _name; } bool NamedType::isEqualTo(const Type *other) const @@ -291,12 +291,12 @@ bool NamedType::isEqualTo(const Type *other) const if (! o) return false; - Name *name = _name; - if (QualifiedNameId *q = name->asQualifiedNameId()) + const Name *name = _name; + if (const QualifiedNameId *q = name->asQualifiedNameId()) name = q->unqualifiedNameId(); - Name *otherName = o->name(); - if (QualifiedNameId *q = otherName->asQualifiedNameId()) + const Name *otherName = o->name(); + if (const QualifiedNameId *q = otherName->asQualifiedNameId()) otherName = q->unqualifiedNameId(); return name->isEqualTo(otherName); diff --git a/src/shared/cplusplus/CoreTypes.h b/src/shared/cplusplus/CoreTypes.h index dc70f06ddf6f3d96794b67a67519fcb8343568ff..42d69b4cb3966c52c5e9c1041e81f2de2ac7154e 100644 --- a/src/shared/cplusplus/CoreTypes.h +++ b/src/shared/cplusplus/CoreTypes.h @@ -186,10 +186,10 @@ private: class CPLUSPLUS_EXPORT PointerToMemberType: public Type { public: - PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType); + PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType); virtual ~PointerToMemberType(); - Name *memberName() const; + const Name *memberName() const; FullySpecifiedType elementType() const; virtual bool isEqualTo(const Type *other) const; @@ -205,7 +205,7 @@ protected: virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const; private: - Name *_memberName; + const Name *_memberName; FullySpecifiedType _elementType; }; @@ -262,10 +262,10 @@ private: class CPLUSPLUS_EXPORT NamedType: public Type { public: - NamedType(Name *name); + NamedType(const Name *name); virtual ~NamedType(); - Name *name() const; + const Name *name() const; virtual bool isEqualTo(const Type *other) const; @@ -280,7 +280,7 @@ protected: virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const; private: - Name *_name; + const Name *_name; }; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/DiagnosticClient.h b/src/shared/cplusplus/DiagnosticClient.h index ff83a4c6f9a010de6d9bf6d9e32511106b56693c..2c1434cbafeb32effdbdc002f5a58039648fe85f 100644 --- a/src/shared/cplusplus/DiagnosticClient.h +++ b/src/shared/cplusplus/DiagnosticClient.h @@ -71,7 +71,7 @@ public: virtual ~DiagnosticClient(); virtual void report(int level, - StringLiteral *fileName, + const StringLiteral *fileName, unsigned line, unsigned column, const char *format, va_list ap) = 0; }; diff --git a/src/shared/cplusplus/Keywords.cpp b/src/shared/cplusplus/Keywords.cpp index 48af12447368460072e1f25d2064cfa19be595b7..6da25125f7b6e0c8657fc8b0b55518c3077fc4b4 100644 --- a/src/shared/cplusplus/Keywords.cpp +++ b/src/shared/cplusplus/Keywords.cpp @@ -65,7 +65,7 @@ static inline int classify2(const char *s, bool) { return T_IDENTIFIER; } -static inline int classify3(const char *s, bool) { +static inline int classify3(const char *s, bool q) { if (s[0] == 'a') { if (s[1] == 's') { if (s[2] == 'm') { @@ -101,6 +101,16 @@ static inline int classify3(const char *s, bool) { } } } + else if (q && s[0] == 'Q') { + if (s[1] == '_') { + if (s[2] == 'D') { + return T_Q_D; + } + else if (s[2] == 'Q') { + return T_Q_Q; + } + } + } return T_IDENTIFIER; } diff --git a/src/shared/cplusplus/LiteralTable.h b/src/shared/cplusplus/LiteralTable.h index ff4246748f9be209f424be109e1d1c58072d00d1..408db390531352d143664d6048c95acc117f3e17 100644 --- a/src/shared/cplusplus/LiteralTable.h +++ b/src/shared/cplusplus/LiteralTable.h @@ -61,7 +61,7 @@ class LiteralTable void operator =(const LiteralTable &other); public: - typedef _Literal **iterator; + typedef _Literal *const *iterator; public: LiteralTable() @@ -74,14 +74,14 @@ public: ~LiteralTable() { - if (_literals) { - _Literal **lastLiteral = _literals + _literalCount + 1; - for (_Literal **it = _literals; it != lastLiteral; ++it) - delete *it; - std::free(_literals); - } - if (_buckets) - std::free(_buckets); + if (_literals) { + _Literal **lastLiteral = _literals + _literalCount + 1; + for (_Literal **it = _literals; it != lastLiteral; ++it) + delete *it; + std::free(_literals); + } + if (_buckets) + std::free(_buckets); } bool empty() const @@ -90,7 +90,7 @@ public: unsigned size() const { return _literalCount + 1; } - _Literal *at(unsigned index) const + const _Literal *at(unsigned index) const { return _literals[index]; } iterator begin() const @@ -99,53 +99,53 @@ public: iterator end() const { return _literals + _literalCount + 1; } - _Literal *findLiteral(const char *chars, unsigned size) const + const _Literal *findLiteral(const char *chars, unsigned size) const { - if (_buckets) { - unsigned h = _Literal::hashCode(chars, size); - _Literal *literal = _buckets[h % _allocatedBuckets]; - for (; literal; literal = static_cast<_Literal *>(literal->_next)) { - if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size)) - return literal; - } - } - - return 0; - } + if (_buckets) { + unsigned h = _Literal::hashCode(chars, size); + _Literal *literal = _buckets[h % _allocatedBuckets]; + for (; literal; literal = static_cast<_Literal *>(literal->_next)) { + if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size)) + return literal; + } + } + + return 0; + } - _Literal *findOrInsertLiteral(const char *chars, unsigned size) + const _Literal *findOrInsertLiteral(const char *chars, unsigned size) { - if (_buckets) { - unsigned h = _Literal::hashCode(chars, size); - _Literal *literal = _buckets[h % _allocatedBuckets]; - for (; literal; literal = static_cast<_Literal *>(literal->_next)) { - if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size)) - return literal; - } - } + if (_buckets) { + unsigned h = _Literal::hashCode(chars, size); + _Literal *literal = _buckets[h % _allocatedBuckets]; + for (; literal; literal = static_cast<_Literal *>(literal->_next)) { + if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size)) + return literal; + } + } - _Literal *literal = new _Literal(chars, size); + _Literal *literal = new _Literal(chars, size); - if (++_literalCount == _allocatedLiterals) { - _allocatedLiterals <<= 1; + if (++_literalCount == _allocatedLiterals) { + _allocatedLiterals <<= 1; - if (! _allocatedLiterals) - _allocatedLiterals = 256; + if (! _allocatedLiterals) + _allocatedLiterals = 256; - _literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals); - } + _literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals); + } - _literals[_literalCount] = literal; + _literals[_literalCount] = literal; - if (! _buckets || _literalCount >= _allocatedBuckets * .6) - rehash(); - else { - unsigned h = literal->hashCode() % _allocatedBuckets; - literal->_next = _buckets[h]; - _buckets[h] = literal; - } + if (! _buckets || _literalCount >= _allocatedBuckets * .6) + rehash(); + else { + unsigned h = literal->hashCode() % _allocatedBuckets; + literal->_next = _buckets[h]; + _buckets[h] = literal; + } - return literal; + return literal; } protected: diff --git a/src/shared/cplusplus/Name.cpp b/src/shared/cplusplus/Name.cpp index 6354382551da38d84d37076433c7d590c4616666..b185409cf6b5db4db9d7cb8ce8c06ae3374f371b 100644 --- a/src/shared/cplusplus/Name.cpp +++ b/src/shared/cplusplus/Name.cpp @@ -79,14 +79,14 @@ bool Name::isQualifiedNameId() const bool Name::isSelectorNameId() const { return asSelectorNameId() != 0; } -void Name::accept(NameVisitor *visitor) +void Name::accept(NameVisitor *visitor) const { if (visitor->preVisit(this)) accept0(visitor); visitor->postVisit(this); } -void Name::accept(Name *name, NameVisitor *visitor) +void Name::accept(const Name *name, NameVisitor *visitor) { if (! name) return; diff --git a/src/shared/cplusplus/Name.h b/src/shared/cplusplus/Name.h index 45dfef86e652416ba3f99a0c6f2bb9c25cae3bdb..ea740bd2497f251ddc81d8b80315eb673838795b 100644 --- a/src/shared/cplusplus/Name.h +++ b/src/shared/cplusplus/Name.h @@ -56,14 +56,11 @@ namespace CPlusPlus { class CPLUSPLUS_EXPORT Name { - Name(const Name &other); - void operator =(const Name &other); - public: Name(); virtual ~Name(); - virtual Identifier *identifier() const = 0; + virtual const Identifier *identifier() const = 0; bool isNameId() const; bool isTemplateNameId() const; @@ -81,21 +78,13 @@ public: virtual const QualifiedNameId *asQualifiedNameId() const { return 0; } virtual const SelectorNameId *asSelectorNameId() const { return 0; } - virtual NameId *asNameId() { return 0; } - virtual TemplateNameId *asTemplateNameId() { return 0; } - virtual DestructorNameId *asDestructorNameId() { return 0; } - virtual OperatorNameId *asOperatorNameId() { return 0; } - virtual ConversionNameId *asConversionNameId() { return 0; } - virtual QualifiedNameId *asQualifiedNameId() { return 0; } - virtual SelectorNameId *asSelectorNameId() { return 0; } - virtual bool isEqualTo(const Name *other) const = 0; - void accept(NameVisitor *visitor); - static void accept(Name *name, NameVisitor *visitor); + void accept(NameVisitor *visitor) const; + static void accept(const Name *name, NameVisitor *visitor); protected: - virtual void accept0(NameVisitor *visitor) = 0; + virtual void accept0(NameVisitor *visitor) const = 0; }; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/NameVisitor.cpp b/src/shared/cplusplus/NameVisitor.cpp index 29630661d78a0b12a9e7956c4738aa126ab049b3..fe9d5cda09bde4ef447be1d8aab0f9436fc267fb 100644 --- a/src/shared/cplusplus/NameVisitor.cpp +++ b/src/shared/cplusplus/NameVisitor.cpp @@ -57,7 +57,5 @@ NameVisitor::NameVisitor() NameVisitor::~NameVisitor() { } -void NameVisitor::accept(Name *name) +void NameVisitor::accept(const Name *name) { Name::accept(name, this); } - - diff --git a/src/shared/cplusplus/NameVisitor.h b/src/shared/cplusplus/NameVisitor.h index f8889b7d7f6294f0a8e67fc3ae95d7b7dbf8faed..d567c30be8b02c501a209ec133f377bb29cc8e75 100644 --- a/src/shared/cplusplus/NameVisitor.h +++ b/src/shared/cplusplus/NameVisitor.h @@ -63,18 +63,18 @@ public: NameVisitor(); virtual ~NameVisitor(); - void accept(Name *name); + void accept(const Name *name); - virtual bool preVisit(Name *) { return true; } - virtual void postVisit(Name *) {} + virtual bool preVisit(const Name *) { return true; } + virtual void postVisit(const Name *) {} - virtual void visit(NameId *) {} - virtual void visit(TemplateNameId *) {} - virtual void visit(DestructorNameId *) {} - virtual void visit(OperatorNameId *) {} - virtual void visit(ConversionNameId *) {} - virtual void visit(QualifiedNameId *) {} - virtual void visit(SelectorNameId *) {} + virtual void visit(const NameId *) {} + virtual void visit(const TemplateNameId *) {} + virtual void visit(const DestructorNameId *) {} + virtual void visit(const OperatorNameId *) {} + virtual void visit(const ConversionNameId *) {} + virtual void visit(const QualifiedNameId *) {} + virtual void visit(const SelectorNameId *) {} }; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/Names.cpp b/src/shared/cplusplus/Names.cpp index e73abb5c471440d092069bb957f1c144fcbb287d..79196da173f75bb09dec4771834f01846af88056 100644 --- a/src/shared/cplusplus/Names.cpp +++ b/src/shared/cplusplus/Names.cpp @@ -50,55 +50,40 @@ #include "NameVisitor.h" #include "Literals.h" #include <cstring> +#include <cassert> #include <algorithm> using namespace CPlusPlus; -QualifiedNameId::QualifiedNameId(Name *const names[], - unsigned nameCount, - bool isGlobal) - : _names(0), - _nameCount(nameCount), - _isGlobal(isGlobal) -{ - if (_nameCount) { - _names = new Name *[_nameCount]; - std::copy(&names[0], &names[nameCount], _names); - } -} - QualifiedNameId::~QualifiedNameId() -{ delete[] _names; } +{ } -void QualifiedNameId::accept0(NameVisitor *visitor) +void QualifiedNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } -Identifier *QualifiedNameId::identifier() const +const Identifier *QualifiedNameId::identifier() const { - if (Name *u = unqualifiedNameId()) + if (const Name *u = unqualifiedNameId()) return u->identifier(); return 0; } unsigned QualifiedNameId::nameCount() const -{ return _nameCount; } +{ return _names.size(); } -Name *QualifiedNameId::nameAt(unsigned index) const +const Name *QualifiedNameId::nameAt(unsigned index) const { return _names[index]; } -Name *const *QualifiedNameId::names() const -{ return _names; } - bool QualifiedNameId::isGlobal() const { return _isGlobal; } -Name *QualifiedNameId::unqualifiedNameId() const +const Name *QualifiedNameId::unqualifiedNameId() const { - if (! _nameCount) + if (_names.empty()) return 0; - return _names[_nameCount - 1]; + return _names.back(); } bool QualifiedNameId::isEqualTo(const Name *other) const @@ -113,8 +98,8 @@ bool QualifiedNameId::isEqualTo(const Name *other) const if (count != q->nameCount()) return false; for (unsigned i = 0; i < count; ++i) { - Name *l = nameAt(i); - Name *r = q->nameAt(i); + const Name *l = nameAt(i); + const Name *r = q->nameAt(i); if (! l->isEqualTo(r)) return false; } @@ -122,17 +107,17 @@ bool QualifiedNameId::isEqualTo(const Name *other) const return true; } -NameId::NameId(Identifier *identifier) +NameId::NameId(const Identifier *identifier) : _identifier(identifier) { } NameId::~NameId() { } -void NameId::accept0(NameVisitor *visitor) +void NameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } -Identifier *NameId::identifier() const +const Identifier *NameId::identifier() const { return _identifier; } bool NameId::isEqualTo(const Name *other) const @@ -140,22 +125,22 @@ bool NameId::isEqualTo(const Name *other) const const NameId *nameId = other->asNameId(); if (! nameId) return false; - Identifier *l = identifier(); - Identifier *r = nameId->identifier(); + const Identifier *l = identifier(); + const Identifier *r = nameId->identifier(); return l->isEqualTo(r); } -DestructorNameId::DestructorNameId(Identifier *identifier) +DestructorNameId::DestructorNameId(const Identifier *identifier) : _identifier(identifier) { } DestructorNameId::~DestructorNameId() { } -void DestructorNameId::accept0(NameVisitor *visitor) +void DestructorNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } -Identifier *DestructorNameId::identifier() const +const Identifier *DestructorNameId::identifier() const { return _identifier; } bool DestructorNameId::isEqualTo(const Name *other) const @@ -163,55 +148,38 @@ bool DestructorNameId::isEqualTo(const Name *other) const const DestructorNameId *d = other->asDestructorNameId(); if (! d) return false; - Identifier *l = identifier(); - Identifier *r = d->identifier(); + const Identifier *l = identifier(); + const Identifier *r = d->identifier(); return l->isEqualTo(r); } -TemplateNameId::TemplateNameId(Identifier *identifier, - const FullySpecifiedType templateArguments[], - unsigned templateArgumentCount) - : _identifier(identifier), - _templateArguments(0), - _templateArgumentCount(templateArgumentCount) -{ - if (_templateArgumentCount) { - _templateArguments = new FullySpecifiedType[_templateArgumentCount]; - std::copy(&templateArguments[0], &templateArguments[_templateArgumentCount], - _templateArguments); - } -} - TemplateNameId::~TemplateNameId() -{ delete[] _templateArguments; } +{ } -void TemplateNameId::accept0(NameVisitor *visitor) +void TemplateNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } -Identifier *TemplateNameId::identifier() const +const Identifier *TemplateNameId::identifier() const { return _identifier; } unsigned TemplateNameId::templateArgumentCount() const -{ return _templateArgumentCount; } +{ return _templateArguments.size(); } const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const { return _templateArguments[index]; } -const FullySpecifiedType *TemplateNameId::templateArguments() const -{ return _templateArguments; } - bool TemplateNameId::isEqualTo(const Name *other) const { const TemplateNameId *t = other->asTemplateNameId(); if (! t) return false; - Identifier *l = identifier(); - Identifier *r = t->identifier(); + const Identifier *l = identifier(); + const Identifier *r = t->identifier(); if (! l->isEqualTo(r)) return false; - if (_templateArgumentCount != t->_templateArgumentCount) + if (templateArgumentCount() != t->templateArgumentCount()) return false; - for (unsigned i = 0; i < _templateArgumentCount; ++i) { + for (unsigned i = 0; i < templateArgumentCount(); ++i) { const FullySpecifiedType &l = _templateArguments[i]; const FullySpecifiedType &r = t->_templateArguments[i]; if (! l.isEqualTo(r)) @@ -227,13 +195,13 @@ OperatorNameId::OperatorNameId(int kind) OperatorNameId::~OperatorNameId() { } -void OperatorNameId::accept0(NameVisitor *visitor) +void OperatorNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } int OperatorNameId::kind() const { return _kind; } -Identifier *OperatorNameId::identifier() const +const Identifier *OperatorNameId::identifier() const { return 0; } bool OperatorNameId::isEqualTo(const Name *other) const @@ -251,13 +219,13 @@ ConversionNameId::ConversionNameId(const FullySpecifiedType &type) ConversionNameId::~ConversionNameId() { } -void ConversionNameId::accept0(NameVisitor *visitor) +void ConversionNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } FullySpecifiedType ConversionNameId::type() const { return _type; } -Identifier *ConversionNameId::identifier() const +const Identifier *ConversionNameId::identifier() const { return 0; } bool ConversionNameId::isEqualTo(const Name *other) const @@ -268,42 +236,26 @@ bool ConversionNameId::isEqualTo(const Name *other) const return _type.isEqualTo(c->type()); } -SelectorNameId::SelectorNameId(Name *const names[], - unsigned nameCount, - bool hasArguments) - : _names(0), - _nameCount(nameCount), - _hasArguments(hasArguments) -{ - if (_nameCount) { - _names = new Name *[_nameCount]; - std::copy(&names[0], &names[nameCount], _names); - } -} - SelectorNameId::~SelectorNameId() -{ delete[] _names; } +{ } -void SelectorNameId::accept0(NameVisitor *visitor) +void SelectorNameId::accept0(NameVisitor *visitor) const { visitor->visit(this); } -Identifier *SelectorNameId::identifier() const +const Identifier *SelectorNameId::identifier() const { - if (! _nameCount) + if (_names.empty()) return 0; return nameAt(0)->identifier(); } unsigned SelectorNameId::nameCount() const -{ return _nameCount; } +{ return _names.size(); } -Name *SelectorNameId::nameAt(unsigned index) const +const Name *SelectorNameId::nameAt(unsigned index) const { return _names[index]; } -Name *const *SelectorNameId::names() const -{ return _names; } - bool SelectorNameId::hasArguments() const { return _hasArguments; } @@ -319,8 +271,8 @@ bool SelectorNameId::isEqualTo(const Name *other) const if (count != q->nameCount()) return false; for (unsigned i = 0; i < count; ++i) { - Name *l = nameAt(i); - Name *r = q->nameAt(i); + const Name *l = nameAt(i); + const Name *r = q->nameAt(i); if (! l->isEqualTo(r)) return false; } diff --git a/src/shared/cplusplus/Names.h b/src/shared/cplusplus/Names.h index a30bffb01352a839fc2e1f77a8fe2ac713cc33a5..9ce31a9b60efaae27390c5a84e3e4e5cf46d343e 100644 --- a/src/shared/cplusplus/Names.h +++ b/src/shared/cplusplus/Names.h @@ -52,24 +52,25 @@ #include "CPlusPlusForwardDeclarations.h" #include "Name.h" #include "FullySpecifiedType.h" +#include <vector> namespace CPlusPlus { class CPLUSPLUS_EXPORT QualifiedNameId: public Name { public: - QualifiedNameId(Name *const names[], - unsigned nameCount, - bool isGlobal = false); + template <typename _Iterator> + QualifiedNameId(_Iterator first, _Iterator last, bool isGlobal = false) + : _names(first, last), _isGlobal(isGlobal) {} + virtual ~QualifiedNameId(); - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; unsigned nameCount() const; - Name *nameAt(unsigned index) const; - Name *const *names() const; - Name *unqualifiedNameId() const; - + const Name *nameAt(unsigned index) const; + const Name *unqualifiedNameId() const; + const Name *const *names() const { return &_names[0]; } // ### remove me bool isGlobal() const; virtual bool isEqualTo(const Name *other) const; @@ -77,94 +78,90 @@ public: virtual const QualifiedNameId *asQualifiedNameId() const { return this; } - virtual QualifiedNameId *asQualifiedNameId() - { return this; } + typedef std::vector<const Name *>::const_iterator NameIterator; + + NameIterator firstName() const { return _names.begin(); } + NameIterator lastName() const { return _names.end(); } protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: - Name **_names; - unsigned _nameCount; + std::vector<const Name *> _names; bool _isGlobal; }; class CPLUSPLUS_EXPORT NameId: public Name { public: - NameId(Identifier *identifier); + NameId(const Identifier *identifier); virtual ~NameId(); - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; virtual bool isEqualTo(const Name *other) const; virtual const NameId *asNameId() const { return this; } - virtual NameId *asNameId() - { return this; } - protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: - Identifier *_identifier; + const Identifier *_identifier; }; class CPLUSPLUS_EXPORT DestructorNameId: public Name { public: - DestructorNameId(Identifier *identifier); + DestructorNameId(const Identifier *identifier); virtual ~DestructorNameId(); - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; virtual bool isEqualTo(const Name *other) const; virtual const DestructorNameId *asDestructorNameId() const { return this; } - virtual DestructorNameId *asDestructorNameId() - { return this; } - protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: - Identifier *_identifier; + const Identifier *_identifier; }; class CPLUSPLUS_EXPORT TemplateNameId: public Name { public: - TemplateNameId(Identifier *identifier, - const FullySpecifiedType templateArguments[], - unsigned templateArgumentCount); + template <typename _Iterator> + TemplateNameId(const Identifier *identifier, _Iterator first, _Iterator last) + : _identifier(identifier), _templateArguments(first, last) {} + virtual ~TemplateNameId(); - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; // ### find a better name unsigned templateArgumentCount() const; const FullySpecifiedType &templateArgumentAt(unsigned index) const; - const FullySpecifiedType *templateArguments() const; virtual bool isEqualTo(const Name *other) const; virtual const TemplateNameId *asTemplateNameId() const { return this; } - virtual TemplateNameId *asTemplateNameId() - { return this; } + typedef std::vector<FullySpecifiedType>::const_iterator TemplateArgumentIterator; + + TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); } + TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); } protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: - Identifier *_identifier; - FullySpecifiedType *_templateArguments; - unsigned _templateArgumentCount; + const Identifier *_identifier; + std::vector<FullySpecifiedType> _templateArguments; }; class CPLUSPLUS_EXPORT OperatorNameId: public Name @@ -230,17 +227,14 @@ public: int kind() const; - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; virtual bool isEqualTo(const Name *other) const; virtual const OperatorNameId *asOperatorNameId() const { return this; } - virtual OperatorNameId *asOperatorNameId() - { return this; } - protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: int _kind; @@ -254,17 +248,14 @@ public: FullySpecifiedType type() const; - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; virtual bool isEqualTo(const Name *other) const; virtual const ConversionNameId *asConversionNameId() const { return this; } - virtual ConversionNameId *asConversionNameId() - { return this; } - protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: FullySpecifiedType _type; @@ -273,17 +264,16 @@ private: class CPLUSPLUS_EXPORT SelectorNameId: public Name { public: - SelectorNameId(Name *const names[], - unsigned nameCount, - bool hasArguments); + template <typename _Iterator> + SelectorNameId(_Iterator first, _Iterator last, bool hasArguments) + : _names(first, last), _hasArguments(hasArguments) {} + virtual ~SelectorNameId(); - virtual Identifier *identifier() const; + virtual const Identifier *identifier() const; unsigned nameCount() const; - Name *nameAt(unsigned index) const; - Name *const *names() const; - + const Name *nameAt(unsigned index) const; bool hasArguments() const; virtual bool isEqualTo(const Name *other) const; @@ -291,19 +281,19 @@ public: virtual const SelectorNameId *asSelectorNameId() const { return this; } - virtual SelectorNameId *asSelectorNameId() - { return this; } + typedef std::vector<const Name *>::const_iterator NameIterator; + + NameIterator firstName() const { return _names.begin(); } + NameIterator lastName() const { return _names.end(); } protected: - virtual void accept0(NameVisitor *visitor); + virtual void accept0(NameVisitor *visitor) const; private: - Name **_names; - unsigned _nameCount; + std::vector<const Name *> _names; bool _hasArguments; }; } // end of namespace CPlusPlus - #endif // CPLUSPLUS_NAMES_H diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 7e464b7d8baf7d4868126dcf09618239ef8efd99..f301963936080684dfc7fea8b41db61936aea0a4 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -2104,6 +2104,16 @@ bool Parser::parseStatement(StatementAST *&node) if (objCEnabled()) return parseObjCSynchronizedStatement(node); + case T_Q_D: + case T_Q_Q: { + QtMemberDeclarationAST *ast = new (_pool) QtMemberDeclarationAST; + ast->q_token = consumeToken(); + match(T_LPAREN, &ast->lparen_token); + parseTypeId(ast->type_id); + match(T_RPAREN, &ast->rparen_token); + node = ast; + } return true; + default: if (LA() == T_IDENTIFIER && LA(2) == T_COLON) return parseLabeledStatement(node); @@ -4971,7 +4981,7 @@ bool Parser::parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node) node = new (_pool) ObjCPropertyAttributeAST; - Identifier *id = tok().identifier; + const Identifier *id = tok().identifier; const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size()); switch (k) { case Token_copy: @@ -5069,7 +5079,7 @@ bool Parser::parseObjCTypeQualifiers(unsigned &type_qualifier) if (LA() != T_IDENTIFIER) return false; - Identifier *id = tok().identifier; + const Identifier *id = tok().identifier; const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size()); if (k == Token_identifier) return false; @@ -5082,7 +5092,7 @@ bool Parser::peekAtObjCContextKeyword(int kind) if (LA() != T_IDENTIFIER) return false; - Identifier *id = tok().identifier; + const Identifier *id = tok().identifier; const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size()); return k == kind; } diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp index 0a7dd294d49735231f456dba88152f3dd1881dc2..0fae6db39198ef369581ecb974cd7886d7759bb3 100644 --- a/src/shared/cplusplus/Scope.cpp +++ b/src/shared/cplusplus/Scope.cpp @@ -204,22 +204,22 @@ void Scope::enterSymbol(Symbol *symbol) } } -Symbol *Scope::lookat(Name *name) const +Symbol *Scope::lookat(const Name *name) const { if (! name) return 0; - else if (OperatorNameId *opId = name->asOperatorNameId()) + else if (const OperatorNameId *opId = name->asOperatorNameId()) return lookat(opId->kind()); - else if (Identifier *id = name->identifier()) + else if (const Identifier *id = name->identifier()) return lookat(id); else return 0; } -Symbol *Scope::lookat(Identifier *id) const +Symbol *Scope::lookat(const Identifier *id) const { if (! _hash || ! id) return 0; @@ -227,21 +227,21 @@ Symbol *Scope::lookat(Identifier *id) const const unsigned h = id->hashCode() % _hashSize; Symbol *symbol = _hash[h]; for (; symbol; symbol = symbol->_next) { - Name *identity = symbol->identity(); + const Name *identity = symbol->identity(); if (! identity) { continue; - } else if (NameId *nameId = identity->asNameId()) { + } else if (const NameId *nameId = identity->asNameId()) { if (nameId->identifier()->isEqualTo(id)) break; - } else if (TemplateNameId *t = identity->asTemplateNameId()) { + } else if (const TemplateNameId *t = identity->asTemplateNameId()) { if (t->identifier()->isEqualTo(id)) break; - } else if (DestructorNameId *d = identity->asDestructorNameId()) { + } else if (const DestructorNameId *d = identity->asDestructorNameId()) { if (d->identifier()->isEqualTo(id)) break; } else if (identity->isQualifiedNameId()) { - assert(0); - } else if (SelectorNameId *selectorNameId = identity->asSelectorNameId()) { + return 0; + } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) { if (selectorNameId->identifier()->isEqualTo(id)) break; } @@ -257,8 +257,8 @@ Symbol *Scope::lookat(int operatorId) const const unsigned h = operatorId % _hashSize; Symbol *symbol = _hash[h]; for (; symbol; symbol = symbol->_next) { - Name *identity = symbol->identity(); - if (OperatorNameId *op = identity->asOperatorNameId()) { + const Name *identity = symbol->identity(); + if (const OperatorNameId *op = identity->asOperatorNameId()) { if (op->kind() == operatorId) break; } diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h index c05a718ff379c9f467db23839cc2287010dab73e..04f735bf2a6b620ffe3fcf9e8a43e042f64a4575 100644 --- a/src/shared/cplusplus/Scope.h +++ b/src/shared/cplusplus/Scope.h @@ -129,8 +129,8 @@ public: /// Returns the last Symbol in the scope. iterator lastSymbol() const; - Symbol *lookat(Name *name) const; - Symbol *lookat(Identifier *id) const; + Symbol *lookat(const Name *name) const; + Symbol *lookat(const Identifier *id) const; Symbol *lookat(int operatorId) const; private: diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp index 74d870a91c0429bf0b068a0bd43e15d7e58091e7..57ac5fe99f34eb1d75a20ebfccf08485486e48aa 100644 --- a/src/shared/cplusplus/Semantic.cpp +++ b/src/shared/cplusplus/Semantic.cpp @@ -132,7 +132,7 @@ void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParamete { d->checkDeclaration->check(declaration, scope, templateParameters); } FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type, - Scope *scope, Name **name) + Scope *scope, const Name **name) { return d->checkDeclarator->check(declarator, type, scope, name); } FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, @@ -154,13 +154,13 @@ FullySpecifiedType Semantic::check(ExpressionAST *expression, Scope *scope) void Semantic::check(StatementAST *statement, Scope *scope) { d->checkStatement->check(statement, scope); } -Name *Semantic::check(NameAST *name, Scope *scope) +const Name *Semantic::check(NameAST *name, Scope *scope) { return d->checkName->check(name, scope); } -Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope) +const Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope) { return d->checkName->check(name, scope); } -Name *Semantic::check(ObjCSelectorAST *args, Scope *scope) +const Name *Semantic::check(ObjCSelectorAST *args, Scope *scope) { return d->checkName->check(args, scope); } bool Semantic::skipFunctionBodies() const diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h index f6a4e528f48e22b4f667be1cc895c525ae069952..6ca0b81c70b610e7852344b08c6bb096da09c634 100644 --- a/src/shared/cplusplus/Semantic.h +++ b/src/shared/cplusplus/Semantic.h @@ -70,7 +70,7 @@ public: FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope); FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type, - Scope *scope, Name **name = 0); // ### ugly + Scope *scope, const Name **name = 0); // ### ugly FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, Scope *scope); @@ -83,11 +83,11 @@ public: void check(StatementAST *statement, Scope *scope); - Name *check(NameAST *name, Scope *scope); + const Name *check(NameAST *name, Scope *scope); - Name *check(NestedNameSpecifierListAST *name, Scope *scope); + const Name *check(NestedNameSpecifierListAST *name, Scope *scope); - Name *check(ObjCSelectorAST *args, Scope *scope); + const Name *check(ObjCSelectorAST *args, Scope *scope); FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope); void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope); diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp index 316fccaaecdb157ca35686f7d8740d0adfcd4871..221af1ad828158f4037f1f8f315ede0a411b92d4 100644 --- a/src/shared/cplusplus/Symbol.cpp +++ b/src/shared/cplusplus/Symbol.cpp @@ -70,7 +70,7 @@ public: virtual ~HashCode() { } - unsigned operator()(Name *name) + unsigned operator()(const Name *name) { unsigned previousValue = switchValue(0); accept(name); @@ -85,25 +85,25 @@ protected: return previousValue; } - virtual void visit(NameId *name) + virtual void visit(const NameId *name) { _value = name->identifier()->hashCode(); } - virtual void visit(TemplateNameId *name) + virtual void visit(const TemplateNameId *name) { _value = name->identifier()->hashCode(); } - virtual void visit(DestructorNameId *name) + virtual void visit(const DestructorNameId *name) { _value = name->identifier()->hashCode(); } - virtual void visit(OperatorNameId *name) + virtual void visit(const OperatorNameId *name) { _value = unsigned(name->kind()); } - virtual void visit(ConversionNameId *) + virtual void visit(const ConversionNameId *) { _value = 0; } // ### TODO: implement me - virtual void visit(QualifiedNameId *name) + virtual void visit(const QualifiedNameId *name) { _value = operator()(name->unqualifiedNameId()); } - virtual void visit(SelectorNameId *name) + virtual void visit(const SelectorNameId *name) { _value = name->identifier()->hashCode(); } private: @@ -120,47 +120,47 @@ public: virtual ~IdentityForName() { } - Name *operator()(Name *name) + const Name *operator()(const Name *name) { - Name *previousIdentity = switchIdentity(0); + const Name *previousIdentity = switchIdentity(0); accept(name); return switchIdentity(previousIdentity); } protected: - Name *switchIdentity(Name *identity) + const Name *switchIdentity(const Name *identity) { - Name *previousIdentity = _identity; + const Name *previousIdentity = _identity; _identity = identity; return previousIdentity; } - virtual void visit(NameId *name) + virtual void visit(const NameId *name) { _identity = name; } - virtual void visit(TemplateNameId *name) + virtual void visit(const TemplateNameId *name) { _identity = name; } - virtual void visit(DestructorNameId *name) + virtual void visit(const DestructorNameId *name) { _identity = name; } - virtual void visit(OperatorNameId *name) + virtual void visit(const OperatorNameId *name) { _identity = name; } - virtual void visit(ConversionNameId *name) + virtual void visit(const ConversionNameId *name) { _identity = name; } - virtual void visit(QualifiedNameId *name) + virtual void visit(const QualifiedNameId *name) { _identity = name->unqualifiedNameId(); } - virtual void visit(SelectorNameId *name) + virtual void visit(const SelectorNameId *name) { _identity = name; } private: - Name *_identity; + const Name *_identity; }; -Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : _control(translationUnit->control()), _sourceLocation(sourceLocation), _sourceOffset(0), @@ -232,7 +232,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation) unsigned Symbol::line() const { unsigned line = 0, column = 0; - StringLiteral *fileId = 0; + const StringLiteral *fileId = 0; translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId); return line; } @@ -240,26 +240,26 @@ unsigned Symbol::line() const unsigned Symbol::column() const { unsigned line = 0, column = 0; - StringLiteral *fileId = 0; + const StringLiteral *fileId = 0; translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId); return column; } -StringLiteral *Symbol::fileId() const +const StringLiteral *Symbol::fileId() const { unsigned line = 0, column = 0; - StringLiteral *fileId = 0; + const StringLiteral *fileId = 0; translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId); return fileId; } -void Symbol::getPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const +void Symbol::getPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const { translationUnit()->getPosition(_sourceOffset, line, column, fileId); } -void Symbol::getStartPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const +void Symbol::getStartPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const { translationUnit()->getPosition(_startOffset, line, column, fileId); } -void Symbol::getEndPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const +void Symbol::getEndPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const { translationUnit()->getPosition(_endOffset, line, column, fileId); } const char *Symbol::fileName() const @@ -280,16 +280,16 @@ unsigned Symbol::endOffset() const void Symbol::setEndOffset(unsigned offset) { _endOffset = offset; } -Name *Symbol::identity() const +const Name *Symbol::identity() const { IdentityForName id; return id(_name); } -Name *Symbol::name() const +const Name *Symbol::name() const { return _name; } -void Symbol::setName(Name *name) +void Symbol::setName(const Name *name) { _name = name; @@ -302,7 +302,7 @@ void Symbol::setName(Name *name) } } -Identifier *Symbol::identifier() const +const Identifier *Symbol::identifier() const { if (_name) return _name->identifier(); diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h index 61abe02c7e1f4c6ef15bd8ac46cb3aca31d23756..e8615dc75b8a5f1e5dc95032e39a86c378fd6435 100644 --- a/src/shared/cplusplus/Symbol.h +++ b/src/shared/cplusplus/Symbol.h @@ -81,7 +81,7 @@ public: public: /// Constructs a Symbol with the given source location, name and translation unit. - Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); /// Destroy this Symbol. virtual ~Symbol(); @@ -102,7 +102,7 @@ public: unsigned column() const; /// Returns this Symbol's file name. - StringLiteral *fileId() const; + const StringLiteral *fileId() const; /// Returns this Symbol's file name. const char *fileName() const; @@ -116,18 +116,18 @@ public: unsigned endOffset() const; void setEndOffset(unsigned offset); - void getPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const; - void getStartPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const; - void getEndPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const; + void getPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const; + void getStartPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const; + void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const; /// Returns this Symbol's name. - Name *name() const; + const Name *name() const; /// Sets this Symbol's name. - void setName(Name *name); // ### dangerous + void setName(const Name *name); // ### dangerous /// Returns this Symbol's (optional) identifier - Identifier *identifier() const; + const Identifier *identifier() const; /// Returns this Symbol's storage class specifier. int storage() const; @@ -282,7 +282,7 @@ public: /// Returns this Symbol's index. unsigned index() const; - Name *identity() const; + const Name *identity() const; bool isGenerated() const; @@ -320,7 +320,7 @@ private: unsigned _sourceOffset; unsigned _startOffset; unsigned _endOffset; - Name *_name; + const Name *_name; unsigned _hashCode; int _storage; int _visibility; diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index 8c044ef03cae695bfea67208343245176c4e7954..22098f82b564e7bf021812fcca86084b8ff4c20f 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -76,7 +76,7 @@ Scope *TemplateParameters::scope() const { return _scope; } UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit, - unsigned sourceLocation, Name *name) + unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) { } @@ -90,7 +90,7 @@ void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit, - unsigned sourceLocation, Name *name) + unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) { } @@ -103,7 +103,7 @@ FullySpecifiedType UsingDeclaration::type() const void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } -Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name), _templateParameters(0) { } @@ -126,7 +126,7 @@ FullySpecifiedType Declaration::type() const void Declaration::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } -Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name), _initializer(false) { } @@ -149,7 +149,7 @@ FullySpecifiedType Argument::type() const void Argument::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } -Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : ScopedSymbol(translationUnit, sourceLocation, name), _templateParameters(0), _flags(0) @@ -203,8 +203,8 @@ bool Function::isEqualTo(const Type *other) const else if (isVolatile() != o->isVolatile()) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) { if (_arguments->symbolCount() != o->_arguments->symbolCount()) return false; @@ -315,7 +315,7 @@ void Function::visitSymbol0(SymbolVisitor *visitor) } } -ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) { _members = new Scope(this); } @@ -361,7 +361,7 @@ void Block::visitSymbol0(SymbolVisitor *visitor) } } -Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : ScopedSymbol(translationUnit, sourceLocation, name) { } @@ -376,8 +376,8 @@ bool Enum::isEqualTo(const Type *other) const const Enum *o = other->asEnumType(); if (! o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r) return true; else if (! l) @@ -405,7 +405,7 @@ void Enum::visitSymbol0(SymbolVisitor *visitor) } } -Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : ScopedSymbol(translationUnit, sourceLocation, name) { } @@ -417,8 +417,8 @@ bool Namespace::isEqualTo(const Type *other) const const Namespace *o = other->asNamespaceType(); if (! o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) return true; return false; @@ -447,7 +447,7 @@ void Namespace::visitSymbol0(SymbolVisitor *visitor) FullySpecifiedType Namespace::type() const { return FullySpecifiedType(const_cast<Namespace *>(this)); } -BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name), _isVirtual(false) { } @@ -468,7 +468,7 @@ void BaseClass::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit, - unsigned sourceLocation, Name *name) + unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name), _templateParameters(0) { } @@ -512,7 +512,7 @@ bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *mat return false; } -Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : ScopedSymbol(translationUnit, sourceLocation, name), _key(ClassKey), _templateParameters(0) @@ -581,8 +581,8 @@ bool Class::isEqualTo(const Type *other) const const Class *o = other->asClassType(); if (! o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) return true; else @@ -601,7 +601,7 @@ void Class::visitSymbol0(SymbolVisitor *visitor) } } -ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) { } @@ -614,7 +614,7 @@ FullySpecifiedType ObjCBaseClass::type() const void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } -ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) { } @@ -627,7 +627,7 @@ FullySpecifiedType ObjCBaseProtocol::type() const void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } -ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): +ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name): ScopedSymbol(translationUnit, sourceLocation, name), _isInterface(false), _categoryName(0), @@ -647,8 +647,8 @@ bool ObjCClass::isEqualTo(const Type *other) const if (!o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) return true; else @@ -680,7 +680,7 @@ bool ObjCClass::matchType0(const Type *otherType, TypeMatcher *matcher) const return false; } -ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): +ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name): ScopedSymbol(translationUnit, sourceLocation, name) { } @@ -697,8 +697,8 @@ bool ObjCProtocol::isEqualTo(const Type *other) const if (!o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) return true; else @@ -724,7 +724,8 @@ bool ObjCProtocol::matchType0(const Type *otherType, TypeMatcher *matcher) const return false; } -ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): +ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, + const Name *name): Symbol(translationUnit, sourceLocation, name) { } @@ -763,7 +764,8 @@ bool ObjCForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher return false; } -ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): +ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, + const Name *name): Symbol(translationUnit, sourceLocation, name) { } @@ -802,7 +804,7 @@ bool ObjCForwardProtocolDeclaration::matchType0(const Type *otherType, TypeMatch return false; } -ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) +ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : ScopedSymbol(translationUnit, sourceLocation, name), _flags(0) { _arguments = new Scope(this); } @@ -818,8 +820,8 @@ bool ObjCMethod::isEqualTo(const Type *other) const if (! o) return false; - Name *l = identity(); - Name *r = o->identity(); + const Name *l = identity(); + const Name *r = o->identity(); if (l == r || (l && l->isEqualTo(r))) { if (_arguments->symbolCount() != o->_arguments->symbolCount()) return false; @@ -902,7 +904,7 @@ void ObjCMethod::visitSymbol0(SymbolVisitor *visitor) ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, - Name *name): + const Name *name): Symbol(translationUnit, sourceLocation, name), _propertyAttributes(None), _getterName(0), diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h index 022846d3c02afc040050b3befb599c9e12f2012a..a75d09e0ffd2522eb4fa8606a7fa147de2e1ae16 100644 --- a/src/shared/cplusplus/Symbols.h +++ b/src/shared/cplusplus/Symbols.h @@ -76,7 +76,7 @@ private: class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol { public: - UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~UsingNamespaceDirective(); // Symbol's interface @@ -95,7 +95,7 @@ protected: class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol { public: - UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~UsingDeclaration(); // Symbol's interface @@ -114,7 +114,7 @@ protected: class CPLUSPLUS_EXPORT Declaration: public Symbol { public: - Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Declaration(); TemplateParameters *templateParameters() const; @@ -142,7 +142,7 @@ private: class CPLUSPLUS_EXPORT Argument: public Symbol { public: - Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Argument(); void setType(const FullySpecifiedType &type); @@ -170,7 +170,7 @@ private: class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol { public: - ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ScopedSymbol(); unsigned memberCount() const; @@ -210,7 +210,7 @@ protected: class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type { public: - ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ForwardClassDeclaration(); TemplateParameters *templateParameters() const; @@ -244,7 +244,7 @@ private: class CPLUSPLUS_EXPORT Enum: public ScopedSymbol, public Type { public: - Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Enum(); // Symbol's interface @@ -281,7 +281,7 @@ public: }; public: - Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Function(); bool isNormal() const; @@ -372,7 +372,7 @@ private: class CPLUSPLUS_EXPORT Namespace: public ScopedSymbol, public Type { public: - Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Namespace(); // Symbol's interface @@ -402,7 +402,7 @@ protected: class CPLUSPLUS_EXPORT BaseClass: public Symbol { public: - BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~BaseClass(); bool isVirtual() const; @@ -427,7 +427,7 @@ private: class CPLUSPLUS_EXPORT Class: public ScopedSymbol, public Type { public: - Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Class(); enum Key { @@ -484,7 +484,7 @@ private: class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol { public: - ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCBaseClass(); // Symbol's interface @@ -505,7 +505,7 @@ private: class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol { public: - ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCBaseProtocol(); // Symbol's interface @@ -526,7 +526,7 @@ private: class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type { public: - ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCForwardProtocolDeclaration(); virtual FullySpecifiedType type() const; @@ -556,7 +556,7 @@ private: class CPLUSPLUS_EXPORT ObjCProtocol: public ScopedSymbol, public Type { public: - ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCProtocol(); unsigned protocolCount() const @@ -598,7 +598,7 @@ private: class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type { public: - ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCForwardClassDeclaration(); virtual FullySpecifiedType type() const; @@ -628,15 +628,15 @@ private: class CPLUSPLUS_EXPORT ObjCClass: public ScopedSymbol, public Type { public: - ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCClass(); bool isInterface() const { return _isInterface; } void setInterface(bool isInterface) { _isInterface = isInterface; } bool isCategory() const { return _categoryName != 0; } - Name *categoryName() const { return _categoryName; } - void setCategoryName(Name *categoryName) { _categoryName = categoryName; } + const Name *categoryName() const { return _categoryName; } + void setCategoryName(const Name *categoryName) { _categoryName = categoryName; } ObjCBaseClass *baseClass() const { return _baseClass; } @@ -677,7 +677,7 @@ protected: private: bool _isInterface; - Name *_categoryName; + const Name *_categoryName; ObjCBaseClass * _baseClass; Array<ObjCBaseProtocol *> _protocols; }; @@ -685,7 +685,7 @@ private: class CPLUSPLUS_EXPORT ObjCMethod: public ScopedSymbol, public Type { public: - ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); + ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ObjCMethod(); FullySpecifiedType returnType() const; @@ -760,7 +760,7 @@ public: public: ObjCPropertyDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, - Name *name); + const Name *name); virtual ~ObjCPropertyDeclaration(); bool hasAttribute(int attribute) const @@ -775,16 +775,16 @@ public: bool hasSetter() const { return hasAttribute(Setter); } - Name *getterName() const + const Name *getterName() const { return _getterName; } - void setGetterName(Name *getterName) + void setGetterName(const Name *getterName) { _getterName = getterName; } - Name *setterName() const + const Name *setterName() const { return _setterName; } - void setSetterName(Name *setterName) + void setSetterName(const Name *setterName) { _setterName = setterName; } void setType(const FullySpecifiedType &type) @@ -805,7 +805,8 @@ protected: private: FullySpecifiedType _type; int _propertyAttributes; - Name *_getterName, *_setterName; + const Name *_getterName; + const Name *_setterName; }; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/Token.cpp b/src/shared/cplusplus/Token.cpp index 48bf61354f023cc8c12fd696dc2ed8bfa471ec0f..ce661e43b0589acceee16473bba35bd2ad5f4b01 100644 --- a/src/shared/cplusplus/Token.cpp +++ b/src/shared/cplusplus/Token.cpp @@ -91,7 +91,7 @@ static const char *token_names[] = { ("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"), ("@synchronized"), ("@synthesize"), ("@throw"), ("@try"), - ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), ("Q_FOREACH") + ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), ("Q_FOREACH"), ("Q_D"), ("Q_Q") }; Token::Token() : diff --git a/src/shared/cplusplus/Token.h b/src/shared/cplusplus/Token.h index 3829baa651f1913c000a2d31425a727cc6caa876..cd1cf577c6d59bdb92411db93b49464ae0708768 100644 --- a/src/shared/cplusplus/Token.h +++ b/src/shared/cplusplus/Token.h @@ -236,8 +236,10 @@ enum Kind { T_Q_SIGNALS, T_Q_SLOTS, T_Q_FOREACH, + T_Q_D, + T_Q_Q, - T_LAST_KEYWORD = T_Q_FOREACH, + T_LAST_KEYWORD = T_Q_Q, // aliases T_OR = T_PIPE_PIPE, @@ -333,10 +335,10 @@ public: union { void *ptr; - Literal *literal; - NumericLiteral *number; - StringLiteral *string; - Identifier *identifier; + const Literal *literal; + const NumericLiteral *number; + const StringLiteral *string; + const Identifier *identifier; unsigned close_brace; unsigned lineno; }; diff --git a/src/shared/cplusplus/TranslationUnit.cpp b/src/shared/cplusplus/TranslationUnit.cpp index 92f2bfb5ce5c1d929d10e2e4fd37ec34dab292b0..fe39d5bb6f4d128f99b9a5ea0e0029e487c8554e 100644 --- a/src/shared/cplusplus/TranslationUnit.cpp +++ b/src/shared/cplusplus/TranslationUnit.cpp @@ -60,7 +60,7 @@ using namespace CPlusPlus; -TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId) +TranslationUnit::TranslationUnit(Control *control, const StringLiteral *fileId) : _control(control), _fileId(fileId), _firstSourceChar(0), @@ -96,7 +96,7 @@ void TranslationUnit::setObjCEnabled(bool onoff) Control *TranslationUnit::control() const { return _control; } -StringLiteral *TranslationUnit::fileId() const +const StringLiteral *TranslationUnit::fileId() const { return _fileId; } const char *TranslationUnit::fileName() const @@ -137,16 +137,16 @@ const char *TranslationUnit::spell(unsigned index) const return _tokens->at(index).spell(); } -Identifier *TranslationUnit::identifier(unsigned index) const +const Identifier *TranslationUnit::identifier(unsigned index) const { return _tokens->at(index).identifier; } -Literal *TranslationUnit::literal(unsigned index) const +const Literal *TranslationUnit::literal(unsigned index) const { return _tokens->at(index).literal; } -StringLiteral *TranslationUnit::stringLiteral(unsigned index) const +const StringLiteral *TranslationUnit::stringLiteral(unsigned index) const { return _tokens->at(index).string; } -NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const +const NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const { return _tokens->at(index).number; } unsigned TranslationUnit::matchingBrace(unsigned index) const @@ -181,8 +181,8 @@ void TranslationUnit::tokenize() pushLineOffset(0); pushPreprocessorLine(0, 1, fileId()); - Identifier *lineId = control()->findOrInsertIdentifier("line"); - Identifier *genId = control()->findOrInsertIdentifier("gen"); + const Identifier *lineId = control()->findOrInsertIdentifier("line"); + const Identifier *genId = control()->findOrInsertIdentifier("gen"); bool generated = false; Token tk; @@ -211,8 +211,8 @@ void TranslationUnit::tokenize() unsigned line = (unsigned) strtoul(tk.spell(), 0, 0); lex(&tk); if (! tk.f.newline && tk.is(T_STRING_LITERAL)) { - StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(), - tk.string->size()); + const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(), + tk.string->size()); pushPreprocessorLine(offset, line, fileName); lex(&tk); } @@ -303,7 +303,7 @@ void TranslationUnit::pushLineOffset(unsigned offset) void TranslationUnit::pushPreprocessorLine(unsigned offset, unsigned line, - StringLiteral *fileName) + const StringLiteral *fileName) { _ppLines.push_back(PPLine(offset, line, fileName)); } unsigned TranslationUnit::findLineNumber(unsigned offset) const @@ -339,23 +339,23 @@ unsigned TranslationUnit::findColumnNumber(unsigned offset, unsigned lineNumber) void TranslationUnit::getTokenPosition(unsigned index, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { return getPosition(tokenAt(index).offset, line, column, fileName); } void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { return getPosition(tokenAt(index).begin(), line, column, fileName); } void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { return getPosition(tokenAt(index).end(), line, column, fileName); } void TranslationUnit::getPosition(unsigned tokenOffset, unsigned *line, unsigned *column, - StringLiteral **fileName) const + const StringLiteral **fileName) const { unsigned lineNumber = findLineNumber(tokenOffset); unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber); @@ -389,7 +389,7 @@ void TranslationUnit::warning(unsigned index, const char *format, ...) index = std::min(index, tokenCount() - 1); unsigned line = 0, column = 0; - StringLiteral *fileName = 0; + const StringLiteral *fileName = 0; getTokenPosition(index, &line, &column, &fileName); if (DiagnosticClient *client = control()->diagnosticClient()) { @@ -420,7 +420,7 @@ void TranslationUnit::error(unsigned index, const char *format, ...) index = std::min(index, tokenCount() - 1); unsigned line = 0, column = 0; - StringLiteral *fileName = 0; + const StringLiteral *fileName = 0; getTokenPosition(index, &line, &column, &fileName); if (DiagnosticClient *client = control()->diagnosticClient()) { @@ -451,7 +451,7 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...) index = std::min(index, tokenCount() - 1); unsigned line = 0, column = 0; - StringLiteral *fileName = 0; + const StringLiteral *fileName = 0; getTokenPosition(index, &line, &column, &fileName); if (DiagnosticClient *client = control()->diagnosticClient()) { diff --git a/src/shared/cplusplus/TranslationUnit.h b/src/shared/cplusplus/TranslationUnit.h index cc26f44be414936485bea93709397073f5c58836..b10a4f3f3f86f8e41131bbc6f8c0f87d6de88d27 100644 --- a/src/shared/cplusplus/TranslationUnit.h +++ b/src/shared/cplusplus/TranslationUnit.h @@ -65,12 +65,12 @@ class CPLUSPLUS_EXPORT TranslationUnit void operator =(const TranslationUnit &other); public: - TranslationUnit(Control *control, StringLiteral *fileId); + TranslationUnit(Control *control, const StringLiteral *fileId); ~TranslationUnit(); Control *control() const; - StringLiteral *fileId() const; + const StringLiteral *fileId() const; const char *fileName() const; unsigned fileNameLength() const; @@ -86,10 +86,10 @@ public: const char *spell(unsigned index) const; unsigned matchingBrace(unsigned index) const; - Identifier *identifier(unsigned index) const; - Literal *literal(unsigned index) const; - StringLiteral *stringLiteral(unsigned index) const; - NumericLiteral *numericLiteral(unsigned index) const; + const Identifier *identifier(unsigned index) const; + const Literal *literal(unsigned index) const; + const StringLiteral *stringLiteral(unsigned index) const; + const NumericLiteral *numericLiteral(unsigned index) const; MemoryPool *memoryPool() const; AST *ast() const; @@ -129,26 +129,26 @@ public: void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void getPosition(unsigned offset, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void getTokenPosition(unsigned index, unsigned *line, unsigned *column = 0, - StringLiteral **fileName = 0) const; + const StringLiteral **fileName = 0) const; void pushLineOffset(unsigned offset); void pushPreprocessorLine(unsigned offset, unsigned line, - StringLiteral *fileName); + const StringLiteral *fileName); unsigned findPreviousLineOffset(unsigned tokenIndex) const; @@ -156,11 +156,11 @@ public: struct PPLine { unsigned offset; unsigned line; - StringLiteral *fileName; + const StringLiteral *fileName; PPLine(unsigned offset = 0, unsigned line = 0, - StringLiteral *fileName = 0) + const StringLiteral *fileName = 0) : offset(offset), line(line), fileName(fileName) { } @@ -181,7 +181,7 @@ private: void showErrorLine(unsigned index, unsigned column, FILE *out); Control *_control; - StringLiteral *_fileId; + const StringLiteral *_fileId; const char *_firstSourceChar; const char *_lastSourceChar; Array<Token, 8> *_tokens; diff --git a/src/shared/cplusplus/Type.h b/src/shared/cplusplus/Type.h index a2e29bf56c039aa2437e6d77adf6293ac0254a84..a64a824d4eb4602808770eab7c0a4555a02158bc 100644 --- a/src/shared/cplusplus/Type.h +++ b/src/shared/cplusplus/Type.h @@ -55,9 +55,6 @@ namespace CPlusPlus { class CPLUSPLUS_EXPORT Type { - Type(const Type &other); - void operator =(const Type &other); - public: Type(); virtual ~Type(); diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index b9b5f04a1595422431992b1cbc5ebf440cebcc8c..62f015cd1ed888f29c43f14d016005aac1cdbb3c 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -640,7 +640,11 @@ void Launcher::handleInstallPackageFinished(const TrkResult &result) if (result.errorCode()) { emit canNotInstall(d->m_installFileName, result.errorString()); disconnectTrk(); - } else if (d->m_startupActions & ActionRun) { + return; + } else { + emit installingFinished(); + } + if (d->m_startupActions & ActionRun) { startInferiorIfNeeded(); } else { disconnectTrk(); diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index 538d367e742a5d4797b34ead8a442d41cdbd6397..93a282171687701505a8ccc4252addd495adb518 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -103,6 +103,7 @@ signals: void canNotCloseFile(const QString &filename, const QString &errorMessage); void installingStarted(); void canNotInstall(const QString &packageFilename, const QString &errorMessage); + void installingFinished(); void startingApplication(); void applicationRunning(uint pid); void canNotRun(const QString &errorMessage); diff --git a/src/tools/cplusplus/Main.cpp b/src/tools/cplusplus/Main.cpp index 342c7751fd1c5771f9e2200ed8c5cc0affeeedf3..7c2e65d22df86002cfa83887563199eef3096a96 100644 --- a/src/tools/cplusplus/Main.cpp +++ b/src/tools/cplusplus/Main.cpp @@ -100,7 +100,7 @@ class FindASTNodes: protected ASTVisitor { public: FindASTNodes(Document::Ptr doc, QTextDocument *document) - : ASTVisitor(doc->control()), document(document) + : ASTVisitor(doc->translationUnit()), document(document) { } @@ -159,8 +159,8 @@ class Accept0CG: protected ASTVisitor QTextStream *out; public: - Accept0CG(const QDir &cplusplusDir, Control *control) - : ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0) + Accept0CG(const QDir &cplusplusDir, TranslationUnit *unit) + : ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0) { } void operator()(AST *ast) @@ -296,8 +296,8 @@ class Match0CG: protected ASTVisitor QTextStream *out; public: - Match0CG(const QDir &cplusplusDir, Control *control) - : ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0) + Match0CG(const QDir &cplusplusDir, TranslationUnit *unit) + : ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0) { } void operator()(AST *ast) @@ -406,8 +406,8 @@ class MatcherCPPCG: protected ASTVisitor QTextStream *out; public: - MatcherCPPCG(const QDir &cplusplusDir, Control *control) - : ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0) + MatcherCPPCG(const QDir &cplusplusDir, TranslationUnit *unit) + : ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0) { } void operator()(AST *ast) @@ -560,7 +560,7 @@ class RemoveCastMethods: protected ASTVisitor { public: RemoveCastMethods(Document::Ptr doc, QTextDocument *document) - : ASTVisitor(doc->control()), document(document) {} + : ASTVisitor(doc->translationUnit()), document(document) {} QList<QTextCursor> operator()(AST *ast) { @@ -666,13 +666,13 @@ QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir) out << document.toPlainText(); } - Accept0CG cg(cplusplusDir, AST_h_document->control()); + Accept0CG cg(cplusplusDir, AST_h_document->translationUnit()); cg(AST_h_document->translationUnit()->ast()); - Match0CG cg2(cplusplusDir, AST_h_document->control()); + Match0CG cg2(cplusplusDir, AST_h_document->translationUnit()); cg2(AST_h_document->translationUnit()->ast()); - MatcherCPPCG cg3(cplusplusDir, AST_h_document->control()); + MatcherCPPCG cg3(cplusplusDir, AST_h_document->translationUnit()); cg3(AST_h_document->translationUnit()->ast()); return astDerivedClasses; @@ -682,7 +682,7 @@ class FindASTForwards: protected ASTVisitor { public: FindASTForwards(Document::Ptr doc, QTextDocument *document) - : ASTVisitor(doc->control()), document(document) + : ASTVisitor(doc->translationUnit()), document(document) {} QList<QTextCursor> operator()(AST *ast) @@ -887,5 +887,5 @@ int main(int argc, char *argv[]) astDerivedClasses.sort(); generateASTFwd_h(snapshot, cplusplusDir, astDerivedClasses); - generateASTPatternBuilder_h(cplusplusDir); + //generateASTPatternBuilder_h(cplusplusDir); } diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index b9ed42aa4b5c18676b031c8c9deb7ea2de7c2d6f..e7050ae1eb8d3af1df8f9518f5991079ec48798d 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -110,7 +110,9 @@ public: void testMi(const char* input) { - QCOMPARE('\n' + QString::fromLatin1(GdbMi(input).toString(false)), + GdbMi gdbmi; + gdbmi.fromString(QByteArray(input)); + QCOMPARE('\n' + QString::fromLatin1(gdbmi.toString(false)), '\n' + QString(input)); }