8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ IF (WITH_GRASS)
SET (GRASS_PREFIX ${GRASS_PREFIX} CACHE PATH "Path to GRASS base directory")
ENDIF (WITH_GRASS)

SET (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")

# mapserver by us disabled default because it needs FastCGI (which is optional dependency)
SET (WITH_MAPSERVER FALSE CACHE BOOL "Determines whether QGIS mapserver should be built")

Expand Down Expand Up @@ -134,8 +136,6 @@ ENDIF(NOT WIN32 AND NOT ANDROID)

# required
FIND_PACKAGE(Proj)
FIND_PACKAGE(Expat) # GPS importer plugin
FIND_PACKAGE(GSL) # Georeferencer
FIND_PACKAGE(GEOS)
FIND_PACKAGE(GDAL)

Expand Down Expand Up @@ -186,7 +186,9 @@ SET(QT_USE_QTXML 1)
SET(QT_USE_QTNETWORK 1)
SET(QT_USE_QTSVG 1)
SET(QT_USE_QTSQL 1)
SET(QT_USE_QTWEBKIT 1)
IF(WITH_DESKTOP)
SET(QT_USE_QTWEBKIT 1)
ENDIF(WITH_DESKTOP)

IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND)
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
Expand Down
1 change: 1 addition & 0 deletions cmake_templates/qgsconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define QGIS_LIBEXEC_SUBDIR "${QGIS_LIBEXEC_SUBDIR}"
#define QGIS_LIB_SUBDIR "${QGIS_LIB_SUBDIR}"
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}"

#cmakedefine HAVE_POSTGRESQL

Expand Down
3 changes: 3 additions & 0 deletions python/core/qgsfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class QgsFeature
{
%TypeHeaderCode
#include <qgsfeature.h>
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End

public:
Expand Down
11 changes: 7 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(analysis)
ADD_SUBDIRECTORY(ui)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(app)
ADD_SUBDIRECTORY(providers)
ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(helpviewer)
ADD_SUBDIRECTORY(crssync)
ADD_SUBDIRECTORY(browser)

IF (WITH_DESKTOP)
ADD_SUBDIRECTORY(app)
ADD_SUBDIRECTORY(helpviewer)
ADD_SUBDIRECTORY(browser)
ADD_SUBDIRECTORY(plugins)
ENDIF(WITH_DESKTOP)

IF (WITH_BINDINGS)
ADD_SUBDIRECTORY(python)
Expand Down
61 changes: 43 additions & 18 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,23 @@ class QgsAttributeTableDock : public QDockWidget


QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFlags flags )
: QDialog( parent, flags ), mDock( NULL )
: QDialog( parent, flags ), mDock( 0 ), mLayer( theLayer ), mProgress( 0 ), mWorkaround( false )
{
mLayer = theLayer;

setupUi( this );

setAttribute( Qt::WA_DeleteOnClose );

QSettings settings;
restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

// extent has to be set before the model is created
QgsAttributeTableModel::setCurrentExtent( QgisApp::instance()->mapCanvas()->extent() );
connect( QgisApp::instance()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( updateExtent() ) );
mView->setCanvasAndLayer( QgisApp::instance()->mapCanvas(), mLayer );

mView->setLayer( mLayer );
mFilterModel = ( QgsAttributeTableFilterModel * ) mView->model();
mModel = ( QgsAttributeTableModel * )(( QgsAttributeTableFilterModel * )mView->model() )->sourceModel();
mModel = qobject_cast<QgsAttributeTableModel * >( dynamic_cast<QgsAttributeTableFilterModel *>( mView->model() )->sourceModel() );

connect( mModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
mModel->loadLayer();
delete mProgress;

mQuery = query;
mColumnBox = columnBox;
Expand Down Expand Up @@ -127,20 +126,21 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
// info from layer to table
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );
connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );

connect( searchButton, SIGNAL( clicked() ), this, SLOT( search() ) );
connect( mAddFeature, SIGNAL( clicked() ), this, SLOT( addFeature() ) );

connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );
connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
connect( mView->verticalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( updateRowSelection( int ) ) );
connect( mView->verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( updateRowPressed( int ) ) );

connect( mModel, SIGNAL( modelChanged() ), this, SLOT( updateSelection() ) );

connect( mView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );

mLastClickedHeaderIndex = 0;
mSelectionModel = new QItemSelectionModel( mFilterModel );
mSelectionModel = new QItemSelectionModel( mFilterModel, this );
updateSelectionFromLayer();

//make sure to show all recs on first load
Expand All @@ -149,7 +149,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid

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

