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