File: form.cpp

package info (click to toggle)
dlt-viewer 2.23.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,432 kB
  • sloc: cpp: 27,832; ansic: 4,454; xml: 491; sh: 154; makefile: 75
file content (107 lines) | stat: -rw-r--r-- 2,588 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
 * @licence app begin@
 * Copyright (C) 2011-2012  BMW AG
 *
 * This file is part of COVESA Project Dlt Viewer.
 *
 * Contributions are licensed to the COVESA Alliance under one or more
 * Contribution License Agreements.
 *
 * \copyright
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * \file form.cpp
 * For further information see http://www.covesa.global/.
 * @licence end@
 */

#include "form.h"
#include "ui_form.h"
#include "dltsystemviewerplugin.h"

using namespace DltSystemViewer;

ProcessItem::ProcessItem(QTreeWidgetItem *parent)
    : QTreeWidgetItem(parent)
{
    lastTimestamp = 0;
}

ProcessItem::~ProcessItem()
{

}

Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
}

Form::~Form()
{
    delete ui;
}

void Form::addProcesses(int pid, QString data,QDltMsg &msg)
{
    QStringList datalist;
    ProcessItem *widget;
    int found = 0;
    int procent = 0;

    datalist = data.split(" ");

    for(int num=0;num<ui->treeWidget->topLevelItemCount();num++) {
        widget = (ProcessItem*) ui->treeWidget->topLevelItem(num);
        if(widget->text(0).toInt()==pid) {
            found = 1;
            //procent = datalist.at(13).toInt()-widget->text(2).toInt()+datalist.at(14).toInt()-widget->text(3).toInt();
            procent = ((datalist.at(13).toInt())-widget->text(2).toInt()+datalist.at(14).toInt()-widget->text(3).toInt())*10000/(msg.getTimestamp()-widget->lastTimestamp);///4;
            widget->setText(2,datalist.at(13));
            widget->setText(3,datalist.at(14));
            widget->setText(4,QString("%1").arg(procent));
            widget->lastTimestamp = msg.getTimestamp();
            break;
        }
    }

    if(!found) {
        widget = new ProcessItem();
        widget->setText(0,QString("%1").arg(pid));
        widget->setText(1,datalist.at(1));
        widget->setText(2,datalist.at(13));
        widget->setText(3,datalist.at(14));
        widget->setText(4,QString("%1").arg(procent));
        ui->treeWidget->insertTopLevelItem(0, widget);
    }
}

void Form::deleteAllProccesses()
{
    ui->treeWidget->clear();
}


void Form::on_pushButtonClear_clicked()
{
    ui->treeWidget->clear();
}

void Form::setUser(QString text)
{
    ui->lineEditUser->setText(text);
}

void Form::setNice(QString text)
{
    ui->lineEditNice->setText(text);
}

void Form::setSystem(QString text)
{
    ui->lineEditSystem->setText(text);
}