Chris@383: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@383: Chris@383: /* Chris@383: Sonic Visualiser Chris@383: An audio file viewer and annotation editor. Chris@383: Centre for Digital Music, Queen Mary, University of London. Chris@383: This file copyright 2007 QMUL. Chris@383: Chris@383: This program is free software; you can redistribute it and/or Chris@383: modify it under the terms of the GNU General Public License as Chris@383: published by the Free Software Foundation; either version 2 of the Chris@383: License, or (at your option) any later version. See the file Chris@383: COPYING included with this distribution for more information. Chris@383: */ Chris@383: Chris@383: #include "ProgressPrinter.h" Chris@383: Chris@383: #include Chris@383: Chris@383: ProgressPrinter::ProgressPrinter(QString prefix, QObject *parent) : Chris@383: QObject(parent), Chris@383: m_prefix(prefix), Chris@383: m_lastProgress(0) Chris@383: { Chris@383: } Chris@383: Chris@383: ProgressPrinter::~ProgressPrinter() Chris@383: { Chris@383: if (m_lastProgress > 0 && m_lastProgress != 100) { Chris@383: std::cerr << "\r\n"; Chris@383: } Chris@383: std::cerr << "(progress printer dtor)" << std::endl; Chris@383: } Chris@383: Chris@383: void Chris@383: ProgressPrinter::progress(int progress) Chris@383: { Chris@383: if (progress == m_lastProgress) return; Chris@383: if (progress == 100) std::cerr << "\r\n"; Chris@383: else { Chris@383: std::cerr << "\r" Chris@383: << m_prefix.toStdString() Chris@383: << (m_prefix == "" ? "" : " ") Chris@383: << progress << "%"; Chris@383: } Chris@383: m_lastProgress = progress; Chris@383: } Chris@383: