1 /***************************************************************************
2 * Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include <KUrlRequester>
23 #include "dvdwizardvob.h"
25 DvdWizardVob::DvdWizardVob(QWidget *parent): QWizardPage(parent) {
27 m_view.intro_vob->setEnabled(false);
28 m_view.vob_1->setFilter("video/mpeg");
29 m_view.intro_vob->setFilter("video/mpeg");
30 connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
31 connect(m_view.vob_1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
35 DvdWizardVob::~DvdWizardVob() {
36 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
42 bool DvdWizardVob::isComplete() const {
43 if (m_view.vob_1->url().path().isEmpty()) return false;
44 if (QFile::exists(m_view.vob_1->url().path())) return true;
48 void DvdWizardVob::setUrl(const QString &url) {
49 m_view.vob_1->setPath(url);
52 QStringList DvdWizardVob::selectedUrls() const {
54 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
55 for (int i = 0; i < allUrls.count(); i++) {
56 if (!allUrls.at(i)->url().path().isEmpty()) {
57 result.append(allUrls.at(i)->url().path());
63 QString DvdWizardVob::introMovie() const {
64 if (!m_view.use_intro->isChecked()) return QString();
65 return m_view.intro_vob->url().path();
68 void DvdWizardVob::slotCheckVobList(const QString &text) {
69 emit completeChanged();
70 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
71 int count = allUrls.count();
72 kDebug() << "// FOUND " << count << " URLS";
74 if (text.isEmpty()) return;
75 // insert second urlrequester
76 KUrlRequester *vob = new KUrlRequester(this);
77 vob->setFilter("video/mpeg");
78 m_view.vob_list->layout()->addWidget(vob);
79 connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
80 } else if (text.isEmpty()) {
81 if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
82 // The last 2 urlrequesters are empty, remove last one
83 KUrlRequester *vob = allUrls.takeLast();
87 if (allUrls.at(count - 1)->url().path().isEmpty()) return;
88 KUrlRequester *vob = new KUrlRequester(this);
89 vob->setFilter("video/mpeg");
90 m_view.vob_list->layout()->addWidget(vob);
91 connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));