MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / addFile

Method addFile

src/Mod/Start/App/DisplayedFilesModel.cpp:143–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void 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
193void DisplayedFilesModel::clear()
194{

Callers 15

buildWidgetMethod · 0.45
SaveMethod · 0.45
RestoreMethod · 0.45
SaveMethod · 0.45
RestoreMethod · 0.45
SaveMethod · 0.45
RestoreMethod · 0.45
SaveMethod · 0.45
RestoreMethod · 0.45
SaveMethod · 0.45
RestoreMethod · 0.45
RestoreMethod · 0.45

Calls 8

freecadCanOpenFunction · 0.85
getCommonFileInfoFunction · 0.85
isReadableMethod · 0.80
toStdStringMethod · 0.80
connectFunction · 0.50
signalsMethod · 0.45
startMethod · 0.45
containsMethod · 0.45

Tested by 2

SaveMethod · 0.36
RestoreMethod · 0.36