2 * wpa_gui - EventHistory class
3 * Copyright (c) 2005-2006, Jouni Malinen <j@w1.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>
18 #include "eventhistory.h"
21 int EventListModel::rowCount(const QModelIndex &) const
23 return msgList.count();
27 int EventListModel::columnCount(const QModelIndex &) const
33 QVariant EventListModel::data(const QModelIndex &index, int role) const
38 if (role == Qt::DisplayRole)
39 if (index.column() == 0) {
40 if (index.row() >= timeList.size())
42 return timeList.at(index.row());
44 if (index.row() >= msgList.size())
46 return msgList.at(index.row());
53 QVariant EventListModel::headerData(int section, Qt::Orientation orientation,
56 if (role != Qt::DisplayRole)
59 if (orientation == Qt::Horizontal) {
62 return QString(tr("Timestamp"));
64 return QString(tr("Message"));
69 return QString("%1").arg(section);
73 void EventListModel::addEvent(QString time, QString msg)
75 beginInsertRows(QModelIndex(), msgList.size(), msgList.size() + 1);
82 EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WFlags)
87 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
89 eventListView->setItemsExpandable(FALSE);
90 eventListView->setRootIsDecorated(FALSE);
91 elm = new EventListModel(parent);
92 eventListView->setModel(elm);
96 EventHistory::~EventHistory()
103 void EventHistory::languageChange()
109 void EventHistory::addEvents(WpaMsgList msgs)
111 WpaMsgList::iterator it;
112 for (it = msgs.begin(); it != msgs.end(); it++)
117 void EventHistory::addEvent(WpaMsg msg)
121 if (eventListView->verticalScrollBar()->value() <
122 eventListView->verticalScrollBar()->maximum())
125 elm->addEvent(msg.getTimestamp().toString("yyyy-MM-dd hh:mm:ss.zzz"),
129 eventListView->scrollToBottom();