feat: use any source for expo/weight/offset (#5220)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
326c58a7fd
commit
4b917b762c
@@ -324,6 +324,37 @@ void Helpers::setBitmappedValue(unsigned int & field, unsigned int value, unsign
|
||||
field = (field & ~fieldmask) | (value << (numbits * index + offset));
|
||||
}
|
||||
|
||||
// return index of 'none' ie zero or first positive data entry in potentially an asymetrical list
|
||||
int Helpers::getFirstPosValueIndex(QComboBox * cbo)
|
||||
{
|
||||
const int cnt = cbo->count();
|
||||
if (cnt == 0)
|
||||
return -1;
|
||||
|
||||
const int idx = cnt / 2;
|
||||
const int val = cbo->itemData(idx).toInt();
|
||||
|
||||
if (val == 0)
|
||||
return idx;
|
||||
|
||||
const int step = val > 0 ? -1 : 1;
|
||||
|
||||
for (int i = idx + step; i >= 0 && i < cbo->count(); i += step) {
|
||||
if (cbo->findData(i) == 0)
|
||||
return i;
|
||||
else if (step < 0 && cbo->itemData(i).toInt() < 0) {
|
||||
if (i++ < cbo->count())
|
||||
return i++;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (step > 0 && cbo->itemData(i).toInt() > 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Flag when simulator is running
|
||||
static bool simulatorRunning = false;
|
||||
|
||||
Reference in New Issue
Block a user