#include "statedebugdialog.h" #include "ui_statedebugdialog.h" StateDebugDialog::StateDebugDialog(QWidget *parent) : QDialog(parent), ui(new Ui::StateDebugDialog) { ui->setupUi(this); connect(&g_FSHost, SIGNAL(newEvent(QSharedPointer)), this, SLOT(newEvent(QSharedPointer))); connect(ui->listUUID, SIGNAL(itemSelectionChanged()), this, SLOT(currentUuidChanged())); connect(ui->listEvents, SIGNAL(itemSelectionChanged()), this, SLOT(currentEventsChanged())); } StateDebugDialog::~StateDebugDialog() { delete ui; } void StateDebugDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } void StateDebugDialog::newEvent(QSharedPointerevent) { /* We don't want to keep track of events that are not calls at this moment */ if (QString(switch_event_get_header_nil(event.data(), "Unique-ID")).isEmpty()) return; QString uuid(switch_event_get_header_nil(event.data(), "Unique-ID")); if (!_events.contains(uuid)) { QList > tmpListEvents; tmpListEvents.append(event); _events.insert(uuid, tmpListEvents); ui->listUUID->addItem(new QListWidgetItem(uuid)); } else { QList > tmpListEvents = _events.value(uuid); tmpListEvents.append(event); _events.insert(uuid, tmpListEvents); } } void StateDebugDialog::currentUuidChanged() {; ui->listEvents->clear(); ui->listDetails->clear(); QString uuid = ui->listUUID->currentItem()->text(); foreach(QSharedPointer e, _events.value(uuid)) { ui->listEvents->addItem(new QListWidgetItem(switch_event_name(e.data()->event_id))); } } void StateDebugDialog::currentEventsChanged() { ui->listDetails->clear(); int r = ui->listEvents->currentRow(); if (r == -1) return; QString uuid = ui->listUUID->currentItem()->text(); QList > tmpListEvents = _events.value(uuid); QSharedPointer e = tmpListEvents.at(r); for(switch_event_header_t* h = e.data()->headers; h != e.data()->last_header; h = h->next) { ui->listDetails->addItem(new QListWidgetItem(QString("%1 = %2").arg(h->name, h->value))); } }