From 9a0c5df74427fee8a9788fbb20165b03cf389906 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 10 Jan 2021 18:00:19 +0100 Subject: statistics/mobile: set currentIndex of QML combo boxes Use Q_PROPERTYs of the StatsManager to correctly set the current index of comboboxes after a state changed. Signed-off-by: Berthold Stoeger --- mobile-widgets/statsmanager.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mobile-widgets/statsmanager.cpp') diff --git a/mobile-widgets/statsmanager.cpp b/mobile-widgets/statsmanager.cpp index d149c9978..8a192fe36 100644 --- a/mobile-widgets/statsmanager.cpp +++ b/mobile-widgets/statsmanager.cpp @@ -28,31 +28,37 @@ void StatsManager::doit() view->plot(state); } -static void setVariableList(const StatsState::VariableList &list, QStringList &stringList) +static void setVariableList(const StatsState::VariableList &list, QStringList &stringList, int &idx) { stringList.clear(); for (const StatsState::Variable &v: list.variables) stringList.push_back(v.name); + idx = list.selected; } -static void setBinnerList(const StatsState::BinnerList &list, QStringList &stringList) +static void setBinnerList(const StatsState::BinnerList &list, QStringList &stringList, int &idx) { stringList.clear(); for (const QString &v: list.binners) stringList.push_back(v); + idx = list.selected; } void StatsManager::updateUi() { uiState = state.getUIState(); - setVariableList(uiState.var1, var1List); - setBinnerList(uiState.binners1, binner1List); - setVariableList(uiState.var2, var2List); - setBinnerList(uiState.binners2, binner2List); + setVariableList(uiState.var1, var1List, var1Index); + setBinnerList(uiState.binners1, binner1List, binner1Index); + setVariableList(uiState.var2, var2List, var2Index); + setBinnerList(uiState.binners2, binner2List, binner2Index); var1ListChanged(); binner1ListChanged(); var2ListChanged(); binner2ListChanged(); + var1IndexChanged(); + binner1IndexChanged(); + var2IndexChanged(); + binner2IndexChanged(); if (view) view->plot(state); -- cgit v1.2.3-70-g09d2