-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocksdisplay.cpp
62 lines (55 loc) · 1.51 KB
/
blocksdisplay.cpp
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
#include "blocksdisplay.h"
#include "ui_blocksdisplay.h"
#include <QLabel>
#include <mkd64/block.h>
BlocksDisplay::BlocksDisplay(QWidget *parent) :
QMainWindow(parent),
nextTrack(0),
ui(new Ui::BlocksDisplay),
statusIcons(new QPixmap[3])
{
ui->setupUi(this);
statusIcons[0].load(":/gfx/blFree.png");
statusIcons[1].load(":/gfx/blReserved.png");
statusIcons[2].load(":/gfx/blAllocated.png");
}
BlocksDisplay::~BlocksDisplay()
{
delete[] statusIcons;
delete ui;
}
void BlocksDisplay::addTrack(Track *t)
{
QLabel *l = new QLabel(this);
l->setFixedWidth(32);
l->setFixedHeight(16);
l->setText(QString::number(nextTrack+1).append(':'));
ui->gridLayout->addWidget(l, nextTrack, 0);
int numSectors = Track_numSectors(t);
for (int i = 0; i < numSectors;)
{
BlockStatus s = Track_blockStatus(t, i);
int status = 0;
if (s & BS_ALLOCATED) status = 2;
else if (s & BS_RESERVED) status = 1;
l = new QLabel(this);
l->setFixedWidth(16);
l->setFixedHeight(16);
l->setPixmap(statusIcons[status]);
ui->gridLayout->addWidget(l, nextTrack, ++i);
}
++nextTrack;
}
void BlocksDisplay::setBlock(int track, int sector, int status)
{
QLayoutItem *i = ui->gridLayout->itemAtPosition(track-1, sector+1);
if (i)
{
QLabel *l = (QLabel *)i->widget();
l->setPixmap(statusIcons[status]);
}
}
void BlocksDisplay::setStatusMsg(const QString &text)
{
ui->statusBar->showMessage(text);
}