void MainWindow::openFromComboBox(QString path) { QFileInfo fileInfo(path); mFileName = fileInfo.fileName(); mPath = path.remove(mFileName); player->setMedia(QMediaContent(QUrl::fromLocalFile(mPath+mFileName))); mDurationTimer->start(200); qDebug() << mPath; qDebug() << mFileName; QDir vidDir(mPath+"imgs"); mFileList = vidDir.entryList(); mFileList.removeFirst(); mFileList.removeFirst(); mImgCount = 0; qDebug() << mFileList; }
/* If the Open function is used, it is necessary for the selected file to be contained in a folder * * hierarchy like the default videos, and must have 'imgs' as the folder name for the images. */ void MainWindow::on_actionOpen_triggered() { mPath = QFileDialog::getOpenFileName(this, "Open File", QDir::currentPath(), "All Files (*.*)"); QFileInfo fileInfo(mPath); mFileName = fileInfo.fileName(); mPath = mPath.remove(mFileName); player->setMedia(QMediaContent(QUrl::fromLocalFile(mPath+mFileName))); mDurationTimer->start(200); qDebug() << mPath; qDebug() << mFileName; QDir vidDir(mPath+"imgs"); mFileList = vidDir.entryList(); mFileList.removeFirst(); mFileList.removeFirst(); mImgCount = 0; qDebug() << mFileList; }
int UPnpMedia::buildFileList(QString directory, int rootID, int itemID, MSqlQuery &query) { int parentid; QDir vidDir(directory); //VERBOSE(VB_UPNP, QString("buildFileList = %1, rootID = %2, itemID = //%3").arg(directory).arg(rootID).arg(itemID)); if (rootID > 0) parentid = rootID; else parentid = itemID; vidDir.setSorting( QDir::DirsFirst | QDir::Name ); QFileInfoList List = vidDir.entryInfoList(); // If we can't read it's contents move on if (List.isEmpty()) return itemID; for (QFileInfoList::iterator it = List.begin(); it != List.end(); ++it) { QFileInfo Info(*it); QString fName = Info.fileName(); QString fPath = Info.filePath(); // We don't want . or .. or something that specifically globs to // either. The "??" and "?" cases can happen when the backend is // running in a non-UTF-8 locale and comes across a UTF-8 filename if (fName == "." || fName == ".." || fName == "?" || fName == "??" || fName == ".?" || fName == "?.") continue; if (Info.isDir()) { // If we are about to recurse into the current directory (which // will cause an infinite recursive loop!), skip this entry. QDir subDir(fPath); if( subDir.canonicalPath() == vidDir.canonicalPath() ) continue; itemID++; query.prepare("INSERT INTO upnpmedia " "(intid, class, itemtype, parentid, itemproperties, " "filepath, filename, title, coverart) " "VALUES (:ITEMID, :ITEMCLASS, 'FOLDER', :PARENTID, '', " ":FILEPATH, :FILENAME, :TITLE, :COVERART)"); query.bindValue(":ITEMCLASS", sMediaType); query.bindValue(":ITEMID", itemID); query.bindValue(":PARENTID", parentid); query.bindValue(":FILEPATH", fPath); query.bindValue(":FILENAME", fName); query.bindValue(":TITLE", GetTitleName(fPath,fName)); query.bindValue(":COVERART", GetCoverArt(fPath)); if (!query.exec()) MythDB::DBError("UPnpMedia::buildFileList", query); itemID = buildFileList(fPath, 0, itemID, query); continue; } else { /* if (handler->validextensions.count() > 0) { QRegExp r; r.setPattern("^" + Info.suffix() + "$"); r.setCaseSensitive(false); QStringList result = handler->validextensions.grep(r); if (result.isEmpty()) { continue; } } */ itemID++; // VERBOSE(VB_UPNP, QString("UPnpMedia Video File : (%1) (%2)") // .arg(itemID) // .arg(fName)); query.prepare("INSERT INTO upnpmedia " "(intid, class, itemtype, parentid, itemproperties, " "filepath, filename, title, coverart) " "VALUES (:ITEMID, :ITEMCLASS, 'FILE', :PARENTID, '', " ":FILEPATH, :FILENAME, :TITLE, :COVERART)"); query.bindValue(":ITEMCLASS", sMediaType); query.bindValue(":ITEMID", itemID); query.bindValue(":PARENTID", parentid); query.bindValue(":FILEPATH", fPath); query.bindValue(":FILENAME", fName); query.bindValue(":TITLE", GetTitleName(fPath,fName)); query.bindValue(":COVERART", GetCoverArt(fPath)); if (!query.exec()) MythDB::DBError("UPnpMedia::buildFileList", query); } } return itemID; }