comparison base/ProgressPrinter.cpp @ 439:beb2948baa77

* Merge revisions 1041 to 1130 from sv-rdf-import branch
author Chris Cannam
date Thu, 18 Sep 2008 12:09:32 +0000
parents cfd11e44ad87
children 1aefb666ecfc
comparison
equal deleted inserted replaced
438:32c399d06374 439:beb2948baa77
18 #include <iostream> 18 #include <iostream>
19 19
20 ProgressPrinter::ProgressPrinter(QString message, QObject *parent) : 20 ProgressPrinter::ProgressPrinter(QString message, QObject *parent) :
21 ProgressReporter(parent), 21 ProgressReporter(parent),
22 m_prefix(message), 22 m_prefix(message),
23 m_lastProgress(0) 23 m_lastProgress(0),
24 m_definite(true)
24 { 25 {
25 } 26 }
26 27
27 ProgressPrinter::~ProgressPrinter() 28 ProgressPrinter::~ProgressPrinter()
28 { 29 {
29 if (m_lastProgress > 0 && m_lastProgress != 100) { 30 if (m_lastProgress > 0 && m_lastProgress != 100) {
30 std::cerr << "\r\n"; 31 std::cerr << "\r\n";
31 } 32 }
32 // std::cerr << "(progress printer dtor)" << std::endl; 33 // std::cerr << "(progress printer dtor)" << std::endl;
34 }
35
36 bool
37 ProgressPrinter::isDefinite() const
38 {
39 return m_definite;
40 }
41
42 void
43 ProgressPrinter::setDefinite(bool definite)
44 {
45 m_definite = definite;
33 } 46 }
34 47
35 void 48 void
36 ProgressPrinter::setMessage(QString message) 49 ProgressPrinter::setMessage(QString message)
37 { 50 {
44 if (progress == m_lastProgress) return; 57 if (progress == m_lastProgress) return;
45 if (progress == 100) std::cerr << "\r\n"; 58 if (progress == 100) std::cerr << "\r\n";
46 else { 59 else {
47 std::cerr << "\r" 60 std::cerr << "\r"
48 << m_prefix.toStdString() 61 << m_prefix.toStdString()
49 << (m_prefix == "" ? "" : " ") 62 << (m_prefix == "" ? "" : " ");
50 << progress << "%"; 63 if (m_definite) {
64 std::cerr << progress << "%";
65 } else {
66 std::cerr << "|/-\\"[progress % 4];
67 }
51 } 68 }
52 m_lastProgress = progress; 69 m_lastProgress = progress;
53 } 70 }
54 71