--- /dev/null
+//
+// vendorlevelwidget.cpp - Vendor level display
+//
+// by James Hammons
+// (C) 2012 Underground Software
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -------------------------------------------------------------
+// JLH 09/24/2012 Created this file
+//
+
+#include "vendorlevelwidget.h"
+#include <QtSql>
+
+
+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));
+}
+