Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76068 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2011-12-19 12:22:00


Author: jofaber
Date: 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
New Revision: 76068
URL: http://svn.boost.org/trac/boost/changeset/76068

Log:
More qt exploration on selections.
Added:
   sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.cpp (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.h (contents, props changed)
Binary files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/media1.db
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql | 12 +++++++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 28 ++++++++++++++++++++++++++--
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 4 ++++
   sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui | 7 ++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro | 12 ++++++++++--
   5 files changed, 57 insertions(+), 6 deletions(-)

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -32,14 +32,24 @@
 
 -- ----------------------------------------------------------------------------
 select Albums.Title, Albums.Genre, Tracks.Title, Tracks.Duration, Tracks.Artist
-from AlbumsByTracks, Albums, Tracks
+from AlbumsByTracks
 inner join Albums on AlbumsByTracks.Album = Albums.Id
 inner join Tracks on AlbumsByTracks.Track = Tracks.Id
 where AlbumsByTracks.Album = Albums.Id and AlbumsByTracks.Track = Tracks.Id
 
 
+-- ----------------------------------------------------------------------------
+-- Grouping
+select AlbumsByTracks.Album, Albums.Title, Albums.Genre, Tracks.Title, Tracks.Artist,
+ sum(Tracks.Duration) as SumDur
+from AlbumsByTracks
+inner join Albums on AlbumsByTracks.Album = Albums.Id
+inner join Tracks on AlbumsByTracks.Track = Tracks.Id
+where AlbumsByTracks.Album = Albums.Id and AlbumsByTracks.Track = Tracks.Id
+group by AlbumsByTracks.Album
 
 -- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
 -- select .. from Refering inner join Target on Refering.Pointer = Target.Id
 -- ----------------------------------------------------------------------------
 select Albums.Title, Albums.Genre, Tracks.Title, Tracks.Duration, Tracks.Artist

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 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -39,6 +39,7 @@
 **
 ****************************************************************************/
 
+#include "exttableview.h"
 #include "browser.h"
 #include "qsqlconnectiondialog.h"
 
@@ -70,8 +71,18 @@
 {
     QSqlQueryModel *model = new QSqlQueryModel(table);
     model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
+
     table->setModel(model);
 
+ //JOFA additions ----------------------------------------------------------
+ table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+
+ table->setSortingEnabled(true);
+ table->setAlternatingRowColors(true);
+ table->resizeColumnsToContents();
+ //JOFA additions ----------------------------------------------------------
+
+
     if (model->lastError().type() != QSqlError::NoError)
         emit statusMessage(model->lastError().text());
     else if (model->query().isSelect())
@@ -190,8 +201,9 @@
     table->resizeColumnsToContents();
     //JOFA additions ----------------------------------------------------------
 
- connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
- this, SLOT(currentChanged()));
+ //connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged()));
+ connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged2()));
+
     updateActions();
 }
 
@@ -269,6 +281,7 @@
 
 void Browser::updateActions()
 {
+ emit statusMessage(tr("udateActions()"));
     bool enableIns = qobject_cast<QSqlTableModel *>(table->model());
     bool enableDel = enableIns && table->currentIndex().isValid();
 
@@ -276,9 +289,20 @@
     deleteRowAction->setEnabled(enableDel);
 }
 
+void Browser::updateActions2()
+{
+ QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
+ int selCount = currentSelection.count();
+ int firstRow = selCount > 0 ? currentSelection.at(1).row() : 0;
+
+ emit statusMessage(QString("Row %1 of %2 selected").arg(firstRow).arg(selCount));
+}
+
 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"));
 }
+
+

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -43,6 +43,7 @@
 #define BROWSER_H
 
 #include <QWidget>
+#include "exttableview.h"
 #include "ui_browserwidget.h"
 
 class ConnectionWidget;
@@ -64,6 +65,7 @@
     void insertRow();
     void deleteRow();
     void updateActions();
+ void updateActions2();
 
 public slots:
     void exec();
@@ -72,6 +74,7 @@
     void addConnection();
     void openFile();
     void currentChanged() { updateActions(); }
+ void currentChanged2() { updateActions2(); }
     void about();
 
     void on_insertRowAction_triggered()
@@ -93,6 +96,7 @@
         sqlEdit->setFocus();
     }
 
+
 signals:
     void statusMessage(const QString &message);
 };

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -86,7 +86,7 @@
        </sizepolicy>
       </property>
      </widget>
- <widget class="QTableView" name="table">
+ <widget class="ExtTableView" name="table">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
         <horstretch>2</horstretch>
@@ -714,6 +714,11 @@
    <extends>QTreeView</extends>
    <header>connectionwidget.h</header>
   </customwidget>
+ <customwidget>
+ <class>ExtTableView</class>
+ <extends>QTableView</extends>
+ <header>exttableview.h</header>
+ </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>sqlEdit</tabstop>

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.cpp 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 "exttableview.h"
+
+ExtTableView::ExtTableView(QWidget* parent) : QTableView(parent){}
+
+ExtTableView::~ExtTableView(){}
+
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/exttableview.h 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 EXTTABLEVIEW_H
+#define EXTTABLEVIEW_H
+
+#include <QTableView>
+
+QT_FORWARD_DECLARE_CLASS(QTableView)
+QT_FORWARD_DECLARE_CLASS(ExtTableView)
+
+class ExtTableView: public QTableView
+{
+ Q_OBJECT
+public:
+ ExtTableView(QWidget* parent = 0);
+ ~ExtTableView();
+
+ /*CL
+signals:
+ void cellClicked(int row, int column);
+
+public slots:
+ void hideNextRow();
+ */
+
+};
+
+#endif

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

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser.pro 2011-12-19 12:21:59 EST (Mon, 19 Dec 2011)
@@ -3,8 +3,10 @@
 
 QT += sql
 
-HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h
-SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp
+HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
+ exttableview.h
+SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp \
+ exttableview.cpp
 
 FORMS = browserwidget.ui qsqlconnectiondialog.ui
 build_all:!build_pass {
@@ -23,3 +25,9 @@
 wince*: {
     DEPLOYMENT_PLUGIN += qsqlite
 }
+
+
+
+
+
+


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