src/primitives.cpp

changeset 1065
c8ecddbd99e9
parent 1064
4c7a353cf583
child 1072
9ce9496427f2
equal deleted inserted replaced
1064:4c7a353cf583 1065:c8ecddbd99e9
73 m_primitives.append(info); 73 m_primitives.append(info);
74 } 74 }
75 } 75 }
76 76
77 populateCategories(); 77 populateCategories();
78 print(tr("%1 primitives loaded.") + "\n", length(m_primitives)); 78 print(tr("%1 primitives loaded.") + "\n", countof(m_primitives));
79 } 79 }
80 } 80 }
81 81
82 82
83 void PrimitiveManager::startScan() 83 void PrimitiveManager::startScan()
91 { 91 {
92 if (m_activeScanner) 92 if (m_activeScanner)
93 { 93 {
94 m_primitives = m_activeScanner->scannedPrimitives(); 94 m_primitives = m_activeScanner->scannedPrimitives();
95 populateCategories(); 95 populateCategories();
96 print(tr("%1 primitives scanned"), length(m_primitives)); 96 print(tr("%1 primitives scanned"), countof(m_primitives));
97 delete m_activeScanner; 97 delete m_activeScanner;
98 m_activeScanner = nullptr; 98 m_activeScanner = nullptr;
99 } 99 }
100 }); 100 });
101 } 101 }
403 QString PrimitiveModel::typeName(PrimitiveModel::Type type) 403 QString PrimitiveModel::typeName(PrimitiveModel::Type type)
404 { 404 {
405 // Not translated as primitives are in English. 405 // Not translated as primitives are in English.
406 const char* names[] = {"Circle", "Cylinder", "Disc", "Disc Negative", "Ring", "Cone"}; 406 const char* names[] = {"Circle", "Cylinder", "Disc", "Disc Negative", "Ring", "Cone"};
407 407
408 if (type >= 0 and type < length(names)) 408 if (type >= 0 and type < countof(names))
409 return names[type]; 409 return names[type];
410 else 410 else
411 return "Unknown"; 411 return "Unknown";
412 } 412 }
413 413
434 QString root = roots[type]; 434 QString root = roots[type];
435 QString numberString = (type == Ring or type == Cone) ? format ("%1", ringNumber) : ""; 435 QString numberString = (type == Ring or type == Cone) ? format ("%1", ringNumber) : "";
436 436
437 // Truncate the root if necessary (7-16rin4.dat for instance). 437 // Truncate the root if necessary (7-16rin4.dat for instance).
438 // However, always keep the root at least 2 characters. 438 // However, always keep the root at least 2 characters.
439 int extra = (length(frac) + length(numberString) + length(root)) - 8; 439 int extra = (countof(frac) + countof(numberString) + countof(root)) - 8;
440 root.chop(qBound(0, extra, 2)); 440 root.chop(qBound(0, extra, 2));
441 441
442 // Stick them all together and return the result. 442 // Stick them all together and return the result.
443 return prefix + frac + root + numberString + ".dat"; 443 return prefix + frac + root + numberString + ".dat";
444 } 444 }
579 QObject(parent), 579 QObject(parent),
580 HierarchyElement(parent), 580 HierarchyElement(parent),
581 m_manager(parent), 581 m_manager(parent),
582 m_iterator(LDPaths::primitivesDir(), QDirIterator::Subdirectories) 582 m_iterator(LDPaths::primitivesDir(), QDirIterator::Subdirectories)
583 { 583 {
584 m_basePathLength = length(LDPaths::primitivesDir().absolutePath()); 584 m_basePathLength = countof(LDPaths::primitivesDir().absolutePath());
585 print("Scanning primitives..."); 585 print("Scanning primitives...");
586 } 586 }
587 587
588 /* 588 /*
589 * PrimitiveScanner :: scannedPrimitives 589 * PrimitiveScanner :: scannedPrimitives

mercurial