Chris@502
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@502
|
2
|
Chris@502
|
3 /*
|
Chris@502
|
4 Sonic Visualiser
|
Chris@502
|
5 An audio file viewer and annotation editor.
|
Chris@502
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@502
|
7 This file copyright 2009 QMUL.
|
Chris@502
|
8
|
Chris@502
|
9 This program is free software; you can redistribute it and/or
|
Chris@502
|
10 modify it under the terms of the GNU General Public License as
|
Chris@502
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@502
|
12 License, or (at your option) any later version. See the file
|
Chris@502
|
13 COPYING included with this distribution for more information.
|
Chris@502
|
14 */
|
Chris@502
|
15
|
Chris@502
|
16 #include "ActivityLog.h"
|
Chris@502
|
17
|
Chris@502
|
18 #include <QListView>
|
Chris@502
|
19 #include <QGridLayout>
|
Chris@502
|
20 #include <QStringListModel>
|
Chris@503
|
21 #include <QTime>
|
Chris@502
|
22
|
Chris@502
|
23 #include <iostream>
|
Chris@502
|
24
|
Chris@502
|
25 ActivityLog::ActivityLog() : QDialog()
|
Chris@502
|
26 {
|
Chris@502
|
27 m_model = new QStringListModel;
|
Chris@502
|
28 m_listView = new QListView;
|
Chris@502
|
29 QGridLayout *layout = new QGridLayout;
|
Chris@502
|
30 layout->addWidget(m_listView, 0, 0);
|
Chris@502
|
31 setLayout(layout);
|
Chris@502
|
32 m_listView->setModel(m_model);
|
Chris@502
|
33 }
|
Chris@502
|
34
|
Chris@502
|
35 ActivityLog::~ActivityLog()
|
Chris@502
|
36 {
|
Chris@502
|
37 }
|
Chris@502
|
38
|
Chris@502
|
39 void
|
Chris@502
|
40 ActivityLog::activityHappened(QString name)
|
Chris@502
|
41 {
|
Chris@502
|
42 name = name.replace("&", "");
|
Chris@502
|
43 std::cerr << "ActivityLog::activityHappened(" << name.toStdString() << ")" << std::endl;
|
Chris@503
|
44 if (name == m_prevName) {
|
Chris@503
|
45 std::cerr << "(ignoring duplicate)" << std::endl;
|
Chris@503
|
46 return;
|
Chris@503
|
47 }
|
Chris@503
|
48 m_prevName = name;
|
Chris@503
|
49 int row = m_model->rowCount();
|
Chris@503
|
50 name = tr("%1: %2").arg(QTime::currentTime().toString()).arg(name);
|
Chris@502
|
51 m_model->insertRows(row, 1);
|
Chris@503
|
52 QModelIndex ix = m_model->index(row, 0);
|
Chris@503
|
53 m_model->setData(ix, name);
|
Chris@503
|
54 if (m_listView->isVisible()) m_listView->scrollTo(ix);
|
Chris@502
|
55 }
|
Chris@502
|
56
|