[QGIS Commit] r10550 - in trunk/qgis/src/app: . legend

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Apr 13 05:10:23 EDT 2009


Author: wonder
Date: 2009-04-13 05:10:22 -0400 (Mon, 13 Apr 2009)
New Revision: 10550

Removed:
   trunk/qgis/src/app/qgsattributetable.cpp
   trunk/qgis/src/app/qgsattributetable.h
   trunk/qgis/src/app/qgsattributetabledisplay.cpp
   trunk/qgis/src/app/qgsattributetabledisplay.h
Modified:
   trunk/qgis/src/app/CMakeLists.txt
   trunk/qgis/src/app/legend/qgslegend.cpp
   trunk/qgis/src/app/legend/qgslegendlayerfile.cpp
   trunk/qgis/src/app/qgisapp.cpp
Log:
Removed "old" attribute table from repository.


Modified: trunk/qgis/src/app/CMakeLists.txt
===================================================================
--- trunk/qgis/src/app/CMakeLists.txt	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/CMakeLists.txt	2009-04-13 09:10:22 UTC (rev 10550)
@@ -6,8 +6,6 @@
   qgsaddattrdialog.cpp
   qgsattributeactiondialog.cpp
   qgsattributedialog.cpp
-  qgsattributetable.cpp
-  qgsattributetabledisplay.cpp
   qgsbookmarkitem.cpp
   qgsbookmarks.cpp
   qgsclipboard.cpp
@@ -98,8 +96,6 @@
   qgsaddattrdialog.h
   qgsattributeactiondialog.h
   qgsattributedialog.h
-  qgsattributetabledisplay.h
-  qgsattributetable.h
   qgsbookmarks.h
   qgscontinuouscolordialog.h
   qgscustomprojectiondialog.h

Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/legend/qgslegend.cpp	2009-04-13 09:10:22 UTC (rev 10550)
@@ -37,7 +37,6 @@
 #include "qgsrasterlayer.h"
 #include "qgsrasterlayerproperties.h"
 #include "qgsvectorlayerproperties.h"
-#include "qgsattributetabledisplay.h"
 
 #include "BeataDialog.h"
 

Modified: trunk/qgis/src/app/legend/qgslegendlayerfile.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegendlayerfile.cpp	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/legend/qgslegendlayerfile.cpp	2009-04-13 09:10:22 UTC (rev 10550)
@@ -32,9 +32,6 @@
 #include "qgsgenericprojectionselector.h"
 
 // attribute table
-#include "qgsattributetable.h"
-#include "qgsattributetabledisplay.h"
-
 #include "BeataDialog.h"
 
 

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-04-13 09:10:22 UTC (rev 10550)
@@ -89,7 +89,6 @@
 #include "qgisplugin.h"
 #include "qgsabout.h"
 #include "qgsapplication.h"
-#include "qgsattributetabledisplay.h"
 #include "qgsbookmarkitem.h"
 #include "qgsbookmarks.h"
 #include "qgsclipboard.h"

