summaryrefslogtreecommitdiffstats
path: root/examples/tutorials/modelview
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tutorials/modelview')
-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.cpp0
-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.cpp0
-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
-rw-r--r--examples/tutorials/modelview/5_edit/modelview.cpp60
-rw-r--r--examples/tutorials/modelview/5_edit/modelview.h59
-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
-rw-r--r--examples/tutorials/modelview/6_treeview/modelview.cpp82
-rw-r--r--examples/tutorials/modelview/6_treeview/modelview.h65
-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
-rw-r--r--examples/tutorials/modelview/7_selections/modelview.cpp107
-rw-r--r--examples/tutorials/modelview/7_selections/modelview.h64
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/modelview.pro10
39 files changed, 128 insertions, 941 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..7be212e 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/main.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/main.cpp
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..7be212e 100644..100755
--- a/examples/tutorials/modelview/4_headers/main.cpp
+++ b/examples/tutorials/modelview/4_headers/main.cpp
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/modelview.cpp
deleted file mode 100644
index a6c6ef5..0000000
--- a/examples/tutorials/modelview/5_edit/modelview.cpp
+++ /dev/null
@@ -1,60 +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);
- QAbstractTableModel *myModel = new MyModel(this);
- tableView->setModel(myModel);
-
- //transfer changes to the model to the window title
- connect(myModel, SIGNAL(editCompleted(const QString &)), this, SLOT(setWindowTitle(const QString &)));
-}
-
-void ModelView::showWindowTitle(const QString & title)
-{
-setWindowTitle(title);
-}
diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/modelview.h
deleted file mode 100644
index 069107b..0000000
--- a/examples/tutorials/modelview/5_edit/modelview.h
+++ /dev/null
@@ -1,59 +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);
-public slots:
- void showWindowTitle(const QString & title);
-};
-
-#endif // MODELVIEW_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/modelview.cpp
deleted file mode 100644
index 772dbdd..0000000
--- a/examples/tutorials/modelview/6_treeview/modelview.cpp
+++ /dev/null
@@ -1,82 +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 <QTreeView>
-#include <QStandardItemModel>
-#include <QStandardItem>
-#include "modelview.h"
-
-
-const int ROWS = 2;
-const int COLUMNS = 3;
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- treeView = new QTreeView(this);
- setCentralWidget(treeView);
- standardModel = new QStandardItemModel ;
-
- QList<QStandardItem *> preparedColumn =prepareColumn("first", "second", "third");
- QStandardItem *item = standardModel->invisibleRootItem();
- // adding a row to the invisible root item produces a root element
- item->appendRow(preparedColumn);
-
- QList<QStandardItem *> secondRow =prepareColumn("111", "222", "333");
- // adding a row to an item starts a subtree
- preparedColumn.first()->appendRow(secondRow);
-
- treeView->setModel(standardModel);
- treeView->expandAll();
-}
-
-QList<QStandardItem *> ModelView::prepareColumn(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;
-}
-//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/modelview.h
deleted file mode 100644
index 55f3470..0000000
--- a/examples/tutorials/modelview/6_treeview/modelview.h
+++ /dev/null
@@ -1,65 +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_BEGIN_NAMESPACE
-class QTreeView; //forward declaration
-class QStandardItemModel;
-class QStandardItem;
-QT_END_NAMESPACE
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTreeView *treeView;
- QStandardItemModel *standardModel;
- QList<QStandardItem *> prepareColumn(const QString &first,
- const QString &second,
- const QString &third);
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_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/modelview.cpp
deleted file mode 100644
index 3b373c6..0000000
--- a/examples/tutorials/modelview/7_selections/modelview.cpp
+++ /dev/null
@@ -1,107 +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_a]
-#include <QTreeView>
-#include <QStandardItemModel>
-#include <QItemSelectionModel>
-#include "modelview.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- treeView = new QTreeView(this);
- setCentralWidget(treeView);
- standardModel = new QStandardItemModel ;
- QStandardItem *rootNode = standardModel->invisibleRootItem();
-
-
- //defining a couple of items
- QStandardItem *americaItem = new QStandardItem("America");
- QStandardItem *mexicoItem = new QStandardItem("Canada");
- QStandardItem *usaItem = new QStandardItem("USA");
- QStandardItem *bostonItem = new QStandardItem("Boston");
- QStandardItem *europeItem = new QStandardItem("Europe");
- QStandardItem *italyItem = new QStandardItem("Italy");
- QStandardItem *romeItem = new QStandardItem("Rome");
- QStandardItem *veronaItem = new QStandardItem("Verona");
-
- //building up the hierarchy
- rootNode-> appendRow(americaItem);
- rootNode-> appendRow(europeItem);
- americaItem-> appendRow(mexicoItem);
- americaItem-> appendRow(usaItem);
- usaItem-> appendRow(bostonItem);
- europeItem-> appendRow(italyItem);
- italyItem-> appendRow(romeItem);
- italyItem-> appendRow(veronaItem);
-
- //register the model
- treeView->setModel(standardModel);
- treeView->expandAll();
-
- //selection changes shall trigger a slot
- QItemSelectionModel *selectionModel= treeView->selectionModel();
- connect(selectionModel, SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)),
- this, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &)));
-}
-//! [quoting modelview_a]
-
-//------------------------------------------------------------------------------------
-
-//! [quoting modelview_b]
-void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
-{
- const QModelIndex index = treeView->selectionModel()->currentIndex();
- QString selectedText = index.data(Qt::DisplayRole).toString();
- int hierarchyLevel=1;
- QModelIndex seekRoot = index;
- while(seekRoot.parent() != QModelIndex())
- {
- seekRoot = seekRoot.parent();
- hierarchyLevel++;
- }
- QString showString = QString("%1, Level %2").arg(selectedText)
- .arg(hierarchyLevel);
- setWindowTitle(showString);
-}
-//! [quoting modelview_b]
-
-
diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/modelview.h
deleted file mode 100644
index d20797e..0000000
--- a/examples/tutorials/modelview/7_selections/modelview.h
+++ /dev/null
@@ -1,64 +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_BEGIN_NAMESPACE
-class QTreeView; //forward declaration
-class QStandardItemModel;
-class QItemSelection;
-QT_END_NAMESPACE
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTreeView *treeView;
- QStandardItemModel *standardModel;
-private slots:
- void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection);
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_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)