From f3eb0983766ccca1a6ba78411f59120f45627743 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Fri, 12 Mar 2010 11:23:30 +0100
Subject: [PATCH] Wizards/CustomWizard: Add examples. Task-number:
 QTCREATORBUG-423

---
 share/qtcreator/templates/wizards/README.txt  |   5 ++
 .../templates/wizards/helloworld/console.png  | Bin 0 -> 567 bytes
 .../templates/wizards/helloworld/main.cpp     |   7 ++
 .../templates/wizards/helloworld/project.pro  |   6 ++
 .../wizards/helloworld/wizard_sample.xml      |  61 ++++++++++++++++++
 .../templates/wizards/listmodel/listmodel.cpp |  23 +++++++
 .../templates/wizards/listmodel/listmodel.h   |  21 ++++++
 .../wizards/listmodel/wizard_sample.xml       |  59 +++++++++++++++++
 8 files changed, 182 insertions(+)
 create mode 100644 share/qtcreator/templates/wizards/README.txt
 create mode 100644 share/qtcreator/templates/wizards/helloworld/console.png
 create mode 100644 share/qtcreator/templates/wizards/helloworld/main.cpp
 create mode 100644 share/qtcreator/templates/wizards/helloworld/project.pro
 create mode 100644 share/qtcreator/templates/wizards/helloworld/wizard_sample.xml
 create mode 100644 share/qtcreator/templates/wizards/listmodel/listmodel.cpp
 create mode 100644 share/qtcreator/templates/wizards/listmodel/listmodel.h
 create mode 100644 share/qtcreator/templates/wizards/listmodel/wizard_sample.xml

