27 #include "ldtypes.h" |
27 #include "ldtypes.h" |
28 #include "document.h" |
28 #include "document.h" |
29 |
29 |
30 // ============================================================================= |
30 // ============================================================================= |
31 // ----------------------------------------------------------------------------- |
31 // ----------------------------------------------------------------------------- |
32 str DoFormat (QList<StringFormatArg> args) |
32 QString DoFormat (QList<StringFormatArg> args) |
33 { |
33 { |
34 assert (args.size() >= 1); |
34 assert (args.size() >= 1); |
35 str text = args[0].value(); |
35 QString text = args[0].value(); |
36 |
36 |
37 for (uchar i = 1; i < args.size(); ++i) |
37 for (uchar i = 1; i < args.size(); ++i) |
38 text = text.arg (args[i].value()); |
38 text = text.arg (args[i].value()); |
39 |
39 |
40 return text; |
40 return text; |
79 return mid; |
79 return mid; |
80 } |
80 } |
81 |
81 |
82 // ============================================================================= |
82 // ============================================================================= |
83 // ----------------------------------------------------------------------------- |
83 // ----------------------------------------------------------------------------- |
84 str Vertex::stringRep (bool mangled) const |
84 QString Vertex::stringRep (bool mangled) const |
85 { |
85 { |
86 str fmtstr = "%1 %2 %3"; |
86 QString fmtstr = "%1 %2 %3"; |
87 |
87 |
88 if (mangled) |
88 if (mangled) |
89 fmtstr = "(%1, %2, %3)"; |
89 fmtstr = "(%1, %2, %3)"; |
90 |
90 |
91 return fmt (fmtstr, coord (X), coord (Y), coord (Z)); |
91 return fmt (fmtstr, coord (X), coord (Y), coord (Z)); |
243 } |
243 } |
244 } |
244 } |
245 |
245 |
246 // ============================================================================= |
246 // ============================================================================= |
247 // ----------------------------------------------------------------------------- |
247 // ----------------------------------------------------------------------------- |
248 str Matrix::stringRep() const |
248 QString Matrix::stringRep() const |
249 { |
249 { |
250 str val; |
250 QString val; |
251 |
251 |
252 for (int i = 0; i < 9; ++i) |
252 for (int i = 0; i < 9; ++i) |
253 { |
253 { |
254 if (i > 0) |
254 if (i > 0) |
255 val += ' '; |
255 val += ' '; |
256 |
256 |
257 val += str::number (m_vals[i]); |
257 val += QString::number (m_vals[i]); |
258 } |
258 } |
259 |
259 |
260 return val; |
260 return val; |
261 } |
261 } |
262 |
262 |
335 m_val = v; |
335 m_val = v; |
336 } |
336 } |
337 |
337 |
338 StringFormatArg::StringFormatArg (const float& v) |
338 StringFormatArg::StringFormatArg (const float& v) |
339 { |
339 { |
340 m_val = str::number (v); |
340 m_val = QString::number (v); |
341 } |
341 } |
342 |
342 |
343 StringFormatArg::StringFormatArg (const double& v) |
343 StringFormatArg::StringFormatArg (const double& v) |
344 { |
344 { |
345 m_val = str::number (v); |
345 m_val = QString::number (v); |
346 } |
346 } |
347 |
347 |
348 StringFormatArg::StringFormatArg (const Vertex& v) |
348 StringFormatArg::StringFormatArg (const Vertex& v) |
349 { |
349 { |
350 m_val = v.stringRep (false); |
350 m_val = v.stringRep (false); |
406 bool File::open (FILE* fp, OpenType rtype) |
406 bool File::open (FILE* fp, OpenType rtype) |
407 { |
407 { |
408 return open ("", rtype, fp); |
408 return open ("", rtype, fp); |
409 } |
409 } |
410 |
410 |
411 bool File::open (str path, OpenType rtype, FILE* fp) |
411 bool File::open (QString path, OpenType rtype, FILE* fp) |
412 { |
412 { |
413 close(); |
413 close(); |
414 |
414 |
415 if (!m_file) |
415 if (!m_file) |
416 m_file = new QFile; |
416 m_file = new QFile; |
452 return m_endIterator; |
452 return m_endIterator; |
453 } |
453 } |
454 |
454 |
455 // ============================================================================= |
455 // ============================================================================= |
456 // ----------------------------------------------------------------------------- |
456 // ----------------------------------------------------------------------------- |
457 void File::write (str msg) |
457 void File::write (QString msg) |
458 { |
458 { |
459 m_file->write (msg.toUtf8(), msg.length()); |
459 m_file->write (msg.toUtf8(), msg.length()); |
460 } |
460 } |
461 |
461 |
462 // ============================================================================= |
462 // ============================================================================= |
463 // ----------------------------------------------------------------------------- |
463 // ----------------------------------------------------------------------------- |
464 bool File::readLine (str& line) |
464 bool File::readLine (QString& line) |
465 { |
465 { |
466 if (!m_textstream || m_textstream->atEnd()) |
466 if (!m_textstream || m_textstream->atEnd()) |
467 return false; |
467 return false; |
468 |
468 |
469 line = m_textstream->readLine(); |
469 line = m_textstream->readLine(); |
542 m_gotdata = m_file->readLine (m_text); |
542 m_gotdata = m_file->readLine (m_text); |
543 } |
543 } |
544 |
544 |
545 // ============================================================================= |
545 // ============================================================================= |
546 // ----------------------------------------------------------------------------- |
546 // ----------------------------------------------------------------------------- |
547 str File::iterator::operator*() |
547 QString File::iterator::operator*() |
548 { |
548 { |
549 return m_text; |
549 return m_text; |
550 } |
550 } |
551 |
551 |
552 // ============================================================================= |
552 // ============================================================================= |