Skip to content

Commit

Permalink
Applied patch to close #25 - allow case insensitive search of attribu…
Browse files Browse the repository at this point in the history
…te table

git-svn-id: http://svn.osgeo.org/qgis/trunk@14241 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Sep 16, 2010
1 parent e6658a0 commit e9f245d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/app/attributetable/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,16 @@ void QgsAttributeTableDialog::search()
int fldIndex = mLayer->fieldNameIndex( fieldName );
QVariant::Type fldType = flds[fldIndex].type();
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
QString sensString = "ILIKE";
if (cbxCaseSensitive->isChecked()) {
sensString = "LIKE";
}

QString str = QString( "%1 %2 '%3'" )
.arg( QgsSearchTreeNode::quotedColumnRef( fieldName ) )
.arg( numeric ? "=" : "~" )
.arg( mQuery->displayText().replace( "'", "''" ) ); // escape quotes

.arg( numeric ? "=" : sensString )
.arg( numeric ? mQuery->displayText().replace( "'", "''" ) :
"%" + mQuery->displayText().replace ("'", "''") + "%" ); // escape quotes
doSearch( str );
}

Expand Down
22 changes: 19 additions & 3 deletions src/ui/qgsattributetabledialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@
<item>
<widget class="QCheckBox" name="cbxShowSelectedOnly">
<property name="text">
<string>Show selected records only</string>
<string>Show selected only</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxSearchSelectedOnly">
<property name="text">
<string>Search selected records only</string>
<string>Search selected only</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxCaseSensitive">
<property name="text">
<string>Case sensitive</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -68,8 +78,14 @@
</item>
<item>
<widget class="QPushButton" name="mHelpButton">
<property name="minimumSize">
<size>
<width>85</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Help</string>
<string>?</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit e9f245d

Please sign in to comment.