Mercurial > hg > svcore
annotate base/ProgressPrinter.cpp @ 618:b1dc68507e46 sv-v1.7.1
* Layer data editor window: fix sorting for columns in region model,
add Find feature
* RDF import: assign names to layers based on event types, if no suitable
labels are found in the RDF
* Add label to status bar showing the last text that was passed in current
layer (so e.g. counting 1, 2, 3, 4 if that's what beats are labelled)
* Better layout of text labels for region layers in segmentation mode when
they are close together
* Give text layer the same method for finding "nearest point" as region and
note layers, should improve its editability
author | Chris Cannam |
---|---|
date | Thu, 22 Oct 2009 15:54:21 +0000 |
parents | 5ebcf099dab0 |
children | 076dcd2ce209 |
rev | line source |
---|---|
Chris@392 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@392 | 2 |
Chris@392 | 3 /* |
Chris@392 | 4 Sonic Visualiser |
Chris@392 | 5 An audio file viewer and annotation editor. |
Chris@392 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@392 | 7 This file copyright 2007 QMUL. |
Chris@392 | 8 |
Chris@392 | 9 This program is free software; you can redistribute it and/or |
Chris@392 | 10 modify it under the terms of the GNU General Public License as |
Chris@392 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@392 | 12 License, or (at your option) any later version. See the file |
Chris@392 | 13 COPYING included with this distribution for more information. |
Chris@392 | 14 */ |
Chris@392 | 15 |
Chris@392 | 16 #include "ProgressPrinter.h" |
Chris@392 | 17 |
Chris@392 | 18 #include <iostream> |
Chris@392 | 19 |
Chris@392 | 20 ProgressPrinter::ProgressPrinter(QString message, QObject *parent) : |
Chris@392 | 21 ProgressReporter(parent), |
Chris@392 | 22 m_prefix(message), |
Chris@439 | 23 m_lastProgress(0), |
Chris@439 | 24 m_definite(true) |
Chris@392 | 25 { |
Chris@521 | 26 if (m_prefix.length() > 70) { |
Chris@521 | 27 m_prefix = m_prefix.left(70) + "..."; |
Chris@521 | 28 } |
Chris@392 | 29 } |
Chris@392 | 30 |
Chris@392 | 31 ProgressPrinter::~ProgressPrinter() |
Chris@392 | 32 { |
Chris@392 | 33 if (m_lastProgress > 0 && m_lastProgress != 100) { |
Chris@392 | 34 std::cerr << "\r\n"; |
Chris@392 | 35 } |
Chris@392 | 36 // std::cerr << "(progress printer dtor)" << std::endl; |
Chris@392 | 37 } |
Chris@392 | 38 |
Chris@439 | 39 bool |
Chris@439 | 40 ProgressPrinter::isDefinite() const |
Chris@439 | 41 { |
Chris@439 | 42 return m_definite; |
Chris@439 | 43 } |
Chris@439 | 44 |
Chris@439 | 45 void |
Chris@439 | 46 ProgressPrinter::setDefinite(bool definite) |
Chris@439 | 47 { |
Chris@439 | 48 m_definite = definite; |
Chris@439 | 49 } |
Chris@439 | 50 |
Chris@392 | 51 void |
Chris@393 | 52 ProgressPrinter::setMessage(QString message) |
Chris@393 | 53 { |
Chris@393 | 54 m_prefix = message; |
Chris@393 | 55 } |
Chris@393 | 56 |
Chris@393 | 57 void |
Chris@515 | 58 ProgressPrinter::done() |
Chris@515 | 59 { |
Chris@517 | 60 std::cerr << "\r" |
Chris@517 | 61 << m_prefix.toStdString() |
Chris@517 | 62 << (m_prefix == "" ? "" : " ") |
Chris@517 | 63 << "Done" << std::endl; |
Chris@515 | 64 } |
Chris@515 | 65 |
Chris@515 | 66 void |
Chris@392 | 67 ProgressPrinter::setProgress(int progress) |
Chris@392 | 68 { |
Chris@392 | 69 if (progress == m_lastProgress) return; |
Chris@517 | 70 std::cerr << "\r" |
Chris@517 | 71 << m_prefix.toStdString() |
Chris@517 | 72 << (m_prefix == "" ? "" : " "); |
Chris@517 | 73 if (m_definite) { |
Chris@517 | 74 std::cerr << progress << "%"; |
Chris@517 | 75 } else { |
Chris@517 | 76 std::cerr << "|/-\\"[progress % 4]; |
Chris@392 | 77 } |
Chris@392 | 78 m_lastProgress = progress; |
Chris@392 | 79 } |
Chris@392 | 80 |