1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "model_logFile.h"
23 #include "thread_encode.h"
26 #include <QApplication>
30 LogFileModel::LogFileModel(const QString &sourceName, const QString &outputName, const QString &configName)
32 m_lines << "Job not started yet." << QString();
33 m_lines << QString("Scheduled source: %1").arg(QDir::toNativeSeparators(sourceName));
34 m_lines << QString("Scheduled output: %1").arg(QDir::toNativeSeparators(outputName));
35 m_lines << QString("Scheduled config: %1").arg(configName);
39 LogFileModel::~LogFileModel(void)
43 ///////////////////////////////////////////////////////////////////////////////
45 ///////////////////////////////////////////////////////////////////////////////
47 int LogFileModel::columnCount(const QModelIndex &parent) const
52 int LogFileModel::rowCount(const QModelIndex &parent) const
54 return m_lines.count();
57 QVariant LogFileModel::headerData(int section, Qt::Orientation orientation, int role) const
62 QModelIndex LogFileModel::index(int row, int column, const QModelIndex &parent) const
64 return createIndex(row, column, NULL);
67 QModelIndex LogFileModel::parent(const QModelIndex &index) const
72 QVariant LogFileModel::data(const QModelIndex &index, int role) const
74 if((role == Qt::DisplayRole) || (role == Qt::ToolTipRole))
76 if(index.row() >= 0 && index.row() < m_lines.count() && index.column() == 0)
78 return m_lines.at(index.row());
85 ///////////////////////////////////////////////////////////////////////////////
87 ///////////////////////////////////////////////////////////////////////////////
89 void LogFileModel::copyToClipboard(void)
91 QClipboard *clipboard = QApplication::clipboard();
92 clipboard->setText(m_lines.join("\r\n"));
95 ///////////////////////////////////////////////////////////////////////////////
97 ///////////////////////////////////////////////////////////////////////////////
99 void LogFileModel::addLogMessage(const QUuid &jobId, const QString &text)
101 beginInsertRows(QModelIndex(), m_lines.count(), m_lines.count());
109 QStringList lines = text.split("\n");
110 for(int i = 0; i < lines.count(); i++)
112 m_lines.append(lines.at(i));