summaryrefslogtreecommitdiffstats
path: root/movieinfopage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'movieinfopage.cpp')
-rw-r--r--movieinfopage.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/movieinfopage.cpp b/movieinfopage.cpp
index 9d19e48..dab024e 100644
--- a/movieinfopage.cpp
+++ b/movieinfopage.cpp
@@ -24,6 +24,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QToolBar>
+#include <QDateEdit>
#include <QApplication>
#include "movieinfopage.h"
@@ -60,10 +61,14 @@ void MovieInfoPage::setupGui(){
//add + remove files
QHBoxLayout *fileButtonLayout = new QHBoxLayout;
+ mCreationDate = new QDateEdit;
+ mCreationDate->setDisplayFormat("dd. MMMM yyyy");
+ mCreationDate->setDate(QDate::currentDate());
+ fileButtonLayout->addWidget(mCreationDate);
fileButtonLayout->addStretch();
- QPushButton *extractTitleB = new QPushButton(tr("Title"));
+ QPushButton *extractTitleB = new QPushButton(tr("Meta"));
fileButtonLayout->addWidget(extractTitleB);
- connect(extractTitleB, &QPushButton::clicked, this, &MovieInfoPage::extractTitle);
+ connect(extractTitleB, &QPushButton::clicked, this, &MovieInfoPage::extractMetadata);
QPushButton *addOldB = new QPushButton(tr("Add Old..."));
fileButtonLayout->addWidget(addOldB);
connect(addOldB, &QPushButton::clicked, this, &MovieInfoPage::addOld);
@@ -125,6 +130,7 @@ void MovieInfoPage::setupGui(){
registerField("subtitle", mSubtitle);
registerField("seriesNo", mSeriesNo);
registerField("quality", mQuality);
+ registerField("creationDate", mCreationDate);
}
void MovieInfoPage::initializePage(){
@@ -201,23 +207,32 @@ void MovieInfoPage::initCompleters(){
mSeriesCompleterModel->setStringList(series);
}
-void MovieInfoPage::extractTitle(){
+void MovieInfoPage::extractMetadata(){
QModelIndexList curIdxList = mFileView->selectionModel()->selectedRows();
if(!curIdxList.isEmpty()){
- QString fp = curIdxList.at(0).data(WizardTreeModel::FullPathRole).toString();
+ QModelIndex selIdx = curIdxList.at(0);
+ QModelIndex selChild = selIdx.model()->index(0, 0, selIdx);
+ if(selChild.isValid()){
+ selIdx = selChild;
+ }
+ QString fp = selIdx.data(WizardTreeModel::FullPathRole).toString();
QJsonDocument jDoc = Helper::streamData(fp);
if(!jDoc.isNull()){
QJsonObject jObj1 = jDoc.object().value("format").toObject();
QJsonObject jObj2 = jObj1.value("tags").toObject();
- QString title = jObj2.value("title").toString().toLower();
- if(!title.isEmpty()){
- mSubtitle->setText(title);
- }else{
- QString fn = curIdxList.at(0).data(WizardTreeModel::FileNameRole).toString().toLower();
- fn.replace(".mkv", "");
- fn.replace(".", " ");
- mSubtitle->setText(fn);
+ QString creationTime = jObj2.value("creation_time").toString();
+ if(!creationTime.isNull()){
+ QDateTime creationTimeObj = QDateTime::fromString(creationTime, Qt::ISODateWithMs);
+ if(creationTimeObj.isValid()){
+ mCreationDate->setDate(creationTimeObj.date());
+ }
}
+ QString fn = curIdxList.at(0).data(WizardTreeModel::FileNameRole).toString().toLower();
+ fn.replace(".mkv", "");
+ fn.replace(".mp4", "");
+ fn.replace(".", " ");
+ mSubtitle->setText(fn);
+
}
}
}