| 148 | } |
| 149 | virtual ~FilterModel() { m_thumbnailingPool.waitForDone(500); } |
| 150 | virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const |
| 151 | { |
| 152 | auto model = sourceModel(); |
| 153 | if (!model) |
| 154 | return QVariant(); |
| 155 | if (role == Qt::DisplayRole || role == Qt::EditRole) |
| 156 | { |
| 157 | QVariant result = sourceModel()->data(mapToSource(proxyIndex), role); |
| 158 | return result.toString().remove(QRegularExpression("\\.png$")); |
| 159 | } |
| 160 | if (role == Qt::DecorationRole) |
| 161 | { |
| 162 | QVariant result = |
| 163 | sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole); |
| 164 | QString filePath = result.toString(); |
| 165 | QIcon temp; |
| 166 | if (!watched.contains(filePath)) |
| 167 | { |
| 168 | ((QFileSystemWatcher &)watcher).addPath(filePath); |
| 169 | ((QSet<QString> &)watched).insert(filePath); |
| 170 | } |
| 171 | if (m_thumbnailCache->get(filePath, temp)) |
| 172 | { |
| 173 | return temp; |
| 174 | } |
| 175 | if (!m_failed.contains(filePath)) |
| 176 | { |
| 177 | ((FilterModel *)this)->thumbnailImage(filePath); |
| 178 | } |
| 179 | return (m_thumbnailCache->get("placeholder")); |
| 180 | } |
| 181 | return sourceModel()->data(mapToSource(proxyIndex), role); |
| 182 | } |
| 183 | virtual bool setData(const QModelIndex &index, const QVariant &value, |
| 184 | int role = Qt::EditRole) |
| 185 | { |
no test coverage detected