Skip to content
Permalink
Browse files

added a function in qgsstyle for wild card searching

  • Loading branch information
tecoholic committed Jul 9, 2012
1 parent 345d096 commit 08b40d8c9e427290cc0f5177fa1766ab6048d007
Showing with 29 additions and 0 deletions.
  1. +26 −0 src/core/symbology-ng/qgsstylev2.cpp
  2. +3 −0 src/core/symbology-ng/qgsstylev2.h
@@ -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;
}
@@ -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;

0 comments on commit 08b40d8

Please sign in to comment.
You can’t perform that action at this time.