Deleted: trunk/qgis/src/app/qgsattributetable.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetable.cpp	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/qgsattributetable.cpp	2009-04-13 09:10:22 UTC (rev 10550)
@@ -1,809 +0,0 @@
-/***************************************************************************
-                          qgsattributetable.cpp  -  description
-                             -------------------
-    begin                : Sat Nov 23 2002
-    copyright            : (C) 2002 by Gary E.Sherman
-    email                : sherman at mrcc dot com
-       Romans 3:23=>Romans 6:23=>Romans 5:8=>Romans 10:9,10=>Romans 12
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id$ */
-#include <QLineEdit>
-#include <QValidator>
-
-#include "qgsattributetable.h"
-#include "qgsfield.h"
-#include "qgslogger.h"
-#include "qgsvectordataprovider.h"
-#include "qgsvectorlayer.h"
-#include "qgisapp.h"
-#include "qgsmapcanvas.h"
-
-#include <QApplication>
-#include <QClipboard>
-#include <QHeaderView>
-#include <QKeyEvent>
-#include <QMenu>
-#include <QSettings>
-
-
-QgsAttributeTableItemDelegate::QgsAttributeTableItemDelegate( QgsAttributeTable *table, QObject *parent )
-    : QItemDelegate( parent ), mTable( table )
-{
-}
-
-QWidget *QgsAttributeTableItemDelegate::createEditor(
-  QWidget *parent,
-  const QStyleOptionViewItem &option,
-  const QModelIndex &index ) const
-{
-  QWidget *editor = QItemDelegate::createEditor( parent, option, index );
-  QLineEdit *le = dynamic_cast<QLineEdit*>( editor );
-  if ( !le )
-    return editor;
-
-  int col = index.column();
-  QTableWidgetItem *twi = mTable->horizontalHeaderItem( col );
-  if ( !twi )
-  {
-    QgsDebugMsg( QString( "horizontalHeaderItem %1 not found" ).arg( col ) );
-    return editor;
-  }
-
-  int type = twi->data( QgsAttributeTable::AttributeType ).toInt();
-  if ( type == QVariant::Int )
-  {
-    le->setValidator( new QIntValidator( le ) );
-  }
-  else if ( type == QVariant::Double )
-  {
-    le->setValidator( new QDoubleValidator( le ) );
-  }
-
-  return editor;
-}
-
-
-QgsAttributeTable::QgsAttributeTable( QWidget * parent ) :
-    QTableWidget( parent ),
-    lockKeyPressed( false ),
-    mEditable( false ),
-    mEdited( false ),
-    mActionPopup( 0 ),
-    mPreviousSortIndicatorColumn( -1 )
-{
-  QFont f( font() );
-#ifdef Q_WS_MAC
-  // The default application font for OS X is Lucida Grande 13 point; for small, use 11 point
-  f.setPointSize( 11 );
-#else
-  f.setFamily( "Helvetica" );
-  f.setPointSize( 9 );
-#endif
-  setFont( f );
-  mDelegate = new QgsAttributeTableItemDelegate( this );
-  setItemDelegate( mDelegate );
-  setSelectionBehavior( QAbstractItemView::SelectRows );
-  connect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
-  connect( horizontalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( columnClicked( int ) ) );
-  connect( verticalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( rowClicked( int ) ) );
-  setFocus();
-}
-
-QgsAttributeTable::~QgsAttributeTable()
-{
-  delete mActionPopup;
-  delete mDelegate;
-}
-
-void QgsAttributeTable::setReadOnly( bool b )
-{
-  blockSignals( true );
-
-  setEditTriggers( b ? QAbstractItemView::NoEditTriggers :
-                   QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed );
-  if ( !b )
-  {
-    setColumnReadOnly( 0, true );
-  }
-
-  blockSignals( false );
-}
-
-void QgsAttributeTable::setColumnReadOnly( int col, bool ro )
-{
-  for ( int i = 0; i < rowCount(); ++i )
-  {
-    QTableWidgetItem *twi = item( i, col );
-    twi->setFlags( ro ? twi->flags() & ~Qt::ItemIsEditable : twi->flags() | Qt::ItemIsEditable );
-  }
-}
-
-void QgsAttributeTable::columnClicked( int col )
-{
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-
-  //store the ids of the selected rows in a list
-  QList<int> idsOfSelected;
-  QList<QTableWidgetSelectionRange> selection = selectedRanges();
-  for ( int i = 0; i < selection.count(); i++ )
-  {
-    for ( int j = selection.at( i ).topRow(); j <= selection.at( i ).bottomRow(); j++ )
-    {
-      idsOfSelected.append( item( j, 0 )->text().toInt() );
-    }
-  }
-
-  QHeaderView *header = horizontalHeader();
-  if ( !header->isSortIndicatorShown() )
-  {
-    header->setSortIndicatorShown( true );
-    header->setSortIndicator( col, Qt::AscendingOrder );
-  }
-  if ( col != mPreviousSortIndicatorColumn )
-  {
-    // Workaround for QTableView sortIndicator displayed in wrong direction
-    header->setSortIndicator( col, header->sortIndicatorOrder() == Qt::AscendingOrder ?
-                              Qt::DescendingOrder : Qt::AscendingOrder );
-  }
-  mPreviousSortIndicatorColumn = col;
-  sortColumn( col, header->sortIndicatorOrder() == Qt::DescendingOrder );
-
-  //clear and rebuild rowIdMap. Overwrite sortColumn later and sort rowIdMap there
-  rowIdMap.clear();
-  int id;
-  for ( int i = 0; i < rowCount(); i++ )
-  {
-    id = item( i, 0 )->text().toInt();
-    rowIdMap.insert( id, i );
-  }
-
-  disconnect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
-  clearSelection();
-
-  //select the rows again after sorting
-
-  QList < int >::iterator it;
-  for ( it = idsOfSelected.begin(); it != idsOfSelected.end(); ++it )
-  {
-    selectRowWithId( *it );
-  }
-  connect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
-
-  QApplication::restoreOverrideCursor();
-}
-
-void QgsAttributeTable::keyPressEvent( QKeyEvent * ev )
-{
-  if ( ev->key() == Qt::Key_Control || ev->key() == Qt::Key_Shift )
-  {
-    lockKeyPressed = true;
-  }
-}
-
-void QgsAttributeTable::keyReleaseEvent( QKeyEvent * ev )
-{
-  if ( ev->key() == Qt::Key_Control || ev->key() == Qt::Key_Shift )
-  {
-    lockKeyPressed = false;
-  }
-}
-
-void QgsAttributeTable::handleChangedSelections()
-{
-  emit selectionRemoved( false );
-
-  QList<QTableWidgetSelectionRange> selectedItemRanges = selectedRanges();
-  QList<QTableWidgetSelectionRange>::const_iterator range_it = selectedItemRanges.constBegin();
-  for ( ; range_it != selectedItemRanges.constEnd(); ++range_it )
-  {
-    for ( int index = range_it->topRow(); index <= range_it->bottomRow(); index++ )
-    {
-      emit selected( item( index, 0 )->text().toInt(), false );
-    }
-  }
-
-  //don't send the signal repaintRequested() from here
-  //but in mouseReleaseEvent() and rowClicked(int)
-  //todo: don't repaint in case of double clicks
-}
-
-void QgsAttributeTable::insertFeatureId( int id, int row )
-{
-  rowIdMap.insert( id, row );
-}
-
-void QgsAttributeTable::selectRowWithId( int id )
-{
-  QMap < int, int >::iterator it = rowIdMap.find( id );
-  setRangeSelected( QTableWidgetSelectionRange( it.value(), 0, it.value(), columnCount() - 1 ), true );
-}
-
-void QgsAttributeTable::sortColumn( int col, bool ascending )
-{
-  int type = horizontalHeaderItem( col )->data( AttributeType ).toInt();
-  qsort( 0, rowCount() - 1, col, ascending, type != QVariant::Int && type != QVariant::Double );
-}
-
-
-/**
-  XXX Doesn't QString have something ilke this already?
-*/
-int QgsAttributeTable::compareItems( QString s1, QString s2, bool ascending, bool alphanumeric )
-{
-  if ( alphanumeric )
-  {
-    int compareValue = QString::localeAwareCompare( s1, s2 );
-    if ( compareValue > 0 )
-    {
-      if ( ascending )
-      {
-        return 1;
-      }
-      else
-      {
-        return -1;
-      }
-    }
-    else if ( compareValue < 0 )
-    {
-      if ( ascending )
-      {
-        return -1;
-      }
-      else
-      {
-        return 1;
-      }
-    }
-    else if ( compareValue == 0 )
-    {
-      return 0;
-    }
-  }
-  else                        //numeric
-  {
-    double d1 = s1.toDouble();
-    double d2 = s2.toDouble();
-    if ( d1 > d2 )
-    {
-      if ( ascending )
-      {
-        return 1;
-      }
-      else
-      {
-        return -1;
-      }
-    }
-    else if ( d1 < d2 )
-    {
-      if ( ascending )
-      {
-        return -1;
-      }
-      else
-      {
-        return 1;
-      }
-    }
-    else if ( d1 == d2 )
-    {
-      return 0;
-    }
-  }
-
-  return 0;                     // XXX has to return something; is this reasonable?
-}
-
-void QgsAttributeTable::qsort( int lower, int upper, int col, bool ascending, bool alphanumeric )
-{
-  int i, j;
-  QString v;
-  if ( upper > lower )
-  {
-    //chose a random element (this avoids n^2 worst case)
-    int element = int (( double )rand() / ( double )RAND_MAX * ( upper - lower ) + lower );
-    swapRows( element, upper );
-    v = item( upper, col )->text();
-    i = lower - 1;
-    j = upper;
-    for ( ;; )
-    {
-      while ( compareItems( item( ++i, col )->text(), v, ascending, alphanumeric ) == -1 )
-        ;
-      while ( compareItems( item( --j, col )->text(), v, ascending, alphanumeric ) == 1 && j > 0 ); //make sure that j does not get negative
-      if ( i >= j )
-      {
-        break;
-      }
-      swapRows( i, j );
-    }
-    swapRows( i, upper );
-    qsort( lower, i - 1, col, ascending, alphanumeric );
-    qsort( i + 1, upper, col, ascending, alphanumeric );
-  }
-}
-
-void QgsAttributeTable::swapRows( int row1, int row2 )
-{
-  for ( int col = 0; col < columnCount(); col++ )
-  {
-    QTableWidgetItem *item = takeItem( row1, col );
-    setItem( row1, col, takeItem( row2, col ) );
-    setItem( row2, col, item );
-  }
-}
-
-void QgsAttributeTable::contextMenuEvent( QContextMenuEvent *event )
-{
-  const QPoint& pos = event->globalPos();
-  int row = rowAt( pos.x() );
-  int col = columnAt( pos.y() );
-
-  // Duplication of code in qgsidentufyresults.cpp. Consider placing
-  // in a seperate class
-  if ( mActionPopup == 0 )
-  {
-    mActionPopup = new QMenu();
-    mActionPopup->addAction( tr( "Run action" ) );
-    mActionPopup->addSeparator();
-
-    QgsAttributeAction::aIter iter = mActions.begin();
-    for ( int j = 0; iter != mActions.end(); ++iter, ++j )
-    {
-      QAction* a = mActionPopup->addAction( iter->name() );
-      // The menu action stores an integer that is used later on to
-      // associate an menu action with an actual qgis action.
-      a->setData( QVariant::fromValue( j ) );
-    }
-    connect( mActionPopup, SIGNAL( triggered( QAction* ) ),
-             this, SLOT( popupItemSelected( QAction* ) ) );
-  }
-
-  // Get and store the attribute values and their column names are
-  // these are needed for substituting into the actions if the user
-  // chooses one.
-  mActionValues.clear();
-
-  for ( int i = 0; i < columnCount(); ++i )
-  {
-    if ( row >= 0 ) //prevent crash if row is negative, see ticket #1149
-    {
-      mActionValues.push_back(
-        std::make_pair(
-          horizontalHeaderItem( i )->text(),
-          item( row, i )->text() ) );
-    }
-  }
-  // The item that was clicked on, stored as an index into the
-  // mActionValues vector.
-  mClickedOnValue = col;
-
-  if ( mActions.size() > 0 )
-    mActionPopup->popup( pos );
-}
-
-void QgsAttributeTable::popupItemSelected( QAction* menuAction )
-{
-  int id = menuAction->data().toInt();
-  mActions.doAction( id, mActionValues, mClickedOnValue );
-}
-
-/* Deprecated: See QgisApp::editCopy() instead */
-void QgsAttributeTable::copySelectedRows()
-{
-  // Copy selected rows to the clipboard
-
-  QString toClipboard;
-  const char fieldSep = '\t';
-
-  // Pick up the headers first
-  for ( int i = 0; i < columnCount(); ++i )
-    toClipboard += horizontalHeaderItem( i )->text() + fieldSep;
-  toClipboard += '\n';
-
-  QList<QTableWidgetSelectionRange> selection = selectedRanges();
-  // Then populate with the cell contents
-  for ( int i = 0; i < selection.count(); ++i )
-  {
-    QTableWidgetSelectionRange sel = selection.at( i );
-    for ( int row = sel.topRow(); row < sel.topRow() + sel.rowCount(); ++row )
-    {
-      for ( int column = 0; column < columnCount(); ++column )
-        toClipboard += item( row, column )->text() + fieldSep;
-      toClipboard += '\n';
-    }
-  }
-#ifdef QGISDEBUG
-  std::cerr << "Selected data in table is:\n" << toClipboard.data(); // OK
-#endif
-  // And then copy to the clipboard
-  QClipboard* clipboard = QApplication::clipboard();
-
-  // With qgis running under Linux, but with a Windows based X
-  // server (Xwin32), ::Selection was necessary to get the data into
-  // the Windows clipboard (which seems contrary to the Qt
-  // docs). With a Linux X server, ::Clipboard was required.
-  // The simple solution was to put the text into both clipboards.
-
-  // The ::Selection setText() below one may need placing inside so
-  // #ifdef so that it doesn't get compiled under Windows.
-  clipboard->setText( toClipboard, QClipboard::Selection );
-  clipboard->setText( toClipboard, QClipboard::Clipboard );
-}
-
-void QgsAttributeTable::addFeatureToTable( QgsVectorLayer *layer, int id )
-{
-  blockSignals( true );
-
-  QgsFeature f;
-  if ( layer->featureAtId( id, f, false, true ) )
-  {
-    putFeatureInTable( rowCount(), f );
-  }
-
-  blockSignals( false );
-}
-
-void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
-{
-  blockSignals( true );
-
-  const QgsFieldMap &fields = layer->pendingFields();
-
-  // set up the column headers
-  setColumnCount( fields.size() + 1 );
-
-  setHorizontalHeaderItem( 0, new QTableWidgetItem( "id" ) ); //label for the id-column
-
-  int h = 1;
-  for ( QgsFieldMap::const_iterator fldIt = fields.begin(); fldIt != fields.end(); fldIt++, h++ )
-  {
-    QgsDebugMsg( QString( "%1: field %2: %3 | %4" )
-                 .arg( h ).arg( fldIt.key() ).arg( fldIt->name() ).arg( QVariant::typeToName( fldIt->type() ) ) );
-
-    QTableWidgetItem *twi = new QTableWidgetItem( fldIt->name() );
-    twi->setData( AttributeIndex, fldIt.key() );
-    twi->setData( AttributeName, fldIt->name() );
-    twi->setData( AttributeType, ( int ) fldIt->type() );
-    setHorizontalHeaderItem( h, twi );
-
-    mAttrIdxMap.insert( fldIt.key(), h );
-  }
-
-  QgsFeatureList features;
-
-  QSettings settings;
-  int behaviour = settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt();
-
-  if ( behaviour == 1 )
-  {
-    features = layer->selectedFeatures();
-  }
-  else
-  {
-    QgsRectangle rect;
-    if ( behaviour == 2 )
-    {
-      // current canvas only
-      rect = QgisApp::instance()->mapCanvas()->extent();
-    }
-
-    layer->select( layer->pendingAllAttributesList(), rect, false );
-
-    QgsFeature f;
-    while ( layer->nextFeature( f ) )
-      features << f;
-  }
-
-  setRowCount( features.size() );
-
-  for ( int i = 0; i < features.size(); i++ )
-    putFeatureInTable( i, features[i] );
-
-  // Default row height is too tall
-  resizeRowsToContents();
-
-  // Make each column wide enough to show all the contents
-  for ( int i = 0; i < columnCount(); i++ )
-    resizeColumnToContents( i );
-
-  blockSignals( false );
-}
-
-void QgsAttributeTable::putFeatureInTable( int row, const QgsFeature& fet )
-{
-  // Prevent a crash if a provider doesn't update the feature count properly
-  if ( row >= rowCount() )
-  {
-    setRowCount( row + 1 );
-  }
-
-  //id-field
-  int id = fet.id();
-  QTableWidgetItem *twi = new QTableWidgetItem( QString::number( id ) );
-  twi->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter );
-  setItem( row, 0, twi );
-  insertFeatureId( id, row );  //insert the id into the search tree of qgsattributetable
-
-  const QgsAttributeMap& attr = fet.attributeMap();
-
-  for ( QgsAttributeMap::const_iterator it = attr.begin(); it != attr.end(); ++it )
-  {
-    if ( !mAttrIdxMap.contains( it.key() ) )
-      continue;
-
-    int h = mAttrIdxMap[ it.key()];
-
-    twi = horizontalHeaderItem( h );
-    if ( !twi )
-    {
-      QgsDebugMsg( "header item not found." );
-      continue;
-    }
-
-    int type = twi->data( AttributeType ).toInt();
-    bool isNum = ( type == QVariant::Double || type == QVariant::Int );
-
-    QString value;
-    // get the field values
-    if ( it->isNull() )
-    {
-      if ( isNum )
-        value = "";
-      else
-        value = "NULL";
-    }
-    else
-    {
-      value = it->toString();
-    }
-
-    twi = new QTableWidgetItem( value );
-    if ( isNum )
-      twi->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter );
-    setItem( row, h, twi );
-  }
-}
-
-void QgsAttributeTable::bringSelectedToTop()
-{
-  blockSignals( true );
-  horizontalHeader()->setSortIndicatorShown( false );
-  mPreviousSortIndicatorColumn = -1;
-  int swaptorow = 0;
-  QList<QTableWidgetSelectionRange> selections = selectedRanges();
-  bool removeselection;
-
-  for ( QList<QTableWidgetSelectionRange>::iterator iter = selections.begin();iter != selections.end();++iter )
-  {
-    removeselection = true;
-    while ( swaptorow < rowCount() && item( swaptorow, 0 )->isSelected() )//selections are not necessary stored in ascending order
-    {
-      ++swaptorow;
-    }
-
-    for ( int j = iter->topRow();j <= iter->bottomRow();++j )
-    {
-      if ( j > swaptorow )//selections are not necessary stored in ascending order
-      {
-        swapRows( j, swaptorow );
-        setRangeSelected( QTableWidgetSelectionRange( swaptorow, 0, swaptorow, columnCount() - 1 ), true );
-        ++swaptorow;
-
-      }
-      else
-      {
-        removeselection = false;//keep selection
-      }
-    }
-    if ( removeselection )
-    {
-      setRangeSelected( *iter, false );
-    }
-  }
-
-  //clear and rebuild rowIdMap.
-  rowIdMap.clear();
-  int id;
-  for ( int i = 0; i < rowCount(); i++ )
-  {
-    id = item( i, 0 )->text().toInt();
-    rowIdMap.insert( id, i );
-  }
-
-  blockSignals( false );
-}
-
-void QgsAttributeTable::selectRowsWithId( const QgsFeatureIds &ids, QgsVectorLayer *layer )
-{
-#if 0
-  // if selecting rows takes too much time we can use progress dialog
-  QProgressDialog progress( tr( "Updating selection..." ), tr( "Abort" ), 0, mSelected.size(), tabledisplay );
-  int i = 0;
-  for ( std::set<int>::iterator iter = mSelected.begin();iter != mSelected.end();++iter )
-  {
-    ++i;
-    progress.setValue( i );
-    qApp->processEvents();
-    if ( progress.wasCanceled() )
-    {
-      //deselect the remaining features if action was canceled
-      mSelected.erase( iter, --mSelected.end() );
-      break;
-    }
-    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()
-  // otherwise it will repaint map everytime row is selected
-
-  disconnect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
-
-  clearSelection();
-  QgsFeatureIds::const_iterator 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 );
-  }
-
-  connect( this, SIGNAL( itemSelectionChanged() ), this, SLOT( handleChangedSelections() ) );
-  emit repaintRequested();
-}
-
-void QgsAttributeTable::showRowsWithId( const QgsFeatureIds& ids )
-{
-  setUpdatesEnabled( false );
-
-  // hide all rows first
-  for ( int i = 0; i < rowCount(); i++ )
-    hideRow( i );
-
-  // show only matching rows
-  QgsFeatureIds::const_iterator it;
-  for ( it = ids.begin(); it != ids.end(); it++ )
-  {
-    showRow( rowIdMap[*it] );
-  }
-
-  clearSelection(); // deselect all
-  setUpdatesEnabled( true );
-}
-
-void QgsAttributeTable::showAllRows()
-{
-  for ( int i = 0; i < rowCount(); i++ )
-    showRow( i );
-}
-
-void QgsAttributeTable::rowClicked( int row )
-{
-  if ( checkSelectionChanges() )//only repaint the canvas if the selection has changed
-  {
-    emit repaintRequested();
-  }
-}
-
-void QgsAttributeTable::mouseReleaseEvent( QMouseEvent* e )
-{
-  QTableWidget::mouseReleaseEvent( e );
-  if ( checkSelectionChanges() )//only repaint the canvas if the selection has changed
-  {
-    emit repaintRequested();
-  }
-}
-
-bool QgsAttributeTable::checkSelectionChanges()
-{
-  std::set<int> theCurrentSelection;
-  QList<QTableWidgetSelectionRange> selectedItemRanges = selectedRanges();
-  QList<QTableWidgetSelectionRange>::const_iterator range_it = selectedItemRanges.constBegin();
-  for ( ; range_it != selectedItemRanges.constEnd(); ++range_it )
-  {
-    for ( int index = range_it->topRow(); index <= range_it->bottomRow(); index++ )
-    {
-      theCurrentSelection.insert( index );
-    }
-  }
-
-  if ( theCurrentSelection == mLastSelectedRows )
-  {
-    return false;
-  }
-  else
-  {
-    mLastSelectedRows = theCurrentSelection;
-    return true;
-  }
-}
-
-void QgsAttributeTable::attributeValueChanged( int fid, int idx, const QVariant &value )
-{
-  if ( !rowIdMap.contains( fid ) )
-    return;
-
-  if ( !mAttrIdxMap.contains( idx ) )
-    return;
-
-  QTableWidgetItem *twi = horizontalHeaderItem( mAttrIdxMap[ idx ] );
-  if ( !twi )
-  {
-    QgsDebugMsg( "header item not found." );
-    return;
-  }
-
-  int type = twi->data( AttributeType ).toInt();
-  bool isNum = ( type == QVariant::Double || type == QVariant::Int );
-
-  QString v;
-  // get the field values
-  if ( value.isNull() )
-  {
-    if ( isNum )
-      v = "";
-    else
-      v = "NULL";
-  }
-  else
-  {
-    v = value.toString();
-  }
-
-  item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( v );
-}
-
-void QgsAttributeTable::featureDeleted( int fid )
-{
-  if ( !rowIdMap.contains( fid ) )
-    return;
-
-  int row = rowIdMap[fid];
-
-  removeRow( row );
-
-  for ( QMap<int, int>::iterator it = rowIdMap.begin(); it != rowIdMap.end(); it++ )
-    if ( it.value() > row )
-      rowIdMap[ it.key()]--;
-}
-
-void QgsAttributeTable::addAttribute( int attr, const QgsField &fld )
-{
-  QTableWidgetItem *twi = new QTableWidgetItem( fld.name() );
-  twi->setData( AttributeIndex, attr );
-  twi->setData( AttributeName, fld.name() );
-  twi->setData( AttributeType, ( int ) fld.type() );
-
-  insertColumn( columnCount() );
-  setHorizontalHeaderItem( columnCount() - 1, twi );
-
-  mAttrIdxMap.insert( attr, columnCount() - 1 );
-}
-
-void QgsAttributeTable::deleteAttribute( int attr )
-{
-  int column = mAttrIdxMap[attr];
-
-  removeColumn( column );
-  mAttrIdxMap.remove( attr );
-  for ( QMap<int, int>::iterator it = mAttrIdxMap.begin(); it != mAttrIdxMap.end(); it++ )
-  {
-    if ( it.value() > column )
-      mAttrIdxMap[ it.key()]--;
-  }
-}

