Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76091 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2011-12-21 10:15:16


Author: jofaber
Date: 2011-12-21 10:15:14 EST (Wed, 21 Dec 2011)
New Revision: 76091
URL: http://svn.boost.org/trac/boost/changeset/76091

Log:
Xperiments on selectionModel and using Sql-Views
Binary files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/media1.db
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/MakeMedia1.sql | 8 +++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 24 +++++++++++++++++++++---
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 3 +++
   sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp | 5 +++++
   4 files changed, 36 insertions(+), 4 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-21 10:15:14 EST (Wed, 21 Dec 2011)
@@ -35,7 +35,13 @@
 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
+
+-- ----------------------------------------------------------------------------
+create view TracksInAlbums as
+ select Albums.Title, Albums.Genre, Tracks.Title, Tracks.Duration, Tracks.Artist
+ from AlbumsByTracks
+ inner join Albums on AlbumsByTracks.Album = Albums.Id
+ inner join Tracks on AlbumsByTracks.Track = Tracks.Id
 
 
 -- ----------------------------------------------------------------------------

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-21 10:15:14 EST (Wed, 21 Dec 2011)
@@ -305,6 +305,18 @@
     emit statusMessage(clickedCellInfo);
 }
 
+
+void Browser::deselectFirstCell(int selectedRow)
+{
+ QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
+ QModelIndex firstCell;
+ const int firstCol = 0;
+ firstCell = model->index(selectedRow, firstCol, QModelIndex());
+ QItemSelection toggleSelection;
+ toggleSelection.select(firstCell, firstCell);
+ table->selectionModel()->select(toggleSelection, QItemSelectionModel::Toggle);
+}
+
 void Browser::on_rowSelectChanged()
 {
     QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
@@ -313,13 +325,19 @@
     int firstColumn = selCount > 0 ? currentSelection.at(1).column() : -1;
 
     // Alway the last selection is found, not the current one.
- QString selectedRowInfo = QString("Row %1 of %2 selected").arg(firstRow).arg(selCount);
+ QString selectedRowInfo = QString("Row %1 Col %2 of %3 selected").arg(firstRow).arg(firstColumn).arg(selCount);
     emit statusMessage(selectedRowInfo);
 
     int nextRow = firstRow + 1;
- if (firstRow > -1 && !table->isRowHidden(nextRow))
+ if (firstRow > -1 && firstColumn == 1 && !table->isRowHidden(nextRow))
+ {
+ deselectFirstCell(firstRow);
         table->hideRow(nextRow);
- else if(firstRow > -1 && table->isRowHidden(nextRow))
+ }
+ else if(firstRow > -1 && firstColumn == 1 && table->isRowHidden(nextRow))
+ {
+ deselectFirstCell(firstRow);
         table->showRow(nextRow);
+ }
 }
 

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-21 10:15:14 EST (Wed, 21 Dec 2011)
@@ -101,6 +101,9 @@
 
 signals:
     void statusMessage(const QString &message);
+
+private:
+ void deselectFirstCell(int selectedRow);
 };
 
 #endif

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/connectionwidget.cpp 2011-12-21 10:15:14 EST (Wed, 21 Dec 2011)
@@ -99,6 +99,11 @@
                 QTreeWidgetItem *table = new QTreeWidgetItem(root);
                 table->setText(0, tables.at(t));
             }
+ QStringList dbViews = db.tables(QSql::Views);
+ for (int v = 0; v < dbViews.count(); ++v) {
+ QTreeWidgetItem *dbView = new QTreeWidgetItem(root);
+ dbView->setText(0, dbViews.at(v));
+ }
         }
     }
     if (!gotActiveDb) {

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