diff --git a/qt/org.eclipse.cdt.qt.core/plugin.properties b/qt/org.eclipse.cdt.qt.core/plugin.properties
index 9f9360a2955..322b6ca7011 100644
--- a/qt/org.eclipse.cdt.qt.core/plugin.properties
+++ b/qt/org.eclipse.cdt.qt.core/plugin.properties
@@ -1,3 +1,10 @@
+# Copyright (c) 2013 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+
qtProjectFile.name = Qt Project File
qmlFile.name = QML File
qmakeEnvProvider.name = QMake Environment Provider
+QtInstallHeaders.pathProvider.name = Qt Installed Headers
\ No newline at end of file
diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml
index 7b3ebd7ffcb..e1e3cc1de54 100644
--- a/qt/org.eclipse.cdt.qt.core/plugin.xml
+++ b/qt/org.eclipse.cdt.qt.core/plugin.xml
@@ -7,22 +7,33 @@
point="org.eclipse.cdt.core.templates">
-
+ id="org.eclipse.cdt.qt.core.template.helloWorld.Qt4"
+ location="templates/project/Qt4/template.xml"
+ projectType="org.eclipse.cdt.build.makefile.projectType"/>
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtPlugin.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtPlugin.java
index cfe7a36d479..b4f1de57ab7 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtPlugin.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtPlugin.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.cdt.qt.core;
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.QualifiedName;
@@ -51,22 +52,29 @@ public class QtPlugin extends Plugin {
return new Status(IStatus.ERROR, ID, msg, e);
}
- public static IStatus log(String e) {
- return log(IStatus.INFO, e, null);
+ public static void log(String e) {
+ log(IStatus.INFO, e, null);
}
- public static IStatus log(Throwable e) {
- String msg = e.getMessage();
- return msg == null ? log("Error", e) : log("Error: " + msg, e);
+ public static void log(Throwable e) {
+ String msg= e.getMessage();
+ if (msg == null) {
+ log("Error", e); //$NON-NLS-1$
+ } else {
+ log("Error: " + msg, e); //$NON-NLS-1$
+ }
}
- public static IStatus log(String message, Throwable e) {
- return log(IStatus.ERROR, message, e);
+ public static void log(String message, Throwable e) {
+ Throwable nestedException;
+ if (e instanceof CModelException
+ && (nestedException = ((CModelException)e).getException()) != null) {
+ e = nestedException;
+ }
+ log(IStatus.ERROR, message, e);
}
- public static IStatus log(int code, String msg, Throwable e) {
- IStatus status = new Status(code, ID, msg, e);
- instance.getLog().log(status);
- return status;
+ public static void log(int code, String msg, Throwable e) {
+ getDefault().getLog().log(new Status(code, ID, msg, e));
}
}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePaths.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePaths.java
new file mode 100644
index 00000000000..20a75126d36
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePaths.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.eclipse.cdt.qt.internal.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.qt.core.QtPlugin;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.resources.IResource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Discovers and persists the list of Qt include paths for a particular installation of
+ * Qt. The Qt installation is described by the path to qmake.
+ *
+ * Qt uses a tool called qmake to generate makefiles for Qt projects. The tool has a
+ * query mode that can be used to discover information about the Qt installation. Here
+ * qmake is used to build a list of all installed Qt include paths.
+ *
+ * These paths are persisted into a file called language-settings.xml in the workspace
+ * metadata area.
+ *
+ * @see QtIncludePathsProvider
+ */
+public class QtIncludePaths extends LanguageSettingsSerializableProvider {
+
+ /**
+ * The path to the qmake executable uniquely identifies this installation.
+ */
+ private final String qmakePath;
+
+ /**
+ * The cached data is reloaded when the qmake executable is modified.
+ */
+ private long qmakeModTime;
+
+ /**
+ * The cached data is reloaded when the folder holding the include paths
+ * is removed.
+ */
+ private String qtInstallHeadersPath;
+
+ /**
+ * The cached data is reloaded when the folder containing the include folders is
+ * modified.
+ */
+ private long qtInstallHeadersModTime;
+
+ private static final String ATTR_QMAKE = "qmake";
+ private static final String ATTR_QMAKE_MOD = "qmakeModification";
+ private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS";
+ private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification";
+
+ /**
+ * Create a new instance of the include path wrapper for the Qt installation for
+ * the given qmake binary.
+ */
+ public QtIncludePaths(String qmakePath) {
+ this.qmakePath = qmakePath;
+ }
+
+ /**
+ * Create and load an instance of QtIncludePaths from data that was serialized into the
+ * given XML element. Return null if an instance cannot be loaded or if the installation
+ * is no longer valid.
+ */
+ public static QtIncludePaths loadFrom(Node node) {
+ if (node.getNodeType() != Node.ELEMENT_NODE)
+ return null;
+
+ Element element = (Element) node;
+ String qmakePath = element.getAttribute(ATTR_QMAKE);
+ if (qmakePath == null
+ || qmakePath.isEmpty())
+ return null;
+
+ QtIncludePaths qtIncludePaths = new QtIncludePaths(qmakePath);
+ qtIncludePaths.load(element);
+ return qtIncludePaths;
+ }
+
+ public String getQMakePath() {
+ return qmakePath;
+ }
+
+ /**
+ * Return true if the receiver points to a valid Qt installation and false otherwise.
+ * The installation is considered valid if an executable qmake binary exists at the
+ * expected location.
+ */
+ public boolean isValid() {
+ if (qmakePath == null
+ || qmakePath.isEmpty())
+ return false;
+
+ File qmake = new File(qmakePath);
+ return qmake.exists()
+ && qmake.canExecute();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof QtIncludePaths))
+ return super.equals(obj);
+
+ // Include paths are equivalent when they point to the same qmake binary. All other
+ // values are reloaded from that binary and do not need to be directly compared.
+ QtIncludePaths other = (QtIncludePaths) obj;
+ return qmakePath == null ? other.qmakePath == null : qmakePath.equals(other.qmakePath);
+ }
+
+ @Override
+ public int hashCode() {
+ return qmakePath == null ? 0 : qmakePath.hashCode();
+ }
+
+ /**
+ * Return a current list of the include paths for this Qt installation. Return null if
+ * no such paths can be found.
+ *
+ * Updates the cached results if needed. If the settings are updated then the new list
+ * will be serialized into the workspace metadata area.
+ */
+ @Override
+ public List getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
+ List entries = null;
+
+ File qmake = new File(qmakePath);
+ if (!qmake.exists()
+ || qmakeModTime != qmake.lastModified())
+ entries = reload();
+ else {
+ File qtInstallHeadersDir = new File(qtInstallHeadersPath);
+ if (!qtInstallHeadersDir.exists()
+ || qtInstallHeadersModTime != qtInstallHeadersDir.lastModified())
+ entries = reload();
+ }
+
+ // If the cache was not reloaded, then return the previously discovered entries.
+ if (entries == null)
+ return super.getSettingEntries(configDesc, rc, languageId);
+
+ // Otherwise store, persist, and return the newly discovered values.
+ setSettingEntries(configDesc, rc, languageId, entries);
+ serializeLanguageSettingsInBackground(null);
+ return entries;
+ }
+
+ @Override
+ public Element serializeAttributes(Element parentElement) {
+ parentElement.setAttribute(ATTR_QMAKE, qmakePath);
+ parentElement.setAttribute(ATTR_QMAKE_MOD, Long.toString(qmakeModTime));
+ parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS, qtInstallHeadersPath);
+ parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS_MOD, Long.toString(qtInstallHeadersModTime));
+
+ // The parent implementation tries to create a new child node (provider) that is used
+ // as the part for later entries. This isn't needed in this case, we just want to
+ // use the part that serializes the languages.
+ return parentElement;
+ }
+
+ @Override
+ public void loadAttributes(Element element) {
+ qmakeModTime = getLongAttribute(element, ATTR_QMAKE_MOD);
+ qtInstallHeadersPath = element.getAttribute(ATTR_QT_INSTALL_HEADERS);
+ qtInstallHeadersModTime = getLongAttribute(element, ATTR_QT_INSTALL_HEADERS_MOD);
+
+ // The parent implementation tries to create a new child node (provider) that is used
+ // as the part for later entries. This isn't needed in this case, we just want to
+ // use the part that serializes the languages.
+ }
+
+ /**
+ * Parse and return the given attribute as a long. Return 0 if the attribute does
+ * not have a valid value.
+ */
+ private static long getLongAttribute(Element element, String attr) {
+ String value = element.getAttribute(attr);
+ if (value == null
+ || value.isEmpty())
+ return 0;
+
+ try {
+ return Long.parseLong(value);
+ } catch(NumberFormatException e) {
+ QtPlugin.log("attribute name:" + attr + " value:" + value, e);
+ return 0;
+ }
+ }
+
+ /**
+ * Reload and return the entries if possible, return null otherwise.
+ */
+ private List reload() {
+ // All keys are reset and then updated as their values are discovered. This allows partial
+ // success to skip over previously calculated values.
+ qmakeModTime = 0;
+ qtInstallHeadersPath = null;
+ qtInstallHeadersModTime = 0;
+
+ File qmake = new File(qmakePath);
+ if (!qmake.exists()
+ || !qmake.canExecute())
+ return Collections.emptyList();
+
+ qmakeModTime = qmake.lastModified();
+
+ // Run `qmake -query QT_INSTALL_HEADERS` to get output like "/opt/qt-5.0.0/include".
+ BufferedReader reader = null;
+ Process process = null;
+ try {
+ process = ProcessFactory.getFactory().exec(new String[]{ qmakePath, "-query", "QT_INSTALL_HEADERS" });
+ reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ qtInstallHeadersPath = reader.readLine();
+ } catch(IOException e) {
+ QtPlugin.log(e);
+ } finally {
+ try {
+ if (reader != null)
+ reader.close();
+ } catch(IOException e) {
+ /* ignore */
+ } finally {
+ if (process != null)
+ process.destroy();
+ }
+ }
+
+ if (qtInstallHeadersPath == null)
+ return Collections.emptyList();
+
+ File qtInstallHeadersDir = new File(qtInstallHeadersPath);
+
+ qtInstallHeadersModTime = qtInstallHeadersDir.lastModified();
+ if (!qtInstallHeadersDir.exists()
+ || !qtInstallHeadersDir.canRead()
+ || !qtInstallHeadersDir.isDirectory())
+ return Collections.emptyList();
+
+ // Create an include path entry for all sub-folders in the QT_INSTALL_HEADERS location, including
+ // the QT_INSTALL_HEADERS folder itself.
+ File[] files = qtInstallHeadersDir.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return pathname.exists() && pathname.isDirectory();
+ }
+ });
+
+ List entries = new ArrayList(files.length + 1);
+ safeAdd(entries, qtInstallHeadersDir);
+ for(File file : files)
+ safeAdd(entries, file);
+
+ return entries;
+ }
+
+ private static void safeAdd(List entries, File file) {
+ try {
+ entries.add(new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED));
+ } catch(IOException e) {
+ QtPlugin.log(e);
+ }
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePathsProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePathsProvider.java
new file mode 100644
index 00000000000..6c2076bd48d
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/internal/core/QtIncludePathsProvider.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.eclipse.cdt.qt.internal.core;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.core.resources.IResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This provider uses persistent cache to store the include paths for different
+ * Qt installations. A Qt installation is uniquely identified by the path to
+ * the qmake binary within the installation.
+ *
+ * This result is shared among all Build Configurations that use the provider
+ * with the same value for the QMAKE environment variable.
+ */
+public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider {
+
+ /**
+ * The provider identifies Qt installations by the absolute path to the qmake binary. The
+ * include paths relevant to the installations are computed and persisted in {@link QtIncludePaths}.
+ */
+ private final Map qtInstallHeaders = new HashMap();
+
+ /**
+ * The build configuration stores the path to the qmake binary as an environment variable.
+ */
+ private static final String ENVVAR_QMAKE = "QMAKE";
+
+ private static final String ELEMENT_QMAKE = "qmake";
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof QtIncludePathsProvider))
+ return super.equals(obj);
+
+ /**
+ * Providers are equal when they have the same cached values.
+ */
+ QtIncludePathsProvider other = (QtIncludePathsProvider) obj;
+ if (qtInstallHeaders == null)
+ return other.qtInstallHeaders == null;
+ return qtInstallHeaders.equals(other.qtInstallHeaders);
+ }
+
+ @Override
+ public int hashCode() {
+ return qtInstallHeaders == null ? 0 : qtInstallHeaders.hashCode();
+ }
+
+ @Override
+ public void loadEntries(Element providerNode) {
+ super.loadEntries(providerNode);
+
+ // Find and load all qmake child nodes. There will be one node for each Qt
+ // installation that has been used. Qt installations that are no longer valid
+ // are not loaded. This means they will be removed from the file the next time
+ // that the language setting providers are serialized.
+ NodeList children = providerNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); ++i) {
+ Node child = children.item(i);
+ if (ELEMENT_QMAKE.equals(child.getNodeName())) {
+ QtIncludePaths qtIncludePaths = QtIncludePaths.loadFrom(child);
+ if (qtIncludePaths != null
+ && qtIncludePaths.isValid())
+ qtInstallHeaders.put(qtIncludePaths.getQMakePath(), qtIncludePaths);
+ }
+ }
+ }
+
+ @Override
+ public void serializeEntries(Element parent) {
+ // NOTE: This creates its own XML structure where children of the provider node are qmake nodes.
+ // Within each qmake node is a list of include paths for that installation. Calling the
+ // base #serializeEntries here would try to write this instance's (empty) list of settings
+ // to the file.
+
+ // Each value is serialized into a new element in the XML document.
+ Document document = parent instanceof Document ? (Document)parent : parent.getOwnerDocument();
+ for(QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) {
+ Element child = document.createElement(ELEMENT_QMAKE);
+ qtIncludePaths.serialize(child);
+ parent.appendChild(child);
+ }
+ }
+
+ /**
+ * The given build configuration's QMAKE environment variable is used to identify the appropriate
+ * Qt installation. The language settings are then either returned from the previously persisted
+ * data or loaded, serialized, and returned.
+ */
+ @Override
+ public synchronized List getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
+ // Make sure the requested language is in scope for this provider.
+ if (!getLanguageScope().contains(languageId))
+ return null;
+
+ // The value of the build configuration's QMAKE environment variable is used to select the
+ // right version of qmake.
+ IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE, configDesc, true);
+ if (qmake_var == null)
+ return null;
+
+ String qmake = qmake_var.getValue();
+ if (qmake == null)
+ return null;
+
+ // The path to qmake is used as the key into the in-memory cache of header paths.
+ QtIncludePaths paths = qtInstallHeaders.get(qmake);
+ if (paths == null) {
+ paths = new QtIncludePaths(qmake);
+ qtInstallHeaders.put(qmake, paths);
+ }
+
+ return paths.getSettingEntries(configDesc, null, languageId);
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.cpp
new file mode 100644
index 00000000000..eb5c18318c1
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.cpp
@@ -0,0 +1,17 @@
+
+#include "DateTime.hh"
+#include
+
+DateTime::DateTime()
+{
+ startTimer( 500 );
+}
+
+DateTime::~DateTime()
+{
+}
+
+void DateTime::timerEvent( QTimerEvent * )
+{
+ emit changed( QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ) );
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.hh b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.hh
new file mode 100644
index 00000000000..c3959b41178
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/DateTime.hh
@@ -0,0 +1,22 @@
+
+#ifndef DATETIME_H
+#define DATETIME_H
+
+#include
+
+class DateTime : public QObject
+{
+Q_OBJECT
+
+public:
+ DateTime();
+ virtual ~DateTime();
+
+protected:
+ virtual void timerEvent( QTimerEvent * );
+
+private:
+ Q_SIGNAL void changed( QString now );
+};
+
+#endif
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/Makefile b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/Makefile
new file mode 100644
index 00000000000..348cb3b7be0
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/Makefile
@@ -0,0 +1,29 @@
+
+PRO = {{baseName}}.pro
+QMAKE = {{qmake.Qt4}}
+
+all: debug release
+
+clean: clean-debug clean-release
+
+build-debug/Makefile: $(PRO)
+ @mkdir -p $(dir $@)
+ $(QMAKE) -o $@ $(PRO) CONFIG+=debug
+
+debug: build-debug/Makefile
+ $(MAKE) -wC build-debug all
+
+clean-debug:
+ rm -fr build-debug
+
+build-release/Makefile: $(PRO)
+ @mkdir -p $(dir $@)
+ $(QMAKE) -o $@ $(PRO) CONFIG+=release
+
+release: build-release/Makefile
+ $(MAKE) -wC build-release
+
+clean-release:
+ rm -fr build-release
+
+.PHONY: all clean debug clean-debug release clean-release
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.cpp
new file mode 100644
index 00000000000..90d1fff3a0f
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.cpp
@@ -0,0 +1,22 @@
+
+#include "DateTime.hh"
+#include
+#include
+#include
+#include
+
+int main( int argc, char * argv[] )
+{
+ QApplication app( argc, argv );
+
+ DateTime datetime;
+
+ QDeclarativeView view;
+ view.rootContext()->setContextProperty( "datetimeModel", &datetime );
+ view.setSource( QUrl::fromLocalFile( "$(baseName).qml" ) );
+
+ app.connect( view.engine(), SIGNAL( quit() ), SLOT( quit() ) );
+
+ view.show();
+ return app.exec();
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.pro b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.pro
new file mode 100644
index 00000000000..e5802297343
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.pro
@@ -0,0 +1,7 @@
+
+QT += declarative
+HEADERS = DateTime.hh
+SOURCES = DateTime.cpp {{baseName}}.cpp
+RESOURCES =
+
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.qml b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.qml
new file mode 100644
index 00000000000..90192eab1fc
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/baseName.qml
@@ -0,0 +1,38 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 480
+ height: 320
+ color: "lightgreen"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+
+ Text {
+ id: title
+ text: "Hello World from Qt4"
+ font.family: "Helvetica"
+ font.pointSize: 24
+ anchors.centerIn: parent
+ }
+
+ Text {
+ id: datetime
+ objectName: "datetime"
+ font.family: "Helvetica"
+ font.pointSize: 16
+ anchors {
+ horizontalCenter: title.horizontalCenter
+ top: title.bottom
+ }
+
+ Connections {
+ target: datetimeModel
+ onChanged: {
+ datetime.text = now
+ }
+ }
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.properties b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.properties
new file mode 100644
index 00000000000..833a289feec
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2013 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html"
+###############################################################################
+
+Qt4HelloWorld.label=Qt4 Hello World Project
+Qt4HelloWorld.description=A sample Qt4 declarative project
+Qt4HelloWorld.basics.label=Basic Settings
+Qt4HelloWorld.basics.description=Basic properties of a project
+Qt4HelloWorld.qmake.label=Qt4 qmake location
+Qt4HelloWorld.qmake.description=Location of the qmake executable
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.xml b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.xml
new file mode 100644
index 00000000000..efa99afb62b
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt4/template.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.cpp
new file mode 100644
index 00000000000..eb5c18318c1
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.cpp
@@ -0,0 +1,17 @@
+
+#include "DateTime.hh"
+#include
+
+DateTime::DateTime()
+{
+ startTimer( 500 );
+}
+
+DateTime::~DateTime()
+{
+}
+
+void DateTime::timerEvent( QTimerEvent * )
+{
+ emit changed( QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ) );
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.hh b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.hh
new file mode 100644
index 00000000000..fca23e2c785
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/DateTime.hh
@@ -0,0 +1,22 @@
+
+#ifndef DATETIME_H
+#define DATETIME_H
+
+#include
+
+class DateTime : public QObject
+{
+Q_OBJECT
+
+public:
+ DateTime();
+ virtual ~DateTime();
+
+protected:
+ virtual void timerEvent( QTimerEvent * );
+
+signals:
+ void changed( QString now );
+};
+
+#endif
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/Makefile b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/Makefile
new file mode 100644
index 00000000000..a77d655957a
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/Makefile
@@ -0,0 +1,29 @@
+
+PRO = {{baseName}}.pro
+QMAKE = {{qmake.Qt5}}
+
+all: debug release
+
+clean: clean-debug clean-release
+
+build-debug/Makefile: $(PRO)
+ @mkdir -p $(dir $@)
+ $(QMAKE) -o $@ $(PRO) CONFIG+=debug
+
+debug: build-debug/Makefile
+ $(MAKE) -wC build-debug all
+
+clean-debug:
+ rm -fr build-debug
+
+build-release/Makefile: $(PRO)
+ @mkdir -p $(dir $@)
+ $(QMAKE) -o $@ $(PRO) CONFIG+=release
+
+release: build-release/Makefile
+ $(MAKE) -wC build-release
+
+clean-release:
+ rm -fr build-release
+
+.PHONY: all clean debug clean-debug release clean-release
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.cpp
new file mode 100644
index 00000000000..9b271b68b0f
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.cpp
@@ -0,0 +1,20 @@
+
+#include "DateTime.hh"
+#include
+#include
+
+int main( int argc, char * argv[] )
+{
+ QGuiApplication app(argc, argv);
+
+ DateTime datetime;
+
+ QQuickView view;
+ view.rootContext()->setContextProperty( "datetimeModel", &datetime );
+ view.setSource( QStringLiteral( "$(baseName).qml" ) );
+ view.show();
+
+ app.connect( view.engine(), SIGNAL( quit() ), SLOT( quit() ) );
+
+ return app.exec();
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.pro b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.pro
new file mode 100644
index 00000000000..13ce5ce3718
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.pro
@@ -0,0 +1,5 @@
+
+QT += qml quick
+HEADERS = DateTime.hh
+SOURCES = DateTime.cpp {{baseName}}.cpp
+RESOURCES =
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.qml b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.qml
new file mode 100644
index 00000000000..527072d536a
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/baseName.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 480
+ height: 320
+ color: "lightblue"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+
+ Text {
+ id: title
+ text: "Hello World from Qt5"
+ font.family: "Helvetica"
+ font.pointSize: 24
+ anchors.centerIn: parent
+ }
+
+ Text {
+ id: datetime
+ objectName: "datetime"
+ font.family: "Helvetica"
+ font.pointSize: 16
+ anchors {
+ horizontalCenter: title.horizontalCenter
+ top: title.bottom
+ }
+
+ Connections {
+ target: datetimeModel
+ onChanged: {
+ datetime.text = now
+ }
+ }
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.properties b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.properties
new file mode 100644
index 00000000000..5b7132fbfc6
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2013 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html"
+###############################################################################
+
+Qt5HelloWorld.label=Qt5 Hello World Project
+Qt5HelloWorld.description=A sample Qt5 QtQuick2 project
+Qt5HelloWorld.basics.label=Basic Settings
+Qt5HelloWorld.basics.description=Basic properties of a project
+Qt5HelloWorld.qmake.label=Qt5 qmake location
+Qt5HelloWorld.qmake.description=Location of the qmake executable
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.xml b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.xml
new file mode 100644
index 00000000000..25baf4badd4
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/Qt5/template.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp
deleted file mode 100644
index 0d4874b0b29..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include
-#include
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QQuickView viewer(QStringLiteral("$(baseName).qml"));
- viewer.show();
-
- return app.exec();
-}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro
deleted file mode 100644
index d8bd5026732..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-QT += qml quick
-
-SOURCES += {{baseName}}.cpp
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml
deleted file mode 100644
index 2ff2ef6170c..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- width: 360
- height: 360
- Text {
- text: qsTr("Hello World from $(baseName)")
- anchors.centerIn: parent
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- Qt.quit();
- }
- }
-}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile
deleted file mode 100644
index 5a41246df1d..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-QMAKE = {{qmake}}
-
-all: debug release
-
-clean: clean-debug clean-release
-
-build-debug/Makefile:
- @mkdir -p $(dir $@)
- $(QMAKE) -o $@ {{baseName}}.pro CONFIG+=debug
-
-debug: build-debug/Makefile
- $(MAKE) -w -C build-debug
-
-clean-debug:
- rm -fr build-debug
-
-build-release/Makefile:
- @mkdir -p $(dir $@)
- $(QMAKE) -o $@ {{baseName}}.pro CONFIG+=release
-
-release: build-release/Makefile
- $(MAKE) -w -C build-release
-
-clean-release:
- rm -fr build-release
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties
deleted file mode 100644
index a8695c78663..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Symbian Software Private Ltd. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Bala Torati (Symbian) - initial API and implementation
-###############################################################################
-
-#Template Default Values
-QtHelloWorld.label=Hello World QtQuick2 Project
-QtHelloWorld.description=A Hello World QtQuick2 Project
-QtHelloWorld.basics.label=Basic Settings
-QtHelloWorld.basics.description=Basic properties of a project
-QtHelloWorld.qmake.label=qmake location
-QtHelloWorld.qmake.description=Location of the qmake executable
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml
deleted file mode 100644
index 58bdd9e8b00..00000000000
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-