~feng-kylin/youker-assistant/youker-assistant

« back to all changes in this revision

Viewing changes to info/driverwidget.cpp

  • Committer: lixiang
  • Date: 2018-03-06 03:13:06 UTC
  • Revision ID: lixiang@kylinos.cn-20180306031306-fd7qnru3vm4a1xjd
Rewrite with Qt5, and add system monitor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
3
 
 *
4
 
 * Authors:
5
 
 *  Kobe Lee    xiangli@ubuntukylin.com/kobe24_lixiang@126.com
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; version 3.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
#include "driverwidget.h"
21
 
#include "devicemanager.h"
22
 
#include <QDebug>
23
 
 
24
 
DriverWidget::DriverWidget(QWidget *parent/*, SystemDispatcher *proxy*/) :
25
 
    QWidget(parent)
26
 
//    systemproxy(proxy)
27
 
{
28
 
    this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
29
 
    setFixedSize(750, 403);
30
 
    scroll_widget = new ScrollWidget(this);
31
 
    scroll_widget->setGeometry(0, 0, 750, 403);
32
 
    this->initData();
33
 
    if(driver_info_map.count() != 0)
34
 
    {
35
 
        page = new ComputerPage(scroll_widget->zone, tr("Driver Info"));
36
 
        page->setMap(driver_info_map,"");
37
 
        page->initUI(false);
38
 
        scroll_widget->addScrollWidget(page);
39
 
    }
40
 
    else {
41
 
        page = NULL;
42
 
    }
43
 
}
44
 
 
45
 
DriverWidget::~DriverWidget()
46
 
{
47
 
    if (page != NULL) {
48
 
        delete page;
49
 
        page = NULL;
50
 
    }
51
 
    if (scroll_widget != NULL) {
52
 
        delete scroll_widget;
53
 
        scroll_widget = NULL;
54
 
    }
55
 
}
56
 
 
57
 
void DriverWidget::initData()
58
 
{
59
 
    DeviceManager manager;
60
 
    QStringList list = manager.getDeviceMsg();
61
 
    for (int i=0 ; i < list.length() ; i++) {
62
 
        QStringList splitlist = list.at(i).split(";");
63
 
        if(splitlist.length() == 1) {
64
 
            QStringList name = splitlist.at(0).split(":");
65
 
            driver_info_map.insert(name.at(0).trimmed(), name.at(1));
66
 
//            driver_info_map.insert("deviceName", name.at(0));
67
 
//            driver_info_map.insert("deviceNameText", name.at(1));
68
 
        }
69
 
        else if(splitlist.length() == 2) {
70
 
            QStringList name1 = splitlist.at(0).split(":");
71
 
            QStringList name2 = splitlist.at(1).split(":");
72
 
            driver_info_map.insert(name1.at(0).trimmed(), name1.at(1));
73
 
            driver_info_map.insert(name2.at(0).trimmed(), name2.at(1));
74
 
//            driver_info_map.insert("deviceName", name1.at(0));
75
 
//            driver_info_map.insert("deviceNameText", name1.at(1));
76
 
//            driver_info_map.insert("inUseName", name2.at(0));
77
 
//            driver_info_map.insert("inUseNameText", name2.at(1));
78
 
        }
79
 
        else if(splitlist.length() == 3) {
80
 
            QStringList name3 = splitlist[0].split(":");
81
 
            QStringList name4 = splitlist[1].split(":");
82
 
            QStringList name5 = splitlist[2].split(":");
83
 
            driver_info_map.insert(name3.at(0).trimmed(), name3.at(1));
84
 
            driver_info_map.insert(name4.at(0).trimmed(), name4.at(1));
85
 
            driver_info_map.insert(name5.at(0).trimmed(), name5.at(1));
86
 
//            driver_info_map.insert("deviceName", name3.at(0));
87
 
//            driver_info_map.insert("deviceNameText", name3.at(1));
88
 
//            driver_info_map.insert("inUseName", name4.at(0));
89
 
//            driver_info_map.insert("inUseNameText", name4.at(1));
90
 
//            driver_info_map.insert("existName", name5.at(0));
91
 
//            driver_info_map.insert("existNameText", name5.at(1));
92
 
        }
93
 
    }
94
 
}