summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-08-30 13:18:56 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-08-30 13:18:56 (GMT)
commit07736804359d877c4050314a264390c0fb32f840 (patch)
tree51dffc2e349ee176fcac3496078331d288399ad4 /examples
parent2d42128a7aad4a13b99198d13d7681c75ed568cf (diff)
parent2299cc27db5e40fe43c6b46d5560fe65bc9e6da5 (diff)
downloadQt-07736804359d877c4050314a264390c0fb32f840.zip
Qt-07736804359d877c4050314a264390c0fb32f840.tar.gz
Qt-07736804359d877c4050314a264390c0fb32f840.tar.bz2
Merge branch '4.7' of ../msculls-modelview-qdoc-enhancement into 4.7
Diffstat (limited to 'examples')
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/1_readonly.pro13
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/main.cpp9
-rw-r--r--examples/tutorials/modelview/1_readonly/modelview.cpp54
-rw-r--r--examples/tutorials/modelview/1_readonly/modelview.h61
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/2_formatting.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/main.cpp12
-rw-r--r--examples/tutorials/modelview/2_formatting/modelview.cpp52
-rw-r--r--examples/tutorials/modelview/2_formatting/modelview.h57
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/mymodel.cpp6
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/main.cpp9
-rw-r--r--examples/tutorials/modelview/3_changingmodel/modelview.cpp52
-rw-r--r--examples/tutorials/modelview/3_changingmodel/modelview.h57
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/mymodel.h2
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/4_headers.pro14
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/main.cpp11
-rw-r--r--examples/tutorials/modelview/4_headers/modelview.cpp54
-rw-r--r--examples/tutorials/modelview/4_headers/modelview.h58
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/5_edit.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mainwindow.cpp (renamed from examples/tutorials/modelview/5_edit/modelview.cpp)6
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mainwindow.h (renamed from examples/tutorials/modelview/5_edit/modelview.h)12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mymodel.cpp40
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mymodel.h9
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/6_treeview.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/mainwindow.cpp (renamed from examples/tutorials/modelview/6_treeview/modelview.cpp)24
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/mainwindow.h (renamed from examples/tutorials/modelview/6_treeview/modelview.h)19
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/7_selections.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/mainwindow.cpp (renamed from examples/tutorials/modelview/7_selections/modelview.cpp)8
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/mainwindow.h (renamed from examples/tutorials/modelview/7_selections/modelview.h)13
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/modelview.pro10
39 files changed, 182 insertions, 552 deletions
diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro
index 1162d5a..3ecebc2 100644..100755
--- a/examples/tutorials/modelview/1_readonly/1_readonly.pro
+++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro
@@ -3,8 +3,15 @@ TARGET = mv_readonly
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/1_readonly
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 1_readonly.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/1_readonly
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp
index fb4726a..2143854 100644..100755
--- a/examples/tutorials/modelview/1_readonly/main.cpp
+++ b/examples/tutorials/modelview/1_readonly/main.cpp
@@ -41,13 +41,16 @@
//! [Quoting ModelView Tutorial]
// main.cpp
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp
deleted file mode 100644
index 91a97bf..0000000
--- a/examples/tutorials/modelview/1_readonly/modelview.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [Quoting ModelView Tutorial]
-// modelview.cpp
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h
deleted file mode 100644
index cc14d90..0000000
--- a/examples/tutorials/modelview/1_readonly/modelview.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-//! [Quoting ModelView Tutorial]
-// modelview.h
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-
-};
-//! [Quoting ModelView Tutorial]
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp
index 394605a..394605a 100644..100755
--- a/examples/tutorials/modelview/1_readonly/mymodel.cpp
+++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp
diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h
index 6065f6e..6065f6e 100644..100755
--- a/examples/tutorials/modelview/1_readonly/mymodel.h
+++ b/examples/tutorials/modelview/1_readonly/mymodel.h
diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro
index 7e70d81..c6ad27c 100644..100755
--- a/examples/tutorials/modelview/2_formatting/2_formatting.pro
+++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro
@@ -3,8 +3,14 @@ TARGET = mv_formatting
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/2_formatting
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 2_formatting.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/2_formatting
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/2_formatting/main.cpp b/examples/tutorials/modelview/2_formatting/main.cpp
index 7be212e..2143854 100644..100755
--- a/examples/tutorials/modelview/2_formatting/main.cpp
+++ b/examples/tutorials/modelview/2_formatting/main.cpp
@@ -38,13 +38,19 @@
**
****************************************************************************/
+//! [Quoting ModelView Tutorial]
+// main.cpp
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
+//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/2_formatting/modelview.cpp b/examples/tutorials/modelview/2_formatting/modelview.cpp
deleted file mode 100644
index 9a5ce64..0000000
--- a/examples/tutorials/modelview/2_formatting/modelview.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-
diff --git a/examples/tutorials/modelview/2_formatting/modelview.h b/examples/tutorials/modelview/2_formatting/modelview.h
deleted file mode 100644
index b2943ac..0000000
--- a/examples/tutorials/modelview/2_formatting/modelview.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp
index f7ff504..3e13ff4 100644..100755
--- a/examples/tutorials/modelview/2_formatting/mymodel.cpp
+++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp
@@ -43,8 +43,6 @@
#include "mymodel.h"
#include <QDebug>
-//! [Quoting ModelView Tutorial]
-// mymodel.cpp
MyModel::MyModel(QObject *parent)
:QAbstractTableModel(parent)
{
@@ -60,6 +58,8 @@ int MyModel::columnCount(const QModelIndex & /*parent */) const
return 3;
}
+//! [Quoting ModelView Tutorial]
+// mymodel.cpp
QVariant MyModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
@@ -89,7 +89,7 @@ QVariant MyModel::data(const QModelIndex &index, int role) const
if (row == 1 && col == 2) //change background only for cell(1,2)
{
- QBrush redBackground = QBrush(Qt::red);
+ QBrush redBackground(QColor(Qt::red));
return redBackground;
}
break;
diff --git a/examples/tutorials/modelview/2_formatting/mymodel.h b/examples/tutorials/modelview/2_formatting/mymodel.h
index 4dc405a..4dc405a 100644..100755
--- a/examples/tutorials/modelview/2_formatting/mymodel.h
+++ b/examples/tutorials/modelview/2_formatting/mymodel.h
diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
index d61ee4c..e977731 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
+++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
@@ -3,8 +3,14 @@ TARGET = mv_changingmodel
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/3_changingmodel
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 3_changingmodel.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/3_changingmodel
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/3_changingmodel/main.cpp b/examples/tutorials/modelview/3_changingmodel/main.cpp
index 7be212e..3b6061a 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/main.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/main.cpp
@@ -39,12 +39,15 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.cpp b/examples/tutorials/modelview/3_changingmodel/modelview.cpp
deleted file mode 100644
index 9a5ce64..0000000
--- a/examples/tutorials/modelview/3_changingmodel/modelview.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-
diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.h b/examples/tutorials/modelview/3_changingmodel/modelview.h
deleted file mode 100644
index b2943ac..0000000
--- a/examples/tutorials/modelview/3_changingmodel/modelview.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
index 42915b0..42915b0 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.h b/examples/tutorials/modelview/3_changingmodel/mymodel.h
index 01ad88d..47b026e 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/mymodel.h
+++ b/examples/tutorials/modelview/3_changingmodel/mymodel.h
@@ -43,7 +43,7 @@
#include <QAbstractTableModel>
-QT_FORWARD_DECLARE_CLASS(QTimer)
+class QTimer; // forward declaration
class MyModel : public QAbstractTableModel
{
diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro
index d6f8d23..f6c60b2 100644..100755
--- a/examples/tutorials/modelview/4_headers/4_headers.pro
+++ b/examples/tutorials/modelview/4_headers/4_headers.pro
@@ -2,9 +2,15 @@ TARGET = mv_headers
TEMPLATE = app
-SOURCES += main.cpp \
- modelview.cpp \
+SOURCES += main.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/4_headers
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 4_headers.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/4_headers
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/4_headers/main.cpp b/examples/tutorials/modelview/4_headers/main.cpp
index 7be212e..5f5d05f 100644..100755
--- a/examples/tutorials/modelview/4_headers/main.cpp
+++ b/examples/tutorials/modelview/4_headers/main.cpp
@@ -39,12 +39,15 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
-}
+} \ No newline at end of file
diff --git a/examples/tutorials/modelview/4_headers/modelview.cpp b/examples/tutorials/modelview/4_headers/modelview.cpp
deleted file mode 100644
index 449dbbc..0000000
--- a/examples/tutorials/modelview/4_headers/modelview.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include <QHeaderView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
- tableView->verticalHeader()->hide();
-}
-
diff --git a/examples/tutorials/modelview/4_headers/modelview.h b/examples/tutorials/modelview/4_headers/modelview.h
deleted file mode 100644
index 03f99c0..0000000
--- a/examples/tutorials/modelview/4_headers/modelview.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp
index e6f977d..e6f977d 100644..100755
--- a/examples/tutorials/modelview/4_headers/mymodel.cpp
+++ b/examples/tutorials/modelview/4_headers/mymodel.cpp
diff --git a/examples/tutorials/modelview/4_headers/mymodel.h b/examples/tutorials/modelview/4_headers/mymodel.h
index ada3169..ada3169 100644..100755
--- a/examples/tutorials/modelview/4_headers/mymodel.h
+++ b/examples/tutorials/modelview/4_headers/mymodel.h
diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro
index e18c596..2ef343f 100644..100755
--- a/examples/tutorials/modelview/5_edit/5_edit.pro
+++ b/examples/tutorials/modelview/5_edit/5_edit.pro
@@ -3,8 +3,16 @@ TARGET = mv_edit
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
+ mainwindow.cpp \
mymodel.cpp
-HEADERS += modelview.h \
+HEADERS += mainwindow.h \
mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/5_edit
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 5_edit.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/5_edit
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/5_edit/main.cpp b/examples/tutorials/modelview/5_edit/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/5_edit/main.cpp
+++ b/examples/tutorials/modelview/5_edit/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/5_edit/modelview.cpp b/examples/tutorials/modelview/5_edit/mainwindow.cpp
index a6c6ef5..542f3d6 100644..100755
--- a/examples/tutorials/modelview/5_edit/modelview.cpp
+++ b/examples/tutorials/modelview/5_edit/mainwindow.cpp
@@ -39,10 +39,10 @@
****************************************************************************/
#include <QTableView>
-#include "modelview.h"
+#include "mainwindow.h"
#include "mymodel.h"
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
tableView = new QTableView(this);
@@ -54,7 +54,7 @@ ModelView::ModelView(QWidget *parent)
connect(myModel, SIGNAL(editCompleted(const QString &)), this, SLOT(setWindowTitle(const QString &)));
}
-void ModelView::showWindowTitle(const QString & title)
+void MainWindow::showWindowTitle(const QString & title)
{
setWindowTitle(title);
}
diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/mainwindow.h
index 069107b..1d49f47 100644..100755
--- a/examples/tutorials/modelview/5_edit/modelview.h
+++ b/examples/tutorials/modelview/5_edit/mainwindow.h
@@ -38,22 +38,22 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_FORWARD_DECLARE_CLASS(QTableView)
+class QTableView; //forward declaration
-class ModelView : public QMainWindow
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QTableView *tableView;
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
public slots:
void showWindowTitle(const QString & title);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp
index 67181ca..e2fd391 100644..100755
--- a/examples/tutorials/modelview/5_edit/mymodel.cpp
+++ b/examples/tutorials/modelview/5_edit/mymodel.cpp
@@ -38,62 +38,64 @@
**
****************************************************************************/
-//! [quoting mymodel_d]
+
#include "mymodel.h"
-const int COLS= 3;
-const int ROWS= 2;
MyModel::MyModel(QObject *parent)
:QAbstractTableModel(parent)
{
- //gridData needs to have 6 element, one for each table cell
- m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ;
}
-//! [quoting mymodel_d]
-//! [quoting mymodel_e]
+//-----------------------------------------------------------------
int MyModel::rowCount(const QModelIndex & /*parent*/) const
{
return ROWS;
}
+//-----------------------------------------------------------------
int MyModel::columnCount(const QModelIndex & /*parent*/) const
{
return COLS;
}
+//-----------------------------------------------------------------
QVariant MyModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole)
{
- return m_gridData[modelIndexToOffset(index)];
+ return m_gridData[index.row()][index.column()];
}
return QVariant();
}
-//! [quoting mymodel_e]
//-----------------------------------------------------------------
-
-//! [quoting mymodel_f]
+//! [quoting mymodel_e]
bool MyModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
if (role == Qt::EditRole)
{
- m_gridData[modelIndexToOffset(index)] = value.toString();
- emit editCompleted(m_gridData.join(" | "));
+ //save value from editor to member m_gridData
+ m_gridData[index.row()][index.column()] = value.toString();
+ //for presentation purposes only: build and emit a joined string
+ QString result;
+ for(int row= 0; row < ROWS; row++)
+ {
+ for(int col= 0; col < COLS; col++)
+ {
+ result += m_gridData[row][col] + " ";
+ }
+ }
+ emit editCompleted( result );
}
return true;
}
+//! [quoting mymodel_e]
+//-----------------------------------------------------------------
+//! [quoting mymodel_f]
Qt::ItemFlags MyModel::flags(const QModelIndex & /*index*/) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ;
}
-
-//convert row and column information to array offset
-int MyModel::modelIndexToOffset(const QModelIndex & index) const
-{
- return index.row()*COLS + index.column();
-}
//! [quoting mymodel_f]
diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h
index 0d2a1b8..574808e 100644..100755
--- a/examples/tutorials/modelview/5_edit/mymodel.h
+++ b/examples/tutorials/modelview/5_edit/mymodel.h
@@ -44,7 +44,11 @@
//! [Quoting ModelView Tutorial]
// mymodel.h
#include <QAbstractTableModel>
-#include <QStringList>
+#include <QString>
+
+const int COLS= 3;
+const int ROWS= 2;
+
class MyModel : public QAbstractTableModel
{
@@ -57,8 +61,7 @@ public:
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex & index) const ;
private:
- QStringList m_gridData; //holds text entered into QTableView
- int modelIndexToOffset(const QModelIndex & index) const;
+ QString m_gridData[ROWS][COLS]; //holds text entered into QTableView
signals:
void editCompleted(const QString &);
};
diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro
index 6d078be..e79ef20 100644..100755
--- a/examples/tutorials/modelview/6_treeview/6_treeview.pro
+++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro
@@ -1,5 +1,13 @@
TARGET = mv_tree
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp
-HEADERS += modelview.h
+ mainwindow.cpp
+HEADERS += mainwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 6_treeview.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/6_treeview/main.cpp
+++ b/examples/tutorials/modelview/6_treeview/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/mainwindow.cpp
index 772dbdd..a105232 100644..100755
--- a/examples/tutorials/modelview/6_treeview/modelview.cpp
+++ b/examples/tutorials/modelview/6_treeview/mainwindow.cpp
@@ -43,40 +43,40 @@
#include <QTreeView>
#include <QStandardItemModel>
#include <QStandardItem>
-#include "modelview.h"
+#include "mainwindow.h"
const int ROWS = 2;
const int COLUMNS = 3;
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
treeView = new QTreeView(this);
setCentralWidget(treeView);
standardModel = new QStandardItemModel ;
- QList<QStandardItem *> preparedColumn =prepareColumn("first", "second", "third");
+ QList<QStandardItem *> preparedRow =prepareRow("first", "second", "third");
QStandardItem *item = standardModel->invisibleRootItem();
// adding a row to the invisible root item produces a root element
- item->appendRow(preparedColumn);
+ item->appendRow(preparedRow);
- QList<QStandardItem *> secondRow =prepareColumn("111", "222", "333");
+ QList<QStandardItem *> secondRow =prepareRow("111", "222", "333");
// adding a row to an item starts a subtree
- preparedColumn.first()->appendRow(secondRow);
+ preparedRow.first()->appendRow(secondRow);
treeView->setModel(standardModel);
treeView->expandAll();
}
-QList<QStandardItem *> ModelView::prepareColumn(const QString &first,
+QList<QStandardItem *> MainWindow::prepareRow(const QString &first,
const QString &second,
const QString &third)
{
- QList<QStandardItem *> colItems;
- colItems << new QStandardItem(first);
- colItems << new QStandardItem(second);
- colItems << new QStandardItem(third);
- return colItems;
+ QList<QStandardItem *> rowItems;
+ rowItems << new QStandardItem(first);
+ rowItems << new QStandardItem(second);
+ rowItems << new QStandardItem(third);
+ return rowItems;
}
//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/mainwindow.h
index 55f3470..fb8de79 100644..100755
--- a/examples/tutorials/modelview/6_treeview/modelview.h
+++ b/examples/tutorials/modelview/6_treeview/mainwindow.h
@@ -38,28 +38,27 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_BEGIN_NAMESPACE
class QTreeView; //forward declaration
class QStandardItemModel;
class QStandardItem;
-QT_END_NAMESPACE
-class ModelView : public QMainWindow
+
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QTreeView *treeView;
QStandardItemModel *standardModel;
- QList<QStandardItem *> prepareColumn(const QString &first,
- const QString &second,
- const QString &third);
+ QList<QStandardItem *> prepareRow( const QString &first,
+ const QString &second,
+ const QString &third );
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro
index 952641c6..6945bf7 100644..100755
--- a/examples/tutorials/modelview/7_selections/7_selections.pro
+++ b/examples/tutorials/modelview/7_selections/7_selections.pro
@@ -1,5 +1,13 @@
TARGET = mv_selections
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp
-HEADERS += modelview.h
+ mainwindow.cpp
+HEADERS += mainwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/7_selections
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 7_selections.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/7_selections
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/7_selections/main.cpp b/examples/tutorials/modelview/7_selections/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/7_selections/main.cpp
+++ b/examples/tutorials/modelview/7_selections/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/mainwindow.cpp
index 3b373c6..cb09633 100644..100755
--- a/examples/tutorials/modelview/7_selections/modelview.cpp
+++ b/examples/tutorials/modelview/7_selections/mainwindow.cpp
@@ -42,9 +42,9 @@
#include <QTreeView>
#include <QStandardItemModel>
#include <QItemSelectionModel>
-#include "modelview.h"
+#include "mainwindow.h"
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
treeView = new QTreeView(this);
@@ -87,10 +87,12 @@ ModelView::ModelView(QWidget *parent)
//------------------------------------------------------------------------------------
//! [quoting modelview_b]
-void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
+void MainWindow::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
{
+ //get the text of the selected item
const QModelIndex index = treeView->selectionModel()->currentIndex();
QString selectedText = index.data(Qt::DisplayRole).toString();
+ //find out the hierarchy level of the selected item
int hierarchyLevel=1;
QModelIndex seekRoot = index;
while(seekRoot.parent() != QModelIndex())
diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/mainwindow.h
index d20797e..f2defb5 100644..100755
--- a/examples/tutorials/modelview/7_selections/modelview.h
+++ b/examples/tutorials/modelview/7_selections/mainwindow.h
@@ -38,18 +38,17 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_BEGIN_NAMESPACE
class QTreeView; //forward declaration
class QStandardItemModel;
class QItemSelection;
-QT_END_NAMESPACE
-class ModelView : public QMainWindow
+
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
@@ -58,7 +57,7 @@ private:
private slots:
void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection);
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/modelview.pro b/examples/tutorials/modelview/modelview.pro
index 7f684ba..50f5c3a 100644..100755
--- a/examples/tutorials/modelview/modelview.pro
+++ b/examples/tutorials/modelview/modelview.pro
@@ -1,5 +1,4 @@
-TEMPLATE = subdirs
-
+TEMPLATE = subdirs
SUBDIRS = 1_readonly \
2_formatting \
3_changingmodel \
@@ -8,3 +7,10 @@ SUBDIRS = 1_readonly \
6_treeview \
7_selections
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS modelview.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)