Changeset 6343515 in subsurface


Ignore:
Timestamp:
Nov 25, 2017, 3:41:55 PM (2 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
82898a8
Parents:
72318f2
git-author:
Berthold Stoeger <bstoeger@…> (11/25/17 09:26:00)
git-committer:
Dirk Hohndel <dirk@…> (11/25/17 15:41:55)
Message:

Use equality instead of substring comparison in suits and buddy filter

This commit is a continuation of commit 739b27427cfb5119eebe214c984843cd5d155620,
in which a substring comparison was replaced by equality comparison to
avoid confusing UI behavior of the filter interface.

The suit and buddy filters were plagued by the same problem, so change
their code in analogy.

Fixes #551 (in conjunction with commit dd2466f51899aae406dc8c13904787710f30ec1c).

Signed-off-by: Berthold Stoeger <bstoeger@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qt-models/filtermodels.cpp

    rdd2466f5 r6343515  
    137137        // there is a suit selected
    138138        QStringList suitList = stringList();
    139         if (!suitList.isEmpty()) {
    140                 suitList.removeLast(); // remove the "Show Empty Suits";
    141                 for (int i = 0; i < rowCount(); i++) {
    142                         if (checkState[i] && (suit.indexOf(stringList()[i]) != -1)) {
    143                                 return true;
    144                         }
    145                 }
     139        // Ignore last item, since this is the "Show Empty Tags" entry
     140        for (int i = 0; i < rowCount() - 1; i++) {
     141                if (checkState[i] && suit == suitList[i])
     142                        return true;
    146143        }
    147144        return false;
     
    244241        // have at least one buddy
    245242        QStringList buddyList = stringList();
    246         if (!buddyList.isEmpty()) {
    247                 buddyList.removeLast(); // remove the "Show Empty Tags";
    248                 for (int i = 0; i < rowCount(); i++) {
    249                         if (checkState[i] && (diveBuddy.indexOf(stringList()[i]) != -1 || divemaster.indexOf(stringList()[i]) != -1)) {
    250                                 return true;
    251                         }
    252                 }
     243        // Ignore last item, since this is the "Show Empty Tags" entry
     244        for (int i = 0; i < rowCount() - 1; i++) {
     245                if (checkState[i] && (diveBuddy == buddyList[i] || divemaster == buddyList[i]))
     246                        return true;
    253247        }
    254248        return false;
Note: See TracChangeset for help on using the changeset viewer.