2022-10-11 09:26:24 +00:00
|
|
|
pragma Singleton
|
|
|
|
import QtQml 2.14
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function singleShotConnection(prop, handler) {
|
|
|
|
const internalHandler = (...args) => {
|
|
|
|
handler(...args)
|
|
|
|
prop.disconnect(internalHandler)
|
|
|
|
}
|
|
|
|
prop.connect(internalHandler)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getUniqueValuesFromModel(model, prop) {
|
2022-10-17 14:30:35 +00:00
|
|
|
if (!model)
|
|
|
|
return []
|
|
|
|
|
2022-10-11 09:26:24 +00:00
|
|
|
const values = []
|
|
|
|
for (let i = 0; i < model.count; i++)
|
|
|
|
values.push(model.get(i)[prop])
|
|
|
|
|
|
|
|
const onlyUnique = (value, index, self) => self.indexOf(value) === index
|
|
|
|
return values.filter(onlyUnique)
|
|
|
|
}
|
|
|
|
}
|