comparison widgets/ActivityLog.cpp @ 505:299d0ffebb38

* Make Activity Log a bit more of a proper window
author Chris Cannam
date Wed, 25 Feb 2009 11:26:07 +0000
parents d95635d6b82b
children 33572f3ad62b
comparison
equal deleted inserted replaced
504:d95635d6b82b 505:299d0ffebb38
16 #include "ActivityLog.h" 16 #include "ActivityLog.h"
17 17
18 #include <QListView> 18 #include <QListView>
19 #include <QGridLayout> 19 #include <QGridLayout>
20 #include <QStringListModel> 20 #include <QStringListModel>
21 #include <QLabel>
22 #include <QDialogButtonBox>
21 #include <QTime> 23 #include <QTime>
24 #include <QApplication>
22 25
23 #include <iostream> 26 #include <iostream>
24 27
25 ActivityLog::ActivityLog() : QDialog() 28 ActivityLog::ActivityLog() : QDialog()
26 { 29 {
30 setWindowTitle(tr("Activity Log"));
31
32 QGridLayout *layout = new QGridLayout;
33 setLayout(layout);
34
35 layout->addWidget(new QLabel(tr("<p>Activity Log shows a list of your interactions and other events within %1.</p>").arg(QApplication::applicationName())), 0, 0);
36
37 m_listView = new QListView;
27 m_model = new QStringListModel; 38 m_model = new QStringListModel;
28 m_listView = new QListView;
29 QGridLayout *layout = new QGridLayout;
30 layout->addWidget(m_listView, 0, 0);
31 setLayout(layout);
32 m_listView->setModel(m_model); 39 m_listView->setModel(m_model);
40 layout->addWidget(m_listView, 1, 0);
41 layout->setRowStretch(1, 10);
42
43 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
44 connect(bb, SIGNAL(rejected()), this, SLOT(hide()));
45 layout->addWidget(bb, 2, 0);
33 } 46 }
34 47
35 ActivityLog::~ActivityLog() 48 ActivityLog::~ActivityLog()
36 { 49 {
37 } 50 }
52 QModelIndex ix = m_model->index(row, 0); 65 QModelIndex ix = m_model->index(row, 0);
53 m_model->setData(ix, name); 66 m_model->setData(ix, name);
54 if (isVisible()) m_listView->scrollTo(ix); 67 if (isVisible()) m_listView->scrollTo(ix);
55 } 68 }
56 69
70 void
71 ActivityLog::scrollToEnd()
72 {
73 if (m_model->rowCount() == 0 || !isVisible()) return;
74 QModelIndex ix = m_model->index(m_model->rowCount()-1, 0);
75 m_listView->scrollTo(ix);
76 }
77
78