void QgsAttributeTableDialog::updateTitle()
Expand Down Expand Up @@ -797,12 +796,6 @@ void QgsAttributeTableDialog::addFeature()
}
}

void QgsAttributeTableDialog::updateExtent()
{
// let the model know about the new extent (we may be showing only features from current extent)
QgsAttributeTableModel::setCurrentExtent( QgisApp::instance()->mapCanvas()->extent() );
}

void QgsAttributeTableDialog::viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex )
{
QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );
Expand All @@ -829,6 +822,38 @@ void QgsAttributeTableDialog::viewWillShowContextMenu( QMenu* menu, QModelIndex
menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
}

void QgsAttributeTableDialog::progress( int i, bool &cancel )
{
if ( !mProgress )
{
mProgress = new QProgressDialog( tr( "Loading feature attributes..." ), tr( "Abort" ), 0, 0, this );
mProgress->setWindowTitle( tr( "Attribute table" ) );
mProgress->setWindowModality( Qt::WindowModal );
mStarted.start();
}

mProgress->setValue( i );

if ( i > 0 && i % 1000 == 0 )
{
mProgress->setLabelText( tr( "%1 features loaded." ).arg( i ) );
}

if ( !mProgress->isVisible() && mStarted.elapsed() > mProgress->minimumDuration()*5 / 4 )
{
// for some reason this is sometimes necessary
mProgress->show();
mWorkaround = true;
}

if ( mWorkaround )
{
QCoreApplication::processEvents();
}

cancel = mProgress->wasCanceled();
}

void QgsAttributeTableAction::execute()
{
mModel->executeAction( mAction, mFieldIdx );
Expand Down
15 changes: 9 additions & 6 deletions src/app/qgsattributetabledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <QDialog>
#include <QModelIndex>
#include <QItemSelectionModel>
#include <QMutex>

#include <time.h>

#include "ui_qgsattributetabledialog.h"
#include "qgscontexthelp.h"
Expand All @@ -33,6 +34,7 @@ class QLineEdit;
class QComboBox;
class QMenu;
class QDockWidget;
class QProgressDialog;

class QgsAttributeTableModel;
class QgsAttributeTableFilterModel;
Expand All @@ -58,10 +60,10 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
*/
void editingToggled();

void updateExtent();

void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );

void progress( int i, bool &cancel );

private slots:
/**
* submits the data
Expand Down Expand Up @@ -208,21 +210,22 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia

QLineEdit *mQuery;
QComboBox *mColumnBox;
QComboBox *mShowBox;

QMenu* mMenuActions;
QAction* mActionToggleEditing;

QgsAttributeTableModel *mModel;
QgsAttributeTableFilterModel *mFilterModel;
QDockWidget *mDock;
QgsVectorLayer *mLayer;
QProgressDialog *mProgress;
QTime mStarted;
bool mWorkaround;
QgsFeatureIds mSelectedFeatures;
int mIndexPressed;

QItemSelectionModel* mSelectionModel;
int mLastClickedHeaderIndex;

QDockWidget *mDock;
};


Expand Down
11 changes: 7 additions & 4 deletions src/browser/qgsbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#include "qgsvectorlayer.h"
#include "qgsrasterlayer.h"
#include "qgsnewvectorlayerdialog.h"

#include "qgsattributetablemodel.h"
#include "qgsattributetablefiltermodel.h"

QgsBrowser::QgsBrowser( QWidget *parent, Qt::WFlags flags )
: QMainWindow( parent, flags )
Expand Down Expand Up @@ -114,7 +115,8 @@ void QgsBrowser::itemClicked( const QModelIndex& index )
mDirtyAttributes = true;

// clear the previous stuff
attributeTable->setLayer( NULL );
attributeTable->setCanvasAndLayer( 0, 0 );

QList<QgsMapCanvasLayer> nolayers;
mapCanvas->setLayerSet( nolayers );
metaTextBrowser->clear();
Expand Down Expand Up @@ -478,12 +480,13 @@ void QgsBrowser::updateCurrentTab()
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayer );
QApplication::setOverrideCursor( Qt::WaitCursor );
attributeTable->setLayer( vlayer );
attributeTable->setCanvasAndLayer( mapCanvas, vlayer );
qobject_cast<QgsAttributeTableModel * >( dynamic_cast<QgsAttributeTableFilterModel *>( attributeTable->model() )->sourceModel() )->loadLayer();
QApplication::restoreOverrideCursor();
}
else
{
attributeTable->setLayer( NULL );
attributeTable->setCanvasAndLayer( 0, 0 );
}
mDirtyAttributes = false;
}
Expand Down
Loading