@@ -225,15 +225,15 @@ void QgsLegendLayerFile::table()
225
225
if (!vlayer)
226
226
{
227
227
QMessageBox::information (0 , tr (" Not a vector layer" ),
228
- tr (" To open an attribute table, you must select a vector layer in the legend" ));
228
+ tr (" To open an attribute table, you must select a vector layer in the legend" ));
229
229
return ;
230
230
}
231
-
231
+
232
232
QgsAttributeAction& actions = *vlayer->actions ();
233
-
233
+
234
234
if (mTableDisplay )
235
235
{
236
-
236
+
237
237
mTableDisplay ->raise ();
238
238
239
239
// Give the table the most recent copy of the actions for this layer.
@@ -256,37 +256,38 @@ void QgsLegendLayerFile::table()
256
256
if ( list[i]->windowTitle ().startsWith (" Quantum GIS" ) )
257
257
{
258
258
app=reinterpret_cast <QgisApp*>(list[i]);
259
- break ;
259
+ break ;
260
260
}
261
261
262
- mTableDisplay = new QgsAttributeTableDisplay (vlayer, app);
263
- try
262
+ mTableDisplay = new QgsAttributeTableDisplay (vlayer, app);
263
+ try
264
264
{
265
- mTableDisplay ->table ()->fillTable (vlayer);
265
+ mTableDisplay ->table ()->fillTable (vlayer);
266
266
}
267
- catch (std::bad_alloc& ba)
267
+ catch (std::bad_alloc& ba)
268
268
{
269
- QMessageBox::critical (0 , tr (" bad_alloc exception" ), tr (" Filling the attribute table has been stopped because there was no more virtual memory left" ));
269
+ UNUSED (ba);
270
+ QMessageBox::critical (0 , tr (" bad_alloc exception" ), tr (" Filling the attribute table has been stopped because there was no more virtual memory left" ));
270
271
}
271
- mTableDisplay ->table ()->setSorting (true );
272
+ mTableDisplay ->table ()->setSorting (true );
272
273
273
- connect (mTableDisplay , SIGNAL (deleted ()), this , SLOT (invalidateTableDisplay ()));
274
+ connect (mTableDisplay , SIGNAL (deleted ()), this , SLOT (invalidateTableDisplay ()));
274
275
275
- mTableDisplay ->setTitle (tr (" Attribute table - " ) + name ());
276
- mTableDisplay ->show ();
276
+ mTableDisplay ->setTitle (tr (" Attribute table - " ) + name ());
277
+ mTableDisplay ->show ();
277
278
278
- // Give the table the most recent copy of the actions for this layer.
279
- mTableDisplay ->table ()->setAttributeActions (actions);
280
-
281
- // select rows which should be selected
282
- selectionChanged ();
283
-
284
- // etablish the necessary connections between the table and the vector layer
285
- connect (mTableDisplay ->table (), SIGNAL (selected (int , bool )), mLyr .layer (), SLOT (select (int , bool )));
286
- connect (mTableDisplay ->table (), SIGNAL (selectionRemoved (bool )), mLyr .layer (), SLOT (removeSelection (bool )));
287
- connect (mTableDisplay ->table (), SIGNAL (repaintRequested ()), mLyr .layer (), SLOT (triggerRepaint ()));
288
-
289
- QApplication::restoreOverrideCursor ();
279
+ // Give the table the most recent copy of the actions for this layer.
280
+ mTableDisplay ->table ()->setAttributeActions (actions);
281
+
282
+ // select rows which should be selected
283
+ selectionChanged ();
284
+
285
+ // etablish the necessary connections between the table and the vector layer
286
+ connect (mTableDisplay ->table (), SIGNAL (selected (int , bool )), mLyr .layer (), SLOT (select (int , bool )));
287
+ connect (mTableDisplay ->table (), SIGNAL (selectionRemoved (bool )), mLyr .layer (), SLOT (removeSelection (bool )));
288
+ connect (mTableDisplay ->table (), SIGNAL (repaintRequested ()), mLyr .layer (), SLOT (triggerRepaint ()));
289
+
290
+ QApplication::restoreOverrideCursor ();
290
291
}
291
292
292
293
}
@@ -412,58 +413,58 @@ void QgsLegendLayerFile::toggleEditing()
412
413
QgsVectorLayer* vlayer = dynamic_cast <QgsVectorLayer*>(mLyr .layer ());
413
414
if (!vlayer)
414
415
return ;
415
-
416
+
416
417
if (!vlayer->isEditable ())
417
418
{
418
419
vlayer->startEditing ();
419
420
if (!(vlayer->getDataProvider ()->capabilities () & QgsVectorDataProvider::AddFeatures))
420
- {
421
- QMessageBox::information (0 ,tr (" Start editing failed" ),
422
- tr (" Provider cannot be opened for editing" ));
423
- }
421
+ {
422
+ QMessageBox::information (0 ,tr (" Start editing failed" ),
423
+ tr (" Provider cannot be opened for editing" ));
424
+ }
424
425
else
425
- {
426
- vlayer->triggerRepaint ();
427
- }
426
+ {
427
+ vlayer->triggerRepaint ();
428
+ }
428
429
}
429
430
else
430
431
{
431
432
if (vlayer->isModified ())
432
- {
433
+ {
433
434
434
- // commit or roll back?
435
- QMessageBox::StandardButton commit = QMessageBox::information (0 ,tr (" Stop editing" ),
436
- tr (" Do you want to save the changes?" ),
437
- QMessageBox::Save | QMessageBox::Discard);
438
-
439
- if (commit==QMessageBox::Save)
440
- {
441
- if (!vlayer->commitChanges ())
442
- {
443
- QMessageBox::information (0 ,tr (" Error" ),tr (" Could not commit changes" ));
444
-
445
- // Leave the in-memory editing state alone,
446
- // to give the user a chance to enter different values
447
- // and try the commit again later
448
- }
449
- }
450
- else if (commit==QMessageBox::Discard)
451
- {
452
- if (!vlayer->rollBack ())
453
- {
454
- QMessageBox::information (0 ,tr (" Error" ),
455
- tr (" Problems during roll back" ));
456
- }
457
- }
435
+ // commit or roll back?
436
+ QMessageBox::StandardButton commit = QMessageBox::information (0 ,tr (" Stop editing" ),
437
+ tr (" Do you want to save the changes?" ),
438
+ QMessageBox::Save | QMessageBox::Discard);
439
+
440
+ if (commit==QMessageBox::Save)
441
+ {
442
+ if (!vlayer->commitChanges ())
443
+ {
444
+ QMessageBox::information (0 ,tr (" Error" ),tr (" Could not commit changes" ));
445
+
446
+ // Leave the in-memory editing state alone,
447
+ // to give the user a chance to enter different values
448
+ // and try the commit again later
449
+ }
458
450
}
459
- else // layer not modified
451
+ else if (commit==QMessageBox::Discard)
460
452
{
461
- vlayer->rollBack ();
453
+ if (!vlayer->rollBack ())
454
+ {
455
+ QMessageBox::information (0 ,tr (" Error" ),
456
+ tr (" Problems during roll back" ));
457
+ }
462
458
}
459
+ }
460
+ else // layer not modified
461
+ {
462
+ vlayer->rollBack ();
463
+ }
463
464
vlayer->triggerRepaint ();
464
-
465
+
465
466
}
466
-
467
+
467
468
updateLegendItem ();
468
469
469
470
}
0 commit comments