2
0

statedebugdialog.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "statedebugdialog.h"
  2. #include "ui_statedebugdialog.h"
  3. StateDebugDialog::StateDebugDialog(QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::StateDebugDialog)
  6. {
  7. ui->setupUi(this);
  8. connect(g_FSHost, SIGNAL(newEvent(QSharedPointer<switch_event_t>)), this, SLOT(newEvent(QSharedPointer<switch_event_t>)));
  9. connect(ui->listUUID, SIGNAL(itemSelectionChanged()), this, SLOT(currentUuidChanged()));
  10. connect(ui->listEvents, SIGNAL(itemSelectionChanged()), this, SLOT(currentEventsChanged()));
  11. }
  12. StateDebugDialog::~StateDebugDialog()
  13. {
  14. delete ui;
  15. }
  16. void StateDebugDialog::changeEvent(QEvent *e)
  17. {
  18. QDialog::changeEvent(e);
  19. switch (e->type()) {
  20. case QEvent::LanguageChange:
  21. ui->retranslateUi(this);
  22. break;
  23. default:
  24. break;
  25. }
  26. }
  27. void StateDebugDialog::newEvent(QSharedPointer<switch_event_t>event)
  28. {
  29. /* We don't want to keep track of events that are not calls at this moment */
  30. if (QString(switch_event_get_header_nil(event.data(), "Unique-ID")).isEmpty())
  31. return;
  32. QString uuid(switch_event_get_header_nil(event.data(), "Unique-ID"));
  33. if (!_events.contains(uuid))
  34. {
  35. QList<QSharedPointer<switch_event_t> > tmpListEvents;
  36. tmpListEvents.append(event);
  37. _events.insert(uuid, tmpListEvents);
  38. ui->listUUID->addItem(new QListWidgetItem(uuid));
  39. }
  40. else
  41. {
  42. QList<QSharedPointer<switch_event_t> > tmpListEvents = _events.value(uuid);
  43. tmpListEvents.append(event);
  44. _events.insert(uuid, tmpListEvents);
  45. }
  46. }
  47. void StateDebugDialog::currentUuidChanged()
  48. {;
  49. ui->listEvents->clear();
  50. ui->listDetails->clear();
  51. QString uuid = ui->listUUID->currentItem()->text();
  52. foreach(QSharedPointer<switch_event_t> e, _events.value(uuid))
  53. {
  54. ui->listEvents->addItem(new QListWidgetItem(switch_event_name(e.data()->event_id)));
  55. }
  56. }
  57. void StateDebugDialog::currentEventsChanged()
  58. {
  59. ui->listDetails->clear();
  60. int r = ui->listEvents->currentRow();
  61. if (r == -1) return;
  62. QString uuid = ui->listUUID->currentItem()->text();
  63. QList<QSharedPointer<switch_event_t> > tmpListEvents = _events.value(uuid);
  64. QSharedPointer<switch_event_t> e = tmpListEvents.at(r);
  65. for(switch_event_header_t* h = e.data()->headers; h != e.data()->last_header; h = h->next)
  66. {
  67. ui->listDetails->addItem(new QListWidgetItem(QString("%1 = %2").arg(h->name, h->value)));
  68. }
  69. }