Chris@502: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@502: Chris@502: /* Chris@502: Sonic Visualiser Chris@502: An audio file viewer and annotation editor. Chris@502: Centre for Digital Music, Queen Mary, University of London. Chris@502: This file copyright 2009 QMUL. Chris@502: Chris@502: This program is free software; you can redistribute it and/or Chris@502: modify it under the terms of the GNU General Public License as Chris@502: published by the Free Software Foundation; either version 2 of the Chris@502: License, or (at your option) any later version. See the file Chris@502: COPYING included with this distribution for more information. Chris@502: */ Chris@502: Chris@502: #include "ActivityLog.h" Chris@502: Chris@502: #include Chris@502: #include Chris@502: #include Chris@503: #include Chris@502: Chris@502: #include Chris@502: Chris@502: ActivityLog::ActivityLog() : QDialog() Chris@502: { Chris@502: m_model = new QStringListModel; Chris@502: m_listView = new QListView; Chris@502: QGridLayout *layout = new QGridLayout; Chris@502: layout->addWidget(m_listView, 0, 0); Chris@502: setLayout(layout); Chris@502: m_listView->setModel(m_model); Chris@502: } Chris@502: Chris@502: ActivityLog::~ActivityLog() Chris@502: { Chris@502: } Chris@502: Chris@502: void Chris@502: ActivityLog::activityHappened(QString name) Chris@502: { Chris@502: name = name.replace("&", ""); Chris@502: std::cerr << "ActivityLog::activityHappened(" << name.toStdString() << ")" << std::endl; Chris@503: if (name == m_prevName) { Chris@503: std::cerr << "(ignoring duplicate)" << std::endl; Chris@503: return; Chris@503: } Chris@503: m_prevName = name; Chris@503: int row = m_model->rowCount(); Chris@503: name = tr("%1: %2").arg(QTime::currentTime().toString()).arg(name); Chris@502: m_model->insertRows(row, 1); Chris@503: QModelIndex ix = m_model->index(row, 0); Chris@503: m_model->setData(ix, name); Chris@504: if (isVisible()) m_listView->scrollTo(ix); Chris@502: } Chris@502: