00001 #include <mythtv/mythcontext.h>
00002 #include <mythtv/uitypes.h>
00003 #include <mythtv/mythdialogs.h>
00004 #include "mythtv/mythdbcon.h"
00005
00006 #include "flixutil.h"
00007
00008 QString chooseQueue(QString excludedQueue)
00009 {
00010 MSqlQuery query(MSqlQuery::InitCon());
00011 QString queueName = "";
00012
00013 QString sql ="SELECT DISTINCT queue "
00014 "FROM netflix "
00015 "WHERE queue <> ''";
00016
00017 if (excludedQueue != "")
00018 sql += QString(" AND queue <> '%1'").arg(excludedQueue);
00019
00020 query.exec(sql);
00021
00022 if (!query.isActive())
00023 {
00024 VERBOSE(VB_IMPORTANT,
00025 QString("MythFlixQueue: Error in loading queue from DB"));
00026 }
00027 else
00028 {
00029 QStringList queues;
00030 while ( query.next() )
00031 {
00032 queues += query.value(0).toString();
00033 }
00034
00035 if (queues.size() > 1 || excludedQueue != "")
00036 {
00037 MythPopupBox *queuePopup;
00038 queuePopup = new MythPopupBox(gContext->GetMainWindow(),
00039 "queuepopup");
00040 QLabel *label = queuePopup->addLabel("Queue Name",
00041 MythPopupBox::Large, false);
00042 label->setAlignment(Qt::AlignCenter);
00043
00044 MythListBox *queueList;
00045 queueList = new MythListBox(queuePopup);
00046 queueList->insertStringList(queues);
00047
00048 queuePopup->addWidget(queueList);
00049 queueList->setFocus();
00050
00051 MythDialog::connect(queueList, SIGNAL(accepted(int)),
00052 queuePopup, SLOT(AcceptItem(int)));
00053
00054 DialogCode result = queuePopup->ExecPopup();
00055
00056 if (result != MythDialog::Rejected)
00057 {
00058 queueName = queueList->currentText();
00059 }
00060 else
00061 {
00062 queueName = "__NONE__";
00063 }
00064
00065 queuePopup->hide();
00066 queuePopup->deleteLater();
00067 }
00068 else if (queues.size() == 1)
00069 {
00070 queueName = queues[0];
00071 }
00072 }
00073
00074 return queueName;
00075 }
00076
00077