Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76325 - in sandbox/icl/libs/xplore/br1: editabletreemodel sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-01-05 13:18:05


Author: jofaber
Date: 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
New Revision: 76325
URL: http://svn.boost.org/trac/boost/changeset/76325

Log:
Explorations on tree models and collapsability
Added:
   sandbox/icl/libs/xplore/br1/editabletreemodel/ (props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/default.txt (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.pro (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/main.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.ui (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h (contents, props changed)
Binary files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/media1.db
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 4 ++++
   1 files changed, 4 insertions(+), 0 deletions(-)

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/default.txt
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/default.txt 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,40 @@
+Getting Started How to familiarize yourself with Qt Designer
+ Launching Designer Running the Qt Designer application
+ The User Interface How to interact with Qt Designer
+
+Designing a Component Creating a GUI for your application
+ Creating a Dialog How to create a dialog
+ Composing the Dialog Putting widgets into the dialog example
+ Creating a Layout Arranging widgets on a form
+ Signal and Slot Connections Making widget communicate with each other
+
+Using a Component in Your Application Generating code from forms
+ The Direct Approach Using a form without any adjustments
+ The Single Inheritance Approach Subclassing a form's base class
+ The Multiple Inheritance Approach Subclassing the form itself
+ Automatic Connections Connecting widgets using a naming scheme
+ A Dialog Without Auto-Connect How to connect widgets without a naming scheme
+ A Dialog With Auto-Connect Using automatic connections
+
+Form Editing Mode How to edit a form in Qt Designer
+ Managing Forms Loading and saving forms
+ Editing a Form Basic editing techniques
+ The Property Editor Changing widget properties
+ The Object Inspector Examining the hierarchy of objects on a form
+ Layouts Objects that arrange widgets on a form
+ Applying and Breaking Layouts Managing widgets in layouts
+ Horizontal and Vertical Layouts Standard row and column layouts
+ The Grid Layout Arranging widgets in a matrix
+ Previewing Forms Checking that the design works
+
+Using Containers How to group widgets together
+ General Features Common container features
+ Frames QFrame
+ Group Boxes QGroupBox
+ Stacked Widgets QStackedWidget
+ Tab Widgets QTabWidget
+ Toolbox Widgets QToolBox
+
+Connection Editing Mode Connecting widgets together with signals and slots
+ Connecting Objects Making connections in Qt Designer
+ Editing Connections Changing existing connections

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.pro
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.pro 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,21 @@
+FORMS = mainwindow.ui
+HEADERS = mainwindow.h \
+ treeitem.h \
+ treemodel.h
+RESOURCES = editabletreemodel.qrc
+SOURCES = mainwindow.cpp \
+ treeitem.cpp \
+ treemodel.cpp \
+ main.cpp
+CONFIG += qt
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/editabletreemodel
+sources.files = $$FORMS $$HEADERS $$RESOURCES $$SOURCES *.pro *.txt
+sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/editabletreemodel
+INSTALLS += target sources
+
+symbian: include($$PWD/../../symbianpkgrules.pri)
+maemo5: include($$PWD/../../maemo5pkgrules.pri)
+contains(MEEGO_EDITION,harmattan): include($$PWD/../../harmattanpkgrules.pri)
+

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/main.cpp 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(editabletreemodel);
+
+ QApplication app(argc, argv);
+ MainWindow window;
+#if defined(Q_OS_SYMBIAN)
+ window.showMaximized();
+#else
+ window.show();
+#endif
+ return app.exec();
+}

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.cpp 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 <QtGui>
+
+#include "mainwindow.h"
+#include "treemodel.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setupUi(this);
+
+#ifdef Q_WS_MAEMO_5
+ // Alternating row colors look bad on Maemo
+ view->setAlternatingRowColors(false);
+ view2->setAlternatingRowColors(false);
+#endif
+
+ QStringList headers;
+ headers << tr("Title") << tr("Description");
+
+ QFile file(":/default.txt");
+ file.open(QIODevice::ReadOnly);
+ TreeModel *model = new TreeModel(headers, file.readAll());
+ file.close();
+
+ view->setModel(model);
+ for (int column = 0; column < model->columnCount(); ++column)
+ view->resizeColumnToContents(column);
+
+ view2->setModel(model);
+ for (int column = 0; column < model->columnCount(); ++column)
+ view2->resizeColumnToContents(column);
+
+ connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+
+ connect(view->selectionModel(),
+ SIGNAL(selectionChanged(const QItemSelection &,
+ const QItemSelection &)),
+ this, SLOT(updateActions()));
+
+ connect(view2->selectionModel(),
+ SIGNAL(selectionChanged(const QItemSelection &,
+ const QItemSelection &)),
+ this, SLOT(updateActions()));
+
+ connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions()));
+ connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow()));
+ connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn()));
+ connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
+ connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn()));
+ connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));
+
+ updateActions();
+
+ statusBar()->showMessage(tr("Tree: %1").arg(model->toString()));
+}
+
+void MainWindow::insertChild()
+{
+ QModelIndex index = view->selectionModel()->currentIndex();
+ QAbstractItemModel *model = view->model();
+
+ if (model->columnCount(index) == 0) {
+ if (!model->insertColumn(0, index))
+ return;
+ }
+
+ if (!model->insertRow(0, index))
+ return;
+
+ for (int column = 0; column < model->columnCount(index); ++column) {
+ QModelIndex child = model->index(0, column, index);
+ model->setData(child, QVariant("[No data]"), Qt::EditRole);
+ if (!model->headerData(column, Qt::Horizontal).isValid())
+ model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"),
+ Qt::EditRole);
+ }
+
+ view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
+ QItemSelectionModel::ClearAndSelect);
+ updateActions();
+}
+
+bool MainWindow::insertColumn(const QModelIndex &parent)
+{
+ QAbstractItemModel *model = view->model();
+ int column = view->selectionModel()->currentIndex().column();
+
+ // Insert a column in the parent item.
+ bool changed = model->insertColumn(column + 1, parent);
+ if (changed)
+ model->setHeaderData(column + 1, Qt::Horizontal, QVariant("[No header]"),
+ Qt::EditRole);
+
+ updateActions();
+
+ return changed;
+}
+
+void MainWindow::insertRow()
+{
+ QModelIndex index = view->selectionModel()->currentIndex();
+ QAbstractItemModel *model = view->model();
+
+ if (!model->insertRow(index.row()+1, index.parent()))
+ return;
+
+ updateActions();
+
+ for (int column = 0; column < model->columnCount(index.parent()); ++column) {
+ QModelIndex child = model->index(index.row()+1, column, index.parent());
+ model->setData(child, QVariant("[No data]"), Qt::EditRole);
+ }
+}
+
+bool MainWindow::removeColumn(const QModelIndex &parent)
+{
+ QAbstractItemModel *model = view->model();
+ int column = view->selectionModel()->currentIndex().column();
+
+ // Insert columns in each child of the parent item.
+ bool changed = model->removeColumn(column, parent);
+
+ if (!parent.isValid() && changed)
+ updateActions();
+
+ return changed;
+}
+
+void MainWindow::removeRow()
+{
+ QModelIndex index = view->selectionModel()->currentIndex();
+ QAbstractItemModel *model = view->model();
+ if (model->removeRow(index.row(), index.parent()))
+ updateActions();
+}
+
+void MainWindow::updateActions()
+{
+ bool hasSelection = !view->selectionModel()->selection().isEmpty();
+ removeRowAction->setEnabled(hasSelection);
+ removeColumnAction->setEnabled(hasSelection);
+
+ bool hasCurrent = view->selectionModel()->currentIndex().isValid();
+ insertRowAction->setEnabled(hasCurrent);
+ insertColumnAction->setEnabled(hasCurrent);
+
+ if (hasCurrent) {
+ view->closePersistentEditor(view->selectionModel()->currentIndex());
+
+ int row = view->selectionModel()->currentIndex().row();
+ int column = view->selectionModel()->currentIndex().column();
+ if (view->selectionModel()->currentIndex().parent().isValid())
+ statusBar()->showMessage(tr("Position: (%1,%2)").arg(row).arg(column));
+ else
+ statusBar()->showMessage(tr("Position: (%1,%2) in top level").arg(row).arg(column));
+ }
+}

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.h 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+#include "ui_mainwindow.h"
+
+class QAction;
+class QTreeView;
+class QWidget;
+
+class MainWindow : public QMainWindow, private Ui::MainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void updateActions();
+
+private slots:
+ void insertChild();
+ bool insertColumn(const QModelIndex &parent = QModelIndex());
+ void insertRow();
+ bool removeColumn(const QModelIndex &parent = QModelIndex());
+ void removeRow();
+};
+
+#endif

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.ui
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/mainwindow.ui 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>916</width>
+ <height>434</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Editable Tree Model</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTreeView" name="view">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectItems</enum>
+ </property>
+ <property name="horizontalScrollMode">
+ <enum>QAbstractItemView::ScrollPerPixel</enum>
+ </property>
+ <property name="animated">
+ <bool>false</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableView" name="view2"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>916</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="fileMenu">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="exitAction"/>
+ </widget>
+ <widget class="QMenu" name="actionsMenu">
+ <property name="title">
+ <string>&amp;Actions</string>
+ </property>
+ <addaction name="insertRowAction"/>
+ <addaction name="insertColumnAction"/>
+ <addaction name="separator"/>
+ <addaction name="removeRowAction"/>
+ <addaction name="removeColumnAction"/>
+ <addaction name="separator"/>
+ <addaction name="insertChildAction"/>
+ </widget>
+ <addaction name="fileMenu"/>
+ <addaction name="actionsMenu"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="exitAction">
+ <property name="text">
+ <string>E&amp;xit</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
+ </action>
+ <action name="insertRowAction">
+ <property name="text">
+ <string>Insert Row</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+I, R</string>
+ </property>
+ </action>
+ <action name="removeRowAction">
+ <property name="text">
+ <string>Remove Row</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+R, R</string>
+ </property>
+ </action>
+ <action name="insertColumnAction">
+ <property name="text">
+ <string>Insert Column</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+I, C</string>
+ </property>
+ </action>
+ <action name="removeColumnAction">
+ <property name="text">
+ <string>Remove Column</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+R, C</string>
+ </property>
+ </action>
+ <action name="insertChildAction">
+ <property name="text">
+ <string>Insert Child</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.cpp 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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$
+**
+****************************************************************************/
+
+/*
+ treeitem.cpp
+
+ A container for items of data supplied by the simple tree model.
+*/
+
+#include <QStringList>
+
+#include "treeitem.h"
+
+//! [0]
+TreeItem::TreeItem(const QVector<QVariant> &data, TreeItem *parent)
+{
+ parentItem = parent;
+ itemData = data;
+}
+//! [0]
+
+//! [1]
+TreeItem::~TreeItem()
+{
+ qDeleteAll(childItems);
+}
+//! [1]
+
+//! [2]
+TreeItem *TreeItem::child(int number)
+{
+ return childItems.value(number);
+}
+//! [2]
+
+//! [3]
+int TreeItem::childCount() const
+{
+ return childItems.count();
+}
+//! [3]
+
+//! [4]
+int TreeItem::childNumber() const
+{
+ if (parentItem)
+ return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
+
+ return 0;
+}
+//! [4]
+
+//! [5]
+int TreeItem::columnCount() const
+{
+ return itemData.count();
+}
+//! [5]
+
+//! [6]
+QVariant TreeItem::data(int column) const
+{
+ return itemData.value(column);
+}
+//! [6]
+
+//! [7]
+bool TreeItem::insertChildren(int position, int count, int columns)
+{
+ if (position < 0 || position > childItems.size())
+ return false;
+
+ for (int row = 0; row < count; ++row) {
+ QVector<QVariant> data(columns);
+ TreeItem *item = new TreeItem(data, this);
+ childItems.insert(position, item);
+ }
+
+ return true;
+}
+//! [7]
+
+//! [8]
+bool TreeItem::insertColumns(int position, int columns)
+{
+ if (position < 0 || position > itemData.size())
+ return false;
+
+ for (int column = 0; column < columns; ++column)
+ itemData.insert(position, QVariant());
+
+ foreach (TreeItem *child, childItems)
+ child->insertColumns(position, columns);
+
+ return true;
+}
+//! [8]
+
+//! [9]
+TreeItem *TreeItem::parent()
+{
+ return parentItem;
+}
+//! [9]
+
+//! [10]
+bool TreeItem::removeChildren(int position, int count)
+{
+ if (position < 0 || position + count > childItems.size())
+ return false;
+
+ for (int row = 0; row < count; ++row)
+ delete childItems.takeAt(position);
+
+ return true;
+}
+//! [10]
+
+bool TreeItem::removeColumns(int position, int columns)
+{
+ if (position < 0 || position + columns > itemData.size())
+ return false;
+
+ for (int column = 0; column < columns; ++column)
+ itemData.remove(position);
+
+ foreach (TreeItem *child, childItems)
+ child->removeColumns(position, columns);
+
+ return true;
+}
+
+//! [11]
+bool TreeItem::setData(int column, const QVariant &value)
+{
+ if (column < 0 || column >= itemData.size())
+ return false;
+
+ itemData[column] = value;
+ return true;
+}
+//! [11]

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treeitem.h 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 TREEITEM_H
+#define TREEITEM_H
+
+#include <QList>
+#include <QVariant>
+#include <QVector>
+
+//! [0]
+class TreeItem
+{
+public:
+ TreeItem(const QVector<QVariant> &data, TreeItem *parent = 0);
+ ~TreeItem();
+
+ TreeItem *child(int number);
+ int childCount() const;
+ int columnCount() const;
+ QVariant data(int column) const;
+ bool insertChildren(int position, int count, int columns);
+ bool insertColumns(int position, int columns);
+ TreeItem *parent();
+ bool removeChildren(int position, int count);
+ bool removeColumns(int position, int columns);
+ int childNumber() const;
+ bool setData(int column, const QVariant &value);
+
+private:
+ QList<TreeItem*> childItems;
+ QVector<QVariant> itemData;
+ TreeItem *parentItem;
+};
+//! [0]
+
+#endif

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 <QtGui>
+
+#include "treeitem.h"
+#include "treemodel.h"
+
+//! [0]
+TreeModel::TreeModel(const QStringList &headers, const QString &data,
+ QObject *parent)
+ : QAbstractItemModel(parent)
+{
+ QVector<QVariant> rootData;
+ foreach (QString header, headers)
+ rootData << header;
+
+ rootItem = new TreeItem(rootData);
+ setupModelData(data.split(QString("\n")), rootItem);
+}
+//! [0]
+
+//! [1]
+TreeModel::~TreeModel()
+{
+ delete rootItem;
+}
+//! [1]
+
+//! [2]
+int TreeModel::columnCount(const QModelIndex & /* parent */) const
+{
+ return rootItem->columnCount();
+}
+//! [2]
+
+QVariant TreeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole && role != Qt::EditRole)
+ return QVariant();
+
+ TreeItem *item = getItem(index);
+
+ return item->data(index.column());
+}
+
+//! [3]
+Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+//! [3]
+
+//! [4]
+TreeItem *TreeModel::getItem(const QModelIndex &index) const
+{
+ if (index.isValid()) {
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+ if (item) return item;
+ }
+ return rootItem;
+}
+//! [4]
+
+QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ return rootItem->data(section);
+
+ return QVariant();
+}
+
+//! [5]
+QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (parent.isValid() && parent.column() != 0)
+ return QModelIndex();
+//! [5]
+
+//! [6]
+ TreeItem *parentItem = getItem(parent);
+
+ TreeItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+//! [6]
+
+bool TreeModel::insertColumns(int position, int columns, const QModelIndex &parent)
+{
+ bool success;
+
+ beginInsertColumns(parent, position, position + columns - 1);
+ success = rootItem->insertColumns(position, columns);
+ endInsertColumns();
+
+ return success;
+}
+
+bool TreeModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem = getItem(parent);
+ bool success;
+
+ beginInsertRows(parent, position, position + rows - 1);
+ success = parentItem->insertChildren(position, rows, rootItem->columnCount());
+ endInsertRows();
+
+ return success;
+}
+
+//! [7]
+QModelIndex TreeModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ TreeItem *childItem = getItem(index);
+ TreeItem *parentItem = childItem->parent();
+
+ if (parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->childNumber(), 0, parentItem);
+}
+//! [7]
+
+bool TreeModel::removeColumns(int position, int columns, const QModelIndex &parent)
+{
+ bool success;
+
+ beginRemoveColumns(parent, position, position + columns - 1);
+ success = rootItem->removeColumns(position, columns);
+ endRemoveColumns();
+
+ if (rootItem->columnCount() == 0)
+ removeRows(0, rowCount());
+
+ return success;
+}
+
+bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem = getItem(parent);
+ bool success = true;
+
+ beginRemoveRows(parent, position, position + rows - 1);
+ success = parentItem->removeChildren(position, rows);
+ endRemoveRows();
+
+ return success;
+}
+
+//! [8]
+int TreeModel::rowCount(const QModelIndex &parent) const
+{
+ TreeItem *parentItem = getItem(parent);
+
+ return parentItem->childCount();
+}
+//! [8]
+
+bool TreeModel::setData(const QModelIndex &index, const QVariant &value,
+ int role)
+{
+ if (role != Qt::EditRole)
+ return false;
+
+ TreeItem *item = getItem(index);
+ bool result = item->setData(index.column(), value);
+
+ if (result)
+ emit dataChanged(index, index);
+
+ return result;
+}
+
+bool TreeModel::setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role)
+{
+ if (role != Qt::EditRole || orientation != Qt::Horizontal)
+ return false;
+
+ bool result = rootItem->setData(section, value);
+
+ if (result)
+ emit headerDataChanged(orientation, section, section);
+
+ return result;
+}
+
+void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
+{
+ QList<TreeItem*> parents;
+ QList<int> indentations;
+ parents << parent;
+ indentations << 0;
+
+ int number = 0;
+
+ while (number < lines.count()) {
+ int position = 0;
+ while (position < lines[number].length()) {
+ if (lines[number].mid(position, 1) != " ")
+ break;
+ position++;
+ }
+
+ QString lineData = lines[number].mid(position).trimmed();
+
+ if (!lineData.isEmpty()) {
+ // Read the column data from the rest of the line.
+ QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
+ QVector<QVariant> columnData;
+ for (int column = 0; column < columnStrings.count(); ++column)
+ columnData << columnStrings[column];
+
+ if (position > indentations.last()) {
+ // The last child of the current parent is now the new parent
+ // unless the current parent has no children.
+
+ if (parents.last()->childCount() > 0) {
+ parents << parents.last()->child(parents.last()->childCount()-1);
+ indentations << position;
+ }
+ } else {
+ while (position < indentations.last() && parents.count() > 0) {
+ parents.pop_back();
+ indentations.pop_back();
+ }
+ }
+
+ // Append a new item to the current parent's list of children.
+ TreeItem *parent = parents.last();
+ parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
+ for (int column = 0; column < columnData.size(); ++column)
+ parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
+ }
+
+ number++;
+ }
+}
+
+
+//JOFA Iteration example: The container as String
+QString TreeModel::toString()const
+{
+ QString repr;
+ QModelIndex curIndex = QModelIndex();
+ for(int row = 0; row < rowCount(); row++)
+ {
+ repr += tr("(%1").arg(row);
+ //QModelIndex curIndex = QModelIndex(row, curIndex);
+ int colEnd = columnCount();
+
+ if(hasChildren(curIndex))
+ repr += tr(" %1").arg(1);
+
+ repr += ")";
+ }
+
+ return repr;
+}

