Skip to content

Commit

Permalink
fix #1130
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8672 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 23, 2008
1 parent 19158b3 commit 13d7f00
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/app/qgsdbtablemodel.cpp
Expand Up @@ -93,14 +93,16 @@ void QgsDbTableModel::setSql(const QModelIndex& index, const QString& sql)
//find out schema name and table name
QModelIndex schemaSibling = index.sibling(index.row(), 0);
QModelIndex tableSibling = index.sibling(index.row(), 1);
QModelIndex geomSibling = index.sibling(index.row(), 3);

if(!schemaSibling.isValid() || !tableSibling.isValid())
if(!schemaSibling.isValid() || !tableSibling.isValid() || !geomSibling.isValid())
{
return;
}

QString schemaName = itemFromIndex(schemaSibling)->text();
QString tableName = itemFromIndex(tableSibling)->text();
QString tableName = itemFromIndex(tableSibling)->text();
QString geomName = itemFromIndex(geomSibling)->text();

QList<QStandardItem*> schemaItems = findItems(schemaName, Qt::MatchExactly, 0);
if(schemaItems.size() < 1)
Expand All @@ -113,6 +115,7 @@ void QgsDbTableModel::setSql(const QModelIndex& index, const QString& sql)

QModelIndex currentChildIndex;
QModelIndex currentTableIndex;
QModelIndex currentGeomIndex;

for(int i = 0; i < numChildren; ++i)
{
Expand All @@ -127,7 +130,14 @@ void QgsDbTableModel::setSql(const QModelIndex& index, const QString& sql)
continue;
}

if(itemFromIndex(currentTableIndex)->text() == tableName)
currentGeomIndex = currentChildIndex.sibling(i, 3);
if(!currentGeomIndex.isValid())
{
continue;
}

if(itemFromIndex(currentTableIndex)->text() == tableName &&
itemFromIndex(currentGeomIndex)->text() == geomName )
{
QModelIndex sqlIndex = currentChildIndex.sibling(i, 4);
if(sqlIndex.isValid())
Expand Down

0 comments on commit 13d7f00

Please sign in to comment.