Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improvements for merge tool. Show a progress dialog during the merge …
…and make the item showing the attribute values after the merge editable

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10943 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 17, 2009
1 parent 5312471 commit e43495f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -53,6 +53,7 @@
#include <QPrinter>
#include <QProcess>
#include <QProgressBar>
#include <QProgressDialog>
#include <QRegExp>
#include <QRegExpValidator>
#include <QSettings>
Expand Down Expand Up @@ -4139,7 +4140,7 @@ void QgisApp::deletePart()
mMapCanvas->setMapTool( mMapTools.mDeletePart );
}

QgsGeometry* QgisApp::unionGeometries(const QgsVectorLayer* vl, QgsFeatureList& featureList) const
QgsGeometry* QgisApp::unionGeometries(const QgsVectorLayer* vl, QgsFeatureList& featureList)
{
if(!vl || featureList.size() < 2)
{
Expand All @@ -4153,8 +4154,20 @@ QgsGeometry* QgisApp::unionGeometries(const QgsVectorLayer* vl, QgsFeatureList&
return 0;
}

QProgressDialog progress(tr("Merging features..."), tr("Abort"), 0, featureList.size(), this);
progress.setWindowModality(Qt::WindowModal);

QApplication::setOverrideCursor( Qt::WaitCursor );

for(int i = 1; i < featureList.size(); ++i)
{
if(progress.wasCanceled())
{
delete unionGeom;
QApplication::restoreOverrideCursor();
return 0;
}
progress.setValue(i);
QgsGeometry* currentGeom = featureList[i].geometry();
if(currentGeom)
{
Expand All @@ -4167,6 +4180,9 @@ QgsGeometry* QgisApp::unionGeometries(const QgsVectorLayer* vl, QgsFeatureList&
}
}
}

QApplication::restoreOverrideCursor();
progress.setValue(featureList.size());
return unionGeom;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -667,7 +667,7 @@ class QgisApp : public QMainWindow
bool saveDirty();
/** Helper function to union several geometries together (used in function mergeSelectedFeatures)
@return 0 in case of error*/
QgsGeometry* unionGeometries(const QgsVectorLayer* vl, QgsFeatureList& featureList) const;
QgsGeometry* unionGeometries(const QgsVectorLayer* vl, QgsFeatureList& featureList);

/// QgisApp aren't copyable
QgisApp( QgisApp const & );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -248,7 +248,7 @@ void QgsMergeAttributesDialog::refreshMergedValue(int col)

//insert string into table widget
QTableWidgetItem* newTotalItem = new QTableWidgetItem(evalText);
newTotalItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
newTotalItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
mTableWidget->setItem(mTableWidget->rowCount() - 1, col, newTotalItem);
}

Expand Down

0 comments on commit e43495f

Please sign in to comment.