| 260 | } |
| 261 | |
| 262 | QVariant TemplateTableModel::templateData(Template* temp, const QModelIndex &index, int role) const |
| 263 | { |
| 264 | if (role == Qt::BackgroundRole) |
| 265 | { |
| 266 | #ifdef Q_OS_ANDROID |
| 267 | return QBrush(paletteColor(view, QPalette::Background)); |
| 268 | #else |
| 269 | return QBrush(paletteColor(view, QPalette::Base)); |
| 270 | #endif |
| 271 | } |
| 272 | |
| 273 | auto visibility = view.getTemplateVisibility(temp); |
| 274 | if (role == Qt::ForegroundRole) |
| 275 | { |
| 276 | auto text_color = QColor::fromRgb(255, 51, 51); |
| 277 | if (temp->getTemplateState() == Template::Invalid) |
| 278 | { |
| 279 | if (visibility.visible) |
| 280 | text_color = text_color.darker(); |
| 281 | } |
| 282 | else if (visibility.visible) |
| 283 | text_color = paletteColor(view, QPalette::Foreground); |
| 284 | else |
| 285 | text_color = QPalette().color(QPalette::Disabled, QPalette::Foreground); |
| 286 | return QBrush(text_color); |
| 287 | } |
| 288 | |
| 289 | switch (combined(index.column(), Qt::ItemDataRole(role))) |
| 290 | { |
| 291 | case combined(visibilityColumn(), Qt::CheckStateRole): |
| 292 | if (visibility.visible && temp->getTemplateState() != Template::Loaded) |
| 293 | return Qt::PartiallyChecked; |
| 294 | return toCheckState(visibility.visible); |
| 295 | |
| 296 | case combined(opacityColumn(), Qt::DisplayRole): |
| 297 | case combined(opacityColumn(), Qt::EditRole): |
| 298 | return visibility.opacity; |
| 299 | |
| 300 | case combined(opacityColumn(), Qt::DecorationRole): |
| 301 | if (temp->getTemplateState() == Template::Invalid) |
| 302 | return QIcon::fromTheme(QLatin1String("image-missing"), QIcon{QLatin1String(":/images/close.png")}); |
| 303 | if (visibility.visible) |
| 304 | return QColor::fromCmykF(0, 0, 0, visibility.opacity); |
| 305 | return QColor{Qt::transparent}; |
| 306 | |
| 307 | case combined(visibilityColumn(), Qt::DisplayRole): |
| 308 | if (!touchMode()) |
| 309 | break; |
| 310 | Q_FALLTHROUGH(); |
| 311 | case combined(nameColumn(), Qt::DisplayRole): |
| 312 | return temp->getTemplateFilename(); |
| 313 | |
| 314 | case combined(visibilityColumn(), Qt::ToolTipRole): |
| 315 | if (!touchMode()) |
| 316 | break; |
| 317 | Q_FALLTHROUGH(); |
| 318 | case combined(nameColumn(), Qt::ToolTipRole): |
| 319 | return temp->getTemplatePath(); |
nothing calls this directly
no test coverage detected