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