Began removal of platform/. The Monitor:: namespace is completely converted.
[aesalon.git] / src / gui / ActiveSessionOverview.cpp
blobdfe3ddda5d87b428420399f47b0495d374a612c5
1 #include <iostream>
3 #include "ActiveSessionOverview.h"
4 #include "ActiveSessionOverview.moc"
5 #include "platform/BlockEvent.h"
7 namespace Aesalon {
8 namespace GUI {
10 ActiveSessionOverview::ActiveSessionOverview(Session *session, QWidget *parent) : session(session), allocations(0), deallocations(0) {
11 info_form = new QFormLayout();
13 info_form->addRow(tr("Session name:"), new QLabel(session->get_session_name()));
14 info_form->addRow(tr("Executable path:"), new QLabel(session->get_executable_path()));
15 info_form->addRow(tr("Arguments:"), new QLabel(session->get_arguments()));
16 info_form->addRow(tr("Port:"), new QLabel(QString().setNum(session->get_port())));
17 /* Use an empty QLabel as a separator. */
18 info_form->addWidget(new QLabel());
19 status = new QLabel();
20 info_form->addRow(tr("Status:"), status);
22 allocation_info = new QLabel("0/0");
23 info_form->addRow(tr("Allocations/Deallocations:"), allocation_info);
24 active_blocks = new QLabel("0");
25 info_form->addRow(tr("Active blocks:"), active_blocks);
26 this->setLayout(info_form);
29 void ActiveSessionOverview::update_status(QString new_status) {
30 status->setText(new_status);
33 void ActiveSessionOverview::handle_event(Platform::Event *event) {
34 if(event->get_type() != Platform::Event::BLOCK_EVENT) return;
35 Platform::BlockEvent *be = dynamic_cast<Platform::BlockEvent *>(event);
36 if(be->get_block_type() != Platform::BlockEvent::ALLOC_EVENT) deallocations ++;
37 if(be->get_block_type() != Platform::BlockEvent::FREE_EVENT) allocations ++;
38 allocation_info->setText(QString().setNum(allocations) + "/" + QString().setNum(deallocations));
39 active_blocks->setText(QString().setNum((signed)(allocations-deallocations)));
42 } // namespace GUI
43 } // namespace Aesalon