X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvendorlevelwidget.cpp;fp=src%2Fvendorlevelwidget.cpp;h=fde3ab14db5c07bc58636e953b2c41229383571a;hb=6df1a447a1fa1b9e51fd177a806f910813657b09;hp=0000000000000000000000000000000000000000;hpb=f3116511d09acfd5b32d3412c82c4337d89f2ad9;p=schematic diff --git a/src/vendorlevelwidget.cpp b/src/vendorlevelwidget.cpp new file mode 100644 index 0000000..fde3ab1 --- /dev/null +++ b/src/vendorlevelwidget.cpp @@ -0,0 +1,79 @@ +// +// vendorlevelwidget.cpp - Vendor level display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "vendorlevelwidget.h" +#include + + +VendorLevelWidget::VendorLevelWidget(QWidget * parent/*= 0*/): QWidget(parent), + topLine(new QLabel), + level(new QLabel), + color(0xFFFF00), + description("?;Unknown"), + usable(false) +{ + QVBoxLayout * layout = new QVBoxLayout; + + QFont * font = new QFont; + font->setPointSize(48); + level->setFont(*font); +// level->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + level->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); + level->setAlignment(Qt::AlignCenter); +// level->setStyleSheet("QLabel { background-color: yellow; color: blue; }"); + level->setStyleSheet("QLabel { background-color: yellow; }"); + + topLine->setAlignment(Qt::AlignCenter); + topLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + topLine->setMargin(0); + + layout->addStretch(); + layout->addWidget(topLine); + layout->addWidget(level); + + setLayout(layout); + + ParseDescription(); +} + + +void VendorLevelWidget::DoQuery(int key) +{ + QSqlQuery query("SELECT vendorUsable, color, description FROM VendorLevel WHERE VLID=?"); + query.addBindValue(key); + query.exec(); + + if (query.next()) + { + // We have a winner! + usable = query.value(0).toBool(); + color = query.value(1).toInt(); + description = query.value(2).toString(); + } + else + { + usable = false; + color = 0xFFFF00; + description = "?;Unknown"; + } + + ParseDescription(); +} + + +void VendorLevelWidget::ParseDescription(void) +{ + level->setText(description.left(1)); + topLine->setText(description.mid(2)); +} +