2 // vendorlevelwidget.cpp - Vendor level display
5 // (C) 2012 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 09/24/2012 Created this file
14 #include "vendorlevelwidget.h"
18 VendorLevelWidget::VendorLevelWidget(QWidget * parent/*= 0*/): QWidget(parent),
22 description("?;Unknown"),
25 QVBoxLayout * layout = new QVBoxLayout;
27 QFont * font = new QFont;
28 font->setPointSize(48);
29 level->setFont(*font);
30 // level->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
31 level->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
32 level->setAlignment(Qt::AlignCenter);
33 // level->setStyleSheet("QLabel { background-color: yellow; color: blue; }");
34 level->setStyleSheet("QLabel { background-color: yellow; }");
36 topLine->setAlignment(Qt::AlignCenter);
37 topLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
38 topLine->setMargin(0);
41 layout->addWidget(topLine);
42 layout->addWidget(level);
50 void VendorLevelWidget::DoQuery(int key)
53 query.prepare("SELECT vendorUsable, color, description FROM VendorLevel WHERE VLID=?");
54 query.addBindValue(key);
60 usable = query.value(0).toBool();
61 color = query.value(1).toInt();
62 description = query.value(2).toString();
68 description = "?;Unknown";
75 void VendorLevelWidget::ParseDescription(void)
77 level->setText(description.left(1));
78 topLine->setText(description.mid(2));
81 sprintf(hexDigits, "%06X", color);
82 QString s = QString("QLabel { background-color: #%1; }").arg(hexDigits);
83 level->setStyleSheet(s);