annotate data/fileio/ProgressPrinter.cpp @ 383:94fc0591ea43 1.2-stable

* merge from trunk (1.2 ended up being tracked from trunk, but we may want this branch for fixes later)
author Chris Cannam
date Wed, 27 Feb 2008 10:32:45 +0000
parents
children
rev   line source
Chris@383 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@383 2
Chris@383 3 /*
Chris@383 4 Sonic Visualiser
Chris@383 5 An audio file viewer and annotation editor.
Chris@383 6 Centre for Digital Music, Queen Mary, University of London.
Chris@383 7 This file copyright 2007 QMUL.
Chris@383 8
Chris@383 9 This program is free software; you can redistribute it and/or
Chris@383 10 modify it under the terms of the GNU General Public License as
Chris@383 11 published by the Free Software Foundation; either version 2 of the
Chris@383 12 License, or (at your option) any later version. See the file
Chris@383 13 COPYING included with this distribution for more information.
Chris@383 14 */
Chris@383 15
Chris@383 16 #include "ProgressPrinter.h"
Chris@383 17
Chris@383 18 #include <iostream>
Chris@383 19
Chris@383 20 ProgressPrinter::ProgressPrinter(QString prefix, QObject *parent) :
Chris@383 21 QObject(parent),
Chris@383 22 m_prefix(prefix),
Chris@383 23 m_lastProgress(0)
Chris@383 24 {
Chris@383 25 }
Chris@383 26
Chris@383 27 ProgressPrinter::~ProgressPrinter()
Chris@383 28 {
Chris@383 29 if (m_lastProgress > 0 && m_lastProgress != 100) {
Chris@383 30 std::cerr << "\r\n";
Chris@383 31 }
Chris@383 32 std::cerr << "(progress printer dtor)" << std::endl;
Chris@383 33 }
Chris@383 34
Chris@383 35 void
Chris@383 36 ProgressPrinter::progress(int progress)
Chris@383 37 {
Chris@383 38 if (progress == m_lastProgress) return;
Chris@383 39 if (progress == 100) std::cerr << "\r\n";
Chris@383 40 else {
Chris@383 41 std::cerr << "\r"
Chris@383 42 << m_prefix.toStdString()
Chris@383 43 << (m_prefix == "" ? "" : " ")
Chris@383 44 << progress << "%";
Chris@383 45 }
Chris@383 46 m_lastProgress = progress;
Chris@383 47 }
Chris@383 48