Deleted: trunk/qgis/src/app/qgsattributetable.h
===================================================================
--- trunk/qgis/src/app/qgsattributetable.h	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/qgsattributetable.h	2009-04-13 09:10:22 UTC (rev 10550)
@@ -1,179 +0,0 @@
-/***************************************************************************
-                          qgsattributetable.h  -  description
-                             -------------------
-    begin                : Sat Nov 23 2002
-    copyright            : (C) 2002 by Gary E.Sherman
-    email                : sherman at mrcc dot com
-        Romans 3:23=>Romans 6:23=>Romans 5:8=>Romans 10:9,10=>Romans 12
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id$ */
-#ifndef QGSATTRIBUTETABLE_H
-#define QGSATTRIBUTETABLE_H
-
-#include "qgsattributeaction.h"
-#include "qgsvectorlayer.h"
-#include "qgsfield.h"
-
-#include <QItemDelegate>
-#include <QTableWidget>
-
-#include <set>
-
-/**
- *@author Gary E.Sherman
- */
-
-class QgsAttributeTable;
-
-class QgsAttributeTableItemDelegate: public QItemDelegate
-{
-    Q_OBJECT
-
-  public:
-    QgsAttributeTableItemDelegate( QgsAttributeTable *table, QObject * parent = 0 );
-    QWidget * createEditor( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
-
-  private:
-    QgsAttributeTable *mTable;
-};
-
-class QgsAttributeTable : public QTableWidget
-{
-    Q_OBJECT
-
-  public:
-    QgsAttributeTable( QWidget * parent = 0 );
-    ~QgsAttributeTable();
-
-    enum
-    {
-      AttributeIndex = Qt::UserRole,
-      AttributeName = Qt::UserRole + 1,
-      AttributeType = Qt::UserRole + 2
-    };
-
-    void setReadOnly( bool b );
-    void setColumnReadOnly( int col, bool ro );
-
-    /* Inserts the feature with the specified id into rowIdMap. This function has to be called
-       (e.g. from QgsShapeFileLayer) when a row is inserted into the table */
-    void insertFeatureId( int id, int row );
-    /**Selects the row which belongs to the feature with the specified id*/
-    void selectRowWithId( int id );
-    /**Sorts a column. If the first entry contains a letter, sort alphanumerically, otherwise numerically.*/
-    void sortColumn( int col, bool ascending );
-    /* Use this to give this class the current attribute actions,
-       which are used when the user requests a popup menu */
-    void setAttributeActions( const QgsAttributeAction& actions )
-    { mActions = actions; }
-    /**Returns if the table contains uncommited changes*/
-    bool edited() const {return mEdited;}
-    /**Switches editing mode on and off*/
-    void setEditable( bool enabled ) {mEditable = enabled;}
-
-    /** Copies the selected rows to the clipboard
-        Deprecated: See QgisApp::editCopy() instead */
-    void copySelectedRows();
-
-    /**Swaps the selected rows such that the selected ones are on the top of the table*/
-    void bringSelectedToTop();
-    /** Selects rows with chosen feature IDs */
-    void selectRowsWithId( const QgsFeatureIds& ids, QgsVectorLayer *layer = 0 );
-    /** Shows only rows with chosen feature IDs, others get hidden */
-    void showRowsWithId( const QgsFeatureIds& ids );
-    /** Shows all rows */
-    void showAllRows();
-
-    /**Fills the contents of a provider into this table*/
-    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 deleteAttribute( int idx );
-
-  public slots:
-    void columnClicked( int col );
-    void rowClicked( int row );
-
-    // Called when the user chooses an item on the popup menu
-    void popupItemSelected( QAction * menuAction );
-
-    void attributeValueChanged( int fid, int idx, const QVariant &value );
-    void featureDeleted( int fid );
-
-  protected slots:
-    void handleChangedSelections();
-
-  protected:
-    /**Flag telling if the ctrl-button or the shift-button is pressed*/
-    bool lockKeyPressed;
-    /**Search tree to find a row corresponding to a feature id*/
-    QMap<int, int> rowIdMap;
-    /**Map attribute index to columns*/
-    QMap<int, int> mAttrIdxMap;
-    bool mEditable;
-    /**True if table has been edited and contains uncommited changes*/
-    bool mEdited;
-
-    /**Stors the numbers of the last selected rows. This is used to check for selection changes before emit repaintRequested()*/
-    std::set<int> mLastSelectedRows;
-
-    /* Compares the content of two cells either alphanumeric or numeric.
-       If 'ascending' is true, -1 means s1 is less, 0 equal, 1 greater.
-       If 'ascending' is false, -1 means s1 is more, 0 equal, 1 greater.
-       This method is used mainly to sort a column*/
-    int compareItems( QString s1, QString s2, bool ascending, bool alphanumeric );
-    void keyPressEvent( QKeyEvent* ev );
-    void keyReleaseEvent( QKeyEvent* ev );
-    /**Method used by sortColumn (implementation of a quicksort)*/
-    void qsort( int lower, int upper, int col, bool ascending, bool alphanumeric );
-    /**Called when the user requests a popup menu*/
-    void contextMenuEvent( QContextMenuEvent* event );
-    /**Removes the column belonging to an attribute from the table
-      @name attribut name*/
-    void removeAttrColumn( const QString& name );
-    /** puts attributes of feature to the chosen table row */
-    void putFeatureInTable( int row, const QgsFeature& fet );
-    void mouseReleaseEvent( QMouseEvent* e );
-    /**This function compares the current selection and the selection of the last repaint.
-       Returns true if there are differences in the selection.
-       Also, mLastSelectedRows is updated*/
-    bool checkSelectionChanges();
-
-  signals:
-    /**Is emitted when a row was selected*/
-    void selected( int, bool );
-    /**Is emitted when all rows have been deselected*/
-    void selectionRemoved( bool );
-    /**Is emitted when a set of related selection and deselection signals have been emitted*/
-    void repaintRequested();
-
-  private:
-    void swapRows( int row1, int row2 );
-
-    // Data to do with providing a popup menu of actions that
-    std::vector<std::pair<QString, QString> > mActionValues;
-    int mClickedOnValue;
-    QMenu* mActionPopup;
-    QgsAttributeAction mActions;
-
-    QgsAttributeTableItemDelegate *mDelegate;
-
-    // Track previous columm for QTableView sortIndicator wrong direction workaround
-    int mPreviousSortIndicatorColumn;
-
-    QgsVectorLayer *mLayer;
-};
-
-#endif

Deleted: trunk/qgis/src/app/qgsattributetabledisplay.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetabledisplay.cpp	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/qgsattributetabledisplay.cpp	2009-04-13 09:10:22 UTC (rev 10550)
@@ -1,507 +0,0 @@
-/***************************************************************************
-                          QgsAttributeTableDisplay.cpp  -  description
-                             -------------------
-    begin                : Sat Nov 23 2002
-    copyright            : (C) 2002 by Gary E.Sherman
-    email                : sherman at mrcc dot com
-       Romans 3:23=>Romans 6:23=>Romans 5:8=>Romans 10:9,10=>Romans 12
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id$ */
-
-#include "qgsattributetabledisplay.h"
-
-#include "qgisapp.h"
-#include "qgsapplication.h"
-#include "qgsfeature.h"
-#include "qgsfield.h"
-#include "qgslogger.h"
-#include "qgssearchquerybuilder.h"
-#include "qgssearchstring.h"
-#include "qgssearchtreenode.h"
-#include "qgsvectorlayer.h"
-#include "qgsvectordataprovider.h"
-#include "qgscontexthelp.h"
-
-#include <QCloseEvent>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QIcon>
-#include <QPixmap>
-#include <QSettings>
-#include <QToolButton>
-#include <QDockWidget>
-
-class QAttributeTableDock : public QDockWidget
-{
-  public:
-    QAttributeTableDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )
-        : QDockWidget( title, parent, flags )
-    {
-    }
-
-    virtual void closeEvent( QCloseEvent * ev )
-    {
-      deleteLater();
-    }
-};
-
-QgsAttributeTableDisplay::QgsAttributeTableDisplay( QgsVectorLayer* layer )
-    : QDialog( 0, Qt::Window ),
-    mLayer( layer ),
-    mDock( NULL )
-{
-  setupUi( this );
-  restorePosition();
-  setTheme();
-
-  mToggleEditingButton->setEnabled( layer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
-  mToggleEditingButton->setChecked( layer->isEditable() );
-
-  connect( mRemoveSelectionButton, SIGNAL( clicked() ), this, SLOT( removeSelection() ) );
-  connect( mSelectedToTopButton, SIGNAL( clicked() ), this, SLOT( selectedToTop() ) );
-  connect( mInvertSelectionButton, SIGNAL( clicked() ), this, SLOT( invertSelection() ) );
-  connect( mCopySelectedRowsButton, SIGNAL( clicked() ), this, SLOT( copySelectedRowsToClipboard() ) );
-  connect( mZoomMapToSelectedRowsButton, SIGNAL( clicked() ), this, SLOT( zoomMapToSelectedRows() ) );
-  connect( mSearchButton, SIGNAL( clicked() ), this, SLOT( search() ) );
-  connect( mSearchShowResults, SIGNAL( activated( int ) ), this, SLOT( searchShowResultsChanged( int ) ) );
-  connect( btnAdvancedSearch, SIGNAL( clicked() ), this, SLOT( advancedSearch() ) );
-  connect( buttonBox, SIGNAL( helpRequested() ), this, SLOT( showHelp() ) );
-  connect( buttonBox->button( QDialogButtonBox::Close ), SIGNAL( clicked() ), this, SLOT( close() ) );
-
-  connect( mToggleEditingButton, SIGNAL( clicked() ), this, SLOT( toggleEditing() ) );
-  connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
-
-  // establish connection to table
-  connect( tblAttributes, SIGNAL( cellChanged( int, int ) ), this, SLOT( changeFeatureAttribute( int, int ) ) );
-
-  // establish connections to layer
-  connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
-
-  connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
-
-  connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
-  connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
-
-  connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( attributeAdded( int ) ) );
-  connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( attributeDeleted( int ) ) );
-
-  connect( mLayer, SIGNAL( attributeValueChanged( int, int, const QVariant & ) ),
-           tblAttributes, SLOT( attributeValueChanged( int, int, const QVariant & ) ) );
-
-  connect( mLayer, SIGNAL( featureDeleted( int ) ),
-           tblAttributes, SLOT( featureDeleted( int ) ) );
-
-  // establish connections between table and vector layer
-  connect( tblAttributes, SIGNAL( selected( int, bool ) ), mLayer, SLOT( select( int, bool ) ) );
-  connect( tblAttributes, SIGNAL( selectionRemoved( bool ) ), mLayer, SLOT( removeSelection( bool ) ) );
-  connect( tblAttributes, SIGNAL( repaintRequested() ), mLayer, SLOT( triggerRepaint() ) );
-
-  // fill in mSearchColumns with available columns
-  const QgsFieldMap& xfields = mLayer->pendingFields();
-  QgsFieldMap::const_iterator fldIt;
-  for ( fldIt = xfields.constBegin(); fldIt != xfields.constEnd(); ++fldIt )
-  {
-    mSearchColumns->addItem( fldIt->name() );
-  }
-
-  // TODO: create better labels
-  mSearchShowResults->addItem( tr( "select" ) );
-  mSearchShowResults->addItem( tr( "select and bring to top" ) );
-  mSearchShowResults->addItem( tr( "show only matching" ) );
-
-  QSettings mySettings;
-  bool myDockFlag = mySettings.value( "/qgis/dockAttributeTable", false ).toBool();
-  if ( myDockFlag )
-  {
-    mDock = new QAttributeTableDock( tr( "Attribute table - %1" ).arg( layer->name() ), QgisApp::instance() );
-    mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea );
-    mDock->setWidget( this );
-    QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
-    buttonBox->setVisible( false );
-  }
-
-  setWindowTitle( tr( "Attribute table - %1" ).arg( layer->name() ) );
-
-#ifdef Q_WS_MAC
-  if ( !myDockFlag )
-  {
-    QMenuBar *menuBar = new QMenuBar( this );
-
-    QMenu *appMenu = menuBar->addMenu( tr( "QGIS" ) );
-    appMenu->addAction( QgisApp::instance()->actionAbout() );
-    appMenu->addAction( QgisApp::instance()->actionOptions() );
-
-    QMenu *fileMenu = menuBar->addMenu( tr( "File" ) );
-    QAction *closeAction = fileMenu->addAction( tr( "Close" ), this, SLOT( close() ), tr( "Ctrl+W" ) );
-
-    QMenu *editMenu = menuBar->addMenu( tr( "Edit" ) );
-    QAction *undoAction = editMenu->addAction( tr( "&Undo" ), this, SLOT( undo() ), tr( "Ctrl+Z" ) );
-    undoAction->setEnabled( false );
-    editMenu->addSeparator();
-    QAction *cutAction = editMenu->addAction( tr( "Cu&t" ), this, SLOT( cut() ), tr( "Ctrl+X" ) );
-    cutAction->setEnabled( false );
-    QAction *copyAction = editMenu->addAction(
-                            mCopySelectedRowsButton->icon(), tr( "&Copy" ), this, SLOT( copySelectedRowsToClipboard() ), tr( "Ctrl+C" ) );
-    QAction *pasteAction = editMenu->addAction( tr( "&Paste" ), this, SLOT( paste() ), tr( "Ctrl+V" ) );
-    pasteAction->setEnabled( false );
-    QAction *deleteAction = editMenu->addAction(
-                              mRemoveSelectionButton->icon(), tr( "Delete" ), this, SLOT( removeSelection() ) );
-
-    QMenu *layerMenu = menuBar->addMenu( tr( "Layer" ) );
-    QAction *zoomToSelectedAction = layerMenu->addAction(
-                                      mZoomMapToSelectedRowsButton->icon(), tr( "Zoom to Selection" ), this, SLOT( zoomMapToSelectedRows() ), tr( "Ctrl+J" ) );
-    layerMenu->addSeparator();
-    QAction *toggleEditingAction = layerMenu->addAction(
-                                     mToggleEditingButton->icon(), tr( "Toggle Editing" ), this, SLOT( toggleEditing() ) );
-    toggleEditingAction->setEnabled( mToggleEditingButton->isEnabled() );
-    toggleEditingAction->setCheckable( true );
-    toggleEditingAction->setChecked( mToggleEditingButton->isChecked() );
-    connect( mToggleEditingButton, SIGNAL( toggled( bool ) ), toggleEditingAction, SLOT( setChecked( bool ) ) );
-
-    QMenu *tableMenu = menuBar->addMenu( tr( "Table" ) );
-    QAction *moveToTopAction = tableMenu->addAction(
-                                 mSelectedToTopButton->icon(), tr( "Move to Top" ), this, SLOT( selectedToTop() ) );
-    QAction *invertAction = tableMenu->addAction(
-                              mInvertSelectionButton->icon(), tr( "Invert" ), this, SLOT( invertSelection() ) );
-
-#ifndef Q_WS_MAC64 /* assertion failure in NSMenuItem setSubmenu (Qt 4.5.0-snapshot-20080830) */
-    menuBar->addMenu( QgisApp::instance()->windowMenu() );
-
-    menuBar->addMenu( QgisApp::instance()->helpMenu() );
-#endif
-
-    // Create action to select this window and add it to Window menu
-    mWindowAction = new QAction( windowTitle(), this );
-    connect( mWindowAction, SIGNAL( triggered() ), this, SLOT( activate() ) );
-    QgisApp::instance()->addWindow( mWindowAction );
-  }
-#endif
-}
-
-QgsAttributeTableDisplay::~QgsAttributeTableDisplay()
-{
-  smTables.remove( mLayer );
-}
-
-#ifdef Q_WS_MAC
-void QgsAttributeTableDisplay::changeEvent( QEvent* event )
-{
-  QDialog::changeEvent( event );
-  switch ( event->type() )
-  {
-    case QEvent::ActivationChange:
-      if ( QApplication::activeWindow() == this )
-      {
-        mWindowAction->setChecked( true );
-      }
-      break;
-
-    default:
-      break;
-  }
-}
-#endif
-
-void QgsAttributeTableDisplay::closeEvent( QCloseEvent *ev )
-{
-  QDialog::closeEvent( ev );
-
-  if ( mDock == NULL )
-    saveWindowLocation();
-
-  deleteLater();
-}
-
-void QgsAttributeTableDisplay::fillTable()
-{
-  tblAttributes->fillTable( mLayer );
-  tblAttributes->setReadOnly( !mLayer->isEditable() );
-
-  selectionChanged();
-
-  // Give the table the most recent copy of the actions for this layer.
-  setAttributeActions( *mLayer->actions() );
-}
-
-void QgsAttributeTableDisplay::toggleEditing()
-{
-  emit editingToggled( mLayer );
-}
-
-void QgsAttributeTableDisplay::setAttributeActions( const QgsAttributeAction &action )
-{
-  tblAttributes->setAttributeActions( action );
-}
-
-void QgsAttributeTableDisplay::selectRowsWithId( const QgsFeatureIds &ids )
-{
-  tblAttributes->selectRowsWithId( ids, mLayer );
-}
-
-void QgsAttributeTableDisplay::setTheme()
-{
-  mRemoveSelectionButton->setIcon( QgisApp::getThemeIcon( "/mActionUnselectAttributes.png" ) );
-  mSelectedToTopButton->setIcon( QgisApp::getThemeIcon( "/mActionSelectedToTop.png" ) );
-  mInvertSelectionButton->setIcon( QgisApp::getThemeIcon( "/mActionInvertSelection.png" ) );
-  mCopySelectedRowsButton->setIcon( QgisApp::getThemeIcon( "/mActionCopySelected.png" ) );
-  mZoomMapToSelectedRowsButton->setIcon( QgisApp::getThemeIcon( "/mActionZoomToSelected.png" ) );
-  mToggleEditingButton->setIcon( QgisApp::getThemeIcon( "/mActionToggleEditing.png" ) );
-}
-
-void QgsAttributeTableDisplay::editingToggled()
-{
-  mToggleEditingButton->setChecked( mLayer->isEditable() );
-  tblAttributes->setReadOnly( !mLayer->isEditable() );
-}
-
-void QgsAttributeTableDisplay::selectedToTop()
-{
-  tblAttributes->bringSelectedToTop();
-}
-
-void QgsAttributeTableDisplay::invertSelection()
-{
-  if ( !mLayer )
-    return;
-
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-  mLayer->invertSelection();
-  QApplication::restoreOverrideCursor();
-}
-
-void QgsAttributeTableDisplay::removeSelection()
-{
-  tblAttributes->clearSelection();
-  mLayer->triggerRepaint();
-}
-
-void QgsAttributeTableDisplay::copySelectedRowsToClipboard()
-{
-  QgisApp::instance()->editCopy( mLayer );
-}
-
-void QgsAttributeTableDisplay::zoomMapToSelectedRows()
-{
-  QgisApp::instance()->zoomToSelected();
-}
-
-void QgsAttributeTableDisplay::search()
-{
-  if ( tblAttributes->rowCount() == 0 )
-    return;
-
-  int type = tblAttributes->item( 0, mSearchColumns->currentIndex() )->data( QgsAttributeTable::AttributeType ).toInt();
-  bool numeric = ( type == QVariant::Int || type == QVariant::Double );
-
-  QString str;
-  str = mSearchColumns->currentText();
-  if ( numeric )
-    str += " = '";
-  else
-    str += " ~ '";
-  str += mSearchText->text();
-  str += "'";
-
-  doSearch( str );
-}
-
-
-void QgsAttributeTableDisplay::advancedSearch()
-{
-  QgsSearchQueryBuilder dlg( mLayer, this );
-  dlg.setSearchString( mSearchString );
-  if ( dlg.exec() )
-  {
-    doSearch( dlg.searchString() );
-  }
-}
-
-
-void QgsAttributeTableDisplay::searchShowResultsChanged( int item )
-{
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-
-  if ( item == 2 ) // show only matching
-  {
-    tblAttributes->showRowsWithId( mSearchIds );
-  }
-  else
-  {
-    // make sure that all rows are shown
-    tblAttributes->showAllRows();
-
-    // select matching
-    mLayer->setSelectedFeatures( mSearchIds );
-
-    if ( item == 1 ) // select matching and bring to top
-      tblAttributes->bringSelectedToTop();
-  }
-
-  QApplication::restoreOverrideCursor();
-}
-
-
-void QgsAttributeTableDisplay::doSearch( QString searchString )
-{
-  mSearchString = searchString;
-
-  // parse search string (and build parsed tree)
-  QgsSearchString search;
-  if ( !search.setString( searchString ) )
-  {
-    QMessageBox::critical( this, tr( "Search string parsing error" ), search.parserErrorMsg() );
-    return;
-  }
-
-  QgsSearchTreeNode* searchTree = search.tree();
-  if ( searchTree == NULL )
-  {
-    QMessageBox::information( this, tr( "Search results" ), tr( "You've supplied an empty search string." ) );
-    return;
-  }
-
-  QgsDebugMsg( "Search by attribute: " + searchString + " parsed as: " + search.tree()->makeSearchString() );
-
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-
-  mSearchIds.clear();
-
-  mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false );
-
-  QgsFeature f;
-  while ( mLayer->nextFeature( f ) )
-  {
-    if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
-    {
-      mSearchIds << f.id();
-    }
-
-    // check if there were errors during evaluating
-    if ( searchTree->hasError() )
-      break;
-  }
-
-  QApplication::restoreOverrideCursor();
-
-  if ( searchTree->hasError() )
-  {
-    QMessageBox::critical( this, tr( "Error during search" ), searchTree->errorMsg() );
-    return;
-  }
-
-  // update table
-  searchShowResultsChanged( mSearchShowResults->currentIndex() );
-
-  QMessageBox::information( this, tr( "Search results" ), tr( "Found %n matching feature(s).", "search results", mSearchIds.size() ) );
-}
-
-void QgsAttributeTableDisplay::restorePosition()
-{
-  QSettings settings;
-  restoreGeometry( settings.value( "/Windows/AttributeTable/geometry" ).toByteArray() );
-}
-
-void QgsAttributeTableDisplay::saveWindowLocation()
-{
-  QSettings settings;
-  settings.setValue( "/Windows/AttributeTable/geometry", saveGeometry() );
-}
-
-void QgsAttributeTableDisplay::showHelp()
-{
-  QgsContextHelp::run( context_id );
-}
-
-void QgsAttributeTableDisplay::changeFeatureAttribute( int row, int column )
-{
-  if ( column == 0 )
-    return;
-
-  if ( !mLayer->isEditable() )
-    return;
-
-  mLayer->changeAttributeValue(
-    tblAttributes->item( row, 0 )->text().toInt(),
-    tblAttributes->horizontalHeaderItem( column )->data( QgsAttributeTable::AttributeIndex ).toInt(),
-    tblAttributes->item( row, column )->text(),
-    false
-  );
-}
-
-QMap<QgsVectorLayer *, QgsAttributeTableDisplay *> QgsAttributeTableDisplay::smTables;
-
-QgsAttributeTableDisplay *QgsAttributeTableDisplay::attributeTable( QgsVectorLayer *layer )
-{
-  if ( !layer )
-    return NULL;
-
-  if ( smTables.contains( layer ) )
-  {
-    QgsAttributeTableDisplay *td = smTables[layer];
-    td->setAttributeActions( *layer->actions() );
-    td->activate();
-
-    return td;
-  }
-
-  QgsAttributeTableDisplay *td = new QgsAttributeTableDisplay( layer );
-  if ( !td )
-    return NULL;
-
-  // display the attribute table
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-
-  try
-  {
-    td->fillTable();
-  }
-  catch ( std::bad_alloc& ba )
-  {
-    Q_UNUSED( ba );
-    QMessageBox::critical( 0, tr( "bad_alloc exception" ), tr( "Filling the attribute table has been stopped because there was no more virtual memory left" ) );
-    delete td;
-    td = NULL;
-  }
-
-  QApplication::restoreOverrideCursor();
-
-  if ( !td )
-    return NULL;
-
-  smTables[layer] = td;
-  td->show();
-
-  return td;
-}
-
-void QgsAttributeTableDisplay::activate()
-{
-  raise();
-  setWindowState( windowState() & ~Qt::WindowMinimized );
-  activateWindow();
-}
-
-void QgsAttributeTableDisplay::selectionChanged()
-{
-  // select rows which should be selected
-  selectRowsWithId( mLayer->selectedFeaturesIds() );
-}
-
-void QgsAttributeTableDisplay::attributeAdded( int attr )
-{
-  tblAttributes->addAttribute( attr, mLayer->pendingFields()[attr] );
-}
-
-void QgsAttributeTableDisplay::attributeDeleted( int attr )
-{
-  tblAttributes->deleteAttribute( attr );
-}

