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 |