From 18c6039f6130b89276719a0cfa8fe0596aad6ca9 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 4 Dec 2012 20:00:22 +0000 Subject: [PATCH] Remove some old unused code from smartplaylist.cpp --- .../mythmusic/mythmusic/smartplaylist.cpp | 326 ------------------ 1 file changed, 326 deletions(-) diff --git a/mythplugins/mythmusic/mythmusic/smartplaylist.cpp b/mythplugins/mythmusic/mythmusic/smartplaylist.cpp index a61d071e43d..966ac0786d0 100644 --- a/mythplugins/mythmusic/mythmusic/smartplaylist.cpp +++ b/mythplugins/mythmusic/mythmusic/smartplaylist.cpp @@ -2050,332 +2050,6 @@ void SmartPLOrderByDialog::getOrderByFields(void) new MythUIButtonListItem(m_orderSelector, SmartPLFields[x].name); } -#if 0 -/* ---------------------------------------------------------------------- -*/ - -SmartPlaylistDialog::SmartPlaylistDialog(MythMainWindow *parent, const char *name) - :MythPopupBox(parent, name) -{ - bool keyboard_accelerators = gCoreContext->GetNumSetting("KeyboardAccelerators", 1); - - // we have to create a parentless layout because otherwise MythPopupbox - // complains about already having a layout - vbox = new Q3VBoxLayout((QWidget *) 0, (int)(10 * hmult)); - - Q3HBoxLayout *hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); - - // create the widgets - - caption = new QLabel(QString(tr("Smart Playlists")), this); - QFont font = caption->font(); - font.setPointSize(int (font.pointSize() * 1.2)); - font.setBold(true); - caption->setFont(font); - caption->setPaletteForegroundColor(QColor("yellow")); - caption->setBackgroundOrigin(ParentOrigin); - caption->setAlignment(Qt::AlignCenter); - caption->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - caption->setMinimumWidth((int)(600 * hmult)); - caption->setMaximumWidth((int)(600 * hmult)); - hbox->addWidget(caption); - - // category - hbox = new Q3HBoxLayout(vbox, (int)(10 * hmult)); - categoryCombo = new MythComboBox(false, this, "categoryCombo"); - categoryCombo->setFocus(); - connect(categoryCombo, SIGNAL(highlighted(int)), this, SLOT(categoryChanged(void))); - connect(categoryCombo, SIGNAL(activated(int)), this, SLOT(categoryChanged(void))); - hbox->addWidget(categoryCombo); - getSmartPlaylistCategories(); - - // listbox - hbox = new Q3HBoxLayout(vbox, (int)(5 * hmult)); - listbox = new Q3MythListBox(this); - listbox->setScrollBar(false); - listbox->setBottomScrollBar(false); - hbox->addWidget(listbox); - - hbox = new Q3HBoxLayout(vbox, (int)(5 * wmult)); - selectButton = new MythPushButton(this, "selectbutton"); - if (keyboard_accelerators) - selectButton->setText(tr("1 Select")); - else - selectButton->setText(tr("Select")); - hbox->addWidget(selectButton); - - newButton = new MythPushButton(this, "newbutton"); - if (keyboard_accelerators) - newButton->setText(tr("2 New")); - else - newButton->setText(tr("New")); - hbox->addWidget(newButton); - - hbox = new Q3HBoxLayout(vbox, (int)(5 * wmult)); - editButton = new MythPushButton(this, "editbutton"); - if (keyboard_accelerators) - editButton->setText(tr("3 Edit")); - else - editButton->setText(tr("Edit")); - hbox->addWidget(editButton); - - deleteButton = new MythPushButton(this, "deletebutton"); - if (keyboard_accelerators) - deleteButton->setText(tr("4 Delete")); - else - deleteButton->setText(tr("Delete")); - hbox->addWidget(deleteButton); - - addLayout(vbox); - - connect(newButton, SIGNAL(clicked()), this, SLOT(newPressed())); - connect(editButton, SIGNAL(clicked()), this, SLOT(editPressed())); - connect(deleteButton, SIGNAL(clicked()), this, SLOT(deletePressed())); - connect(selectButton, SIGNAL(clicked()), this, SLOT(selectPressed())); - - categoryChanged(); -} - -void SmartPlaylistDialog::setSmartPlaylist(QString Category, QString Name) -{ - // try to set the current playlist - for (int x = 0; x < categoryCombo->count(); x++) - { - if (categoryCombo->text(x) == Category) - { - categoryCombo->setCurrentItem(x); - categoryChanged(); - listbox->setCurrentItem(Name); - listbox->setFocus(); - return; - } - } - - // can't find the smartplaylist just select the first item - categoryCombo->setCurrentItem(0); - listbox->setCurrentItem(0); -} - -SmartPlaylistDialog::~SmartPlaylistDialog(void) -{ - if (vbox) - { - delete vbox; - vbox = NULL; - } -} - -void SmartPlaylistDialog::keyPressEvent(QKeyEvent *e) -{ - bool handled = false; - QStringList actions; - handled = GetMythMainWindow()->TranslateKeyPress("qt", e, actions); - - for (int i = 0; i < actions.size() && !handled; i++) - { - QString action = actions[i]; - if (action == "ESCAPE") - { - handled = true; - reject(); - } - else if (action == "LEFT") - { - handled = true; - focusNextPrevChild(false); - } - else if (action == "RIGHT") - { - handled = true; - focusNextPrevChild(true); - } - else if (action == "UP") - { - handled = true; - focusNextPrevChild(false); - } - else if (action == "DOWN") - { - handled = true; - focusNextPrevChild(true); - } - else if (action == "1") - { - handled = true; - selectPressed(); - } - else if (action == "2") - { - handled = true; - newPressed(); - } - else if (action == "3") - { - handled = true; - editPressed(); - } - else if (action == "4") - { - handled = true; - deletePressed(); - } - else if (action == "SELECT" && listbox->hasFocus()) - { - handled = true; - selectPressed(); - } - - } - - if (!handled) - MythPopupBox::keyPressEvent(e); -} - -void SmartPlaylistDialog::newPressed(void) -{ -#if 0 - SmartPlaylistEditor* editor = new SmartPlaylistEditor(GetMythMainWindow(), "SmartPlaylistEditor"); - editor->newSmartPlaylist(categoryCombo->currentText()); - - editor->exec(); - QString category; - QString name; - editor->getCategoryAndName(category, name); - - delete editor; - - getSmartPlaylistCategories(); - - // try to select the correct category and name - categoryCombo->setCurrentText(category); - categoryChanged(); - listbox->setCurrentItem(name); - listbox->setFocus(); -#endif -} - -void SmartPlaylistDialog::selectPressed(void) -{ - accept(); -} - -void SmartPlaylistDialog::deletePressed(void) -{ - if (!listbox->selectedItem()) - return; - - QString category = categoryCombo->currentText(); - QString name = listbox->selectedItem()->text(); - - if (!MythPopupBox::showOkCancelPopup(GetMythMainWindow(), - "Delete SmartPlaylist", - tr("Are you sure you want to delete this SmartPlaylist?") - + "\n\n\"" + name + "\"", false)) - { - deleteButton->setFocus(); - return; - } - - SmartPlaylistEditor::deleteSmartPlaylist(category, name); - - //refresh lists - getSmartPlaylistCategories(); - categoryCombo->setCurrentText(category); - categoryChanged(); - - if (listbox->count() > 0) - deleteButton->setFocus(); - else - newButton->setFocus(); -} - -void SmartPlaylistDialog::editPressed(void) -{ -#if 0 - QString category = categoryCombo->currentText(); - QString name = listbox->currentText(); - - SmartPlaylistEditor* editor = new SmartPlaylistEditor(GetMythMainWindow(), "SmartPlaylistEditor"); - editor->editSmartPlaylist(category, name); - - editor->exec(); - editor->getCategoryAndName(category, name); - getSmartPlaylistCategories(); - categoryChanged(); - - delete editor; - - // try to select the correct category and name - categoryCombo->setCurrentText(category); - listbox->setCurrentItem(name); - listbox->setFocus(); -#endif -} - -void SmartPlaylistDialog::categoryChanged(void) -{ - getSmartPlaylists(categoryCombo->currentText()); -} - -void SmartPlaylistDialog::getSmartPlaylistCategories(void) -{ - categoryCombo->clear(); - MSqlQuery query(MSqlQuery::InitCon()); - - if (query.exec("SELECT name FROM music_smartplaylist_categories ORDER BY name;")) - { - if (query.isActive() && query.size() > 0) - { - while (query.next()) - categoryCombo->insertItem(query.value(0).toString()); - } - } - else - { - MythDB::DBError("Load smartplaylist categories", query); - } -} - -void SmartPlaylistDialog::getSmartPlaylists(QString category) -{ - int categoryid = SmartPlaylistEditor::lookupCategoryID(category); - - listbox->clear(); - - MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("SELECT name FROM music_smartplaylists WHERE categoryid = :CATEGORYID " - "ORDER BY name;"); - query.bindValue(":CATEGORYID", categoryid); - if (query.exec()) - { - if (query.isActive() && query.size() > 0) - { - while (query.next()) - { - listbox->insertItem(query.value(0).toString()); - } - - listbox->setCurrentItem(0); - listbox->setTopItem(0); - } - } - else - MythDB::DBError("Load smartplaylist names", query); - - - deleteButton->setEnabled( (listbox->count() > 0) ); - selectButton->setEnabled( (listbox->count() > 0) ); - editButton->setEnabled( (listbox->count() > 0) ); -} - -void SmartPlaylistDialog::getSmartPlaylist(QString &category, QString &name) -{ - category = categoryCombo->currentText(); - name = listbox->currentText(); -} - -#endif /* --------------------------------------------------------------------- */