src/documentmanager.cpp

changeset 1323
05b3e173c900
parent 1318
568fcfc6da71
child 1326
69a90bd2dba2
equal deleted inserted replaced
1322:d8935cdb24c0 1323:05b3e173c900
17 */ 17 */
18 18
19 #include <QDir> 19 #include <QDir>
20 #include <QFileInfo> 20 #include <QFileInfo>
21 #include <QMessageBox> 21 #include <QMessageBox>
22 #include <QSettings>
22 #include "documentmanager.h" 23 #include "documentmanager.h"
23 #include "lddocument.h" 24 #include "lddocument.h"
24 #include "partdownloader.h" 25 #include "partdownloader.h"
25 #include "parser.h" 26 #include "parser.h"
26 #include "editHistory.h" 27 #include "editHistory.h"
141 if (document == nullptr) 142 if (document == nullptr)
142 unknowns << reference->referenceName(); 143 unknowns << reference->referenceName();
143 } 144 }
144 } 145 }
145 146
146 if (m_config->tryDownloadMissingFiles() and not unknowns.isEmpty()) 147 if (config::tryDownloadMissingFiles() and not unknowns.isEmpty())
147 { 148 {
148 PartDownloader dl (m_window); 149 PartDownloader dl (m_window);
149 dl.setSourceType (PartDownloader::PartsTracker); 150 dl.setSourceType (PartDownloader::PartsTracker);
150 dl.setPrimaryFile (file); 151 dl.setPrimaryFile (file);
151 152
198 199
199 QString DocumentManager::findDocument(QString name) const 200 QString DocumentManager::findDocument(QString name) const
200 { 201 {
201 name = name.replace("\\", "/"); 202 name = name.replace("\\", "/");
202 203
203 for (const Library& library : ::config->libraries()) 204 for (const Library& library : config::libraries())
204 { 205 {
205 for (const QString& subdirectory : {"parts", "p"}) 206 for (const QString& subdirectory : {"parts", "p"})
206 { 207 {
207 QDir dir {library.path + "/" + subdirectory}; 208 QDir dir {library.path + "/" + subdirectory};
208 209
278 } 279 }
279 } 280 }
280 281
281 void DocumentManager::addRecentFile (QString path) 282 void DocumentManager::addRecentFile (QString path)
282 { 283 {
283 QStringList recentFiles = m_config->recentFiles(); 284 QStringList recentFiles = config::recentFiles();
284 int idx = recentFiles.indexOf (path); 285 int idx = recentFiles.indexOf (path);
285 286
286 // If this file already is in the list, pop it out. 287 // If this file already is in the list, pop it out.
287 if (idx != -1) 288 if (idx != -1)
288 { 289 {
296 while (countof(recentFiles) > (MaxRecentFiles - 1)) 297 while (countof(recentFiles) > (MaxRecentFiles - 1))
297 recentFiles.removeAt (0); 298 recentFiles.removeAt (0);
298 299
299 // Add the file 300 // Add the file
300 recentFiles << path; 301 recentFiles << path;
301 m_config->setRecentFiles (recentFiles); 302 config::setRecentFiles (recentFiles);
302 m_window->syncSettings(); 303 settingsObject().sync();
303 m_window->updateRecentFilesMenu(); 304 m_window->updateRecentFilesMenu();
304 } 305 }
305 306
306 bool DocumentManager::isSafeToCloseAll() 307 bool DocumentManager::isSafeToCloseAll()
307 { 308 {
331 bool DocumentManager::preInline (LDDocument* doc, Model& model, bool deep, bool renderinline) 332 bool DocumentManager::preInline (LDDocument* doc, Model& model, bool deep, bool renderinline)
332 { 333 {
333 // Possibly substitute with logoed studs: 334 // Possibly substitute with logoed studs:
334 // stud.dat -> stud-logo.dat 335 // stud.dat -> stud-logo.dat
335 // stud2.dat -> stud-logo2.dat 336 // stud2.dat -> stud-logo2.dat
336 if (m_config->useLogoStuds() and renderinline) 337 if (config::useLogoStuds() and renderinline)
337 { 338 {
338 // Ensure logoed studs are loaded first 339 // Ensure logoed studs are loaded first
339 loadLogoedStuds(); 340 loadLogoedStuds();
340 341
341 if (doc->name() == "stud.dat" and m_logoedStud) 342 if (doc->name() == "stud.dat" and m_logoedStud)

mercurial