Skip to content
Permalink
Browse files

tags included in symbol searching

  • Loading branch information
tecoholic committed Jul 18, 2012
1 parent 4a6ac28 commit dec6216f6a152639156f5028b91fed4c16bd5780
Showing with 34 additions and 0 deletions.
  1. +34 −0 src/core/symbology-ng/qgsstylev2.cpp
@@ -656,6 +656,9 @@ QStringList QgsStyleV2::findSymbols( QString qword )
}

QStringList symbols;
QStringList tagids;
QStringList symbolids;

char *query;
sqlite3_stmt *ppStmt;
QByteArray array = qword.toUtf8();
@@ -669,6 +672,37 @@ QStringList QgsStyleV2::findSymbols( QString qword )
}
sqlite3_finalize( ppStmt );

query = sqlite3_mprintf( "SELECT id FROM tag WHERE name LIKE '%%%q%%';", array.constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
tagids.append( reinterpret_cast<const char*>( sqlite3_column_text( ppStmt, 0 ) ) );
}
sqlite3_finalize( ppStmt );

QString dummy = tagids.join( ", " );
QByteArray dummyArray = dummy.toUtf8();

query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q);", dummyArray.constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
symbolids.append( reinterpret_cast<const char*>( sqlite3_column_text( ppStmt, 0 ) ) );
}
sqlite3_finalize( ppStmt );

dummy = symbolids.join( ", " );
dummyArray = dummy.toUtf8();
query = sqlite3_mprintf( "SELECT name FROM symbol WHERE id IN (%q);", dummyArray.constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, 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 ) ) );
if ( !symbols.contains( symbolName ) )
symbols.append( symbolName );
}
sqlite3_finalize( ppStmt );

return symbols;
}

0 comments on commit dec6216

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