2
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
5
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
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.
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.
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/>.
20
#include "sensorwidget.h"
21
#include "computerpage.h"
23
SensorWieget::SensorWieget(QWidget *parent, SystemDispatcher *proxy) :
27
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
28
setFixedSize(750, 403);
30
timer = new QTimer(this);
31
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeValue()));
32
scroll_widget = new ScrollWidget(this);
33
scroll_widget->setGeometry(0, 0, 750, 403);
37
SensorWieget::~SensorWieget()
40
disconnect(timer,SIGNAL(timeout()),this,SLOT(updateTimeValue()));
41
if(timer->isActive()) {
47
this->clear_page_list();
48
if (scroll_widget != NULL) {
55
void SensorWieget::clear_page_list()
62
scroll_widget->resetWidget();
65
void SensorWieget::updateTimeValue()
67
QMap<QString, QVariant> tmpMap = systemproxy->get_sensor_info_qt();
68
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
72
sensor_info_map.clear();
73
QMap<QString,QVariant>::iterator it;
74
for (it = tmpMap.begin(); it != tmpMap.end(); ++it) {
75
if (it.value().toString().length() > 0) {
76
sensor_info_map.insert(it.key(), it.value());
79
if (!sensor_info_map.isEmpty() && sensor_info_map.count() > 0) {
80
page->resetSensor(sensor_info_map);
85
void SensorWieget::initData()
87
QMap<QString, QVariant> tmpMap = systemproxy->get_sensor_info_qt();
88
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
92
QMap<QString,QVariant>::iterator it;
93
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
94
if (it.value().toString().length() > 0) {
95
sensor_info_map.insert(it.key(), it.value());
98
if (sensor_info_map.isEmpty() || sensor_info_map.count() <= 0) {
102
page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information"));
103
page->setMap(sensor_info_map, "");
104
page->setsensor(true);
106
scroll_widget->addScrollWidget(page);
107
timer->start(1000*4);
110
/*QMap<QString,QVariant>::iterator it;
111
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
112
if (it.value().toString().length() > 0) {
113
sensor_info_map.insert(it.key(), it.value());
116
if(sensor_info_map.count() == 0)
121
page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information"));
122
page->setMap(sensor_info_map, "");
123
page->setsensor(true);
125
scroll_widget->addScrollWidget(page);
126
timer->start(1000*4);