| 64 | } |
| 65 | |
| 66 | QVariant QmitkModuleTableModel::data(const QModelIndex &index, int role) const |
| 67 | { |
| 68 | if (!index.isValid()) |
| 69 | return QVariant(); |
| 70 | |
| 71 | if (role == Qt::DisplayRole) |
| 72 | { |
| 73 | us::Module *module = d->modules[index.row() + 1]; |
| 74 | switch (index.column()) |
| 75 | { |
| 76 | case 0: |
| 77 | return QVariant::fromValue(static_cast<int>(module->GetModuleId())); |
| 78 | case 1: |
| 79 | return QString::fromStdString(module->GetName()); |
| 80 | case 2: |
| 81 | return QString::fromStdString(module->GetVersion().ToString()); |
| 82 | case 3: |
| 83 | return QString::fromStdString(module->GetLocation()); |
| 84 | } |
| 85 | } |
| 86 | else if (role == Qt::ForegroundRole) |
| 87 | { |
| 88 | us::Module *module = d->modules[index.row() + 1]; |
| 89 | if (!module->IsLoaded()) |
| 90 | { |
| 91 | return QBrush(Qt::gray); |
| 92 | } |
| 93 | } |
| 94 | else if (role == Qt::ToolTipRole) |
| 95 | { |
| 96 | us::Module *module = d->modules[index.row() + 1]; |
| 97 | QString id = QString::number(module->GetModuleId()); |
| 98 | QString name = QString::fromStdString(module->GetName()); |
| 99 | QString version = QString::fromStdString(module->GetVersion().ToString()); |
| 100 | QString location = QString::fromStdString(module->GetLocation()); |
| 101 | QString state = module->IsLoaded() ? "Loaded" : "Unloaded"; |
| 102 | |
| 103 | QString tooltip = "Id: %1\nName: %2\nVersion: %3\nLocation: %7\nState: %9"; |
| 104 | |
| 105 | return tooltip.arg(id, name, version, location, state); |
| 106 | } |
| 107 | return QVariant(); |
| 108 | } |
| 109 | |
| 110 | QVariant QmitkModuleTableModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 111 | { |
nothing calls this directly
no test coverage detected