! depending on the currently selected values column type (column mode) updates the widgets for the values column format, shows/hides the allowed widgets, fills the corresponding combobox with the possible entries. Called when the values column was changed. */
| 152 | values column was changed. |
| 153 | */ |
| 154 | void ValueWidget::updateWidgets() { |
| 155 | const auto type = Value::Type(ui.cbType->currentIndex()); |
| 156 | bool showValues = (type != Value::Type::NoValues); |
| 157 | |
| 158 | ui.cbPosition->setEnabled(showValues); |
| 159 | ui.sbDistance->setEnabled(showValues); |
| 160 | ui.sbRotation->setEnabled(showValues); |
| 161 | ui.sbOpacity->setEnabled(showValues); |
| 162 | ui.kfrFont->setEnabled(showValues); |
| 163 | ui.kcbColor->setEnabled(showValues); |
| 164 | |
| 165 | bool hasInteger = false; |
| 166 | bool hasNumeric = false; |
| 167 | bool hasDateTime = false; |
| 168 | |
| 169 | if (type == Value::Type::CustomColumn) { |
| 170 | ui.lColumn->show(); |
| 171 | cbColumn->show(); |
| 172 | |
| 173 | auto* column = static_cast<Column*>(cbColumn->currentModelIndex().internalPointer()); |
| 174 | if (column) { |
| 175 | if (column->columnMode() == AbstractColumn::ColumnMode::Double) |
| 176 | hasNumeric = true; |
| 177 | else if (column->columnMode() == AbstractColumn::ColumnMode::Integer || column->columnMode() == AbstractColumn::ColumnMode::BigInt) |
| 178 | hasInteger = true; |
| 179 | else if (column->columnMode() == AbstractColumn::ColumnMode::DateTime) |
| 180 | hasDateTime = true; |
| 181 | } |
| 182 | } else { |
| 183 | ui.lColumn->hide(); |
| 184 | cbColumn->hide(); |
| 185 | |
| 186 | if (type == Value::Type::BinEntries) |
| 187 | hasInteger = true; |
| 188 | } |
| 189 | |
| 190 | // hide all the format related widgets first and |
| 191 | // then show only what is required depending of the column mode(s) |
| 192 | ui.lFormat->hide(); |
| 193 | ui.lNumericFormat->hide(); |
| 194 | ui.cbNumericFormat->hide(); |
| 195 | ui.lPrecision->hide(); |
| 196 | ui.sbPrecision->hide(); |
| 197 | ui.lDateTimeFormat->hide(); |
| 198 | ui.cbDateTimeFormat->hide(); |
| 199 | |
| 200 | if (hasNumeric || hasInteger) { |
| 201 | ui.lFormat->show(); |
| 202 | ui.lNumericFormat->show(); |
| 203 | ui.cbNumericFormat->show(); |
| 204 | } |
| 205 | |
| 206 | // precision is only available for Numeric |
| 207 | if (hasNumeric) { |
| 208 | ui.lPrecision->show(); |
| 209 | ui.sbPrecision->show(); |
| 210 | } |
| 211 |
no test coverage detected