src/documentmanager.cpp

changeset 1215
77a0270352a3
parent 1012
413ecd6b9801
child 1217
314e12e23c3a
equal deleted inserted replaced
1214:fed9aacd1fab 1215:77a0270352a3
137 continue; 137 continue;
138 138
139 unknowns << static_cast<LDError*> (obj)->fileReferenced(); 139 unknowns << static_cast<LDError*> (obj)->fileReferenced();
140 } 140 }
141 141
142 if (Config->tryDownloadMissingFiles() and not unknowns.isEmpty()) 142 if (config.tryDownloadMissingFiles() and not unknowns.isEmpty())
143 { 143 {
144 PartDownloader dl (m_window); 144 PartDownloader dl (m_window);
145 dl.setSourceType (PartDownloader::PartsTracker); 145 dl.setSourceType (PartDownloader::PartsTracker);
146 dl.setPrimaryFile (file); 146 dl.setPrimaryFile (file);
147 147
223 223
224 if (QFileInfo::exists (relativePath)) 224 if (QFileInfo::exists (relativePath))
225 return relativePath; 225 return relativePath;
226 226
227 // Try with just the LDraw path first 227 // Try with just the LDraw path first
228 QString fullPath = format ("%1" DIRSLASH "%2", Config->lDrawPath(), relativePath); 228 QString fullPath = format ("%1" DIRSLASH "%2", config.lDrawPath(), relativePath);
229 229
230 if (QFileInfo::exists (fullPath)) 230 if (QFileInfo::exists (fullPath))
231 return fullPath; 231 return fullPath;
232 232
233 if (subdirs) 233 if (subdirs)
234 { 234 {
235 // Look in sub-directories: parts and p. Also look in the download path, since that's where we download parts 235 // Look in sub-directories: parts and p. Also look in the download path, since that's where we download parts
236 // from the PT to. 236 // from the PT to.
237 QStringList dirs = { Config->lDrawPath(), Config->downloadFilePath() }; 237 QStringList dirs = { config.lDrawPath(), config.downloadFilePath() };
238 for (const QString& topdir : dirs) 238 for (const QString& topdir : dirs)
239 { 239 {
240 for (const QString& subdir : QStringList ({ "parts", "p" })) 240 for (const QString& subdir : QStringList ({ "parts", "p" }))
241 { 241 {
242 fullPath = format ("%1" DIRSLASH "%2" DIRSLASH "%3", topdir, subdir, relativePath); 242 fullPath = format ("%1" DIRSLASH "%2" DIRSLASH "%3", topdir, subdir, relativePath);
360 return load; 360 return load;
361 } 361 }
362 362
363 void DocumentManager::addRecentFile (QString path) 363 void DocumentManager::addRecentFile (QString path)
364 { 364 {
365 QStringList recentFiles = Config->recentFiles(); 365 QStringList recentFiles = config.recentFiles();
366 int idx = recentFiles.indexOf (path); 366 int idx = recentFiles.indexOf (path);
367 367
368 // If this file already is in the list, pop it out. 368 // If this file already is in the list, pop it out.
369 if (idx != -1) 369 if (idx != -1)
370 { 370 {
378 while (recentFiles.size() > (MaxRecentFiles - 1)) 378 while (recentFiles.size() > (MaxRecentFiles - 1))
379 recentFiles.removeAt (0); 379 recentFiles.removeAt (0);
380 380
381 // Add the file 381 // Add the file
382 recentFiles << path; 382 recentFiles << path;
383 Config->setRecentFiles (recentFiles); 383 config.setRecentFiles (recentFiles);
384 m_window->syncSettings(); 384 m_window->syncSettings();
385 m_window->updateRecentFilesMenu(); 385 m_window->updateRecentFilesMenu();
386 } 386 }
387 387
388 bool DocumentManager::isSafeToCloseAll() 388 bool DocumentManager::isSafeToCloseAll()
413 bool DocumentManager::preInline (LDDocument* doc, LDObjectList& objs, bool deep, bool renderinline) 413 bool DocumentManager::preInline (LDDocument* doc, LDObjectList& objs, bool deep, bool renderinline)
414 { 414 {
415 // Possibly substitute with logoed studs: 415 // Possibly substitute with logoed studs:
416 // stud.dat -> stud-logo.dat 416 // stud.dat -> stud-logo.dat
417 // stud2.dat -> stud-logo2.dat 417 // stud2.dat -> stud-logo2.dat
418 if (Config->useLogoStuds() and renderinline) 418 if (config.useLogoStuds() and renderinline)
419 { 419 {
420 // Ensure logoed studs are loaded first 420 // Ensure logoed studs are loaded first
421 loadLogoedStuds(); 421 loadLogoedStuds();
422 422
423 if (doc->name() == "stud.dat" and m_logoedStud) 423 if (doc->name() == "stud.dat" and m_logoedStud)

mercurial