///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
-#include "model_jobList.h"
#include "global.h"
+#include "model_jobList.h"
#include "thread_encode.h"
+#include "model_options.h"
+#include "model_preferences.h"
+#include "resource.h"
#include <QIcon>
#include <QFileInfo>
-JobListModel::JobListModel(void)
+#include <Mmsystem.h>
+
+JobListModel::JobListModel(PreferencesModel *preferences)
{
+ m_preferences = preferences;
}
JobListModel::~JobListModel(void)
QModelIndex JobListModel::insertJob(EncodeThread *thread)
{
QUuid id = thread->getId();
- LogFileModel *logFile = NULL;
if(m_jobs.contains(id))
{
return QModelIndex();
}
-
+
+ QString config = "N/A";
+
+ switch(thread->options()->rcMode())
+ {
+ case OptionsModel::RCMode_CRF:
+ config = QString("CRF@%1").arg(QString::number(thread->options()->quantizer()));
+ break;
+ case OptionsModel::RCMode_CQ:
+ config = QString("CQ@%1").arg(QString::number(qRound(thread->options()->quantizer())));
+ break;
+ case OptionsModel::RCMode_2Pass:
+ config = QString("2Pass@%1").arg(QString::number(thread->options()->bitrate()));
+ break;
+ case OptionsModel::RCMode_ABR:
+ config = QString("ABR@%1").arg(QString::number(thread->options()->bitrate()));
+ break;
+ }
+
int n = 2;
- QString jobName = QFileInfo(thread->sourceFileName()).completeBaseName();
+ QString jobName = QString("%1 (%2)").arg(QFileInfo(thread->sourceFileName()).completeBaseName().simplified(), config);
forever
{
}
if(!unique)
{
- jobName = QString("%1 (%2)").arg(QFileInfo(thread->sourceFileName()).completeBaseName(), QString::number(n++));
+ jobName = QString("%1 %2 (%3)").arg(QFileInfo(thread->sourceFileName()).completeBaseName().simplified(), QString::number(n++), config);
continue;
}
break;
}
-
+
+ LogFileModel *logFile = new LogFileModel(thread->sourceFileName(), thread->outputFileName(), config);
+
beginInsertRows(QModelIndex(), m_jobs.count(), m_jobs.count());
m_jobs.append(id);
m_name.insert(id, jobName);
m_status.insert(id, EncodeThread::JobStatus_Enqueued);
m_progress.insert(id, 0);
m_threads.insert(id, thread);
- m_logFile.insert(id, (logFile = new LogFileModel));
+ m_logFile.insert(id, logFile);
m_details.insert(id, tr("Not started yet."));
endInsertRows();
return NULL;
}
+const QString &JobListModel::getJobSourceFile(const QModelIndex &index)
+{
+ static QString nullStr;
+
+ if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
+ {
+ EncodeThread *thread = m_threads.value(m_jobs.at(index.row()));
+ return (thread != NULL) ? thread->sourceFileName() : nullStr;
+ }
+
+ return nullStr;
+}
+
const QString &JobListModel::getJobOutputFile(const QModelIndex &index)
{
static QString nullStr;
return 0;
}
+const OptionsModel *JobListModel::getJobOptions(const QModelIndex &index)
+{
+ static QString nullStr;
+
+ if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
+ {
+ EncodeThread *thread = m_threads.value(m_jobs.at(index.row()));
+ return (thread != NULL) ? thread->options() : NULL;
+ }
+
+ return NULL;
+}
+
QModelIndex JobListModel::getJobIndexById(const QUuid &id)
{
if(m_jobs.contains(id))
{
m_status.insert(jobId, newStatus);
emit dataChanged(createIndex(index, 0), createIndex(index, 1));
+
+ if(m_preferences->enableSounds())
+ {
+ switch(newStatus)
+ {
+ case EncodeThread::JobStatus_Completed:
+ PlaySound(MAKEINTRESOURCE(IDR_WAVE4), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
+ break;
+ case EncodeThread::JobStatus_Aborted:
+ PlaySound(MAKEINTRESOURCE(IDR_WAVE5), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
+ break;
+ case EncodeThread::JobStatus_Failed:
+ PlaySound(MAKEINTRESOURCE(IDR_WAVE6), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
+ break;
+ }
+ }
}
}