Mercurial > hg > svcore
annotate data/fileio/ProgressPrinter.cpp @ 377:166c22eff678
* Ensure waveforms are strictly correct even when using a non-power-of-two
non-power-of-sqrt-two block size with cacheing off and painting only small
areas at a time
author | Chris Cannam |
---|---|
date | Thu, 07 Feb 2008 15:25:05 +0000 |
parents | b92513201610 |
children |
rev | line source |
---|---|
Chris@357 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@357 | 2 |
Chris@357 | 3 /* |
Chris@357 | 4 Sonic Visualiser |
Chris@357 | 5 An audio file viewer and annotation editor. |
Chris@357 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@357 | 7 This file copyright 2007 QMUL. |
Chris@357 | 8 |
Chris@357 | 9 This program is free software; you can redistribute it and/or |
Chris@357 | 10 modify it under the terms of the GNU General Public License as |
Chris@357 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@357 | 12 License, or (at your option) any later version. See the file |
Chris@357 | 13 COPYING included with this distribution for more information. |
Chris@357 | 14 */ |
Chris@357 | 15 |
Chris@357 | 16 #include "ProgressPrinter.h" |
Chris@357 | 17 |
Chris@357 | 18 #include <iostream> |
Chris@357 | 19 |
Chris@357 | 20 ProgressPrinter::ProgressPrinter(QString prefix, QObject *parent) : |
Chris@357 | 21 QObject(parent), |
Chris@357 | 22 m_prefix(prefix), |
Chris@357 | 23 m_lastProgress(0) |
Chris@357 | 24 { |
Chris@357 | 25 } |
Chris@357 | 26 |
Chris@357 | 27 ProgressPrinter::~ProgressPrinter() |
Chris@357 | 28 { |
Chris@357 | 29 if (m_lastProgress > 0 && m_lastProgress != 100) { |
Chris@357 | 30 std::cerr << "\r\n"; |
Chris@357 | 31 } |
Chris@357 | 32 std::cerr << "(progress printer dtor)" << std::endl; |
Chris@357 | 33 } |
Chris@357 | 34 |
Chris@357 | 35 void |
Chris@357 | 36 ProgressPrinter::progress(int progress) |
Chris@357 | 37 { |
Chris@357 | 38 if (progress == m_lastProgress) return; |
Chris@357 | 39 if (progress == 100) std::cerr << "\r\n"; |
Chris@357 | 40 else { |
Chris@357 | 41 std::cerr << "\r" |
Chris@357 | 42 << m_prefix.toStdString() |
Chris@357 | 43 << (m_prefix == "" ? "" : " ") |
Chris@357 | 44 << progress << "%"; |
Chris@357 | 45 } |
Chris@357 | 46 m_lastProgress = progress; |
Chris@357 | 47 } |
Chris@357 | 48 |