[fix] Fix IndexFilter bug with negative limits
This commit is contained in:
parent
a96701bb85
commit
e260eac830
16
filter.cpp
16
filter.cpp
|
@ -254,15 +254,21 @@ bool IndexFilter::filterRow(const QModelIndex& sourceIndex) const
|
|||
|
||||
bool minimumIsValid;
|
||||
int minimum = m_minimumIndex.toInt(&minimumIsValid);
|
||||
int actualMinimum = (sourceRowCount + minimum) % sourceRowCount;
|
||||
bool lowerThanMinimumIndex = minimumIsValid && sourceRow < actualMinimum;
|
||||
if (minimumIsValid) {
|
||||
int actualMinimum = minimum < 0 ? sourceRowCount + minimum : minimum;
|
||||
if (sourceRow < actualMinimum)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool maximumIsValid;
|
||||
int maximum = m_maximumIndex.toInt(&maximumIsValid);
|
||||
int actualMaximum = (sourceRowCount + maximum) % sourceRowCount;
|
||||
bool greaterThanMaximumIndex = maximumIsValid && sourceRow >actualMaximum;
|
||||
if (maximumIsValid) {
|
||||
int actualMaximum = maximum < 0 ? sourceRowCount + maximum : maximum;
|
||||
if (sourceRow > actualMaximum)
|
||||
return false;
|
||||
}
|
||||
|
||||
return !lowerThanMinimumIndex && !greaterThanMaximumIndex;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue