-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtableview.cpp
More file actions
65 lines (60 loc) · 2.24 KB
/
tableview.cpp
File metadata and controls
65 lines (60 loc) · 2.24 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
#include "tableview.h"
#include <QWidget>
#include <QStorageInfo>
#include <QTranslator>
myTableView::myTableView(int width,int height,QTableView *parent)
:QTableView(parent)
{
DDiskManager myDiskm;
QStringList Urls = myDiskm.blockDevices();
this->setStyleSheet("QTableView{background-color:#ffffff}");
this->verticalHeader()->setDefaultSectionSize(200);
this->horizontalHeader()->setDefaultSectionSize(300);
this->verticalHeader()->setVisible(false);
this->horizontalHeader()->setVisible(false);
this->setShowGrid(false) ;
this->setStyleSheet("selection-background-color: #eeeeee");
myCol = width/(300);
opModel = new QStandardItemModel();
opModel->setColumnCount(myCol);
opModel->setRowCount(width/myCol);
this->setModel(opModel);
this->setGeometry(0,0,width,height);
for(auto url:Urls){
QList<QString> devAttribute;
devJob = myDiskm.createBlockDevice(url);
devName = devJob->idLabel();
if(devName=="")
devName ="_spareDev"+QString("%1").arg(num++);
QByteArrayList moutList = devJob->mountPoints();
if(moutList.size()==0)
continue;
QStorageInfo *dev_info = new QStorageInfo(moutList.first());
devStill = dev_info->bytesAvailable();
devSize = dev_info->bytesTotal();
devUsd = devSize - devStill;
devRate = static_cast<int>((devUsd*1.0)/(1.0*devSize)*100);
devAttribute<<readableFilesize(devUsd)<<readableFilesize(devSize)<<QString::number(devRate)<<QString(moutList.first());
devices.insert(devName,devAttribute);
devicesNames.push_back(devName);
}
qSort(devicesNames.begin(),devicesNames.end());
for(auto dev:devicesNames)
{
QList<QString> devAttribute=devices.value(dev);
mySdk = new widgetSdk (dev,devAttribute[0],devAttribute[1],devAttribute[2].toInt(),devAttribute[3]);
mySdk->setParent(this);
mySdk->setMouseTracking(true);
this->setIndexWidget(opModel->index(row,col),mySdk);
if(++col==myCol){
col=0;
row++;
}
}
}
myTableView::~myTableView()
{
delete(opModel);
delete(devJob);
delete (mySdk);
}