-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasictablewidget.cpp
More file actions
126 lines (116 loc) · 3.75 KB
/
Copy pathasictablewidget.cpp
File metadata and controls
126 lines (116 loc) · 3.75 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <QHeaderView>
#include "asictablewidget.h"
#include "logger.hpp"
#include "main.hpp"
ASICTableWidget::ASICTableWidget(QWidget *parent) : QTableWidget(parent)
{
pWebPort=80;
pAPIPort=DEFAULT_API_PORT;
GroupID=0;
DeviceList=new QVector <ASICDevice *>;
ColumnTitles=new QStringList({"Address", "THSmm", "THSavg", "Freq", "WORKMODE",
"MTmax[0]", "MTmax[1]", "MTmax[2]",
"MTavg[0]", "MTavg[1]", "MTavg[2]",
"MW[0]", "MW[1]", "MW[2]",
"Temp", "TMax",
"Fan[0]", "Fan[1]", "Fan[2]", "Fan[3]",
"FanMax[0]", "FanMax[1]", "FanMax[2]", "FanMax[3]"});
connect(this, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(on_cellDoubleClicked(int,int)));
this->verticalHeader()->hide();
this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
this->setColumnCount(ColumnTitles->count());
this->setHorizontalHeaderLabels(*ColumnTitles);
this->setSortingEnabled(true);
}
void ASICTableWidget::SetUserName(QString userName)
{
pUserName=userName;
}
void ASICTableWidget::SetPassword(QString passWord)
{
pPassWord=passWord;
}
void ASICTableWidget::SetWebPort(quint16 port)
{
pWebPort=port;
}
void ASICTableWidget::SetAPIPort(quint16 port)
{
pAPIPort=port;
}
void ASICTableWidget::SetGroupID(uint id)
{
pGroupID=id;
}
void ASICTableWidget::AddDevice(ASICDevice *deviceToAdd)
{
gAppLogger->Log("ASICTableWidget::AddDevice()", LOG_DEBUG);
for(int device=0; device<DeviceList->count(); device++)
{
if(deviceToAdd->Address()==DeviceList->at(device)->Address())
{
return;
}
}
gAppLogger->Log(deviceToAdd->Address().toString().toStdString(), LOG_DEBUG);
setSortingEnabled(false);
deviceToAdd->SetUserName(this->pUserName);
deviceToAdd->SetPassword(this->pPassWord);
deviceToAdd->SetAPIPort(this->pAPIPort);
deviceToAdd->SetWebPort(this->pWebPort);
deviceToAdd->SetGroupID(this->GroupID);
DeviceList->append(deviceToAdd);
int row=0;
insertRow(row);
for(int column=0; column<this->columnCount(); column++)
{
setItem(row, column, deviceToAdd->dataitems->at(column));
}
setSortingEnabled(true);
}
void ASICTableWidget::RemoveDevice(ASICDevice *deviceToRemove)
{
DeviceList->removeAll(deviceToRemove);
//Refresh();
}
/*
void ASICTableWidget::Refresh()
{
if(DeviceList->isEmpty())
{
return;
}
if(!DeviceList->first()->dataitems->count())
{
return;
}
clearContents();
setSortingEnabled(false);
setRowCount(DeviceList->count());
for(int row=0; row<this->rowCount(); row++)
{
//DeviceList->at(row)->Refresh();
for(int column=0; column<this->columnCount(); column++)
{
//takeItem(row, column);
setItem(row, column, DeviceList->at(row)->dataitems->at(column));
}
}
setSortingEnabled(true);
}
*/
void ASICTableWidget::on_cellDoubleClicked(int row, int column)
{
gAppLogger->Log("ASICTableWidget::on_cellDoubleClicked()", LOG_DEBUG);
QUrl DeviceURL;
if(column==0)
{
DeviceURL.setScheme("http");
DeviceURL.setHost(QHostAddress(model()->index(row, 0).data(Qt::EditRole).toUInt()).toString());
DeviceURL.setPath("/login.cgi");
gAppLogger->Log(DeviceURL.toString().toStdString(), LOG_DEBUG);
QDesktopServices::openUrl(DeviceURL);
}
}