Deleted: trunk/qgis/src/app/qgsattributetabledisplay.h
===================================================================
--- trunk/qgis/src/app/qgsattributetabledisplay.h	2009-04-13 00:42:05 UTC (rev 10549)
+++ trunk/qgis/src/app/qgsattributetabledisplay.h	2009-04-13 09:10:22 UTC (rev 10550)
@@ -1,111 +0,0 @@
-/***************************************************************************
-                          qgsattributetabledisplay.h  -  description
-                             -------------------
-    begin                : Sat Nov 23 2002
-    copyright            : (C) 2002 by Gary E.Sherman
-    email                : sherman at mrcc dot com
-        Romans 3:23=>Romans 6:23=>Romans 5:8=>Romans 10:9,10=>Romans 12
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id$ */
-
-#ifndef QGSATTRIBUTETABLEDISPLAY_H
-#define QGSATTRIBUTETABLEDISPLAY_H
-
-#include "ui_qgsattributetablebase.h"
-
-class QDockWidget;
-class QgsAttributeTable;
-class QgsVectorLayer;
-class QgisApp;
-class QgsAttributeActions;
-
-/**
-  *@author Gary E.Sherman
-  */
-
-class QgsAttributeTableDisplay : public QDialog, private Ui::QgsAttributeTableBase
-{
-    Q_OBJECT
-  public:
-    static QgsAttributeTableDisplay *attributeTable( QgsVectorLayer *layer );
-
-    ~QgsAttributeTableDisplay();
-
-    void fillTable();
-
-  protected:
-    QgsAttributeTableDisplay( QgsVectorLayer* layer );
-
-    QgsVectorLayer* mLayer;
-
-    void doSearch( QString searchString );
-    void setAttributeActions( const QgsAttributeAction &actions );
-    void selectRowsWithId( const QgsFeatureIds &ids );
-
-#ifdef Q_WS_MAC
-    //! Change event (update window menu on ActivationChange)
-    virtual void changeEvent( QEvent *event );
-#endif
-
-    virtual void closeEvent( QCloseEvent *ev );
-
-    /** array of feature IDs that match last searched condition */
-    QgsFeatureIds mSearchIds;
-
-  protected slots:
-    void selectedToTop();
-    void invertSelection();
-    void removeSelection();
-    void copySelectedRowsToClipboard();
-    void zoomMapToSelectedRows();
-    void search();
-    void advancedSearch();
-    void searchShowResultsChanged( int item );
-    void showHelp();
-    void toggleEditing();
-
-    void attributeAdded( int idx );
-    void attributeDeleted( int idx );
-
-  public slots:
-    void changeFeatureAttribute( int row, int column );
-    void editingToggled();
-    void selectionChanged();
-
-  signals:
-    void editingToggled( QgsMapLayer * );
-
-  private slots:
-    void activate();
-
-  private:
-    /** Set the icon theme for this dialog */
-    void setTheme();
-
-    void restorePosition();
-    void saveWindowLocation();
-
-#ifdef Q_WS_MAC
-    /** Window menu action to select this window */
-    QAction *mWindowAction;
-#endif
-
-    QString mSearchString;
-
-    QDockWidget *mDock;
-
-    static const int context_id = 831088384;
-
-    static QMap<QgsVectorLayer *, QgsAttributeTableDisplay *> smTables;
-};
-
-#endif



More information about the QGIS-commit mailing list