Skip to content

Commit

Permalink
fix qml support for non-file data sources
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9019 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 7, 2008
1 parent c2d3a88 commit 23bf2a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsbookmarks.cpp
Expand Up @@ -251,7 +251,7 @@ int QgsBookmarks::connectDb()

int rc;
rc = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &db);
if(rc)
if(rc!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;

Expand Down
56 changes: 26 additions & 30 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -105,14 +105,13 @@ void QgsCustomProjectionDialog::getProjList ()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the PROJECTION list
QString mySql = "select * from tbl_projection order by name";
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
Expand Down Expand Up @@ -140,14 +139,13 @@ void QgsCustomProjectionDialog::getEllipsoidList()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select * from tbl_ellipsoid order by name";
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
Expand Down Expand Up @@ -184,12 +182,12 @@ void QgsCustomProjectionDialog::on_pbnDelete_clicked()
QString myName;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "delete from tbl_srs where srs_id='" + mCurrentRecordId + "'";
Expand Down Expand Up @@ -244,12 +242,12 @@ long QgsCustomProjectionDialog::getRecordCount()
long myRecordCount=0;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select count(*) from tbl_srs";
Expand Down Expand Up @@ -279,12 +277,12 @@ QString QgsCustomProjectionDialog::getProjectionFamilyName(QString theProjection
QString myName;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_projection where acronym='" + theProjectionFamilyAcronym + "'";
Expand All @@ -310,12 +308,12 @@ QString QgsCustomProjectionDialog::getEllipsoidName(QString theEllipsoidAcronym)
QString myName;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidAcronym + "'";
Expand All @@ -341,12 +339,12 @@ QString QgsCustomProjectionDialog::getProjectionFamilyAcronym(QString theProject
QString myName;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select acronym from tbl_projection where name='" + theProjectionFamilyName + "'";
Expand All @@ -372,12 +370,12 @@ QString QgsCustomProjectionDialog::getEllipsoidAcronym(QString theEllipsoidName)
QString myName;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select acronym from tbl_ellipsoid where name='" + theEllipsoidName + "'";
Expand Down Expand Up @@ -406,12 +404,12 @@ void QgsCustomProjectionDialog::on_pbnFirst_clicked()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}

QString mySql = "select * from tbl_srs order by srs_id limit 1";
Expand Down Expand Up @@ -484,12 +482,12 @@ void QgsCustomProjectionDialog::on_pbnPrevious_clicked()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}

QString mySql = "select * from tbl_srs where srs_id < " + mCurrentRecordId + " order by srs_id desc limit 1";
Expand Down Expand Up @@ -563,15 +561,14 @@ void QgsCustomProjectionDialog::on_pbnNext_clicked()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}


QString mySql = "select * from tbl_srs where srs_id > " + mCurrentRecordId + " order by srs_id asc limit 1";
#ifdef QGISDEBUG
std::cout << "Query to move next:" << mySql.toLocal8Bit().data() << std::endl;
Expand Down Expand Up @@ -639,12 +636,12 @@ void QgsCustomProjectionDialog::on_pbnLast_clicked()
int myResult;
//check the db is available
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
if(myResult)
if(myResult!=SQLITE_OK)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}

QString mySql = "select * from tbl_srs order by srs_id desc limit 1";
Expand Down Expand Up @@ -868,7 +865,7 @@ void QgsCustomProjectionDialog::on_pbnSave_clicked()
<< std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
#ifdef QGISDEBUG
std::cout << "Update or insert sql \n" << mySql.toLocal8Bit().data() << std::endl;
Expand Down Expand Up @@ -993,9 +990,8 @@ void QgsCustomProjectionDialog::cboProjectionFamily_highlighted( const QString &
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
assert(myResult == SQLITE_OK);
}
// Set up the query to retrieve the projection information needed to populate the PROJECTION list
QString mySql = "select parameters from tbl_projection name where name='"+theText+"'";
#ifdef QGISDEBUG
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -434,7 +434,7 @@ bool QgsMapLayer::loadNamedStyleFromDb (const QString db, const QString theURI,
QgsDebugMsg( QString("Trying to load style for \"%1\" from \"%2\"").arg(theURI).arg(db) );

myResult = sqlite3_open(db.toUtf8().data(), &myDatabase);
if (!myResult)
if (myResult!=SQLITE_OK)
{
return false;
}
Expand Down Expand Up @@ -610,7 +610,7 @@ QString QgsMapLayer::saveNamedStyle ( const QString theURI, bool & theResultFlag
int myResult;

myResult = sqlite3_open( QDir( QgsApplication::qgisSettingsDirPath() ).absoluteFilePath( "qgis.qmldb").toUtf8().data(), &myDatabase);
if (myResult)
if (myResult!=SQLITE_OK)
{
return tr("User database could not be opened.");
}
Expand Down

0 comments on commit 23bf2a3

Please sign in to comment.