mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
git-svn-id: http://svn.osgeo.org/qgis/trunk@9598 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
933cfb96a7
commit
227f38145b
@ -171,7 +171,7 @@ void QgsAttributeTable::columnClicked( int col )
|
|||||||
QList < int >::iterator it;
|
QList < int >::iterator it;
|
||||||
for ( it = idsOfSelected.begin(); it != idsOfSelected.end(); ++it )
|
for ( it = idsOfSelected.begin(); it != idsOfSelected.end(); ++it )
|
||||||
{
|
{
|
||||||
selectRowWithId(( *it ) );
|
selectRowWithId( *it );
|
||||||
}
|
}
|
||||||
connect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
|
connect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ void QgsAttributeTable::selectRowWithId( int id )
|
|||||||
|
|
||||||
void QgsAttributeTable::sortColumn( int col, bool ascending )
|
void QgsAttributeTable::sortColumn( int col, bool ascending )
|
||||||
{
|
{
|
||||||
int type = horizontalHeaderItem( col )->data( QgsAttributeTable::AttributeType ).toInt();
|
int type = horizontalHeaderItem( col )->data( AttributeType ).toInt();
|
||||||
qsort( 0, rowCount() - 1, col, ascending, type != QVariant::Int && type != QVariant::Double );
|
qsort( 0, rowCount() - 1, col, ascending, type != QVariant::Int && type != QVariant::Double );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,6 +437,19 @@ void QgsAttributeTable::copySelectedRows()
|
|||||||
clipboard->setText( toClipboard, QClipboard::Clipboard );
|
clipboard->setText( toClipboard, QClipboard::Clipboard );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsAttributeTable::addFeatureToTable( QgsVectorLayer *layer, int id )
|
||||||
|
{
|
||||||
|
blockSignals( true );
|
||||||
|
|
||||||
|
QgsFeature f;
|
||||||
|
if ( layer->featureAtId( id, f, false, true ) == 0 )
|
||||||
|
{
|
||||||
|
putFeatureInTable( rowCount(), f );
|
||||||
|
}
|
||||||
|
|
||||||
|
blockSignals( false );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
|
void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
|
||||||
{
|
{
|
||||||
blockSignals( true );
|
blockSignals( true );
|
||||||
@ -457,7 +470,7 @@ void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
|
|||||||
QTableWidgetItem *twi = new QTableWidgetItem( fldIt->name() );
|
QTableWidgetItem *twi = new QTableWidgetItem( fldIt->name() );
|
||||||
twi->setData( AttributeIndex, fldIt.key() );
|
twi->setData( AttributeIndex, fldIt.key() );
|
||||||
twi->setData( AttributeName, fldIt->name() );
|
twi->setData( AttributeName, fldIt->name() );
|
||||||
twi->setData( QgsAttributeTable::AttributeType, (int)(fldIt->type()));
|
twi->setData( AttributeType, ( int ) fldIt->type() );
|
||||||
setHorizontalHeaderItem( h, twi );
|
setHorizontalHeaderItem( h, twi );
|
||||||
|
|
||||||
mAttrIdxMap.insert( fldIt.key(), h );
|
mAttrIdxMap.insert( fldIt.key(), h );
|
||||||
@ -596,27 +609,26 @@ void QgsAttributeTable::bringSelectedToTop()
|
|||||||
blockSignals( false );
|
blockSignals( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTable::selectRowsWithId( const QgsFeatureIds& ids )
|
void QgsAttributeTable::selectRowsWithId( const QgsFeatureIds &ids, QgsVectorLayer *layer )
|
||||||
{
|
{
|
||||||
/*
|
#if 0
|
||||||
// if selecting rows takes too much time we can use progress dialog
|
// if selecting rows takes too much time we can use progress dialog
|
||||||
QProgressDialog progress( tr("Updating selection..."), tr("Abort"), 0, mSelected.size(), tabledisplay);
|
QProgressDialog progress( tr( "Updating selection..." ), tr( "Abort" ), 0, mSelected.size(), tabledisplay );
|
||||||
int i=0;
|
int i = 0;
|
||||||
for(std::set<int>::iterator iter=mSelected.begin();iter!=mSelected.end();++iter)
|
for ( std::set<int>::iterator iter = mSelected.begin();iter != mSelected.end();++iter )
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
progress.setValue(i);
|
progress.setValue( i );
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
if(progress.wasCanceled())
|
if ( progress.wasCanceled() )
|
||||||
{
|
{
|
||||||
//deselect the remaining features if action was canceled
|
//deselect the remaining features if action was canceled
|
||||||
mSelected.erase(iter,--mSelected.end());
|
mSelected.erase( iter, --mSelected.end() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
selectRowWithId(*iter);//todo: avoid that the table gets repainted during each selection
|
selectRowWithId( *iter );//todo: avoid that the table gets repainted during each selection
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// to select more rows at once effectively, we stop sending signals to handleChangedSelections()
|
// to select more rows at once effectively, we stop sending signals to handleChangedSelections()
|
||||||
// otherwise it will repaint map everytime row is selected
|
// otherwise it will repaint map everytime row is selected
|
||||||
@ -627,6 +639,12 @@ void QgsAttributeTable::selectRowsWithId( const QgsFeatureIds& ids )
|
|||||||
QgsFeatureIds::const_iterator it;
|
QgsFeatureIds::const_iterator it;
|
||||||
for ( it = ids.begin(); it != ids.end(); it++ )
|
for ( it = ids.begin(); it != ids.end(); it++ )
|
||||||
{
|
{
|
||||||
|
if ( layer && !rowIdMap.contains( *it ) )
|
||||||
|
{
|
||||||
|
// add feature if we do not already have it
|
||||||
|
addFeatureToTable( layer, *it );
|
||||||
|
}
|
||||||
|
|
||||||
selectRowWithId( *it );
|
selectRowWithId( *it );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,7 +772,7 @@ void QgsAttributeTable::addAttribute( int attr, const QgsField &fld )
|
|||||||
QTableWidgetItem *twi = new QTableWidgetItem( fld.name() );
|
QTableWidgetItem *twi = new QTableWidgetItem( fld.name() );
|
||||||
twi->setData( AttributeIndex, attr );
|
twi->setData( AttributeIndex, attr );
|
||||||
twi->setData( AttributeName, fld.name() );
|
twi->setData( AttributeName, fld.name() );
|
||||||
twi->setData( AttributeType, fld.type() );
|
twi->setData( AttributeType, ( int ) fld.type() );
|
||||||
|
|
||||||
insertColumn( columnCount() );
|
insertColumn( columnCount() );
|
||||||
setHorizontalHeaderItem( columnCount() - 1, twi );
|
setHorizontalHeaderItem( columnCount() - 1, twi );
|
||||||
|
@ -87,7 +87,7 @@ class QgsAttributeTable : public QTableWidget
|
|||||||
/**Swaps the selected rows such that the selected ones are on the top of the table*/
|
/**Swaps the selected rows such that the selected ones are on the top of the table*/
|
||||||
void bringSelectedToTop();
|
void bringSelectedToTop();
|
||||||
/** Selects rows with chosen feature IDs */
|
/** Selects rows with chosen feature IDs */
|
||||||
void selectRowsWithId( const QgsFeatureIds& ids );
|
void selectRowsWithId( const QgsFeatureIds& ids, QgsVectorLayer *layer = 0 );
|
||||||
/** Shows only rows with chosen feature IDs, others get hidden */
|
/** Shows only rows with chosen feature IDs, others get hidden */
|
||||||
void showRowsWithId( const QgsFeatureIds& ids );
|
void showRowsWithId( const QgsFeatureIds& ids );
|
||||||
/** Shows all rows */
|
/** Shows all rows */
|
||||||
@ -95,6 +95,10 @@ class QgsAttributeTable : public QTableWidget
|
|||||||
|
|
||||||
/**Fills the contents of a provider into this table*/
|
/**Fills the contents of a provider into this table*/
|
||||||
void fillTable( QgsVectorLayer *layer );
|
void fillTable( QgsVectorLayer *layer );
|
||||||
|
|
||||||
|
/** adds a feature to the current table */
|
||||||
|
void addFeatureToTable( QgsVectorLayer *layer, int id );
|
||||||
|
|
||||||
void addAttribute( int idx, const QgsField &fld );
|
void addAttribute( int idx, const QgsField &fld );
|
||||||
void deleteAttribute( int idx );
|
void deleteAttribute( int idx );
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ void QgsAttributeTableDisplay::setAttributeActions( const QgsAttributeAction &ac
|
|||||||
|
|
||||||
void QgsAttributeTableDisplay::selectRowsWithId( const QgsFeatureIds &ids )
|
void QgsAttributeTableDisplay::selectRowsWithId( const QgsFeatureIds &ids )
|
||||||
{
|
{
|
||||||
tblAttributes->selectRowsWithId( ids );
|
tblAttributes->selectRowsWithId( ids, mLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTableDisplay::setTheme()
|
void QgsAttributeTableDisplay::setTheme()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user