featureid.diff
python/core/conversions.sip (working copy) | ||
---|---|---|
4 | 4 |
- QVector< QVector<TYPE> > |
5 | 5 |
- QVector< QVector< QVector<TYPE> > > |
6 | 6 |
- QSet<int> |
7 |
- QSet<qint64> |
|
7 | 8 |
- QSet<TYPE> |
8 |
- QMap<int, QMap<int, TYPE> >
|
|
9 |
- QMap<qint64, QMap<int, TYPE> >
|
|
9 | 10 |
- QMap<QString, QVariant::Type> |
10 | 11 |
- QMap<TYPE1, TYPE2*> |
11 | 12 |
- QMultiMap<double, TYPE2> |
... | ... | |
221 | 222 | |
222 | 223 |
}; |
223 | 224 | |
225 |
%MappedType QSet<qint64> |
|
226 |
{ |
|
227 |
%TypeHeaderCode |
|
228 |
#include <QSet> |
|
229 |
%End |
|
224 | 230 | |
231 |
%ConvertFromTypeCode |
|
232 |
// Create the list. |
|
233 |
PyObject *l; |
|
234 | ||
235 |
if ((l = PyList_New(sipCpp->size())) == NULL) |
|
236 |
return NULL; |
|
237 |
|
|
238 |
// Set the list elements. |
|
239 |
QSet<qint64>::iterator it = sipCpp->begin(); |
|
240 |
for (int i = 0; it != sipCpp->end(); ++it, ++i) |
|
241 |
{ |
|
242 |
PyObject *tobj; |
|
243 | ||
244 |
if ((tobj = PyLong_FromLongLong(*it)) == NULL) |
|
245 |
{ |
|
246 |
Py_DECREF(l); |
|
247 |
return NULL; |
|
248 |
} |
|
249 |
PyList_SET_ITEM(l, i, tobj); |
|
250 |
} |
|
251 | ||
252 |
return l; |
|
253 |
%End |
|
254 | ||
255 |
%ConvertToTypeCode |
|
256 |
// Check the type if that is all that is required. |
|
257 |
if (sipIsErr == NULL) |
|
258 |
return PyList_Check(sipPy); |
|
259 | ||
260 |
QSet<qint64> *qset = new QSet<qint64>; |
|
261 | ||
262 |
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) |
|
263 |
{ |
|
264 |
qset->insert(PyLong_AsLongLong(PyList_GET_ITEM(sipPy, i))); |
|
265 |
} |
|
266 | ||
267 |
*sipCppPtr = qset; |
|
268 |
return sipGetState(sipTransferObj); |
|
269 |
%End |
|
270 | ||
271 |
}; |
|
272 | ||
273 | ||
225 | 274 |
template <TYPE> |
226 | 275 |
%MappedType QSet<TYPE> |
227 | 276 |
{ |
... | ... | |
289 | 338 |
*sipCppPtr = qset; |
290 | 339 |
return sipGetState(sipTransferObj); |
291 | 340 |
%End |
292 | ||
293 | 341 |
}; |
294 | 342 | |
295 | ||
296 | ||
297 | 343 |
template<TYPE> |
298 |
%MappedType QMap<int, QMap<int, TYPE> >
|
|
344 |
%MappedType QMap<qint64, QMap<int, TYPE> >
|
|
299 | 345 |
{ |
300 | 346 |
%TypeHeaderCode |
347 |
#include <QtGlobal> |
|
301 | 348 |
#include <QMap> |
302 | 349 |
%End |
303 | 350 | |
... | ... | |
311 | 358 |
const sipMappedType* qmap2 = sipFindMappedType("QMap<int, TYPE>"); |
312 | 359 |
|
313 | 360 |
// Set the list elements. |
314 |
for (QMap<int, QMap<int, TYPE> >::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)
|
|
361 |
for (QMap<qint64, QMap<int, TYPE> >::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)
|
|
315 | 362 |
{ |
316 | 363 |
QMap<int, TYPE>* t = new QMap<int, TYPE>(*it); |
317 | 364 |
|
318 |
PyObject *kobj = PyInt_FromLong(it.key());
|
|
365 |
PyObject *kobj = PyLong_FromLongLong(it.key());
|
|
319 | 366 |
PyObject *tobj = sipConvertFromMappedType(t, qmap2, sipTransferObj); |
320 | 367 | |
321 | 368 |
if (kobj == NULL || tobj == NULL || PyDict_SetItem(d, kobj, tobj) < 0) |
... | ... | |
372 | 419 |
return 1; |
373 | 420 |
} |
374 | 421 |
|
375 |
QMap<int, QMap<int, TYPE> > *qm = new QMap<int, QMap<int, TYPE> >;
|
|
422 |
QMap<qint64, QMap<int, TYPE> > *qm = new QMap<qint64, QMap<int, TYPE> >;
|
|
376 | 423 |
|
377 | 424 | |
378 | 425 |
Py_ssize_t i = 0; |
379 | 426 |
while (PyDict_Next(sipPy, &i, &kobj, &tobj)) |
380 | 427 |
{ |
381 |
int k = PyInt_AsLong(kobj);
|
|
428 |
qint64 k = PyLong_AsLongLong(kobj);
|
|
382 | 429 |
|
383 | 430 |
// using sipConvertToMappedType to convert directly to QMap<int, TYPE> doesn't work |
384 | 431 |
// and ends with a segfault |
... | ... | |
409 | 456 |
*sipCppPtr = qm; |
410 | 457 |
return sipGetState(sipTransferObj); |
411 | 458 |
%End |
459 |
}; |
|
412 | 460 | |
461 |
%MappedType QMap<qint64, QgsGeometry> |
|
462 |
{ |
|
463 |
%TypeHeaderCode |
|
464 |
#include <QMap> |
|
465 |
%End |
|
466 | ||
467 |
%ConvertFromTypeCode |
|
468 |
// Create the list. |
|
469 |
PyObject *d; |
|
470 | ||
471 |
if ((d = PyDict_New()) == NULL) |
|
472 |
return NULL; |
|
473 |
|
|
474 |
// Set the list elements. |
|
475 |
for (QMap<qint64, QgsGeometry>::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it) |
|
476 |
{ |
|
477 |
PyObject *kobj = PyLong_FromLongLong(it.key()); |
|
478 |
PyObject *tobj = sipConvertFromInstance( &it.value(), sipClass_QgsGeometry, sipTransferObj); |
|
479 | ||
480 |
if (kobj == NULL || tobj == NULL || PyDict_SetItem(d, kobj, tobj) < 0) |
|
481 |
{ |
|
482 |
Py_DECREF(d); |
|
483 | ||
484 |
if (kobj) |
|
485 |
{ |
|
486 |
Py_DECREF(kobj); |
|
487 |
} |
|
488 |
|
|
489 |
if (tobj) |
|
490 |
{ |
|
491 |
Py_DECREF(tobj); |
|
492 |
} |
|
493 | ||
494 |
return NULL; |
|
495 |
} |
|
496 |
|
|
497 |
Py_DECREF(tobj); |
|
498 |
} |
|
499 | ||
500 |
return d; |
|
501 |
%End |
|
502 | ||
503 |
%ConvertToTypeCode |
|
504 |
PyObject *kobj, *tobj; |
|
505 | ||
506 |
// Check the type if that is all that is required. |
|
507 |
if (sipIsErr == NULL) |
|
508 |
{ |
|
509 |
if (!PyDict_Check(sipPy)) |
|
510 |
return 0; |
|
511 | ||
512 |
Py_ssize_t i = 0; |
|
513 |
while (PyDict_Next(sipPy, &i, &kobj, &tobj)) |
|
514 |
{ |
|
515 |
if (!PyDict_Check(tobj)) |
|
516 |
return 0; |
|
517 |
|
|
518 |
if (!sipCanConvertToInstance(tobj, sipClass_QgsGeometry, SIP_NOT_NONE)) |
|
519 |
return 0; |
|
520 |
} |
|
521 |
return 1; |
|
522 |
} |
|
523 |
|
|
524 |
QMap<qint64, QgsGeometry> *qm = new QMap<qint64, QgsGeometry>; |
|
525 | ||
526 |
Py_ssize_t i = 0; |
|
527 |
while (PyDict_Next(sipPy, &i, &kobj, &tobj)) |
|
528 |
{ |
|
529 |
int state; |
|
530 |
qint64 k = PyLong_AsLongLong(kobj); |
|
531 |
QgsGeometry * fa = reinterpret_cast<QgsGeometry*>(sipConvertToInstance(tobj, sipClass_QgsGeometry, sipTransferObj,SIP_NOT_NONE,&state,sipIsErr)); |
|
532 |
|
|
533 |
if (*sipIsErr) |
|
534 |
{ |
|
535 |
sipReleaseInstance(tobj, sipClass_QgsGeometry, state); |
|
536 |
delete qm; |
|
537 |
return 0; |
|
538 |
} |
|
539 |
|
|
540 |
qm->insert(k, *fa); |
|
541 |
} |
|
542 | ||
543 |
*sipCppPtr = qm; |
|
544 |
return sipGetState(sipTransferObj); |
|
545 |
%End |
|
413 | 546 |
}; |
414 | 547 | |
415 | 548 |
%MappedType QMap<QString, QVariant::Type> |
... | ... | |
736 | 869 | |
737 | 870 |
return sipGetState(sipTransferObj); |
738 | 871 |
%End |
739 |
}; |
|
872 |
}; |
python/core/qgsfeature.sip (working copy) | ||
---|---|---|
11 | 11 |
typedef unsigned int size_t; |
12 | 12 |
|
13 | 13 |
//! Constructor |
14 |
QgsFeature(int id = 0, QString typeName = "" );
|
|
14 |
QgsFeature(qint64 id = 0, QString typeName = "" );
|
|
15 | 15 | |
16 | 16 |
/** copy ctor needed due to internal pointer */ |
17 | 17 |
QgsFeature(const QgsFeature & rhs ); |
... | ... | |
24 | 24 |
* Get the feature id for this feature |
25 | 25 |
* @return Feature id |
26 | 26 |
*/ |
27 |
int featureId() const;
|
|
27 |
qint64 featureId() const;
|
|
28 | 28 | |
29 | 29 |
/** |
30 | 30 |
* Set the feature id for this feature |
31 | 31 |
* @param id Feature id |
32 | 32 |
*/ |
33 |
void setFeatureId(int id);
|
|
33 |
void setFeatureId(qint64 id);
|
|
34 | 34 | |
35 | 35 | |
36 | 36 |
/** returns the feature's type name |
python/core/qgsvectorlayer.sip (working copy) | ||
---|---|---|
74 | 74 |
QList<QgsFeature> selectedFeatures(); |
75 | 75 |
|
76 | 76 |
/** Return reference to identifiers of selected features */ |
77 |
const QSet<int>& selectedFeaturesIds() const;
|
|
77 |
const QSet<qint64>& selectedFeaturesIds() const;
|
|
78 | 78 |
|
79 | 79 |
/** Change selection to the new set of features */ |
80 |
void setSelectedFeatures(const QSet<int>& ids);
|
|
80 |
void setSelectedFeatures(const QSet<qint64>& ids);
|
|
81 | 81 | |
82 | 82 |
/** Returns the bounding box of the selected features. If there is no selection, QgsRect(0,0,0,0) is returned */ |
83 | 83 |
QgsRect boundingBoxOfSelected(); |
... | ... | |
165 | 165 |
* in the given ring, item (first number is index 0), and feature |
166 | 166 |
* Not meaningful for Point geometries |
167 | 167 |
*/ |
168 |
bool insertVertex(double x, double y, int atFeatureId, int beforeVertex);
|
|
168 |
bool insertVertex(double x, double y, qint64 atFeatureId, int beforeVertex);
|
|
169 | 169 | |
170 | 170 |
/** Moves the vertex at the given position number, |
171 | 171 |
* ring and item (first number is index 0), and feature |
172 | 172 |
* to the given coordinates |
173 | 173 |
*/ |
174 |
bool moveVertex(double x, double y, int atFeatureId, int atVertex);
|
|
174 |
bool moveVertex(double x, double y, qint64 atFeatureId, int atVertex);
|
|
175 | 175 | |
176 | 176 |
/** Deletes the vertex at the given position number, |
177 | 177 |
* ring and item (first number is index 0), and feature |
178 | 178 |
*/ |
179 |
bool deleteVertex(int atFeatureId, int atVertex);
|
|
179 |
bool deleteVertex(qint64 atFeatureId, int atVertex);
|
|
180 | 180 | |
181 | 181 |
/** Deletes the selected features |
182 | 182 |
* @return true in case of success and false otherwise |
... | ... | |
209 | 209 |
@param dx translation of x-coordinate |
210 | 210 |
@param dy translation of y-coordinate |
211 | 211 |
@return 0 in case of success*/ |
212 |
int translateFeature(int featureId, double dx, double dy);
|
|
212 |
int translateFeature(qint64 featureId, double dx, double dy);
|
|
213 | 213 | |
214 | 214 |
/**Splits features cut by the given line |
215 | 215 |
@param splitLine line that splits the layer features |
... | ... | |
304 | 304 |
bool startEditing(); |
305 | 305 | |
306 | 306 |
/** changed an attribute value (but does not commit it */ |
307 |
bool changeAttributeValue(int fid, int field, QVariant value, bool emitSignal = true);
|
|
307 |
bool changeAttributeValue(qint64 fid, int field, QVariant value, bool emitSignal = true);
|
|
308 | 308 | |
309 | 309 |
/** add an attribute field (but does not commit it) |
310 | 310 |
returns the field index or -1 in case of failure */ |
... | ... | |
355 | 355 |
public slots: |
356 | 356 | |
357 | 357 |
/** Select feature by its ID, optionally emit signal selectionChanged() */ |
358 |
void select(int featureId, bool emitSignal = TRUE);
|
|
358 |
void select(qint64 featureId, bool emitSignal = TRUE);
|
|
359 | 359 |
|
360 | 360 |
/** Clear selection */ |
361 | 361 |
void removeSelection(bool emitSignal = TRUE); |
... | ... | |
379 | 379 |
void editingStopped(); |
380 | 380 |
void attributeAdded(int idx); |
381 | 381 |
void attributeDeleted(int idx); |
382 |
void featureDeleted(int fid);
|
|
382 |
void featureDeleted(qint64 fid);
|
|
383 | 383 |
void layerDeleted(); |
384 | 384 | |
385 |
void attributeValueChanged(int fid, int idx, const QVariant &);
|
|
385 |
void attributeValueChanged(qint64 fid, int idx, const QVariant &);
|
|
386 | 386 | |
387 | 387 |
private: // Private methods |
388 | 388 |
python/core/qgsvectordataprovider.sip (working copy) | ||
---|---|---|
70 | 70 |
* @param fetchAttributes a list containing the indexes of the attribute fields to copy |
71 | 71 |
* @return True when feature was found, otherwise false |
72 | 72 |
*/ |
73 |
virtual bool getFeatureAtId(int featureId,
|
|
73 |
virtual bool getFeatureAtId(qint64 featureId,
|
|
74 | 74 |
QgsFeature& feature, |
75 | 75 |
bool fetchGeometry = true, |
76 | 76 |
QList<int> fetchAttributes = QList<int>()); |
... | ... | |
154 | 154 |
* @param id list containing feature ids to delete |
155 | 155 |
* @return true in case of success and false in case of failure |
156 | 156 |
*/ |
157 |
virtual bool deleteFeatures(const QSet<int> & id);
|
|
157 |
virtual bool deleteFeatures(const QSet<qint64> & id);
|
|
158 | 158 | |
159 | 159 |
/** |
160 | 160 |
* Adds new attributes |
... | ... | |
175 | 175 |
* @param attr_map a map containing changed attributes |
176 | 176 |
* @return true in case of success and false in case of failure |
177 | 177 |
*/ |
178 |
virtual bool changeAttributeValues(const QMap<int, QMap<int, QVariant> > & attr_map);
|
|
178 |
virtual bool changeAttributeValues(const QMap<qint64, QMap<int, QVariant> > & attr_map);
|
|
179 | 179 | |
180 | 180 |
/** |
181 | 181 |
* Returns the default value for field specified by @c fieldId |
... | ... | |
188 | 188 |
* the second map parameter being the new geometries themselves |
189 | 189 |
* @return true in case of success and false in case of failure |
190 | 190 |
*/ |
191 |
virtual bool changeGeometryValues(QMap<int, QgsGeometry> & geometry_map);
|
|
191 |
virtual bool changeGeometryValues(QMap<qint64, QgsGeometry> & geometry_map);
|
|
192 | 192 | |
193 | 193 |
/** |
194 | 194 |
* Creates a spatial index on the datasource (if supported by the provider type). |
src/app/qgsidentifyresults.h (working copy) | ||
---|---|---|
20 | 20 |
#define QGSIDENTIFYRESULTS_H |
21 | 21 | |
22 | 22 |
#include "ui_qgsidentifyresultsbase.h" |
23 | ||
23 | 24 |
#include "qgsattributeaction.h" |
25 |
#include "qgsfeature.h" |
|
26 | ||
24 | 27 |
#include <QWidget> |
25 | 28 |
#include <vector> |
26 | 29 |
#include <map> |
... | ... | |
55 | 58 |
void addDerivedAttribute( QTreeWidgetItem *parent, QString field, QString value ); |
56 | 59 | |
57 | 60 |
/** Add an action to the feature display node */ |
58 |
void addAction( QTreeWidgetItem *parent, int id, QString field, QString value );
|
|
61 |
void addAction( QTreeWidgetItem *parent, QgsFeatureId id, QString field, QString value );
|
|
59 | 62 | |
60 | 63 |
/** Add an edit action to the feature display node */ |
61 |
void addEdit( QTreeWidgetItem *parent, int id );
|
|
64 |
void addEdit( QTreeWidgetItem *parent, QgsFeatureId id );
|
|
62 | 65 | |
63 | 66 |
/** Add a feature node to the feature display */ |
64 | 67 |
QTreeWidgetItem * addNode( QString label ); |
... | ... | |
87 | 90 |
//void reject(); |
88 | 91 | |
89 | 92 |
signals: |
90 |
void selectedFeatureChanged( int featureId );
|
|
91 |
void editFeature( int featureId );
|
|
93 |
void selectedFeatureChanged( QgsFeatureId featureId );
|
|
94 |
void editFeature( QgsFeatureId featureId );
|
|
92 | 95 | |
93 | 96 |
public slots: |
94 | 97 |
src/app/qgsattributetable.cpp (working copy) | ||
---|---|---|
200 | 200 |
{ |
201 | 201 |
for ( int index = range_it->topRow(); index <= range_it->bottomRow(); index++ ) |
202 | 202 |
{ |
203 |
emit selected( item( index, 0 )->text().toInt(), false );
|
|
203 |
emit selected( item( index, 0 )->text().toLongLong(), false );
|
|
204 | 204 |
} |
205 | 205 |
} |
206 | 206 | |
... | ... | |
209 | 209 |
//todo: don't repaint in case of double clicks |
210 | 210 |
} |
211 | 211 | |
212 |
void QgsAttributeTable::insertFeatureId( int id, int row )
|
|
212 |
void QgsAttributeTable::insertFeatureId( QgsFeatureId id, int row )
|
|
213 | 213 |
{ |
214 | 214 |
rowIdMap.insert( id, row ); |
215 | 215 |
} |
216 | 216 | |
217 |
void QgsAttributeTable::selectRowWithId( int id )
|
|
217 |
void QgsAttributeTable::selectRowWithId( QgsFeatureId id )
|
|
218 | 218 |
{ |
219 |
QMap < int, int >::iterator it = rowIdMap.find( id );
|
|
219 |
QMap < QgsFeatureId, int >::iterator it = rowIdMap.find( id );
|
|
220 | 220 |
setRangeSelected( QTableWidgetSelectionRange( it.value(), 0, it.value(), columnCount() - 1 ), true ); |
221 | 221 |
} |
222 | 222 | |
... | ... | |
493 | 493 |
} |
494 | 494 | |
495 | 495 |
//id-field |
496 |
int id = fet.featureId();
|
|
497 |
QTableWidgetItem *twi = new QTableWidgetItem( QString::number( id ) );
|
|
496 |
QgsFeatureId id = fet.featureId();
|
|
497 |
QTableWidgetItem *twi = new QTableWidgetItem( FID_TO_STRING( id ) );
|
|
498 | 498 |
twi->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter ); |
499 | 499 |
setItem( row, 0, twi ); |
500 | 500 |
insertFeatureId( id, row ); //insert the id into the search tree of qgsattributetable |
... | ... | |
692 | 692 |
} |
693 | 693 |
} |
694 | 694 | |
695 |
void QgsAttributeTable::attributeValueChanged( int fid, int idx, const QVariant &value )
|
|
695 |
void QgsAttributeTable::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
|
|
696 | 696 |
{ |
697 | 697 |
if ( !rowIdMap.contains( fid ) ) |
698 | 698 |
return; |
... | ... | |
727 | 727 |
item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( v ); |
728 | 728 |
} |
729 | 729 | |
730 |
void QgsAttributeTable::featureDeleted( int fid )
|
|
730 |
void QgsAttributeTable::featureDeleted( QgsFeatureId fid )
|
|
731 | 731 |
{ |
732 | 732 |
if ( !rowIdMap.contains( fid ) ) |
733 | 733 |
return; |
... | ... | |
736 | 736 | |
737 | 737 |
removeRow( row ); |
738 | 738 | |
739 |
for ( QMap<int, int>::iterator it = rowIdMap.begin(); it != rowIdMap.end(); it++ )
|
|
739 |
for ( QMap<QgsFeatureId, int>::iterator it = rowIdMap.begin(); it != rowIdMap.end(); it++ )
|
|
740 | 740 |
if ( it.value() > row ) |
741 | 741 |
rowIdMap[ it.key()]--; |
742 | 742 |
} |
src/app/qgsattributetable.h (working copy) | ||
---|---|---|
66 | 66 | |
67 | 67 |
/* Inserts the feature with the specified id into rowIdMap. This function has to be called |
68 | 68 |
(e.g. from QgsShapeFileLayer) when a row is inserted into the table */ |
69 |
void insertFeatureId( int id, int row );
|
|
69 |
void insertFeatureId( QgsFeatureId id, int row );
|
|
70 | 70 |
/**Selects the row which belongs to the feature with the specified id*/ |
71 |
void selectRowWithId( int id );
|
|
71 |
void selectRowWithId( QgsFeatureId id );
|
|
72 | 72 |
/**Sorts a column. If the first entry contains a letter, sort alphanumerically, otherwise numerically.*/ |
73 | 73 |
void sortColumn( int col, bool ascending ); |
74 | 74 |
/* Use this to give this class the current attribute actions, |
... | ... | |
105 | 105 |
// Called when the user chooses an item on the popup menu |
106 | 106 |
void popupItemSelected( QAction * menuAction ); |
107 | 107 | |
108 |
void attributeValueChanged( int fid, int idx, const QVariant &value );
|
|
109 |
void featureDeleted( int fid );
|
|
108 |
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
|
|
109 |
void featureDeleted( QgsFeatureId fid );
|
|
110 | 110 | |
111 | 111 |
protected slots: |
112 | 112 |
void handleChangedSelections(); |
... | ... | |
115 | 115 |
/**Flag telling if the ctrl-button or the shift-button is pressed*/ |
116 | 116 |
bool lockKeyPressed; |
117 | 117 |
/**Search tree to find a row corresponding to a feature id*/ |
118 |
QMap<int, int> rowIdMap;
|
|
118 |
QMap<QgsFeatureId, int> rowIdMap;
|
|
119 | 119 |
/**Map attribute index to columns*/ |
120 | 120 |
QMap<int, int> mAttrIdxMap; |
121 | 121 |
bool mEditable; |
... | ... | |
149 | 149 | |
150 | 150 |
signals: |
151 | 151 |
/**Is emitted when a row was selected*/ |
152 |
void selected( int, bool );
|
|
152 |
void selected( QgsFeatureId, bool );
|
|
153 | 153 |
/**Is emitted when all rows have been deselected*/ |
154 | 154 |
void selectionRemoved( bool ); |
155 | 155 |
/**Is emitted when a set of related selection and deselection signals have been emitted*/ |
src/app/qgsmaptoolmovefeature.h (working copy) | ||
---|---|---|
43 | 43 |
QgsRubberBand* mRubberBand; |
44 | 44 | |
45 | 45 |
/**Id of moved feature*/ |
46 |
int mMovedFeature;
|
|
46 |
QgsFeatureId mMovedFeature;
|
|
47 | 47 |
}; |
48 | 48 | |
49 | 49 |
#endif |
src/app/qgsdbsourceselect.cpp (working copy) | ||
---|---|---|
414 | 414 |
{ |
415 | 415 |
connect( mColumnTypeThread, SIGNAL( setLayerType( QString, QString, QString, QString ) ), |
416 | 416 |
this, SLOT( setLayerType( QString, QString, QString, QString ) ) ); |
417 |
connect( this, SIGNAL( finished() ), |
|
417 |
connect( this, SIGNAL( finished( int ) ),
|
|
418 | 418 |
mColumnTypeThread, SLOT( stop() ) ); |
419 | 419 | |
420 | 420 |
// Do it in a thread. |
src/app/qgsmaptoolidentify.cpp (working copy) | ||
---|---|---|
284 | 284 |
// Be informed when the dialog box is closed so that we can stop using it. |
285 | 285 |
connect( mResults, SIGNAL( accepted() ), this, SLOT( resultsDialogGone() ) ); |
286 | 286 |
connect( mResults, SIGNAL( rejected() ), this, SLOT( resultsDialogGone() ) ); |
287 |
connect( mResults, SIGNAL( selectedFeatureChanged( int ) ), this, SLOT( highlightFeature( int ) ) );
|
|
288 |
connect( mResults, SIGNAL( editFeature( int ) ), this, SLOT( editFeature( int ) ) );
|
|
287 |
connect( mResults, SIGNAL( selectedFeatureChanged( QgsFeatureId ) ), this, SLOT( highlightFeature( QgsFeatureId ) ) );
|
|
288 |
connect( mResults, SIGNAL( editFeature( QgsFeatureId ) ), this, SLOT( editFeature( QgsFeatureId ) ) );
|
|
289 | 289 | |
290 | 290 |
// restore the identify window position and show it |
291 | 291 |
mResults->restorePosition(); |
... | ... | |
299 | 299 | |
300 | 300 |
QApplication::setOverrideCursor( Qt::WaitCursor ); |
301 | 301 | |
302 |
int lastFeatureId = 0;
|
|
302 |
QgsFeatureId lastFeatureId = 0;
|
|
303 | 303 |
QgsFeatureList::iterator f_it = mFeatureList.begin(); |
304 | 304 | |
305 | 305 |
for ( ; f_it != mFeatureList.end(); ++f_it ) |
... | ... | |
431 | 431 |
QgsMapTool::deactivate(); |
432 | 432 |
} |
433 | 433 | |
434 |
void QgsMapToolIdentify::highlightFeature( int featureId )
|
|
434 |
void QgsMapToolIdentify::highlightFeature( QgsFeatureId featureId )
|
|
435 | 435 |
{ |
436 | 436 |
QgsVectorLayer* layer = dynamic_cast<QgsVectorLayer*>( mLayer ); |
437 | 437 |
if ( !layer ) |
... | ... | |
462 | 462 |
} |
463 | 463 |
} |
464 | 464 | |
465 |
void QgsMapToolIdentify::editFeature( int featureId )
|
|
465 |
void QgsMapToolIdentify::editFeature( QgsFeatureId featureId )
|
|
466 | 466 |
{ |
467 | 467 |
for ( QgsFeatureList::iterator it = mFeatureList.begin(); it != mFeatureList.end(); it++ ) |
468 | 468 |
{ |
src/app/qgsidentifyresults.cpp (working copy) | ||
---|---|---|
185 | 185 |
new QTreeWidgetItem( daRootNode, labels ); |
186 | 186 |
} |
187 | 187 | |
188 |
void QgsIdentifyResults::addEdit( QTreeWidgetItem * fnode, int id )
|
|
188 |
void QgsIdentifyResults::addEdit( QTreeWidgetItem * fnode, QgsFeatureId id )
|
|
189 | 189 |
{ |
190 | 190 |
QStringList labels; |
191 |
labels << "edit" << QString::number( id );
|
|
191 |
labels << "edit" << FID_TO_STRING( id );
|
|
192 | 192 |
QTreeWidgetItem *item = new QTreeWidgetItem( fnode, labels ); |
193 | 193 | |
194 | 194 |
item->setIcon( 0, QgisApp::getThemeIcon( "/mIconEditable.png" ) ); |
195 | 195 |
} |
196 | 196 | |
197 |
void QgsIdentifyResults::addAction( QTreeWidgetItem * fnode, int id, QString field, QString value )
|
|
197 |
void QgsIdentifyResults::addAction( QTreeWidgetItem * fnode, QgsFeatureId id, QString field, QString value )
|
|
198 | 198 |
{ |
199 | 199 |
QStringList labels; |
200 |
labels << field << value << "action" << QString::number( id );
|
|
200 |
labels << field << value << "action" << FID_TO_STRING( id );
|
|
201 | 201 |
QTreeWidgetItem *item = new QTreeWidgetItem( fnode, labels ); |
202 | 202 | |
203 | 203 |
item->setIcon( 0, QgisApp::getThemeIcon( "/mAction.png" ) ); |
src/app/qgsattributetabledisplay.cpp (working copy) | ||
---|---|---|
93 | 93 |
connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( attributeAdded( int ) ) ); |
94 | 94 |
connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( attributeDeleted( int ) ) ); |
95 | 95 | |
96 |
connect( mLayer, SIGNAL( attributeValueChanged( int, int, const QVariant & ) ),
|
|
97 |
tblAttributes, SLOT( attributeValueChanged( int, int, const QVariant & ) ) );
|
|
96 |
connect( mLayer, SIGNAL( attributeValueChanged( QgsFeatureId, int, const QVariant & ) ),
|
|
97 |
tblAttributes, SLOT( attributeValueChanged( QgsFeatureId, int, const QVariant & ) ) );
|
|
98 | 98 | |
99 |
connect( mLayer, SIGNAL( featureDeleted( int ) ),
|
|
100 |
tblAttributes, SLOT( featureDeleted( int ) ) );
|
|
99 |
connect( mLayer, SIGNAL( featureDeleted( QgsFeatureId ) ),
|
|
100 |
tblAttributes, SLOT( featureDeleted( QgsFeatureId ) ) );
|
|
101 | 101 | |
102 | 102 |
// etablish connections between table and vector layer |
103 |
connect( tblAttributes, SIGNAL( selected( int, bool ) ), mLayer, SLOT( select( int, bool ) ) );
|
|
103 |
connect( tblAttributes, SIGNAL( selected( QgsFeatureId, bool ) ), mLayer, SLOT( select( QgsFeatureId, bool ) ) );
|
|
104 | 104 |
connect( tblAttributes, SIGNAL( selectionRemoved( bool ) ), mLayer, SLOT( removeSelection( bool ) ) ); |
105 | 105 |
connect( tblAttributes, SIGNAL( repaintRequested() ), mLayer, SLOT( triggerRepaint() ) ); |
106 | 106 |
src/app/qgsmaptoolidentify.h (working copy) | ||
---|---|---|
60 | 60 | |
61 | 61 |
public slots: |
62 | 62 |
//! creates rubberband on top of the feature to highlight it |
63 |
void highlightFeature( int featureId );
|
|
63 |
void highlightFeature( QgsFeatureId featureId );
|
|
64 | 64 | |
65 | 65 |
//! edit a feature |
66 |
void editFeature( int featureId );
|
|
66 |
void editFeature( QgsFeatureId featureId );
|
|
67 | 67 | |
68 | 68 |
private: |
69 | 69 |
src/core/qgsfeature.cpp (working copy) | ||
---|---|---|
22 | 22 |
* \brief Encapsulates a spatial feature with attributes |
23 | 23 |
*/ |
24 | 24 | |
25 |
QgsFeature::QgsFeature( int id, QString typeName )
|
|
25 |
QgsFeature::QgsFeature( QgsFeatureId id, QString typeName )
|
|
26 | 26 |
: mFid( id ), |
27 | 27 |
mGeometry( 0 ), |
28 | 28 |
mOwnsGeometry( 0 ), |
... | ... | |
84 | 84 |
* Get the feature id for this feature |
85 | 85 |
* @return Feature id |
86 | 86 |
*/ |
87 |
int QgsFeature::featureId() const
|
|
87 |
QgsFeatureId QgsFeature::featureId() const
|
|
88 | 88 |
{ |
89 | 89 |
return mFid; |
90 | 90 |
} |
... | ... | |
140 | 140 | |
141 | 141 |
/** Set the feature id |
142 | 142 |
*/ |
143 |
void QgsFeature::setFeatureId( int id )
|
|
143 |
void QgsFeature::setFeatureId( QgsFeatureId id )
|
|
144 | 144 |
{ |
145 | 145 |
mFid = id; |
146 | 146 |
} |
src/core/qgsvectorlayer.cpp (working copy) | ||
---|---|---|
817 | 817 |
} |
818 | 818 |
} |
819 | 819 | |
820 |
void QgsVectorLayer::select( int number, bool emitSignal )
|
|
820 |
void QgsVectorLayer::select( QgsFeatureId id, bool emitSignal )
|
|
821 | 821 |
{ |
822 |
mSelectedFeatureIds.insert( number );
|
|
822 |
mSelectedFeatureIds.insert( id );
|
|
823 | 823 | |
824 | 824 |
if ( emitSignal ) |
825 | 825 |
{ |
... | ... | |
1208 | 1208 |
// check if changed geometries are in rectangle |
1209 | 1209 |
for ( ; mFetchChangedGeomIt != mChangedGeometries.end(); mFetchChangedGeomIt++ ) |
1210 | 1210 |
{ |
1211 |
int fid = mFetchChangedGeomIt.key();
|
|
1211 |
QgsFeatureId fid = mFetchChangedGeomIt.key();
|
|
1212 | 1212 | |
1213 | 1213 |
if ( mFetchConsidered.contains( fid ) ) |
1214 | 1214 |
// skip deleted features |
... | ... | |
1227 | 1227 | |
1228 | 1228 |
if ( mFetchAttributes.size() > 0 ) |
1229 | 1229 |
{ |
1230 |
if ( fid < 0 )
|
|
1230 |
if ( FID_IS_NEW( fid ) )
|
|
1231 | 1231 |
{ |
1232 | 1232 |
// fid<0 => in mAddedFeatures |
1233 | 1233 |
bool found = false; |
... | ... | |
1265 | 1265 | |
1266 | 1266 |
for ( ; mFetchAddedFeaturesIt != mAddedFeatures.end(); mFetchAddedFeaturesIt++ ) |
1267 | 1267 |
{ |
1268 |
int fid = mFetchAddedFeaturesIt->featureId();
|
|
1268 |
QgsFeatureId fid = mFetchAddedFeaturesIt->featureId();
|
|
1269 | 1269 | |
1270 | 1270 |
if ( mFetchConsidered.contains( fid ) ) |
1271 | 1271 |
// must have changed geometry outside rectangle |
... | ... | |
1311 | 1311 |
return false; |
1312 | 1312 |
} |
1313 | 1313 | |
1314 |
int QgsVectorLayer::getFeatureAtId( int featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
|
|
1314 |
int QgsVectorLayer::getFeatureAtId( QgsFeatureId featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
|
|
1315 | 1315 |
{ |
1316 | 1316 |
if ( !mDataProvider ) |
1317 | 1317 |
return 1; |
... | ... | |
1326 | 1326 | |
1327 | 1327 |
if ( fetchAttributes ) |
1328 | 1328 |
{ |
1329 |
if ( featureId < 0 )
|
|
1329 |
if ( FID_IS_NEW( featureId ) )
|
|
1330 | 1330 |
{ |
1331 | 1331 |
// featureId<0 => in mAddedFeatures |
1332 | 1332 |
bool found = false; |
... | ... | |
1433 | 1433 |
} |
1434 | 1434 | |
1435 | 1435 | |
1436 |
bool QgsVectorLayer::insertVertex( double x, double y, int atFeatureId, int beforeVertex )
|
|
1436 |
bool QgsVectorLayer::insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex )
|
|
1437 | 1437 |
{ |
1438 | 1438 |
if ( !mEditable ) |
1439 | 1439 |
{ |
... | ... | |
1463 | 1463 |
} |
1464 | 1464 | |
1465 | 1465 | |
1466 |
bool QgsVectorLayer::moveVertex( double x, double y, int atFeatureId, int atVertex )
|
|
1466 |
bool QgsVectorLayer::moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex )
|
|
1467 | 1467 |
{ |
1468 | 1468 |
if ( !mEditable ) |
1469 | 1469 |
{ |
... | ... | |
1492 | 1492 |
} |
1493 | 1493 | |
1494 | 1494 | |
1495 |
bool QgsVectorLayer::deleteVertex( int atFeatureId, int atVertex )
|
|
1495 |
bool QgsVectorLayer::deleteVertex( QgsFeatureId atFeatureId, int atVertex )
|
|
1496 | 1496 |
{ |
1497 | 1497 |
if ( !mEditable ) |
1498 | 1498 |
{ |
... | ... | |
1538 | 1538 | |
1539 | 1539 |
while ( mSelectedFeatureIds.size() > 0 ) |
1540 | 1540 |
{ |
1541 |
int fid = *mSelectedFeatureIds.begin();
|
|
1541 |
QgsFeatureId fid = *mSelectedFeatureIds.begin();
|
|
1542 | 1542 |
deleteFeature( fid ); // removes from selection |
1543 | 1543 |
} |
1544 | 1544 | |
... | ... | |
1598 | 1598 |
return 5; |
1599 | 1599 |
} |
1600 | 1600 | |
1601 |
int selectedFeatureId = *mSelectedFeatureIds.constBegin();
|
|
1601 |
QgsFeatureId selectedFeatureId = *mSelectedFeatureIds.constBegin();
|
|
1602 | 1602 | |
1603 | 1603 |
//look if geometry of selected feature already contains geometry changes |
1604 | 1604 |
QgsGeometryMap::iterator changedIt = mChangedGeometries.find( selectedFeatureId ); |
... | ... | |
1632 | 1632 |
return 6; //geometry not found |
1633 | 1633 |
} |
1634 | 1634 | |
1635 |
int QgsVectorLayer::translateFeature( int featureId, double dx, double dy )
|
|
1635 |
int QgsVectorLayer::translateFeature( QgsFeatureId featureId, double dx, double dy )
|
|
1636 | 1636 |
{ |
1637 | 1637 |
//look if geometry of selected feature already contains geometry changes |
1638 | 1638 |
QgsGeometryMap::iterator changedIt = mChangedGeometries.find( featureId ); |
... | ... | |
1715 | 1715 | |
1716 | 1716 |
QgsFeature f; |
1717 | 1717 |
while ( getNextFeature( f ) ) |
1718 |
featureList << QgsFeature(f);
|
|
1718 |
featureList << QgsFeature( f );
|
|
1719 | 1719 |
} |
1720 | 1720 | |
1721 | 1721 |
QgsFeatureList::iterator select_it = featureList.begin(); |
... | ... | |
2449 | 2449 |
return true; |
2450 | 2450 |
} // bool QgsVectorLayer::writeXml |
2451 | 2451 | |
2452 |
bool QgsVectorLayer::changeAttributeValue( int fid, int field, QVariant value, bool emitSignal )
|
|
2452 |
bool QgsVectorLayer::changeAttributeValue( QgsFeatureId fid, int field, QVariant value, bool emitSignal )
|
|
2453 | 2453 |
{ |
2454 | 2454 |
if ( !isEditable() ) |
2455 | 2455 |
return false; |
2456 | 2456 | |
2457 |
if ( fid >= 0 )
|
|
2457 |
if ( !FID_IS_NEW( fid ) )
|
|
2458 | 2458 |
{ |
2459 | 2459 |
// changed attribute of existing feature |
2460 | 2460 |
if ( !mChangedAttributeValues.contains( fid ) ) |
... | ... | |
2532 | 2532 |
return true; |
2533 | 2533 |
} |
2534 | 2534 | |
2535 |
bool QgsVectorLayer::deleteFeature( int fid )
|
|
2535 |
bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )
|
|
2536 | 2536 |
{ |
2537 | 2537 |
if ( !isEditable() ) |
2538 | 2538 |
return false; |
... | ... | |
3096 | 3096 |
return n == 0 ? 2 : 0; |
3097 | 3097 |
} |
3098 | 3098 | |
3099 |
void QgsVectorLayer::snapToGeometry( const QgsPoint& startPoint, int featureId, QgsGeometry* geom, double sqrSnappingTolerance,
|
|
3099 |
void QgsVectorLayer::snapToGeometry( const QgsPoint& startPoint, QgsFeatureId featureId, QgsGeometry* geom, double sqrSnappingTolerance,
|
|
3100 | 3100 |
QMultiMap<double, QgsSnappingResult>& snappingResults, QgsSnapper::SNAP_TO snap_to ) const |
3101 | 3101 |
{ |
3102 | 3102 |
if ( !geom ) |
src/core/qgsvectordataprovider.cpp (working copy) | ||
---|---|---|
47 | 47 |
return -1; |
48 | 48 |
} |
49 | 49 | |
50 |
bool QgsVectorDataProvider::getFeatureAtId( int featureId, |
|
51 |
QgsFeature& feature, |
|
52 |
bool fetchGeometry, |
|
53 |
QgsAttributeList fetchAttributes ) |
|
50 |
bool QgsVectorDataProvider::getFeatureAtId( |
|
51 |
QgsFeatureId featureId, |
|
52 |
QgsFeature& feature, |
|
53 |
bool fetchGeometry, |
|
54 |
QgsAttributeList fetchAttributes ) |
|
54 | 55 |
{ |
55 | 56 |
select( fetchAttributes, QgsRect(), fetchGeometry ); |
56 | 57 |
src/core/qgsfeature.h (working copy) | ||
---|---|---|
21 | 21 |
#include <QString> |
22 | 22 |
#include <QVariant> |
23 | 23 |
#include <QList> |
24 |
#include <QHash> |
|
24 | 25 | |
25 | 26 |
class QgsGeometry; |
26 | 27 |
class QgsRect; |
27 | 28 |
class QgsFeature; |
28 | 29 | |
29 |
// key = field index, value = field value |
|
30 |
typedef QMap<int, QVariant> QgsAttributeMap; |
|
30 |
// feature id class (currently 64 bit) |
|
31 |
#if 0 |
|
32 |
#include <limits> |
|
31 | 33 | |
32 |
// key = feature id, value = changed attributes |
|
33 |
typedef QMap<int, QgsAttributeMap> QgsChangedAttributesMap; |
|
34 |
class QgsFeatureId |
|
35 |
{ |
|
36 |
public: |
|
37 |
QgsFeatureId( qint64 id = 0 ) : mId( id ) {} |
|
38 |
QgsFeatureId &operator=( const QgsFeatureId &other ) { mId = other.mId; return *this; } |
|
34 | 39 | |
35 |
// key = feature id, value = changed geometry |
|
36 |
typedef QMap<int, QgsGeometry> QgsGeometryMap; |
|
40 |
bool operator==( const QgsFeatureId &id ) const { return mId == id.mId; } |
|
41 |
bool operator!=( const QgsFeatureId &id ) const { return mId != id.mId; } |
|
42 |
bool operator<( const QgsFeatureId &id ) const { return mId < id.mId; } |
|
43 |
bool operator>( const QgsFeatureId &id ) const { return mId > id.mId; } |
|
44 |
operator QString() const { return QString::number( mId ); } |
|
37 | 45 | |
38 |
// key = field index, value = field name |
|
39 |
typedef QMap<int, QString> QgsFieldNameMap; |
|
46 |
bool isNew() const |
|
47 |
{ |
|
48 |
return mId < 0; |
|
49 |
} |
|
40 | 50 | |
41 |
typedef QList<QgsFeature> QgsFeatureList; |
|
51 |
long toLong() const |
|
52 |
{ |
|
53 |
Q_ASSERT( mId >= std::numeric_limits<long>::min() && mId <= std::numeric_limits<long>::max() ); |
|
54 |
return static_cast<long>( mId ); |
|
55 |
} |
|
42 | 56 | |
57 |
private: |
|
58 |
qint64 mId; |
|
59 | ||
60 |
friend uint qHash( const QgsFeatureId &id ); |
|
61 |
}; |
|
62 | ||
63 |
inline uint qHash( const QgsFeatureId &id ) |
|
64 |
{ |
|
65 |
return qHash( id.mId ); |
|
66 |
} |
|
67 | ||
68 |
#define FID_IS_NEW(fid) fid.isNew() |
|
69 |
#define FID_TO_LONG(fid) fid.toLong() |
|
70 |
#define FID_TO_STRING(fid) static_cast<QString>(fid) |
|
71 |
#endif |
|
72 | ||
73 |
// 64 bit feature ids |
|
74 |
#if 1 |
|
75 |
typedef qint64 QgsFeatureId; |
|
76 |
#define FID_IS_NEW(fid) (fid<0) |
|
77 |
#define FID_TO_LONG(fid) static_cast<long>(fid) |
|
78 |
#define FID_TO_STRING(fid) QString::number( fid ) |
|
79 |
#endif |
|
80 | ||
81 |
// 32 bit feature ids |
|
82 |
#if 0 |
|
83 |
typedef int QgsFeatureId; |
|
84 |
#define FID_IS_NEW(fid) (fid<0) |
|
85 |
#define FID_TO_LONG(fid) static_cast<long>(fid) |
|
86 |
#define FID_TO_STRING(fid) QString::number( fid ) |
|
87 |
#endif |
|
88 | ||
89 | ||
90 |
// key = field index, value = field value |
|
91 |
typedef QMap<int, QVariant> QgsAttributeMap; |
|
92 | ||
43 | 93 |
/** \ingroup core |
44 | 94 |
* The feature class encapsulates a single feature including its id, |
45 | 95 |
* geometry and a list of field/values attributes. |
... | ... | |
49 | 99 |
class CORE_EXPORT QgsFeature |
50 | 100 |
{ |
51 | 101 |
public: |
102 |
#if 0 |
|
103 |
typedef qint64 FeatureId; |
|
104 |
#endif |
|
105 | ||
106 | ||
52 | 107 |
//! Constructor |
53 |
QgsFeature( int id = 0, QString typeName = "" );
|
|
108 |
QgsFeature( QgsFeatureId id = QgsFeatureId(), QString typeName = "" );
|
|
54 | 109 | |
55 | 110 |
/** copy ctor needed due to internal pointer */ |
56 | 111 |
QgsFeature( QgsFeature const & rhs ); |
... | ... | |
61 | 116 |
//! Destructor |
62 | 117 |
~QgsFeature(); |
63 | 118 | |
64 | ||
65 | 119 |
/** |
66 | 120 |
* Get the feature id for this feature |
67 | 121 |
* @return Feature id |
68 | 122 |
*/ |
69 |
int featureId() const;
|
|
123 |
QgsFeatureId featureId() const;
|
|
70 | 124 | |
71 | 125 |
/** |
72 | 126 |
* Set the feature id for this feature |
73 | 127 |
* @param id Feature id |
74 | 128 |
*/ |
75 |
void setFeatureId( int id );
|
|
129 |
void setFeatureId( QgsFeatureId id );
|
|
76 | 130 | |
77 | 131 | |
78 | 132 |
/** returns the feature's type name |
... | ... | |
159 | 213 |
private: |
160 | 214 | |
161 | 215 |
//! feature id |
162 |
int mFid;
|
|
216 |
QgsFeatureId mFid;
|
|
163 | 217 | |
164 | 218 |
/** map of attributes accessed by field index */ |
165 | 219 |
QgsAttributeMap mAttributes; |
... | ... | |
186 | 240 |
/// feature type name |
187 | 241 |
QString mTypeName; |
188 | 242 | |
189 | ||
190 | 243 |
}; // class QgsFeature |
191 | 244 | |
245 |
// key = feature id, value = changed attributes |
|
246 |
typedef QMap<QgsFeatureId, QgsAttributeMap> QgsChangedAttributesMap; |
|
192 | 247 | |
248 |
// key = feature id, value = changed geometry |
|
249 |
typedef QMap<QgsFeatureId, QgsGeometry> QgsGeometryMap; |
|
250 | ||
251 |
typedef QSet<QgsFeatureId> QgsFeatureIds; |
|
252 | ||
253 |
// key = field index, value = field name |
|
254 |
typedef QMap<int, QString> QgsFieldNameMap; |
|
255 | ||
256 |
typedef QList<QgsFeature> QgsFeatureList; |
|
257 | ||
193 | 258 |
#endif |
src/core/qgsvectorlayer.h (working copy) | ||
---|---|---|
48 | 48 |
class QgsRect; |
49 | 49 | |
50 | 50 |
typedef QList<int> QgsAttributeList; |
51 |
typedef QSet<int> QgsFeatureIds; |
|
52 | 51 |
typedef QSet<int> QgsAttributeIds; |
53 | 52 | |
54 | 53 |
/** \ingroup core |
... | ... | |
210 | 209 | |
211 | 210 |
/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features |
212 | 211 |
@return 0 in case of success*/ |
213 |
int getFeatureAtId( int featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true );
|
|
212 |
int getFeatureAtId( QgsFeatureId featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true );
|
|
214 | 213 | |
215 | 214 |
/** Adds a feature |
216 | 215 |
@param lastFeatureInBatch If True, will also go to the effort of e.g. updating the extents. |
... | ... | |
223 | 222 |
* in the given ring, item (first number is index 0), and feature |
224 | 223 |
* Not meaningful for Point geometries |
225 | 224 |
*/ |
226 |
bool insertVertex( double x, double y, int atFeatureId, int beforeVertex );
|
|
225 |
bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
|
|
227 | 226 | |
228 | 227 |
/** Moves the vertex at the given position number, |
229 | 228 |
* ring and item (first number is index 0), and feature |
230 | 229 |
* to the given coordinates |
231 | 230 |
*/ |
232 |
bool moveVertex( double x, double y, int atFeatureId, int atVertex );
|
|
231 |
bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
|
|
233 | 232 | |
234 | 233 |
/** Deletes a vertex from a feature |
235 | 234 |
*/ |
236 |
bool deleteVertex( int atFeatureId, int atVertex );
|
|
235 |
bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
|
|
237 | 236 | |
238 | 237 |
/** Deletes the selected features |
239 | 238 |
* @return true in case of success and false otherwise |
... | ... | |
266 | 265 |
@param dx translation of x-coordinate |
267 | 266 |
@param dy translation of y-coordinate |
268 | 267 |
@return 0 in case of success*/ |
269 |
int translateFeature( int featureId, double dx, double dy );
|
|
268 |
int translateFeature( QgsFeatureId featureId, double dx, double dy );
|
|
270 | 269 | |
271 | 270 |
/**Splits features cut by the given line |
272 | 271 |
@param splitLine line that splits the layer features |
... | ... | |
327 | 326 |
@param snap_to to segment / to vertex |
328 | 327 |
@return 0 in case of success |
329 | 328 |
*/ |
330 |
int snapWithContext( const QgsPoint& startPoint,
|
|
331 |
double snappingTolerance,
|
|
332 |
QMultiMap<double,
|
|
333 |
QgsSnappingResult>& snappingResults,
|
|
334 |
QgsSnapper::SNAP_TO snap_to ); |
|
329 |
int snapWithContext( const QgsPoint& startPoint, |
|
330 |
double snappingTolerance,
|
|
331 |
QMultiMap < double,
|
|
332 |
QgsSnappingResult > & snappingResults,
|
|
333 |
QgsSnapper::SNAP_TO snap_to );
|
|
335 | 334 | |
336 | 335 |
/** Draws the layer |
337 | 336 |
* @return FALSE if an error occurred during drawing |
... | ... | |
344 | 343 |
/** \brief Draws the layer labels using coordinate transformation |
345 | 344 |
* \param scale size scale, applied to all values in pixels |
346 | 345 |
*/ |
347 |
void drawLabels( QPainter * p, const QgsRect& viewExtent,
|
|
348 |
const QgsMapToPixel* cXf,
|
|
349 |
const QgsCoordinateTransform* ct,
|
|
350 |
double scale ); |
|
346 |
void drawLabels( QPainter * p, const QgsRect& viewExtent, |
|
347 |
const QgsMapToPixel* cXf,
|
|
348 |
const QgsCoordinateTransform* ct,
|
|
349 |
double scale );
|
|
351 | 350 | |
352 | 351 |
/** returns field list in the to-be-committed state */ |
353 | 352 |
const QgsFieldMap &pendingFields(); |
... | ... | |
365 | 364 |
bool startEditing(); |
366 | 365 | |
367 | 366 |
/** changed an attribute value (but does not commit it */ |
368 |
bool changeAttributeValue( int fid, int field, QVariant value, bool emitSignal = true );
|
|
367 |
bool changeAttributeValue( QgsFeatureId fid, int field, QVariant value, bool emitSignal = true );
|
|
369 | 368 | |
370 | 369 |
/** add an attribute field (but does not commit it) |
371 | 370 |
returns the field index or -1 in case of failure */ |
... | ... | |
378 | 377 |
bool addFeatures( QgsFeatureList features, bool makeSelected = TRUE ); |
379 | 378 | |
380 | 379 |
/** delete a feature from the layer (but does not commit it) */ |
381 |
bool deleteFeature( int fid );
|
|
380 |
bool deleteFeature( QgsFeatureId fid );
|
|
382 | 381 | |
383 | 382 |
/** |
384 | 383 |
Attempts to commit any changes to disk. Returns the result of the attempt. |
... | ... | |
415 | 414 | |
416 | 415 |
public slots: |
417 | 416 |
/** Select feature by its ID, optionally emit signal selectionChanged() */ |
418 |
void select( int featureId, bool emitSignal = TRUE );
|
|
417 |
void select( QgsFeatureId featureId, bool emitSignal = TRUE );
|
|
419 | 418 | |
420 | 419 |
/** Clear selection */ |
421 | 420 |
void removeSelection( bool emitSignal = TRUE ); |
... | ... | |
439 | 438 |
void editingStopped(); |
440 | 439 |
void attributeAdded( int idx ); |
441 | 440 |
void attributeDeleted( int idx ); |
442 |
void featureDeleted( int fid );
|
|
441 |
void featureDeleted( QgsFeatureId fid );
|
|
443 | 442 |
void layerDeleted(); |
444 | 443 | |
445 |
void attributeValueChanged( int fid, int idx, const QVariant & );
|
|
444 |
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
|
|
446 | 445 | |
447 | 446 |
private: // Private methods |
448 | 447 | |
... | ... | |
517 | 516 |
@param snappingResult list to which the result is appended |
518 | 517 |
@param snap_to snap to vertex or to segment |
519 | 518 |
*/ |
520 |
void snapToGeometry( const QgsPoint& startPoint, int featureId, QgsGeometry* geom, double sqrSnappingTolerance,
|
|
519 |
void snapToGeometry( const QgsPoint& startPoint, QgsFeatureId featureId, QgsGeometry* geom, double sqrSnappingTolerance,
|
|
521 | 520 |
QMultiMap<double, QgsSnappingResult>& snappingResults, QgsSnapper::SNAP_TO snap_to ) const; |
522 | 521 | |
523 | 522 |
/**Little helper function that gives bounding box from a list of points. |
... | ... | |
620 | 619 |
QgsAttributeList mFetchNullAttributes; |
621 | 620 |
bool mFetchGeometry; |
622 | 621 | |
623 |
QSet<int> mFetchConsidered;
|
|
622 |
QSet<QgsFeatureId> mFetchConsidered;
|
|
624 | 623 |
QgsGeometryMap::iterator mFetchChangedGeomIt; |
625 | 624 |
QgsFeatureList::iterator mFetchAddedFeaturesIt; |
626 | 625 |
}; |
src/core/qgsvectordataprovider.h (working copy) | ||
---|---|---|
35 | 35 |
/** \ingroup core |
36 | 36 |
* This is the base class for vector data providers. |
37 | 37 |
* |
38 |
* Data providers abstract the retrieval and writing (where supported)
|
|
38 |
* Data providers abstract the retrieval and writing (where supported) |
|
39 | 39 |
* of feature and attrubute information from a spatial datasource. |
40 | 40 |
* |
41 | 41 |
* |
... | ... | |
110 | 110 |
* Default implementation traverses all features until it finds the one with correct ID. |
111 | 111 |
* In case the provider supports reading the feature directly, override this function. |
112 | 112 |
*/ |
113 |
virtual bool getFeatureAtId( int featureId,
|
|
113 |
virtual bool getFeatureAtId( QgsFeatureId featureId,
|
|
114 | 114 |
QgsFeature& feature, |
115 | 115 |
bool fetchGeometry = true, |
116 | 116 |
QgsAttributeList fetchAttributes = QgsAttributeList() ); |
... | ... | |
227 | 227 | |
228 | 228 |
/** |
229 | 229 |
* Changes geometries of existing features |
230 |
* @param geometry_map A QgsGeometryMap whose index contains the feature IDs
|
|
230 |
* @param geometry_map A QgsGeometryMap whose index contains the feature IDs |
|
231 | 231 |
* that will have their geometries changed. |
232 | 232 |
* The second map parameter being the new geometries themselves |
233 | 233 |
* @return True in case of success and false in case of failure |
src/core/spatialindex/qgsspatialindex.cpp (working copy) | ||
---|---|---|
94 | 94 |
if ( !g ) |
95 | 95 |
return false; |
96 | 96 | |
97 |
id = f.featureId();
|
|
97 |
id = FID_TO_LONG( f.featureId() );
|
|
98 | 98 |
r = rectToRegion( g->boundingBox() ); |
99 | 99 |
return true; |
100 | 100 |
} |
src/core/qgssnapper.h (working copy) | ||
---|---|---|
21 | 21 |
#include "qgspoint.h" |
22 | 22 |
#include <QList> |
23 | 23 |
#include <QMultiMap> |
24 |
#include "qgsfeature.h" |
|
24 | 25 | |
25 | 26 |
class QgsMapRenderer; |
26 | 27 |
class QgsVectorLayer; |
... | ... | |
47 | 48 |
or -1 if no such vertex*/ |
48 | 49 |
int afterVertexNr; |
49 | 50 |
/**Index of the snapped geometry*/ |
50 |
int snappedAtGeometry;
|
|
51 |
QgsFeatureId snappedAtGeometry;
|
|
51 | 52 |
/**Layer where the snap occured*/ |
52 | 53 |
const QgsVectorLayer* layer; |
53 | 54 |
}; |
src/providers/postgres/qgspostgresprovider.h (working copy) | ||
---|---|---|
319 | 319 |
QgsFeature &feature, |
320 | 320 |
const QgsAttributeList &fetchAttributes ); |
321 | 321 | |
322 |
qint64 getBinaryInt( PGresult *queryResult, int row, int col ); |
|
323 | ||
322 | 324 |
const QgsField &field( int index ) const; |
323 | 325 | |
324 | 326 |
/** Double quote a PostgreSQL identifier for placement in a SQL string. |
src/providers/postgres/qgspostgresprovider.cpp (working copy) | ||
---|---|---|
227 | 227 | |
228 | 228 |
//fill type names into sets |
229 | 229 |
mSupportedNativeTypes.insert( "double precision", QVariant::Double ); |
230 |
mSupportedNativeTypes.insert( "int2", QVariant::Int ); |
|
230 | 231 |
mSupportedNativeTypes.insert( "int4", QVariant::Int ); |
231 | 232 |
mSupportedNativeTypes.insert( "int8", QVariant::LongLong ); |
232 | 233 |
mSupportedNativeTypes.insert( "text", QVariant::String ); |
... | ... | |
443 | 444 |
} |
444 | 445 |
} |
445 | 446 | |
447 |
qint64 QgsPostgresProvider::getBinaryInt( PGresult *queryResult, int row, int col ) |
|
448 |
{ |
|
449 |
qint64 oid; |
|
450 |
void *p = PQgetvalue( queryResult, row, col ); |
|
451 | ||
452 |
size_t s = PQgetlength( queryResult, row, col ); |
|
453 |
switch ( s ) |
|
454 |
{ |
|
455 |
case 2: |
|
456 |
oid = *( qint16 * )p; |
|
457 |
if ( swapEndian ) |
|
458 |
oid = ntohs( oid ); |
|
459 |
break; |
|
460 | ||
461 | ||
462 |
case 8: |
|
463 |
if ( swapEndian ) |
|
464 |
{ |
|
465 |
qint64 oid0 = htonl( *( qint32 * )p ); |
|
466 |
qint64 oid1 = htonl( *(( qint32 * )p + 1 ) ); |
|
467 |
oid = ( oid0 << 32 ) + oid1; |
|
468 |
} |
|
469 |
else |
|
470 |
{ |
|
471 |
oid = *( qint64 * )p; |
|
472 |
} |
|
473 |
break; |
|
474 | ||
475 |
default: |
|
476 |
QgsDebugMsg( QString( "unexpected size %d" ).arg( s ) ); |
|
477 | ||
478 |
case 4: |
|
479 |
oid = *( qint32 * )p; |
|
480 |
if ( swapEndian ) |
|
481 |
oid = ntohl( oid ); |
|
482 |
break; |
|
483 |
} |
|
484 | ||
485 |
return oid; |
|
486 |
} |
|
487 | ||
446 | 488 |
bool QgsPostgresProvider::getFeature( PGresult *queryResult, int row, bool fetchGeometry, |
447 | 489 |
QgsFeature &feature, |
448 | 490 |
const QgsAttributeList &fetchAttributes ) |
449 | 491 |
{ |
450 | 492 |
try |
451 | 493 |
{ |
452 |
int oid = *( int * )PQgetvalue( queryResult, row, 0 ); |
|
453 |
if ( swapEndian ) |
|
454 |
oid = ntohl( oid ); // convert oid to opposite endian |
|
455 | ||
494 |
QgsFeatureId oid = getBinaryInt( queryResult, row, 0 ); |
|
456 | 495 |
feature.setFeatureId( oid ); |
457 | 496 | |
458 | 497 |
int col; // first attribute column after geometry |
... | ... | |
909 | 948 |
// oid isn't indexed (and that they may want to add a |
910 | 949 |
// primary key to the table) |
911 | 950 |
primaryKey = "oid"; |
912 |
primaryKeyType = "int4";
|
|
951 |
primaryKeyType = "int8";
|
|
913 | 952 |
} |
914 | 953 |
else |
915 | 954 |
{ |
916 | 955 |
showMessageBox( tr( "No suitable key column in table" ), |
917 | 956 |
tr( "The table has no column suitable for use as a key.\n\n" |
918 | 957 |
"Qgis requires that the table either has a column of type\n" |
919 |
"int4 with a unique constraint on it (which includes the\n"
|
|
958 |
"int with a unique constraint on it (which includes the\n" |
|
920 | 959 |
"primary key) or has a PostgreSQL oid column.\n" ) ); |
921 | 960 |
} |
922 | 961 |
} |
... | ... | |
955 | 994 |
QString columnName = QString::fromUtf8( PQgetvalue( types, 0, 0 ) ); |
956 | 995 |
QString columnType = QString::fromUtf8( PQgetvalue( types, 0, 1 ) ); |
957 | 996 | |
958 |
if ( columnType != "int4" )
|
|
997 |
if ( columnType != "int2" && columnType != "int4" && columnType != "int8" )
|
|
959 | 998 |
log.append( tr( "The unique index on column" ) + |
960 | 999 |
" '" + columnName + "' " + |
961 | 1000 |
tr( "is unsuitable because Qgis does not currently support" |
962 |
" non-int4 type columns as a key into the table.\n" ) );
|
|
1001 |
" non-int2/4/8 type columns as a key into the table.\n" ) );
|
|
963 | 1002 |
else |
964 | 1003 |
suitableKeyColumns.push_back( std::make_pair( columnName, columnType ) ); |
965 | 1004 |
} |
... | ... | |
1013 | 1052 |
if ( PQntuples( oidCheck ) != 0 ) |
1014 | 1053 |
{ |
1015 | 1054 |
primaryKey = "oid"; |
1016 |
primaryKeyType = "int4";
|
|
1055 |
primaryKeyType = "int8";
|
|
1017 | 1056 |
} |
1018 | 1057 |
else |
1019 | 1058 |
{ |
1020 | 1059 |
log.prepend( "There were no columns in the table that were suitable " |
1021 | 1060 |
"as a qgis key into the table (either a column with a " |
1022 |
"unique index and type int4 or a PostgreSQL oid column.\n" );
|
|
1061 |
"unique index and type int2/4/8 or a PostgreSQL oid column.\n" );
|
|
1023 | 1062 |
} |
1024 | 1063 |
} |
1025 | 1064 | |
... | ... | |
1095 | 1134 |
// This sql returns one or more rows if the column 'tableCol' in |
1096 | 1135 |
// table 'tableName' and schema 'schemaName' has one or more |
1097 | 1136 |
// columns that satisfy the following conditions: |
1098 |
// 1) the column has data type of int4.
|
|
1137 |
// 1) the column has data type of int2/4/8.
|
|
1099 | 1138 |
// 2) the column has a unique constraint or primary key constraint |
1100 | 1139 |
// on it. |
1101 | 1140 |
// 3) the constraint applies just to the column of interest (i.e., |
... | ... | |
1106 | 1145 |
"and array_dims(conkey)='[1:1]'" ).arg( quotedValue( tableCol ) ).arg( rel_oid ); |
1107 | 1146 | |
1108 | 1147 |
result = connectionRO->PQexec( sql ); |
1109 |
if ( PQntuples( result ) == 1 && colType == "int4" )
|
|
1148 |
if ( PQntuples( result ) == 1 && ( colType == "int2" || colType == "int4" || colType == "int8" ) )
|
|
1110 | 1149 |
suitable[viewCol] = iter->second; |
1111 | 1150 | |
1112 | 1151 |
QString details = "'" + viewCol + "'" + tr( " derives from " ) |
1113 | 1152 |
+ "'" + schemaName + "." + tableName + "." + tableCol + "' "; |
1114 | 1153 | |
1115 |
if ( PQntuples( result ) == 1 && colType == "int4" )
|
|
1154 |
if ( PQntuples( result ) == 1 && ( colType == "int2" || colType == "int4" || colType == "int8" ) )
|
|
1116 | 1155 |
{ |
1117 | 1156 |
details += tr( "and is suitable." ); |
1118 | 1157 |
} |
... | ... | |
1224 | 1263 |
"of which satisfy the above conditions:" ) ); |
1225 | 1264 |
log.prepend( tr( "Qgis requires that the view has a column that can be used " |
1226 | 1265 |
"as a unique key. Such a column should be derived from " |
1227 |
"a table column of type int4 and be a primary key, "
|
|
1266 |
"a table column of type int2/4/8 and be a primary key, "
|
|
1228 | 1267 |
"have a unique constraint on it, or be a PostgreSQL " |
1229 | 1268 |
"oid column. To improve " |
1230 | 1269 |
"performance the column should also be indexed.\n" ) ); |
... | ... | |
1994 | 2033 |
// cycle through the features |
1995 | 2034 |
for ( QgsChangedAttributesMap::const_iterator iter = attr_map.begin();iter != attr_map.end();++iter ) |
1996 | 2035 |
{ |
1997 |
int fid = iter.key();
|
|
2036 |
QgsFeatureId fid = iter.key();
|
|
1998 | 2037 | |
1999 | 2038 |
// skip added features |
2000 | 2039 |
if ( fid < 0 ) |
... | ... | |
2399 | 2438 |
swapEndian = true; |
2400 | 2439 |
if ( PQntuples( fResult ) > 0 ) |
2401 | 2440 |
{ |
2402 |
// get the oid value from the binary cursor |
|
2403 |
int oid = *( int * )PQgetvalue( fResult, 0, 0 ); |
|
2441 |
qint64 oid = getBinaryInt( fResult, 0, 0 ); |
|
2404 | 2442 | |
2405 |
//--std::cout << "Got oid of " << oid << " from the binary cursor" << std::endl; |
|
2443 |
QgsDebugMsg( QString( "Got oid of %1 from the binary cursor" ).arg( oid ) ); |
|
2444 |
QgsDebugMsg( QString( "First oid is %1" ).arg( oidValue ) ); |
|
2406 | 2445 | |
2407 |
//--std::cout << "First oid is " << oidValue << std::endl; |
|
2408 | ||
2409 | 2446 |
// compare the two oid values to determine if we need to do an endian swap |
2410 |
if ( oid == oidValue.toInt() )
|
|
2447 |
if ( oid != oidValue.toLongLong() )
|
|
2411 | 2448 |
swapEndian = false; |
2412 | 2449 |
} |
2413 | 2450 |
connectionRO->closeCursor( "oidcursor" ); |
src/providers/ogr/qgsogrprovider.h (working copy) | ||
---|---|---|
250 | 250 |
/**Adds one feature*/ |
251 | 251 |
bool addFeature( QgsFeature& f ); |
252 | 252 |
/**Deletes one feature*/ |
253 |
bool deleteFeature( int id );
|
|
253 |
bool deleteFeature( QgsFeatureId id );
|
|
254 | 254 |
}; |
src/providers/ogr/qgsogrprovider.cpp (working copy) | ||
---|---|---|
612 | 612 |
{ |
613 | 613 |
for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it ) |
614 | 614 |
{ |
615 |
long fid = ( long ) it.key();
|
|
615 |
long fid = FID_TO_LONG( it.key() );
|
|
616 | 616 | |
617 | 617 |
OGRFeatureH of = OGR_L_GetFeature( ogrLayer, fid ); |
618 | 618 | |
... | ... | |
677 | 677 | |
678 | 678 |
for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it ) |
679 | 679 |
{ |
680 |
theOGRFeature = OGR_L_GetFeature( ogrLayer, it.key() );
|
|
680 |
theOGRFeature = OGR_L_GetFeature( ogrLayer, FID_TO_LONG( it.key() ) );
|
|
681 | 681 |
if ( !theOGRFeature ) |
682 | 682 |
{ |
683 | 683 |
QgsLogger::warning( "QgsOgrProvider::changeGeometryValues, cannot find feature" ); |
... | ... | |
759 | 759 |
return returnvalue; |
760 | 760 |
} |
761 | 761 | |
762 |
bool QgsOgrProvider::deleteFeature( int id )
|
|
762 |
bool QgsOgrProvider::deleteFeature( QgsFeatureId id )
|
|
763 | 763 |
{ |
764 |
OGRErr res = OGR_L_DeleteFeature( ogrLayer, id );
|
|
764 |
OGRErr res = OGR_L_DeleteFeature( ogrLayer, FID_TO_LONG( id ) );
|
|
765 | 765 |
return ( res == OGRERR_NONE ); |
766 | 766 |
} |
767 | 767 |
src/providers/memory/memoryprovider.h (working copy) | ||
---|---|---|
16 | 16 |
#include "qgsvectordataprovider.h" |
17 | 17 | |
18 | 18 | |
19 |
typedef QMap<int, QgsFeature> QgsFeatureMap;
|
|
19 |
typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
|
|
20 | 20 | |
21 | 21 |
class QgsSpatialIndex; |
22 | 22 |
src/providers/gpx/gpsdata.cpp (working copy) | ||
---|---|---|
288 | 288 | |
289 | 289 |
void GPSData::removeWaypoints( const QgsFeatureIds & ids ) |
290 | 290 |
{ |
291 |
QList<int> ids2 = ids.toList();
|
|
291 |
QList<QgsFeatureId> ids2 = ids.toList();
|
|
292 | 292 |
qSort( ids2 ); |
293 |
QList<int>::const_iterator iter = ids2.begin();
|
|
293 |
QList<QgsFeatureId>::const_iterator iter = ids2.begin();
|
|
294 | 294 |
WaypointIterator wIter; |
295 | 295 |
for ( wIter = waypoints.begin(); |
296 | 296 |
wIter != waypoints.end() && iter != ids2.end(); ) |
... | ... | |
309 | 309 | |
310 | 310 |
void GPSData::removeRoutes( const QgsFeatureIds & ids ) |
311 | 311 |
{ |
312 |
QList<int> ids2 = ids.toList();
|
|
312 |
QList<QgsFeatureId> ids2 = ids.toList();
|
|
313 | 313 |
qSort( ids2 ); |