@@ -47,7 +47,7 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz"); | |||||
47 | struct VariableModel::VariableModelPrivate { |
|
47 | struct VariableModel::VariableModelPrivate { | |
48 | /// Variables created in SciQlop |
|
48 | /// Variables created in SciQlop | |
49 | std::vector<std::shared_ptr<Variable> > m_Variables; |
|
49 | std::vector<std::shared_ptr<Variable> > m_Variables; | |
50 |
std::unordered_map<Variable |
|
50 | std::unordered_map<std::shared_ptr<Variable>, double> m_VariableToProgress; | |
51 |
|
51 | |||
52 | /// Return the row index of the variable. -1 if it's not found |
|
52 | /// Return the row index of the variable. -1 if it's not found | |
53 | int indexOfVariable(Variable *variable) const noexcept; |
|
53 | int indexOfVariable(Variable *variable) const noexcept; | |
@@ -99,6 +99,9 void VariableModel::deleteVariable(std::shared_ptr<Variable> variable) noexcept | |||||
99 | << tr("Can't delete variable %1 from the model: the variable is not in the model") |
|
99 | << tr("Can't delete variable %1 from the model: the variable is not in the model") | |
100 | .arg(variable->name()); |
|
100 | .arg(variable->name()); | |
101 | } |
|
101 | } | |
|
102 | ||||
|
103 | // Removes variable from progress map | |||
|
104 | impl->m_VariableToProgress.erase(variable); | |||
102 | } |
|
105 | } | |
103 |
|
106 | |||
104 |
|
107 | |||
@@ -109,7 +112,7 std::shared_ptr<Variable> VariableModel::variable(int index) const | |||||
109 |
|
112 | |||
110 | void VariableModel::setDataProgress(std::shared_ptr<Variable> variable, double progress) |
|
113 | void VariableModel::setDataProgress(std::shared_ptr<Variable> variable, double progress) | |
111 | { |
|
114 | { | |
112 |
impl->m_VariableToProgress[variable |
|
115 | impl->m_VariableToProgress[variable] = progress; | |
113 | auto modelIndex = createIndex(impl->indexOfVariable(variable.get()), NAME_COLUMN); |
|
116 | auto modelIndex = createIndex(impl->indexOfVariable(variable.get()), NAME_COLUMN); | |
114 |
|
117 | |||
115 | emit dataChanged(modelIndex, modelIndex); |
|
118 | emit dataChanged(modelIndex, modelIndex); | |
@@ -169,7 +172,7 QVariant VariableModel::data(const QModelIndex &index, int role) const | |||||
169 | else if (role == VariableRoles::ProgressRole) { |
|
172 | else if (role == VariableRoles::ProgressRole) { | |
170 | if (auto variable = impl->m_Variables.at(index.row())) { |
|
173 | if (auto variable = impl->m_Variables.at(index.row())) { | |
171 |
|
174 | |||
172 |
auto it = impl->m_VariableToProgress.find(variable |
|
175 | auto it = impl->m_VariableToProgress.find(variable); | |
173 | if (it != impl->m_VariableToProgress.cend()) { |
|
176 | if (it != impl->m_VariableToProgress.cend()) { | |
174 | return it->second; |
|
177 | return it->second; | |
175 | } |
|
178 | } |
General Comments 0
You need to be logged in to leave comments.
Login now