[QGIS Commit] r10925 - trunk/qgis/src/app/attributetable

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 14 15:00:28 EDT 2009


Author: wonder
Date: 2009-06-14 15:00:28 -0400 (Sun, 14 Jun 2009)
New Revision: 10925

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
   trunk/qgis/src/app/attributetable/qgsattributetableview.cpp
   trunk/qgis/src/app/attributetable/qgsattributetableview.h
Log:
Fix for #1730 and some small updates in attribute table view code. Contributed by Vita Cizek.


Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-06-14 18:03:13 UTC (rev 10924)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-06-14 19:00:28 UTC (rev 10925)
@@ -114,6 +114,7 @@
 
 QgsAttributeTableDialog::~QgsAttributeTableDialog()
 {
+  delete mSelectionModel;
 }
 
 void QgsAttributeTableDialog::closeEvent( QCloseEvent* event )
@@ -279,7 +280,7 @@
   // map index to filter model
   //index = mFilterModel->mapFromSource(mModel->index(index, 0)).row();
 
-  if ( mView->shiftPressed )
+  if ( mView->shiftPressed() )
   {
     QgsDebugMsg( "shift" );
     // get the first and last index of the rows to be selected/deselected
@@ -307,7 +308,7 @@
 
     mLastClickedHeaderIndex = last;
   }
-  else if ( mView->ctrlPressed )
+  else if ( mView->ctrlPressed() )
   {
     QgsDebugMsg( "ctrl" );
     // update the single row selection, without starting a new selection

Modified: trunk/qgis/src/app/attributetable/qgsattributetableview.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetableview.cpp	2009-06-14 18:03:13 UTC (rev 10924)
+++ trunk/qgis/src/app/attributetable/qgsattributetableview.cpp	2009-06-14 19:00:28 UTC (rev 10925)
@@ -42,27 +42,26 @@
   setSelectionMode( QAbstractItemView::NoSelection );
   setSortingEnabled( true );
 
-  shiftPressed = false;
-  ctrlPressed = false;
+  mShiftPressed = false;
+  mCtrlPressed = false;
 }
 
 void QgsAttributeTableView::setLayer( QgsVectorLayer* layer )
 {
-  QgsAttributeTableModel *bModel;
-
   if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::RandomSelectGeometryAtId )
-    bModel = new QgsAttributeTableModel( layer );
+    mModel = new QgsAttributeTableModel( layer );
   else
-    bModel = new QgsAttributeTableMemoryModel( layer );
+    mModel = new QgsAttributeTableMemoryModel( layer );
 
-  QgsAttributeTableFilterModel* bfModel = new QgsAttributeTableFilterModel( layer );
-  bfModel->setSourceModel( bModel );
-
-  setModel( bfModel );
+  mFilterModel = new QgsAttributeTableFilterModel( layer );
+  mFilterModel->setSourceModel( mModel );
+  setModel( mFilterModel );
 }
 
 QgsAttributeTableView::~QgsAttributeTableView()
 {
+  delete mModel;
+  delete mFilterModel;
 }
 
 void QgsAttributeTableView::closeEvent( QCloseEvent *event )
@@ -75,9 +74,9 @@
 {
   // shift pressed
   if ( event->key() == Qt::Key_Shift )// && event->modifiers() & Qt::ShiftModifier)
-    shiftPressed = true;
+    mShiftPressed = true;
   else if ( event->key() == Qt::Key_Control )
-    ctrlPressed = true;
+    mCtrlPressed = true;
   else
     QTableView::keyPressEvent( event );
 }
@@ -86,9 +85,9 @@
 {
   // workaround for some Qt bug
   if ( event->key() == Qt::Key_Shift || event->key() == -1 )
-    shiftPressed = false;
+    mShiftPressed = false;
   else if ( event->key() == Qt::Key_Control )
-    ctrlPressed = false;
+    mCtrlPressed = false;
   else
     QTableView::keyReleaseEvent( event );
 }

Modified: trunk/qgis/src/app/attributetable/qgsattributetableview.h
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetableview.h	2009-06-14 18:03:13 UTC (rev 10924)
+++ trunk/qgis/src/app/attributetable/qgsattributetableview.h	2009-06-14 19:00:28 UTC (rev 10925)
@@ -18,14 +18,14 @@
 
 #include <QTableView>
 
+class QgsAttributeTableModel;
+class QgsAttributeTableFilterModel;
+
 class QgsVectorLayer;
 
 
 class QgsAttributeTableView: public QTableView
 {
-    //private slots:
-    //void setRows(int rows);
-
   public:
     QgsAttributeTableView( QWidget* parent = NULL );
     virtual ~QgsAttributeTableView();
@@ -35,10 +35,15 @@
     void closeEvent( QCloseEvent *event );
     void keyPressEvent( QKeyEvent *event );
     void keyReleaseEvent( QKeyEvent *event );
+    bool shiftPressed() { return mShiftPressed; }
+    bool ctrlPressed() { return mCtrlPressed; }
 
-    //make those private
-    bool shiftPressed;
-    bool ctrlPressed;
+  private:
+    bool mShiftPressed;
+    bool mCtrlPressed;
+
+    QgsAttributeTableModel* mModel;
+    QgsAttributeTableFilterModel* mFilterModel;
 };
 
 #endif



More information about the QGIS-commit mailing list