| 134 | } |
| 135 | |
| 136 | QVariant ItemModel::data(const QModelIndex &index, int role) const |
| 137 | { |
| 138 | if (!index.isValid() || index.row() >= displayItems.size()) |
| 139 | return QVariant(); |
| 140 | |
| 141 | switch (role) { |
| 142 | case Qt::DisplayRole: |
| 143 | if (index.column() == DisplayNameColumn) |
| 144 | return displayItems.at(index.row()).displayName; |
| 145 | else if (index.column() == ExtraInfoColumn) |
| 146 | return displayItems.at(index.row()).extraInfo; |
| 147 | break; |
| 148 | case Qt::ToolTipRole: |
| 149 | if (!displayItems.at(index.row()).extraInfo.isEmpty()) |
| 150 | return displayItems.at(index.row()).extraInfo; |
| 151 | case Qt::DecorationRole: |
| 152 | if (index.column() == DisplayNameColumn) |
| 153 | return displayItems[index.row()].icon; |
| 154 | break; |
| 155 | }; |
| 156 | return QVariant(); |
| 157 | } |
| 158 | |
| 159 | void ItemModel::addItems(const QList<ItemInfo> &items) |
| 160 | { |