Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75989 - in sandbox/icl/libs/xplore: . br1 br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2011-12-16 09:35:09


Author: jofaber
Date: 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
New Revision: 75989
URL: http://svn.boost.org/trac/boost/changeset/75989

Log:
A toy application to explore qt and sqlite.
Added:
   sandbox/icl/libs/xplore/ (props changed)
   sandbox/icl/libs/xplore/br1/ (props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/ (props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/main.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/media1.db (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.ui (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/xperiment.db (contents, props changed)

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,24 @@
+drop table Albums;
+drop table Tracks;
+drop table AlbumsByTracks;
+
+create table Albums (id integer primary key, Title varchar, Artist varchar, Genre varchar, Rating number);
+
+insert into Albums values (1, 'Kind of Blue', 'Miles Davis', 'Jazz', '9.3');
+insert into Albums values (2, 'Nefertiti', 'Miles Davis', 'Jazz', '9.1');
+
+create table Tracks (id integer primary key, Album integer, Pos integer, Title varchar, Artist varchar, Genre varchar, Rating number, Duration varchar, BPM number);
+
+insert into Tracks values (1, 1, 1, 'So What', 'Miles Davis', 'Jazz', '9.6', '09:05', '80');
+insert into Tracks values (2, 1, 2, 'Freddie Freeloader', 'Miles Davis', 'Jazz', '9.3', '09:35', '');
+
+create table AlbumsByTracks (id integer primary key, Album integer, Track integer, Pos integer);
+
+-- ----------------------------------------------------------------------------
+-- select .. from Refering inner join Target on Refering.Pointer = Target.Id
+-- ----------------------------------------------------------------------------
+select Albums.Title, Albums.Genre, Tracks.Title, Tracks.Duration, Tracks.Artist
+from Tracks
+inner join Albums on Tracks.Album = Albums.Id
+order by Albums.Title, Tracks.Pos
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,284 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "browser.h"
+#include "qsqlconnectiondialog.h"
+
+#include <QtGui>
+#include <QtSql>
+
+Browser::Browser(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ table->addAction(insertRowAction);
+ table->addAction(deleteRowAction);
+
+ if (QSqlDatabase::drivers().isEmpty())
+ QMessageBox::information(this, tr("No database drivers found"),
+ tr("This demo requires at least one Qt database driver. "
+ "Please check the documentation how to build the "
+ "Qt SQL plugins."));
+
+ emit statusMessage(tr("Ready."));
+}
+
+Browser::~Browser()
+{
+}
+
+void Browser::exec()
+{
+ QSqlQueryModel *model = new QSqlQueryModel(table);
+ model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
+ table->setModel(model);
+
+ if (model->lastError().type() != QSqlError::NoError)
+ emit statusMessage(model->lastError().text());
+ else if (model->query().isSelect())
+ emit statusMessage(tr("Query OK."));
+ else
+ emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
+ model->query().numRowsAffected()));
+
+ updateActions();
+}
+
+QSqlError Browser::addConnection(const QString &driver, const QString &dbName, const QString &host,
+ const QString &user, const QString &passwd, int port)
+{
+ static int cCount = 0;
+
+ QSqlError err;
+ QSqlDatabase db = QSqlDatabase::addDatabase(driver, QString("Browser%1").arg(++cCount));
+ db.setDatabaseName(dbName);
+ db.setHostName(host);
+ db.setPort(port);
+ if (!db.open(user, passwd)) {
+ err = db.lastError();
+ db = QSqlDatabase();
+ QSqlDatabase::removeDatabase(QString("Browser%1").arg(cCount));
+ }
+ connectionWidget->refresh();
+
+ return err;
+}
+
+void Browser::addConnection()
+{
+ QSqlConnectionDialog dialog(this);
+ if (dialog.exec() != QDialog::Accepted)
+ return;
+
+ if (dialog.useInMemoryDatabase()) {
+ QSqlDatabase::database("in_mem_db", false).close();
+ QSqlDatabase::removeDatabase("in_mem_db");
+ QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "in_mem_db");
+ db.setDatabaseName(":memory:");
+ if (!db.open())
+ QMessageBox::warning(this, tr("Unable to open database")
+ , tr("An error occurred while "
+ "opening the connection: ") + db.lastError().text());
+ QSqlQuery q("", db);
+ q.exec("drop table Movies");
+ q.exec("drop table Names");
+ q.exec("create table Movies (id integer primary key, Title varchar, Director varchar, Rating number)");
+ q.exec("insert into Movies values (0, 'Metropolis', 'Fritz Lang', '8.4')");
+ q.exec("insert into Movies values (1, 'Nosferatu, eine Symphonie des Grauens', 'F.W. Murnau', '8.1')");
+ q.exec("insert into Movies values (2, 'Bis ans Ende der Welt', 'Wim Wenders', '6.5')");
+ q.exec("insert into Movies values (3, 'Hardware', 'Richard Stanley', '5.2')");
+ q.exec("insert into Movies values (4, 'Mitchell', 'Andrew V. McLaglen', '2.1')");
+ q.exec("create table Names (id integer primary key, Firstname varchar, Lastname varchar, City varchar)");
+ q.exec("insert into Names values (0, 'Sala', 'Palmer', 'Morristown')");
+ q.exec("insert into Names values (1, 'Christopher', 'Walker', 'Morristown')");
+ q.exec("insert into Names values (2, 'Donald', 'Duck', 'Andeby')");
+ q.exec("insert into Names values (3, 'Buck', 'Rogers', 'Paris')");
+ q.exec("insert into Names values (4, 'Sherlock', 'Holmes', 'London')");
+ connectionWidget->refresh();
+ } else {
+ int dlgPort = dialog.port();
+ QSqlError err = addConnection(dialog.driverName(), dialog.databaseName(), dialog.hostName(),
+ dialog.userName(), dialog.password(), dialog.port());
+ if (err.type() != QSqlError::NoError)
+ QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
+ "opening the connection: ") + err.text());
+ }
+}
+
+void Browser::openFile()
+{
+ QString fileName
+ = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.*)"));
+
+ QFileInfo fileInfo(fileName);
+ QString file_ext = fileInfo.fileName();
+
+ if(file_ext.endsWith(".db"))
+ {
+ QSqlError err = addConnection(QString("SQLITE"), file_ext, QString(""),
+ QString(""), QString(""), -1);
+
+ if (err.type() != QSqlError::NoError)
+ QMessageBox::warning(this, tr("Unable to open database")
+ , tr("An error occurred while "
+ "opening the connection: ")
+ + err.text());
+ else
+ emit statusMessage("open db-file");
+ }
+ else
+ {
+ QMessageBox::warning(this, tr("Unable to open database")
+ , QString("Expected extension .db for a database-file\n"
+ "The selected file was: '%1'").arg(file_ext));
+ }
+}
+
+void Browser::showTable(const QString &t)
+{
+ QSqlTableModel *model = new QSqlTableModel(table, connectionWidget->currentDatabase());
+ model->setEditStrategy(QSqlTableModel::OnRowChange);
+ model->setTable(connectionWidget->currentDatabase().driver()->escapeIdentifier(t, QSqlDriver::TableName));
+ model->select();
+ if (model->lastError().type() != QSqlError::NoError)
+ emit statusMessage(model->lastError().text());
+ table->setModel(model);
+ table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+
+ //JOFA additions ----------------------------------------------------------
+ table->setSortingEnabled(true);
+ table->setAlternatingRowColors(true);
+ table->resizeColumnsToContents();
+ //JOFA additions ----------------------------------------------------------
+
+ connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ this, SLOT(currentChanged()));
+ updateActions();
+}
+
+void Browser::showMetaData(const QString &t)
+{
+ QSqlRecord rec = connectionWidget->currentDatabase().record(t);
+ QStandardItemModel *model = new QStandardItemModel(table);
+
+ model->insertRows(0, rec.count());
+ model->insertColumns(0, 7);
+
+ model->setHeaderData(0, Qt::Horizontal, "Fieldname");
+ model->setHeaderData(1, Qt::Horizontal, "Type");
+ model->setHeaderData(2, Qt::Horizontal, "Length");
+ model->setHeaderData(3, Qt::Horizontal, "Precision");
+ model->setHeaderData(4, Qt::Horizontal, "Required");
+ model->setHeaderData(5, Qt::Horizontal, "AutoValue");
+ model->setHeaderData(6, Qt::Horizontal, "DefaultValue");
+
+
+ for (int i = 0; i < rec.count(); ++i) {
+ QSqlField fld = rec.field(i);
+ model->setData(model->index(i, 0), fld.name());
+ model->setData(model->index(i, 1), fld.typeID() == -1
+ ? QString(QVariant::typeToName(fld.type()))
+ : QString("%1 (%2)").arg(QVariant::typeToName(fld.type())).arg(fld.typeID()));
+ model->setData(model->index(i, 2), fld.length());
+ model->setData(model->index(i, 3), fld.precision());
+ model->setData(model->index(i, 4), fld.requiredStatus() == -1 ? QVariant("?")
+ : QVariant(bool(fld.requiredStatus())));
+ model->setData(model->index(i, 5), fld.isAutoValue());
+ model->setData(model->index(i, 6), fld.defaultValue());
+ }
+
+ table->setModel(model);
+ table->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+ updateActions();
+}
+
+void Browser::insertRow()
+{
+ QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
+ if (!model)
+ return;
+
+ QModelIndex insertIndex = table->currentIndex();
+ int row = insertIndex.row() == -1 ? 0 : insertIndex.row();
+ model->insertRow(row);
+ insertIndex = model->index(row, 0);
+ table->setCurrentIndex(insertIndex);
+ table->edit(insertIndex);
+}
+
+void Browser::deleteRow()
+{
+ QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
+ if (!model)
+ return;
+
+ model->setEditStrategy(QSqlTableModel::OnManualSubmit);
+
+ QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
+ for (int i = 0; i < currentSelection.count(); ++i) {
+ if (currentSelection.at(i).column() != 0)
+ continue;
+ model->removeRow(currentSelection.at(i).row());
+ }
+
+ model->submitAll();
+ model->setEditStrategy(QSqlTableModel::OnRowChange);
+
+ updateActions();
+}
+
+void Browser::updateActions()
+{
+ bool enableIns = qobject_cast<QSqlTableModel *>(table->model());
+ bool enableDel = enableIns && table->currentIndex().isValid();
+
+ insertRowAction->setEnabled(enableIns);
+ deleteRowAction->setEnabled(enableDel);
+}
+
+void Browser::about()
+{
+ QMessageBox::about(this, tr("About"), tr("The SQL Browser demonstration "
+ "shows how a data browser can be used to visualize the results of SQL"
+ "statements on a live database"));
+}

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BROWSER_H
+#define BROWSER_H
+
+#include <QWidget>
+#include "ui_browserwidget.h"
+
+class ConnectionWidget;
+QT_FORWARD_DECLARE_CLASS(QTableView)
+QT_FORWARD_DECLARE_CLASS(QPushButton)
+QT_FORWARD_DECLARE_CLASS(QTextEdit)
+QT_FORWARD_DECLARE_CLASS(QSqlError)
+
+class Browser: public QWidget, private Ui::Browser
+{
+ Q_OBJECT
+public:
+ Browser(QWidget *parent = 0);
+ virtual ~Browser();
+
+ QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
+ const QString &user, const QString &passwd, int port = -1);
+
+ void insertRow();
+ void deleteRow();
+ void updateActions();
+
+public slots:
+ void exec();
+ void showTable(const QString &table);
+ void showMetaData(const QString &table);
+ void addConnection();
+ void openFile();
+ void currentChanged() { updateActions(); }
+ void about();
+
+ void on_insertRowAction_triggered()
+ { insertRow(); }
+ void on_deleteRowAction_triggered()
+ { deleteRow(); }
+ void on_connectionWidget_tableActivated(const QString &table)
+ { showTable(table); }
+ void on_connectionWidget_metaDataRequested(const QString &table)
+ { showMetaData(table); }
+ void on_submitButton_clicked()
+ {
+ exec();
+ sqlEdit->setFocus();
+ }
+ void on_clearButton_clicked()
+ {
+ sqlEdit->clear();
+ sqlEdit->setFocus();
+ }
+
+signals:
+ void statusMessage(const QString &message);
+};
+
+#endif

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,727 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Browser</class>
+ <widget class="QWidget" name="Browser">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>765</width>
+ <height>515</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Qt SQL Browser</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">#Browser {
+border: none;
+background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+stop: 0 #a6a6a6, stop: 0.08 #7f7f7f,
+stop: 0.39999 #717171, stop: 0.4 #626262,
+stop: 0.9 #4c4c4c, stop: 1 #333333);
+}
+
+
+#groupBox {
+border: none;
+background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+stop: 0 #a6a6a6, stop: 0.08 #7f7f7f,
+stop: 0.39999 #717171, stop: 0.4 #626262,
+stop: 0.9 #4c4c4c, stop: 1 #333333);
+}
+
+
+#groupBox QPushButton {
+color: #333;
+border: 2px solid #555;
+border-radius: 11px;
+padding: 5px;
+background: qradialgradient(cx: 0.3, cy: -0.4,
+fx: 0.3, fy: -0.4,
+radius: 1.35, stop: 0 #fff, stop: 1 #888);
+min-width: 80px;
+}
+
+#groupBox QPushButton:hover {
+background: qradialgradient(cx: 0.3, cy: -0.4,
+fx: 0.3, fy: -0.4,
+radius: 1.35, stop: 0 #fff, stop: 1 #bbb);
+}
+
+QTableView
+{
+ text-color: #ffffff;
+ alternate-background-color: #333;
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #a6a6a6, stop: 0.08 #7f7f7f,
+ stop: 0.39999 #717171, stop: 0.4 #626262,
+ stop: 0.9 #4c4c4c, stop: 1 #333333);
+}
+</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>8</number>
+ </property>
+ <item>
+ <widget class="QSplitter" name="splitter_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="ConnectionWidget" name="connectionWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QTableView" name="table">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="Button">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="AlternateBase">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="Button">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="AlternateBase">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="Button">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>120</red>
+ <green>120</green>
+ <blue>120</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="LinearGradientPattern">
+ <gradient startx="0.000000000000000" starty="0.000000000000000" endx="0.000000000000000" endy="1.000000000000000" type="LinearGradient" spread="PadSpread" coordinatemode="ObjectBoundingMode">
+ <gradientstop position="0.000000000000000">
+ <color alpha="255">
+ <red>166</red>
+ <green>166</green>
+ <blue>166</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.080000000000000">
+ <color alpha="255">
+ <red>127</red>
+ <green>127</green>
+ <blue>127</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.399990000000000">
+ <color alpha="255">
+ <red>113</red>
+ <green>113</green>
+ <blue>113</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.400000000000000">
+ <color alpha="255">
+ <red>98</red>
+ <green>98</green>
+ <blue>98</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="0.900000000000000">
+ <color alpha="255">
+ <red>76</red>
+ <green>76</green>
+ <blue>76</blue>
+ </color>
+ </gradientstop>
+ <gradientstop position="1.000000000000000">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </gradientstop>
+ </gradient>
+ </brush>
+ </colorrole>
+ <colorrole role="AlternateBase">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>51</red>
+ <green>51</green>
+ <blue>51</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>180</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>SQL Query</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <item>
+ <widget class="QTextEdit" name="sqlEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>0</width>
+ <height>120</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>1</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearButton">
+ <property name="text">
+ <string>&amp;Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="submitButton">
+ <property name="text">
+ <string>&amp;Submit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ <action name="insertRowAction">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Insert Row</string>
+ </property>
+ <property name="statusTip">
+ <string>Inserts a new Row</string>
+ </property>
+ </action>
+ <action name="deleteRowAction">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Delete Row</string>
+ </property>
+ <property name="statusTip">
+ <string>Deletes the current Row</string>
+ </property>
+ </action>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>ConnectionWidget</class>
+ <extends>QTreeView</extends>
+ <header>connectionwidget.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>sqlEdit</tabstop>
+ <tabstop>clearButton</tabstop>
+ <tabstop>submitButton</tabstop>
+ <tabstop>connectionWidget</tabstop>
+ <tabstop>table</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "connectionwidget.h"
+
+#include <QtGui>
+#include <QtSql>
+
+ConnectionWidget::ConnectionWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ tree = new QTreeWidget(this);
+ tree->setObjectName(QLatin1String("tree"));
+ tree->setHeaderLabels(QStringList(tr("database")));
+ tree->header()->setResizeMode(QHeaderView::Stretch);
+ QAction *refreshAction = new QAction(tr("Refresh"), tree);
+ metaDataAction = new QAction(tr("Show Schema"), tree);
+ connect(refreshAction, SIGNAL(triggered()), SLOT(refresh()));
+ connect(metaDataAction, SIGNAL(triggered()), SLOT(showMetaData()));
+ tree->addAction(refreshAction);
+ tree->addAction(metaDataAction);
+ tree->setContextMenuPolicy(Qt::ActionsContextMenu);
+
+ layout->addWidget(tree);
+
+ QMetaObject::connectSlotsByName(this);
+}
+
+ConnectionWidget::~ConnectionWidget()
+{
+}
+
+static QString qDBCaption(const QSqlDatabase &db)
+{
+ QString nm = db.driverName();
+ nm.append(QLatin1Char(':'));
+ if (!db.userName().isEmpty())
+ nm.append(db.userName()).append(QLatin1Char('@'));
+ nm.append(db.databaseName());
+ return nm;
+}
+
+void ConnectionWidget::refresh()
+{
+ tree->clear();
+ QStringList connectionNames = QSqlDatabase::connectionNames();
+
+ bool gotActiveDb = false;
+ for (int i = 0; i < connectionNames.count(); ++i) {
+ QTreeWidgetItem *root = new QTreeWidgetItem(tree);
+ QSqlDatabase db = QSqlDatabase::database(connectionNames.at(i), false);
+ root->setText(0, qDBCaption(db));
+ if (connectionNames.at(i) == activeDb) {
+ gotActiveDb = true;
+ setActive(root);
+ }
+ if (db.isOpen()) {
+ QStringList tables = db.tables();
+ for (int t = 0; t < tables.count(); ++t) {
+ QTreeWidgetItem *table = new QTreeWidgetItem(root);
+ table->setText(0, tables.at(t));
+ }
+ }
+ }
+ if (!gotActiveDb) {
+ activeDb = connectionNames.value(0);
+ setActive(tree->topLevelItem(0));
+ }
+
+ tree->doItemsLayout(); // HACK
+}
+
+QSqlDatabase ConnectionWidget::currentDatabase() const
+{
+ return QSqlDatabase::database(activeDb);
+}
+
+static void qSetBold(QTreeWidgetItem *item, bool bold)
+{
+ QFont font = item->font(0);
+ font.setBold(bold);
+ item->setFont(0, font);
+}
+
+void ConnectionWidget::setActive(QTreeWidgetItem *item)
+{
+ for (int i = 0; i < tree->topLevelItemCount(); ++i) {
+ if (tree->topLevelItem(i)->font(0).bold())
+ qSetBold(tree->topLevelItem(i), false);
+ }
+
+ if (!item)
+ return;
+
+ qSetBold(item, true);
+ activeDb = QSqlDatabase::connectionNames().value(tree->indexOfTopLevelItem(item));
+}
+
+void ConnectionWidget::on_tree_itemActivated(QTreeWidgetItem *item, int /* column */)
+{
+
+ if (!item)
+ return;
+
+ if (!item->parent()) {
+ setActive(item);
+ } else {
+ setActive(item->parent());
+ emit tableActivated(item->text(0));
+ }
+}
+
+void ConnectionWidget::showMetaData()
+{
+ QTreeWidgetItem *cItem = tree->currentItem();
+ if (!cItem || !cItem->parent())
+ return;
+ setActive(cItem->parent());
+ emit metaDataRequested(cItem->text(0));
+}
+
+void ConnectionWidget::on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
+{
+ metaDataAction->setEnabled(current && current->parent());
+}
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.h 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONNECTIONWIDGET_H
+#define CONNECTIONWIDGET_H
+
+#include <QWidget>
+
+QT_FORWARD_DECLARE_CLASS(QTreeWidget)
+QT_FORWARD_DECLARE_CLASS(QTreeWidgetItem)
+QT_FORWARD_DECLARE_CLASS(QSqlDatabase)
+QT_FORWARD_DECLARE_CLASS(QMenu)
+
+class ConnectionWidget: public QWidget
+{
+ Q_OBJECT
+public:
+ ConnectionWidget(QWidget *parent = 0);
+ virtual ~ConnectionWidget();
+
+ QSqlDatabase currentDatabase() const;
+
+signals:
+ void tableActivated(const QString &table);
+ void metaDataRequested(const QString &tableName);
+
+public slots:
+ void refresh();
+ void showMetaData();
+ void on_tree_itemActivated(QTreeWidgetItem *item, int column);
+ void on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
+
+private:
+ void setActive(QTreeWidgetItem *);
+
+ QTreeWidget *tree;
+ QAction *metaDataAction;
+ QString activeDb;
+};
+
+#endif

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/main.cpp 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "browser.h"
+
+#include <QtCore>
+#include <QtGui>
+#include <QtSql>
+
+void addConnectionsFromCommandline(const QStringList &args, Browser *browser)
+{
+ for (int i = 1; i < args.count(); ++i) {
+ QUrl url(args.at(i), QUrl::TolerantMode);
+ if (!url.isValid()) {
+ qWarning("Invalid URL: %s", qPrintable(args.at(i)));
+ continue;
+ }
+ QSqlError err = browser->addConnection(url.scheme(), url.path().mid(1), url.host(),
+ url.userName(), url.password(), url.port(-1));
+ if (err.type() != QSqlError::NoError)
+ qDebug() << "Unable to open connection:" << err;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QMainWindow mainWin;
+ mainWin.setWindowTitle(QObject::tr("Qt SQL Browser"));
+
+ Browser browser(&mainWin);
+ mainWin.setCentralWidget(&browser);
+
+ QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File"));
+ fileMenu->addAction(QObject::tr("Add &Connection..."), &browser, SLOT(addConnection()));
+ fileMenu->addAction(QObject::tr("Open"), &browser, SLOT(openFile()) );
+ fileMenu->addSeparator();
+ fileMenu->addAction(QObject::tr("&Quit"), &app, SLOT(quit()));
+
+ QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help"));
+ helpMenu->addAction(QObject::tr("About"), &browser, SLOT(about()));
+ helpMenu->addAction(QObject::tr("About Qt"), qApp, SLOT(aboutQt()));
+
+ QObject::connect(&browser, SIGNAL(statusMessage(QString)),
+ mainWin.statusBar(), SLOT(showMessage(QString)));
+
+ addConnectionsFromCommandline(app.arguments(), &browser);
+ mainWin.show();
+ if (QSqlDatabase::connectionNames().isEmpty())
+ QMetaObject::invokeMethod(&browser, "addConnection", Qt::QueuedConnection);
+
+ return app.exec();
+}

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

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.cpp 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsqlconnectiondialog.h"
+#include "ui_qsqlconnectiondialog.h"
+
+#include <QSqlDatabase>
+
+QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent)
+ : QDialog(parent), m_defaultDbName("xperiment.db")
+{
+ ui.setupUi(this);
+
+ QStringList drivers = QSqlDatabase::drivers();
+
+ // remove compat names
+ drivers.removeAll("QMYSQL3");
+ drivers.removeAll("QOCI8");
+ drivers.removeAll("QODBC3");
+ drivers.removeAll("QPSQL7");
+ drivers.removeAll("QTDS7");
+
+ if (!drivers.contains("QSQLITE"))
+ ui.dbCheckBox->setEnabled(false);
+
+ ui.comboDriver->addItems(drivers);
+}
+
+QSqlConnectionDialog::~QSqlConnectionDialog()
+{
+}
+
+QString QSqlConnectionDialog::driverName() const
+{
+ return ui.comboDriver->currentText();
+}
+
+QString QSqlConnectionDialog::databaseName() const
+{
+ return ui.editDatabase->text();
+}
+
+QString QSqlConnectionDialog::userName() const
+{
+ return ui.editUsername->text();
+}
+
+QString QSqlConnectionDialog::password() const
+{
+ return ui.editPassword->text();
+}
+
+QString QSqlConnectionDialog::hostName() const
+{
+ return ui.editHostname->text();
+}
+
+int QSqlConnectionDialog::port() const
+{
+ return ui.portSpinBox->value();
+}
+
+bool QSqlConnectionDialog::useInMemoryDatabase() const
+{
+ return ui.dbCheckBox->isChecked();
+}
+
+void QSqlConnectionDialog::on_okButton_clicked()
+{
+ if (ui.comboDriver->currentText().isEmpty()) {
+ QMessageBox::information(this, tr("No database driver selected"),
+ tr("Please select a database driver"));
+ ui.comboDriver->setFocus();
+ } else {
+ accept();
+ }
+}

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.h 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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 demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSQLCONNECTIONDIALOG_H
+#define QSQLCONNECTIONDIALOG_H
+
+#include <QDialog>
+#include <QMessageBox>
+
+#include "ui_qsqlconnectiondialog.h"
+
+class QSqlConnectionDialog: public QDialog
+{
+ Q_OBJECT
+public:
+ QSqlConnectionDialog(QWidget *parent = 0);
+ ~QSqlConnectionDialog();
+
+ QString driverName() const;
+ QString databaseName() const;
+ QString userName() const;
+ QString password() const;
+ QString hostName() const;
+ int port() const;
+ bool useInMemoryDatabase() const;
+
+private slots:
+ void on_okButton_clicked();
+ void on_cancelButton_clicked() { reject(); }
+ void on_dbCheckBox_clicked() { ui.connGroupBox->setEnabled(!ui.dbCheckBox->isChecked()); }
+
+private:
+ Ui::QSqlConnectionDialogUi ui;
+ QString m_defaultDbName;
+};
+
+#endif

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.ui
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/qsqlconnectiondialog.ui 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QSqlConnectionDialogUi</class>
+ <widget class="QDialog" name="QSqlConnectionDialogUi">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>315</width>
+ <height>302</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Connect...</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>8</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="connGroupBox">
+ <property name="title">
+ <string>Connection settings</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>8</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboDriver"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel4">
+ <property name="text">
+ <string>&amp;Username:</string>
+ </property>
+ <property name="buddy">
+ <cstring>editUsername</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>D&amp;river</string>
+ </property>
+ <property name="buddy">
+ <cstring>comboDriver</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="editDatabase">
+ <property name="text">
+ <string>xperiment.db</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QSpinBox" name="portSpinBox">
+ <property name="specialValueText">
+ <string>Default</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>Database Name:</string>
+ </property>
+ <property name="buddy">
+ <cstring>editDatabase</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="editPassword">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="editUsername"/>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="editHostname"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel5">
+ <property name="text">
+ <string>&amp;Hostname:</string>
+ </property>
+ <property name="buddy">
+ <cstring>editHostname</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="textLabel5_2">
+ <property name="text">
+ <string>P&amp;ort:</string>
+ </property>
+ <property name="buddy">
+ <cstring>portSpinBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel4_2">
+ <property name="text">
+ <string>&amp;Password:</string>
+ </property>
+ <property name="buddy">
+ <cstring>editPassword</cstring>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="dbCheckBox">
+ <property name="text">
+ <string>Us&amp;e predefined in-memory database</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>comboDriver</tabstop>
+ <tabstop>editDatabase</tabstop>
+ <tabstop>editUsername</tabstop>
+ <tabstop>editPassword</tabstop>
+ <tabstop>editHostname</tabstop>
+ <tabstop>portSpinBox</tabstop>
+ <tabstop>dbCheckBox</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro 2011-12-16 09:35:07 EST (Fri, 16 Dec 2011)
@@ -0,0 +1,25 @@
+TEMPLATE = app
+TARGET = sqlbrowser
+
+QT += sql
+
+HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h
+SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp
+
+FORMS = browserwidget.ui qsqlconnectiondialog.ui
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+
+# install
+target.path = $$[QT_INSTALL_DEMOS]/sqlbrowser
+sources.files = $$SOURCES $$HEADERS $$FORMS *.pro
+sources.path = $$[QT_INSTALL_DEMOS]/sqlbrowser
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+
+wince*: {
+ DEPLOYMENT_PLUGIN += qsqlite
+}

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/xperiment.db
==============================================================================
Binary file. 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