diff --git a/share/qtcreator/templates/wizards/README.txt b/share/qtcreator/templates/wizards/README.txt
new file mode 100644
index 00000000000..891ad644062
--- /dev/null
+++ b/share/qtcreator/templates/wizards/README.txt
@@ -0,0 +1,5 @@
+Qt Creator custom wizard are located in this directory.
+
+The subdirectories 'helloworld' and 'listmodel' are provided as examples.
+To see how they work in Qt Creator, rename the 'wizard_sample.xml' files
+to 'wizard.xml'.
diff --git a/share/qtcreator/templates/wizards/helloworld/console.png b/share/qtcreator/templates/wizards/helloworld/console.png
new file mode 100644
index 0000000000000000000000000000000000000000..7569a988f4a09ad0a72d7250b47db99c88471a79
GIT binary patch
literal 567
zcmV-70?7S|P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800006VoOIv0RI60
z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru)&c_xFagC7Dz5+l03CEi
zSad^gZEa<4bO1wgWnpw>WFU8GbZ8({Xk{QrNlj4iWF>9@00EmxL_t(|+U=LUY63wN
zh0m-**t^BBpbLUq`UqCRYHJH0BQKCnu(8W4<RMa6nP3r!m5*SlqO9U#F|)<ErV^64
z>WceAz|#%P<$T<^Gn`@jZWl$$K*1^;fd5=H`u%+#rsGzN#R33;=Xt2t>zNo&CKC*Y
z!_yrAfWcsJv?(oVt-(3J58*!rP)Z?+qGABH+b!mgb1d`%Qp$V*q?GVIAHh=qzvm<1
zL8=fJ0Zh{bjR<_kp=&yIh>HM*VZhcloQ{(TM4}n6EGsjJ#JAua#4Weus(0W3QGO|-
z6qKNA8mg%fhG9McQc46o!1{TOoxKBn5i0K$5K;C32XnvYL)SF;jKhAlK}2ATrIQD)
zF?Tu+Y;7adAvT-MQ4JA62yr_=6h$Y^Ez81kxy1BsdQ|7O-9!Kvk01;~sHTcFPd$>w
ziHP8QI6wr@h>pyO2yWYrtvjVgzmIXNl?;F}1|bCaCx>a8Fdlw4O$d>w)i({{;SESJ
zl-?83=_6RJR!~Z1Vn#%$R;%X${%**%13!N(_f(vhz5&jR!O)`<rhotd002ovPDHLk
FV1n8)<aGc5

literal 0
HcmV?d00001

diff --git a/share/qtcreator/templates/wizards/helloworld/main.cpp b/share/qtcreator/templates/wizards/helloworld/main.cpp
new file mode 100644
index 00000000000..c68f1dcdce0
--- /dev/null
+++ b/share/qtcreator/templates/wizards/helloworld/main.cpp
@@ -0,0 +1,7 @@
+#include <cstdio>
+
+int main(int, char **)
+{
+    std::printf("%MESSAGE%\n");
+    return 0;
+}
diff --git a/share/qtcreator/templates/wizards/helloworld/project.pro b/share/qtcreator/templates/wizards/helloworld/project.pro
new file mode 100644
index 00000000000..4385bce0d4b
--- /dev/null
+++ b/share/qtcreator/templates/wizards/helloworld/project.pro
@@ -0,0 +1,6 @@
+QT       -= core
+CONFIG   += console
+CONFIG   -= app_bundle
+
+TEMPLATE = app
+SOURCES += main.cpp
diff --git a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml
new file mode 100644
index 00000000000..58e7748bccc
--- /dev/null
+++ b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 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.
+**
+**************************************************************************/
+
+Custom project wizard configuration example file. Note that by convention, 
+the project file goes last.
+The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and 
+leave room for the Qt 4 target page.
+-->
+<wizard version="1" kind="project"
+        class="qt4project" firstpage="10"
+        id="A.HelloWorld" category="B.CustomProjects">
+    <icon>console.png</icon>
+    <description>Creates a hello-world-project with custom message.</description>
+    <description xml:lang="de">Erzeugt ein Hello-Welt-Projekt mit einer Nachricht.</description>
+    <displayName>Hello World</displayName>;
+    <displayName xml:lang="de">Hallo Welt</displayName>;
+    <displayCategory>Custom Projects</displayCategory>
+    <displayCategory xml:lang="de">Benutzerdefinierte Projekte</displayCategory>
+    <files>
+        <file source="main.cpp"/>
+        <file source="project.pro" target="%ProjectName%.pro"/>
+    </files>
+    <!-- Create a 2nd wizard page with parameters -->
+    <fieldpagetitle>Hello World Parameters</fieldpagetitle>
+    <fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle>
+    <fields>
+        <field mandatory="true" name="MESSAGE">
+            <fieldcontrol class="QLineEdit" validator='^[^"]+$'  defaulttext="Hello world!" />
+            <fielddescription>Hello world message:</fielddescription>
+            <fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription>
+        </field>
+    </fields>
+</wizard>
diff --git a/share/qtcreator/templates/wizards/listmodel/listmodel.cpp b/share/qtcreator/templates/wizards/listmodel/listmodel.cpp
new file mode 100644
index 00000000000..8f10b68f04d
--- /dev/null
+++ b/share/qtcreator/templates/wizards/listmodel/listmodel.cpp
@@ -0,0 +1,23 @@
+#include "%ClassName:l%.%CppHeaderSuffix%"
+
+%ClassName%::%ClassName%(QObject *parent) :
+    QAbstractListModel(parent)
+{
+}
+
+void %ClassName%::addItems(const QList<%Datatype%> &newItems)
+{
+    beginInsertRows(QModelIndex(), items.size(), items.size() + newItems.size());
+    items.append(newItems);
+    endInsertRows();
+}
+
+int %ClassName%::rowCount(const QModelIndex &) const
+{
+    return items.size();
+}
+
+QVariant %ClassName%::data(const QModelIndex &index, int)
+{
+    return items.at(index.row());
+}
diff --git a/share/qtcreator/templates/wizards/listmodel/listmodel.h b/share/qtcreator/templates/wizards/listmodel/listmodel.h
new file mode 100644
index 00000000000..25219f635cd
--- /dev/null
+++ b/share/qtcreator/templates/wizards/listmodel/listmodel.h
@@ -0,0 +1,21 @@
+#ifndef %ClassName:u%_H
+#define %ClassName:u%_H
+
+#include <QAbstractListModel>
+#include <QList>
+
+class %ClassName% : public QAbstractListModel {
+    Q_OBJECT
+public:
+    explicit %ClassName%(QObject *parent);
+    void addItems(const QList<%Datatype%> &items);
+
+    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole);
+
+private:
+    QList<%Datatype%> items;
+};
+
+#endif // %ClassName:u%_H
+
diff --git a/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml
new file mode 100644
index 00000000000..c924b896db0
--- /dev/null
+++ b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 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.
+**
+**************************************************************************/
+
+Custom class wizard example configuration file. -->
+<wizard version="1" kind="class" id="A.ListModel" category="B.CustomClasses">
+    <description>Creates a QAbstractListModel implementation.</description>
+    <description xml:lang="de">Erzeugt eine Implementierung von QAbstractListModel.</description>
+    <displayName>QAbstractListModel implementation</displayName>;
+    <displayName xml:lang="de">Implementierung von QAbstractListModel</displayName>;
+    <displayCategory>Custom Classes</displayCategory>
+    <displayCategory xml:lang="de">Benutzerdefinierte Klassen</displayCategory>
+    <files>
+        <file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%"/>
+        <file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%"/>
+    </files>
+    <!-- Create parameter wizard page -->
+    <fieldpagetitle>ListModel parameters</fieldpagetitle>
+    <fieldpagetitle xml:lang="de">Parameter des ListModel</fieldpagetitle>
+    <fields>
+        <field name="ClassName">
+            <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" />
+            <fielddescription>Class name:</fielddescription>
+            <fielddescription xml:lang="de">Klassenname:</fielddescription>
+        </field>
+        <field name="Datatype">
+            <fieldcontrol class="QComboBox" combochoices="QString,int" defaultindex="0" />
+            <fielddescription>Data type:</fielddescription>
+            <fielddescription xml:lang="de">Datentyp:</fielddescription>
+        </field>
+    </fields>
+</wizard>
-- 
GitLab