2
/***************************************************************************
3
QgsBookmarkItem.h - Spatial Bookmark Item
6
copyright : (C) 2005 Gary Sherman
7
email : sherman at mrcc dot com
8
***************************************************************************/
10
/***************************************************************************
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
17
***************************************************************************/
18
/* $Id: qgsbookmarkitem.cpp,v 1.2.2.1 2005/07/09 23:51:17 timlinux Exp $ */
22
#include <qtextstream.h>
27
#include "qgsbookmarkitem.h"
29
QgsBookmarkItem::QgsBookmarkItem(QString name, QString projectTitle,
30
QgsRect viewExtent, int srid, QString dbPath)
31
: mName(name), mProjectTitle(projectTitle), mViewExtent(viewExtent),
32
mSrid(srid), mUserDbPath(dbPath)
35
QgsBookmarkItem::~QgsBookmarkItem()
38
void QgsBookmarkItem::store()
40
// To store the bookmark we have to open the database and insert
41
// the record using the parameters set in the constructor
47
std::cout << "Opening user database: " << mUserDbPath.local8Bit() << std::endl;
49
rc = sqlite3_open(mUserDbPath.local8Bit(), &db);
52
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
54
// XXX This will likely never happen since on open, sqlite creates the
55
// database if it does not exist.
58
// prepare the sql statement
63
QTextOStream sqlStream(&sql);
64
sqlStream << "insert into tbl_bookmarks values(null,'" <<
66
mProjectTitle << "'," <<
67
mViewExtent.xMin() << "," <<
68
mViewExtent.yMin() << "," <<
69
mViewExtent.xMax() << "," <<
70
mViewExtent.yMax() << "," <<
74
std::cout << "Storing bookmark using: " << sql.local8Bit() << std::endl;
76
rc = sqlite3_prepare(db, sql.utf8(), sql.length(), &ppStmt, &pzTail);
77
// XXX Need to free memory from the error msg if one is set
80
// get the first row of the result set
81
if(sqlite3_step(ppStmt) != SQLITE_DONE)
84
// XXX query failed -- warn the user some how
85
std::cout << "Failed to store bookmark: " << sqlite3_errmsg(db) << std::endl;
87
// close the statement
88
sqlite3_finalize(ppStmt);