2 * wpa_gui - EventHistory class
3 * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "eventhistory.h"
15 int EventListModel::rowCount(const QModelIndex &) const
17 return msgList.count();
21 int EventListModel::columnCount(const QModelIndex &) const
27 QVariant EventListModel::data(const QModelIndex &index, int role) const
32 if (role == Qt::DisplayRole)
33 if (index.column() == 0) {
34 if (index.row() >= timeList.size())
36 return timeList.at(index.row());
38 if (index.row() >= msgList.size())
40 return msgList.at(index.row());
47 QVariant EventListModel::headerData(int section, Qt::Orientation orientation,
50 if (role != Qt::DisplayRole)
53 if (orientation == Qt::Horizontal) {
56 return QString(tr("Timestamp"));
58 return QString(tr("Message"));
63 return QString("%1").arg(section);
67 void EventListModel::addEvent(QString time, QString msg)
69 beginInsertRows(QModelIndex(), msgList.size(), msgList.size() + 1);
76 EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WindowFlags)
81 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
83 eventListView->setItemsExpandable(false);
84 eventListView->setRootIsDecorated(false);
85 elm = new EventListModel(parent);
86 eventListView->setModel(elm);
90 EventHistory::~EventHistory()
97 void EventHistory::languageChange()
103 void EventHistory::addEvents(WpaMsgList msgs)
105 WpaMsgList::iterator it;
106 for (it = msgs.begin(); it != msgs.end(); it++)
111 void EventHistory::addEvent(WpaMsg msg)
115 if (eventListView->verticalScrollBar()->value() <
116 eventListView->verticalScrollBar()->maximum())
119 elm->addEvent(msg.getTimestamp().toString("yyyy-MM-dd hh:mm:ss.zzz"),
123 eventListView->scrollToBottom();