-
Notifications
You must be signed in to change notification settings - Fork 6
/
CardSlots.cpp
82 lines (68 loc) · 1.84 KB
/
CardSlots.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Cette classe a pour but de gerer l'affichage du contenu de la carte
memoire, soit les icones, les descriptions et le pays d'origine. */
#include <qpixmap.h>
#include <qlayout.h>
#include <qframe.h>
#include <QTreeWidget>
#include "CardSlots.h"
CardSlots::CardSlots( QWidget *parent, const char *name ) : QFrame(parent), pmEmptyIcon(16,16)
{
// create a 3 X 15 grid
// Parent, row, cols, border, space, name
//QGridLayout *grid = new QGridLayout( this, 5, 15, 1,0,"name" );
setObjectName(name);
QVBoxLayout *box = new QVBoxLayout(this);
box->setMargin(0);
box->setSpacing(0);
this->setFrameStyle(QFrame::Panel | QFrame::Sunken);
listview = new QTreeWidget(this);
listview->setColumnCount(5);
listview->setHeaderLabels({"Block", "Icon", "Title", "Game ID", "Product Code"});
//listview->setColumnWidthMode(2,Maximum);
listview->setAllColumnsShowFocus(true);
for (int i=0; i<15; ++i)
{
card_slots[i] = new QTreeWidgetItem( listview, {QString::number(i+1,10),"", "","",""});
}
box->addWidget(listview);
setLayout(box);
}
void CardSlots::changeIcon(int num, QPixmap pixmap)
{
card_slots[num]->setText(1,"");
card_slots[num]->setIcon(1,QIcon(pixmap));
}
void CardSlots::changeText(int num, QString string)
{
card_slots[num]->setText(2,string);
}
void CardSlots::changePcode(int num, QString pcode)
{
card_slots[num]->setText(4,pcode);
}
void CardSlots::changeGameID(int num, QString gameID)
{
card_slots[num]->setText(3,gameID);
}
void CardSlots::changeCountry(int num, int cnum)
{
// Not very useful so not implemented yet...
}
void CardSlots::clearAll()
{
for (int i=0; i<15; i++)
clear(i);
}
void CardSlots::clear(int num)
{
changeIcon(num, pmEmptyIcon);
changeText(num, "Free");
}
int CardSlots::get_selected_slot()
{
for (int i=0; i<15; i++)
{
if (card_slots[i]->isSelected()) { return i; }
}
return -1; //no slot is selected
}