annotate widgets/ActivityLog.cpp @ 1447:8afea53332f3 single-point

Add option to make pane sizes auto-resize-only (i.e. remove user control via a splitter); also place alignment views above panes instead of below, meaning the extra bit of space that we currently have for the pane without one at least goes to the primary pane
author Chris Cannam
date Tue, 30 Apr 2019 15:53:21 +0100
parents c2e923aa4015
children
rev   line source
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@505 21 #include <QLabel>
Chris@505 22 #include <QDialogButtonBox>
Chris@503 23 #include <QTime>
Chris@505 24 #include <QApplication>
Chris@502 25
Chris@502 26 #include <iostream>
Chris@502 27
Chris@751 28 #include "base/Debug.h"
Chris@751 29
Chris@751 30 using std::cerr;
Chris@751 31 using std::endl;
Chris@751 32
Chris@1240 33 #ifndef NO_PRINT_ACTIVITY
Chris@1240 34 #define PRINT_ACTIVITY 1
Chris@1240 35 #endif
Chris@751 36
Chris@502 37 ActivityLog::ActivityLog() : QDialog()
Chris@502 38 {
Chris@505 39 setWindowTitle(tr("Activity Log"));
Chris@505 40
Chris@505 41 QGridLayout *layout = new QGridLayout;
Chris@505 42 setLayout(layout);
Chris@505 43
Chris@506 44 layout->addWidget(new QLabel(tr("<p>Activity Log lists your interactions and other events within %1.</p>").arg(QApplication::applicationName())), 0, 0);
Chris@505 45
Chris@505 46 m_listView = new QListView;
Chris@502 47 m_model = new QStringListModel;
Chris@502 48 m_listView->setModel(m_model);
Chris@505 49 layout->addWidget(m_listView, 1, 0);
Chris@505 50 layout->setRowStretch(1, 10);
Chris@505 51
Chris@505 52 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
Chris@505 53 connect(bb, SIGNAL(rejected()), this, SLOT(hide()));
Chris@505 54 layout->addWidget(bb, 2, 0);
Chris@502 55 }
Chris@502 56
Chris@502 57 ActivityLog::~ActivityLog()
Chris@502 58 {
Chris@502 59 }
Chris@502 60
Chris@502 61 void
Chris@502 62 ActivityLog::activityHappened(QString name)
Chris@502 63 {
Chris@502 64 name = name.replace("&", "");
Chris@751 65
Chris@751 66 #ifdef PRINT_ACTIVITY
Chris@1240 67 SVDEBUG << "ActivityLog: " << name;
Chris@503 68 if (name == m_prevName) {
Chris@1240 69 SVDEBUG << " (duplicate)";
Chris@751 70 }
Chris@1240 71 SVDEBUG << endl;
Chris@751 72 #endif
Chris@751 73
Chris@751 74 if (name == m_prevName) {
Chris@503 75 return;
Chris@503 76 }
Chris@503 77 m_prevName = name;
Chris@503 78 int row = m_model->rowCount();
Chris@503 79 name = tr("%1: %2").arg(QTime::currentTime().toString()).arg(name);
Chris@502 80 m_model->insertRows(row, 1);
Chris@503 81 QModelIndex ix = m_model->index(row, 0);
Chris@503 82 m_model->setData(ix, name);
Chris@504 83 if (isVisible()) m_listView->scrollTo(ix);
Chris@502 84 }
Chris@502 85
Chris@505 86 void
Chris@505 87 ActivityLog::scrollToEnd()
Chris@505 88 {
Chris@505 89 if (m_model->rowCount() == 0 || !isVisible()) return;
Chris@505 90 QModelIndex ix = m_model->index(m_model->rowCount()-1, 0);
Chris@505 91 m_listView->scrollTo(ix);
Chris@505 92 }
Chris@505 93
Chris@505 94