Skip to content

Commit 6a2bd62

Browse files
author
Arunmozhi
committed
added searching of colorramps in style manager
1 parent f22c62a commit 6a2bd62

File tree

6 files changed

+42
-11
lines changed

6 files changed

+42
-11
lines changed

python/core/symbology-ng/qgsstylev2.sip

+7-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ class QgsStyleV2
218218
QString fileName();
219219

220220
//! return the names of the symbols which have a matching 'substring' in its defintion
221-
QStringList findSymbols( QString qword );
221+
/*!
222+
* \param type is either SymbolEntity or ColorrampEntity
223+
* \param qword is the query string to search the symbols or colorramps.
224+
* \return A QStringList of the matched symbols or colorramps
225+
* */
226+
QStringList findSymbols( StyleEntity type, QString qword );
227+
222228

223229
//! return the tags associated with the symbol
224230
/*!

src/core/symbology-ng/qgsstylev2.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -744,15 +744,17 @@ bool QgsStyleV2::group( StyleEntity type, QString name, int groupid )
744744
return runEmptyQuery( query );
745745
}
746746

747-
QStringList QgsStyleV2::findSymbols( QString qword )
747+
QStringList QgsStyleV2::findSymbols( StyleEntity type, QString qword )
748748
{
749749
if ( !mCurrentDB )
750750
{
751751
QgsDebugMsg( "Sorry! Cannot open database to search" );
752752
return QStringList();
753753
}
754754

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

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

766768
sqlite3_finalize( ppStmt );
767769

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

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

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

783-
query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q)", dummy.toUtf8().constData() );
784+
if ( type == SymbolEntity )
785+
{
786+
query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q)",
787+
dummy.toUtf8().constData() );
788+
}
789+
else
790+
{
791+
query = sqlite3_mprintf( "SELECT colorramp_id FROM ctagmap WHERE tag_id IN (%q)",
792+
dummy.toUtf8().constData() );
793+
}
784794
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
785795

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

794804

795805
dummy = symbolids.join( ", " );
796-
query = sqlite3_mprintf( "SELECT name FROM symbol WHERE id IN (%q)", dummy.toUtf8().constData() );
806+
query = sqlite3_mprintf( "SELECT name FROM %q WHERE id IN (%q)",
807+
item.toUtf8().constData(), dummy.toUtf8().constData() );
797808
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
798809
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
799810
{

src/core/symbology-ng/qgsstylev2.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ class CORE_EXPORT QgsStyleV2
278278
QString fileName() { return mFileName; }
279279

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

283288
//! return the tags associated with the symbol
284289
/*!

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,17 @@ void QgsStyleV2ManagerDialog::setSymbolsChecked( QStringList symbols )
11241124

11251125
void QgsStyleV2ManagerDialog::filterSymbols( QString qword )
11261126
{
1127-
QStringList symbols = mStyle->findSymbols( qword );
1128-
populateSymbols( symbols );
1127+
QStringList items;
1128+
if ( currentItemType() == 3 )
1129+
{
1130+
items = mStyle->findSymbols( QgsStyleV2::ColorrampEntity, qword );
1131+
populateColorRamps( items );
1132+
}
1133+
else
1134+
{
1135+
items = mStyle->findSymbols( QgsStyleV2::SymbolEntity, qword );
1136+
populateSymbols( items );
1137+
}
11291138
}
11301139

11311140
void QgsStyleV2ManagerDialog::tagsChanged()

src/gui/symbology-ng/qgsstylev2managerdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
103103
void populateSymbols( QStringList symbolNames, bool checkable = false );
104104

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

108108
int currentItemType();
109109
QString currentItemName();

src/gui/symbology-ng/qgssymbolslistwidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,6 @@ void QgsSymbolsListWidget::on_groupsCombo_currentIndexChanged( int index )
357357

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

0 commit comments

Comments
 (0)