From d44cada7cd8eee4a0967da2649a8332bdb12346f Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 11 Nov 2016 06:27:40 +0100 Subject: Actually play movies! Finally do something with the random selection! Implement playAll and playSelected. --- randomtab.cpp | 28 +++++++++++++++++++++++++++- randomtab.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/randomtab.cpp b/randomtab.cpp index 5f0245f..835a750 100644 --- a/randomtab.cpp +++ b/randomtab.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -392,11 +393,36 @@ void RandomTab::select(){ } void RandomTab::playAll(){ - + logMessage(tr("Playing All")); + QStringList files; + QStandardItem *root = mFileModel->invisibleRootItem(); + for(int i = 0; i < root->rowCount(); ++i){ + QStandardItem *c = root->child(i, FullPath); + logMessage(QString(tr("Adding %1")).arg(c->text())); + files << c->text(); + } + play(files); } void RandomTab::playSelected(){ + logMessage(tr("Playing Selected")); + QStringList files; + QModelIndexList idxs = mFileView->selectionModel()->selectedRows(FullPath); + foreach(QModelIndex i, idxs){ + QString fp = i.data().toString(); + logMessage(QString(tr("Adding %1")).arg(fp)); + files << fp; + } + play(files); +} +void RandomTab::play(const QStringList &files){ + QPair pgdata = Helper::programData("movieviewer"); + QString program = pgdata.first; + QStringList args = pgdata.second; + args.append(files); + logMessage(QString(tr("Cmd: %1 %2")).arg(program).arg(args.join(" "))); + QProcess::startDetached(program, args); } void RandomTab::logMessage(const QString &msg){ diff --git a/randomtab.h b/randomtab.h index a66ee10..3f400e8 100644 --- a/randomtab.h +++ b/randomtab.h @@ -24,6 +24,7 @@ class RandomTab : public QWidget { Q_OBJECT public: enum CustomRoles { IdRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, DurationRole = Qt::UserRole + 3, DvdNoRole = Qt::UserRole + 4 }; + enum Columns { FileName = 0, Size = 1, Duration = 2, Md5 = 3, Location = 4, FullPath = 5 }; enum { ColumnCount = 6 }; explicit RandomTab(QWidget *parent = 0); virtual ~RandomTab(); @@ -35,6 +36,7 @@ class RandomTab : public QWidget { void select(); void playAll(); void playSelected(); + void play(const QStringList &files); void logMessage(const QString &msg); private: -- cgit v1.2.3-70-g09d2