Skip to content

Instantly share code, notes, and snippets.

@slarosa
Created February 25, 2015 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slarosa/d6ef8828d1f0b5edd1ed to your computer and use it in GitHub Desktop.
Save slarosa/d6ef8828d1f0b5edd1ed to your computer and use it in GitHub Desktop.
diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp
index 34f0277..9fc522e 100644
--- a/src/app/qgsbookmarks.cpp
+++ b/src/app/qgsbookmarks.cpp
@@ -299,13 +299,13 @@ void QgsBookmarks::importFromXML()
for ( int i = 0;i < nodeList.count(); i++ )
{
QDomNode bookmark = nodeList.at( i );
- QDomElement name = bookmark.firstChildElement( "Name" );
- QDomElement prjname = bookmark.firstChildElement( "Project" );
- QDomElement xmin = bookmark.firstChildElement( "xMin" );
- QDomElement xmax = bookmark.firstChildElement( "xMax" );
- QDomElement ymin = bookmark.firstChildElement( "yMin" );
- QDomElement ymax = bookmark.firstChildElement( "yMax" );
- QDomElement srid = bookmark.firstChildElement( "SRID" );
+ QDomElement name = bookmark.firstChildElement( "name" );
+ QDomElement prjname = bookmark.firstChildElement( "project" );
+ QDomElement xmin = bookmark.firstChildElement( "xmin" );
+ QDomElement xmax = bookmark.firstChildElement( "xmax" );
+ QDomElement ymin = bookmark.firstChildElement( "ymin" );
+ QDomElement ymax = bookmark.firstChildElement( "ymax" );
+ QDomElement srid = bookmark.firstChildElement( "sr_id" );
queries += "INSERT INTO tbl_bookmarks(bookmark_id,name,project_name,xmin,ymin,xmax,ymax,projection_srid)"
" VALUES (NULL,"
@@ -364,19 +364,23 @@ void QgsBookmarks::exportToXML()
int rowCount = lstBookmarks->model()->rowCount();
int colCount = lstBookmarks->model()->columnCount();
+ QList<QString> headerList;
+ headerList << "name" << "project" << "xmin" << "ymin" << "xmax" << "ymax" << "sr_id";
+
for ( int i = 0; i < rowCount; ++i )
{
QDomElement bookmark = doc.createElement( "bookmark" );
root.appendChild( bookmark );
- for ( int j = 0; j < colCount; j++ )
+ for ( int j = 1; j < colCount; j++ )
{
QModelIndex idx = lstBookmarks->model()->index( i, j );
if ( idx.isValid() )
{
QString value = idx.data( Qt::DisplayRole ).toString();
QDomText idText = doc.createTextNode( value );
- QVariant header = lstBookmarks->model()->headerData( j, Qt::Horizontal );
- QDomElement id = doc.createElement( header.toString() );
+ QString header = headerList.at(j-1);
+ QDomElement id = doc.createElement( header );
id.appendChild( idText );
bookmark.appendChild( id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment