Skip to content

Commit

Permalink
qgslegendlayerfile.cpp: fix a unused warning
Browse files Browse the repository at this point in the history
qgisapp.cpp: fix indentation and use QgsDebugMsg
qgsgrassmodule.h: fix 2 comment typos


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7704 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 1, 2007
1 parent 1df3e43 commit 9e7012d
Show file tree
Hide file tree
Showing 3 changed files with 324 additions and 463 deletions.
127 changes: 64 additions & 63 deletions src/app/legend/qgslegendlayerfile.cpp
Expand Up @@ -225,15 +225,15 @@ void QgsLegendLayerFile::table()
if (!vlayer)
{
QMessageBox::information(0, tr("Not a vector layer"),
tr("To open an attribute table, you must select a vector layer in the legend"));
tr("To open an attribute table, you must select a vector layer in the legend"));
return;
}

QgsAttributeAction& actions = *vlayer->actions();

if (mTableDisplay)
{

mTableDisplay->raise();

// Give the table the most recent copy of the actions for this layer.
Expand All @@ -256,37 +256,38 @@ void QgsLegendLayerFile::table()
if( list[i]->windowTitle().startsWith("Quantum GIS") )
{
app=reinterpret_cast<QgisApp*>(list[i]);
break;
break;
}

mTableDisplay = new QgsAttributeTableDisplay(vlayer, app);
try
mTableDisplay = new QgsAttributeTableDisplay(vlayer, app);
try
{
mTableDisplay->table()->fillTable(vlayer);
mTableDisplay->table()->fillTable(vlayer);
}
catch(std::bad_alloc& ba)
catch(std::bad_alloc& ba)
{
QMessageBox::critical(0, tr("bad_alloc exception"), tr("Filling the attribute table has been stopped because there was no more virtual memory left"));
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"));
}
mTableDisplay->table()->setSorting(true);
mTableDisplay->table()->setSorting(true);

connect(mTableDisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDisplay()));
connect(mTableDisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDisplay()));

mTableDisplay->setTitle(tr("Attribute table - ") + name());
mTableDisplay->show();
mTableDisplay->setTitle(tr("Attribute table - ") + name());
mTableDisplay->show();

// Give the table the most recent copy of the actions for this layer.
mTableDisplay->table()->setAttributeActions(actions);
// select rows which should be selected
selectionChanged();
// etablish the necessary connections between the table and the vector layer
connect(mTableDisplay->table(), SIGNAL(selected(int, bool)), mLyr.layer(), SLOT(select(int, bool)));
connect(mTableDisplay->table(), SIGNAL(selectionRemoved(bool)), mLyr.layer(), SLOT(removeSelection(bool)));
connect(mTableDisplay->table(), SIGNAL(repaintRequested()), mLyr.layer(), SLOT(triggerRepaint()));
QApplication::restoreOverrideCursor();
// Give the table the most recent copy of the actions for this layer.
mTableDisplay->table()->setAttributeActions(actions);

// select rows which should be selected
selectionChanged();

// etablish the necessary connections between the table and the vector layer
connect(mTableDisplay->table(), SIGNAL(selected(int, bool)), mLyr.layer(), SLOT(select(int, bool)));
connect(mTableDisplay->table(), SIGNAL(selectionRemoved(bool)), mLyr.layer(), SLOT(removeSelection(bool)));
connect(mTableDisplay->table(), SIGNAL(repaintRequested()), mLyr.layer(), SLOT(triggerRepaint()));

QApplication::restoreOverrideCursor();
}

}
Expand Down Expand Up @@ -412,58 +413,58 @@ void QgsLegendLayerFile::toggleEditing()
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(mLyr.layer());
if (!vlayer)
return;

if (!vlayer->isEditable())
{
vlayer->startEditing();
if(!(vlayer->getDataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures))
{
QMessageBox::information(0,tr("Start editing failed"),
tr("Provider cannot be opened for editing"));
}
{
QMessageBox::information(0,tr("Start editing failed"),
tr("Provider cannot be opened for editing"));
}
else
{
vlayer->triggerRepaint();
}
{
vlayer->triggerRepaint();
}
}
else
{
if(vlayer->isModified())
{
{

// commit or roll back?
QMessageBox::StandardButton commit = QMessageBox::information(0,tr("Stop editing"),
tr("Do you want to save the changes?"),
QMessageBox::Save | QMessageBox::Discard);

if(commit==QMessageBox::Save)
{
if(!vlayer->commitChanges())
{
QMessageBox::information(0,tr("Error"),tr("Could not commit changes"));

// Leave the in-memory editing state alone,
// to give the user a chance to enter different values
// and try the commit again later
}
}
else if(commit==QMessageBox::Discard)
{
if(!vlayer->rollBack())
{
QMessageBox::information(0,tr("Error"),
tr("Problems during roll back"));
}
}
// commit or roll back?
QMessageBox::StandardButton commit = QMessageBox::information(0,tr("Stop editing"),
tr("Do you want to save the changes?"),
QMessageBox::Save | QMessageBox::Discard);

if(commit==QMessageBox::Save)
{
if(!vlayer->commitChanges())
{
QMessageBox::information(0,tr("Error"),tr("Could not commit changes"));

// Leave the in-memory editing state alone,
// to give the user a chance to enter different values
// and try the commit again later
}
}
else //layer not modified
else if(commit==QMessageBox::Discard)
{
vlayer->rollBack();
if(!vlayer->rollBack())
{
QMessageBox::information(0,tr("Error"),
tr("Problems during roll back"));
}
}
}
else //layer not modified
{
vlayer->rollBack();
}
vlayer->triggerRepaint();

}

updateLegendItem();

}
Expand Down

0 comments on commit 9e7012d

Please sign in to comment.