2
* wpa_gui - EventHistory class
3
* Copyright (c) 2005-2006, Jouni Malinen <jkmaline@cc.hut.fi>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
15
#include <QHeaderView>
17
#include "eventhistory.h"
20
int EventListModel::rowCount(const QModelIndex &) const
22
return msgList.count();
26
int EventListModel::columnCount(const QModelIndex &) const
32
QVariant EventListModel::data(const QModelIndex &index, int role) const
37
if (role == Qt::DisplayRole)
38
if (index.column() == 0) {
39
if (index.row() >= timeList.size())
41
return timeList.at(index.row());
43
if (index.row() >= msgList.size())
45
return msgList.at(index.row());
52
QVariant EventListModel::headerData(int section, Qt::Orientation orientation,
55
if (role != Qt::DisplayRole)
58
if (orientation == Qt::Horizontal) {
61
return QString("Timestamp");
63
return QString("Message");
68
return QString("%1").arg(section);
72
void EventListModel::addEvent(QString time, QString msg)
74
beginInsertRows(QModelIndex(), msgList.size(), msgList.size() + 1);
81
EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WFlags)
86
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
88
elm = new EventListModel(parent);
89
eventListView->setModel(elm);
93
EventHistory::~EventHistory()
100
void EventHistory::languageChange()
106
void EventHistory::addEvents(WpaMsgList msgs)
108
WpaMsgList::iterator it;
109
for (it = msgs.begin(); it != msgs.end(); it++)
114
void EventHistory::addEvent(WpaMsg msg)
116
elm->addEvent(msg.getTimestamp().toString("yyyy-MM-dd hh:mm:ss.zzz"),
118
#if QT_VERSION >= 0x040100
119
eventListView->resizeColumnsToContents();
120
eventListView->resizeRowsToContents();