annotate data/fileio/ProgressPrinter.cpp @ 384:6f6ab834449d spectrogram-cache-rejig

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