Skip to content
Permalink
Browse files

Fix for #1730 and some small updates in attribute table view code. Co…

…ntributed by Vita Cizek.

git-svn-id: http://svn.osgeo.org/qgis/trunk@10925 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jun 14, 2009
1 parent 198bf73 commit 6e1f579f089ba1de1993c7d10cc5dd6297f2c6d2
@@ -114,6 +114,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid

QgsAttributeTableDialog::~QgsAttributeTableDialog()
{
delete mSelectionModel;
}

void QgsAttributeTableDialog::closeEvent( QCloseEvent* event )
@@ -279,7 +280,7 @@ void QgsAttributeTableDialog::updateRowSelection( int index )
// 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 @@ void QgsAttributeTableDialog::updateRowSelection( int index )

mLastClickedHeaderIndex = last;
}
else if ( mView->ctrlPressed )
else if ( mView->ctrlPressed() )
{
QgsDebugMsg( "ctrl" );
// update the single row selection, without starting a new selection
@@ -42,27 +42,26 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget* parent )
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 );

QgsAttributeTableFilterModel* bfModel = new QgsAttributeTableFilterModel( layer );
bfModel->setSourceModel( bModel );
mModel = new QgsAttributeTableMemoryModel( layer );

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 @@ void QgsAttributeTableView::keyPressEvent( QKeyEvent *event )
{
// 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 @@ void QgsAttributeTableView::keyReleaseEvent( QKeyEvent *event )
{
// 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 );
}
@@ -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 @@ class QgsAttributeTableView: public QTableView
void closeEvent( QCloseEvent *event );
void keyPressEvent( QKeyEvent *event );
void keyReleaseEvent( QKeyEvent *event );
bool shiftPressed() { return mShiftPressed; }
bool ctrlPressed() { return mCtrlPressed; }

private:
bool mShiftPressed;
bool mCtrlPressed;

//make those private
bool shiftPressed;
bool ctrlPressed;
QgsAttributeTableModel* mModel;
QgsAttributeTableFilterModel* mFilterModel;
};

#endif

0 comments on commit 6e1f579

Please sign in to comment.
You can’t perform that action at this time.