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