-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlistwidget.cpp
More file actions
71 lines (52 loc) · 1.26 KB
/
Copy pathlistwidget.cpp
File metadata and controls
71 lines (52 loc) · 1.26 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
#include <QVBoxLayout>
#include "listwidget.h"
#include "ui_listwidget.h"
ListWidget::ListWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ListWidget)
{
ui->setupUi(this);
init();
}
ListWidget::~ListWidget()
{
delete ui;
}
void ListWidget::init()
{
QVBoxLayout *vLayout = new QVBoxLayout;
QHBoxLayout *hLayout = new QHBoxLayout;
head = new QLabel(this);
fileName = new QLabel(this);
totalBytes = new QLabel(this);
downloadSpeed = new QLabel(this);
ui->horizontalLayout->addWidget(head);
hLayout->addWidget(fileName);
hLayout->addWidget(totalBytes);
vLayout->addLayout(hLayout);
vLayout->addWidget(downloadSpeed);
ui->horizontalLayout->addLayout(vLayout);
}
void ListWidget::setHead(QString path)
{
QImage *image = new QImage(path);
*image = image->scaled(36, 36, Qt::KeepAspectRatio);
head->setFixedSize(36, 36);
head->setPixmap(QPixmap::fromImage(*image));
}
void ListWidget::setFileName(QString name)
{
fileName->setText(name);
}
void ListWidget::setFileSize(qint64 size)
{
totalBytes->setText(QString("%1 B").arg(size));
}
void ListWidget::setSpeed(QString speed)
{
downloadSpeed->setText(speed);
}
QString ListWidget::getFileName()
{
return fileName->text();
}