Skip to content

Commit

Permalink
added a function in qgsstyle for wild card searching
Browse files Browse the repository at this point in the history
  • Loading branch information
Arunmozhi committed Jul 9, 2012
1 parent 345d096 commit 08b40d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/core/symbology-ng/qgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,29 @@ bool QgsStyleV2::regroup( QString symbolName, int groupid )
: sqlite3_mprintf( "UPDATE symbol SET groupid=NULL WHERE name='%q';", array.constData() );
return runEmptyQuery( query );
}

QStringList QgsStyleV2::findSymbols( QString qword )
{
QByteArray array = qword.toUtf8();
char *query;
query = sqlite3_mprintf( "SELECT name FROM symbol WHERE xml LIKE '\%%q\%'", array.constData() );

QStringList symbols;
sqlite3 *db = openDB( mFileName );
if ( db == NULL )
{
QgsDebugMsg( "Sorry! Cannot open DB to search" );
return QStringList();
}
sqlite3_stmt *ppStmt;
int nErr = sqlite3_prepare_v2( db, query, -1, &ppStmt, NULL );
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QString symbolName = QString( reinterpret_cast<const char*>( sqlite3_column_text( ppStmt, 0 ) ) );
symbols.append( symbolName );
}
sqlite3_finalize( ppStmt );
sqlite3_close( db );

return symbols;
}
3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgsstylev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class CORE_EXPORT QgsStyleV2
//! return current file name of the style
QString fileName() { return mFileName; }

//! return the names of the symbols which have a matching 'substring' in its defintion
QStringList findSymbols( QString qword );

protected:

QgsSymbolV2Map mSymbols;
Expand Down

0 comments on commit 08b40d8

Please sign in to comment.