Added: sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info_at_[hidden])
+**
+** 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 TREEMODEL_H
+#define TREEMODEL_H
+
+#include <QAbstractItemModel>
+#include <QModelIndex>
+#include <QVariant>
+
+class TreeItem;
+
+//! [0]
+class TreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ TreeModel(const QStringList &headers, const QString &data,
+ QObject *parent = 0);
+ ~TreeModel();
+
+//! [0] //! [1]
+
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+//! [1]
+
+//! [2]
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+ bool setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role = Qt::EditRole);
+
+ bool insertColumns(int position, int columns,
+ const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns,
+ const QModelIndex &parent = QModelIndex());
+ bool insertRows(int position, int rows,
+ const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows,
+ const QModelIndex &parent = QModelIndex());
+
+ //JOFA Iteration example: The container as String
+ QString toString()const;
+
+private:
+ void setupModelData(const QStringList &lines, TreeItem *parent);
+ TreeItem *getItem(const QModelIndex &index) const;
+
+ TreeItem *rootItem;
+};
+//! [2]
+
+#endif

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-01-05 13:18:03 EST (Thu, 05 Jan 2012)
@@ -217,6 +217,10 @@
     ext_tree->setModel(model);
     //JODO? ext_tree->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
 
+ //JOFA additions ----------------------------------------------------------
+ ext_tree->setItemsExpandable(true);
+ //JOFA additions ----------------------------------------------------------
+
     //REV connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged()));
     connect(ext_tree->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(on_rowSelectChanged()));
 

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/media1.db
==============================================================================
Binary files. No diff available.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk