Skip to content
Permalink
Browse files

Merge pull request #429 from tecoholic/ramp_srch

added searching of colorramps in style manager
  • Loading branch information
etiennesky committed Jul 3, 2013
2 parents d2b2bb1 + 6a2bd62 commit 07897600442341177a874c60feafa51ee460bc70
@@ -218,7 +218,13 @@ class QgsStyleV2
QString fileName();

//! return the names of the symbols which have a matching 'substring' in its defintion
QStringList findSymbols( QString qword );
/*!
* \param type is either SymbolEntity or ColorrampEntity
* \param qword is the query string to search the symbols or colorramps.
* \return A QStringList of the matched symbols or colorramps
* */
QStringList findSymbols( StyleEntity type, QString qword );


//! return the tags associated with the symbol
/*!
@@ -744,15 +744,17 @@ bool QgsStyleV2::group( StyleEntity type, QString name, int groupid )
return runEmptyQuery( query );
}

QStringList QgsStyleV2::findSymbols( QString qword )
QStringList QgsStyleV2::findSymbols( StyleEntity type, QString qword )
{
if ( !mCurrentDB )
{
QgsDebugMsg( "Sorry! Cannot open database to search" );
return QStringList();
}

char *query = sqlite3_mprintf( "SELECT name FROM symbol WHERE xml LIKE '%%%q%%'", qword.toUtf8().constData() );
QString item = ( type == SymbolEntity ) ? "symbol" : "colorramp";
char *query = sqlite3_mprintf( "SELECT name FROM %q WHERE xml LIKE '%%%q%%'",
item.toUtf8().constData(), qword.toUtf8().constData() );

sqlite3_stmt *ppStmt;
int nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
@@ -765,7 +767,6 @@ QStringList QgsStyleV2::findSymbols( QString qword )

sqlite3_finalize( ppStmt );


query = sqlite3_mprintf( "SELECT id FROM tag WHERE name LIKE '%%%q%%'", qword.toUtf8().constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );

@@ -780,7 +781,16 @@ QStringList QgsStyleV2::findSymbols( QString qword )

QString dummy = tagids.join( ", " );

query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q)", dummy.toUtf8().constData() );
if ( type == SymbolEntity )
{
query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q)",
dummy.toUtf8().constData() );
}
else
{
query = sqlite3_mprintf( "SELECT colorramp_id FROM ctagmap WHERE tag_id IN (%q)",
dummy.toUtf8().constData() );
}
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );

QStringList symbolids;
@@ -793,7 +803,8 @@ QStringList QgsStyleV2::findSymbols( QString qword )


dummy = symbolids.join( ", " );
query = sqlite3_mprintf( "SELECT name FROM symbol WHERE id IN (%q)", dummy.toUtf8().constData() );
query = sqlite3_mprintf( "SELECT name FROM %q WHERE id IN (%q)",
item.toUtf8().constData(), dummy.toUtf8().constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
@@ -278,7 +278,12 @@ class CORE_EXPORT QgsStyleV2
QString fileName() { return mFileName; }

//! return the names of the symbols which have a matching 'substring' in its defintion
QStringList findSymbols( QString qword );
/*!
* \param type is either SymbolEntity or ColorrampEntity
* \param qword is the query string to search the symbols or colorramps.
* \return A QStringList of the matched symbols or colorramps
* */
QStringList findSymbols( StyleEntity type, QString qword );

//! return the tags associated with the symbol
/*!
@@ -1127,8 +1127,17 @@ void QgsStyleV2ManagerDialog::setSymbolsChecked( QStringList symbols )

void QgsStyleV2ManagerDialog::filterSymbols( QString qword )
{
QStringList symbols = mStyle->findSymbols( qword );
populateSymbols( symbols );
QStringList items;
if ( currentItemType() == 3 )
{
items = mStyle->findSymbols( QgsStyleV2::ColorrampEntity, qword );
populateColorRamps( items );
}
else
{
items = mStyle->findSymbols( QgsStyleV2::SymbolEntity, qword );
populateSymbols( items );
}
}

void QgsStyleV2ManagerDialog::tagsChanged()
@@ -103,7 +103,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
void populateSymbols( QStringList symbolNames, bool checkable = false );

//! populate list view with color ramps
void populateColorRamps( QStringList colorRamps, bool check );
void populateColorRamps( QStringList colorRamps, bool checkable = false );

int currentItemType();
QString currentItemName();
@@ -349,6 +349,6 @@ void QgsSymbolsListWidget::on_groupsCombo_currentIndexChanged( int index )

void QgsSymbolsListWidget::on_groupsCombo_editTextChanged( const QString &text )
{
QStringList symbols = mStyle->findSymbols( text );
QStringList symbols = mStyle->findSymbols( QgsStyleV2::SymbolEntity, text );
populateSymbols( symbols );
}

0 comments on commit 0789760

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