diff options
Diffstat (limited to 'abs/core/mythinstall/autocard.cpp')
-rwxr-xr-x | abs/core/mythinstall/autocard.cpp | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/abs/core/mythinstall/autocard.cpp b/abs/core/mythinstall/autocard.cpp deleted file mode 100755 index 585fba7..0000000 --- a/abs/core/mythinstall/autocard.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "libmyth/mythcontext.h" -#include "libmyth/mythdbcon.h" -#include <qsqldatabase.h> -#include <qheader.h> -#include <qcursor.h> -#include <qlayout.h> -#include <iostream> -#include "autocard.h" -#include <stdlib.h> -#include <cstdlib> - -AutoCard::AutoCard(void) : - listbox(new ListBoxSetting(this)) -{ - listbox->setLabel(tr("Cards")); - addChild(listbox); -} -void AutoCard::popup_menu(void) -{ - QString name = listbox->getValue(); -// cout << "in popup" << name << endl; - QString uniqid = name.section(' ', -1); - QString description = name.section('*',-3,-3); - description = description.section('.',1); - description = description.stripWhiteSpace(); -// cout << uniqid << endl; -// cout << "descriptn" << endl; -// cout << description << endl; - if (name.isEmpty() || name == "Default") - return; - - QString message = tr("Cardme:") + - QString("\n'%1'?").arg(name); - - DialogCode value = MythPopupBox::Show2ButtonPopup(gContext->GetMainWindow(), - "", message, - tr("Add Card"), - tr("Do not Add"), kDialogCodeButton0); - - if ( value == kDialogCodeButton1) - { - MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("update autocard set devicestatus ='unused' where uniqid=:UNIQID and description=:DESCRIPTION;"); - query.bindValue(":UNIQID",uniqid ); - query.bindValue(":DESCRIPTION",description ); - if (!query.exec()) - MythContext::DBError("Autocard::popup", query); - - int lastIndex = listbox->getValueIndex(name); - lastValue = ""; - load(); - listbox->setValue(lastIndex); - } - else if (value == kDialogCodeButton0) - { - MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("update autocard set devicestatus ='will-add' where uniqid=:UNIQID and description=:DESCRIPTION;"); - query.bindValue(":UNIQID",uniqid ); - query.bindValue(":DESCRIPTION",description ); - - - if (!query.exec()) - MythContext::DBError("Autocard::popup", query); - - int lastIndex = listbox->getValueIndex(name); - lastValue = ""; - load(); - listbox->setValue(lastIndex); - - - - - } - - - listbox->setFocus(); -} - - - -QStringList AutoCard::GetNames(void) -{ - QStringList names; - QString device; - QString description; - QString displayname ; - QString status ; - QString uniqid; - MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("SELECT dev,description,uniqid,devicestatus FROM autocard order by uniqid"); - if (query.exec() && query.isActive() && query.size() > 0) - { - while (query.next()) - { - device=query.value(0).toString(); - description=query.value(1).toString(); - uniqid=query.value(2).toString(); - status=query.value(3).toString(); - //displayname=device; - displayname=". "; - displayname.append(description); - displayname.append(" * "); - displayname.append(status); - displayname.append(" * "); - - displayname.append(uniqid); - names << displayname ; - } - - return names; - } -} - -void AutoCard::open(QString name) -{ - lastValue = name; - bool created = false; - cout << name << endl; - if (name == "Mark all cards for addition") - { - cout <<"updating all cards" << endl; - MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("update autocard set devicestatus='will-add' where devicestatus='unused' order by uniqid"); - query.exec(); - } - else if ( name == "Perform actions" ) - { - // write udev rules and reload udev - - system ("sudo autocard.py -w -i"); - system ("sudo autocard.py -r"); - - } - else if ( name == "Exit" ) - { - // write udev rules and reload udev - exit(0); - } - else - { - popup_menu(); -// bool ok = MythPopupBox::showGetTextPopup(gContext->GetMainWindow(), -// tr("Create New Playback Group"), -// tr("Enter group name or press SELECT to enter text via the " -// "On Screen Keyboard"), name); - - - } - -}; - -void AutoCard::load(void) -{ - listbox->clearSelections(); - - - QStringList names = AutoCard::GetNames(); - while (!names.isEmpty()) - { - listbox->addSelection(names.front()); - names.pop_front(); - } - listbox->addSelection("Mark all cards for addition"); - listbox->addSelection("Perform actions"); - listbox->addSelection("Exit"); - listbox->setValue(lastValue); - -} - - -int AutoCard::exec(void) -{ - while (ConfigurationDialog::exec() == QDialog::Accepted) - open(listbox->getValue()); - - return QDialog::Rejected; -} - - -MythDialog* AutoCard::dialogWidget(MythMainWindow* parent, - const char* widgetName) -{ - dialog = ConfigurationDialog::dialogWidget(parent, widgetName); - connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(popup_menu())); - return dialog; -} |