| 141 | } |
| 142 | |
| 143 | void DisplayedFilesModel::addFile(const QString& filePath) |
| 144 | { |
| 145 | const QFileInfo qfi(filePath); |
| 146 | if (!qfi.isReadable()) { |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | if (!freecadCanOpen(qfi.suffix())) { |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | { |
| 155 | QMutexLocker locker(&_mutex); |
| 156 | _fileInfoCache.emplace_back(getCommonFileInfo(filePath.toStdString())); |
| 157 | } |
| 158 | |
| 159 | const auto lowercaseExtension = qfi.suffix().toLower(); |
| 160 | if (lowercaseExtension == QLatin1String("fcstd")) { |
| 161 | const auto runner = new FcstdInfoSource(filePath); |
| 162 | connect( |
| 163 | runner->signals(), |
| 164 | &FcstdInfoSource::Signals::infoAvailable, |
| 165 | this, |
| 166 | &DisplayedFilesModel::processNewFcstdInfo |
| 167 | ); |
| 168 | QThreadPool::globalInstance()->start(runner); |
| 169 | return; |
| 170 | } |
| 171 | const QStringList ignoredExtensions { |
| 172 | QLatin1String("fcmacro"), |
| 173 | QLatin1String("py"), |
| 174 | QLatin1String("pyi"), |
| 175 | QLatin1String("csv"), |
| 176 | QLatin1String("txt") |
| 177 | }; |
| 178 | if (ignoredExtensions.contains(lowercaseExtension)) { |
| 179 | // Don't try to generate a thumbnail for things like this: FreeCAD can read them, but |
| 180 | // there's not much point in showing anything besides a generic icon |
| 181 | return; |
| 182 | } |
| 183 | const auto runner = new ThumbnailSource(filePath); |
| 184 | connect( |
| 185 | runner->signals(), |
| 186 | &ThumbnailSource::Signals::thumbnailAvailable, |
| 187 | this, |
| 188 | &DisplayedFilesModel::processNewThumbnail |
| 189 | ); |
| 190 | QThreadPool::globalInstance()->start(runner); |
| 191 | } |
| 192 | |
| 193 | void DisplayedFilesModel::clear() |
| 194 | { |