Some code simplification.

This commit is contained in:
LoRd_MuldeR 2015-03-23 22:05:58 +01:00
parent 8e4e381408
commit 404218e947
3 changed files with 10 additions and 22 deletions

View File

@ -101,20 +101,22 @@ bool LogFileModel::saveToLocalFile(const QString &fileName)
return false; return false;
} }
QTextStream out(&file); QTextStream stream(&file);
out.setCodec("UTF-8"); stream.setCodec("UTF-8");
stream.setGenerateByteOrderMark(true);
for(QStringList::ConstIterator iter = m_lines.constBegin(); iter != m_lines.constEnd(); iter++) for(QStringList::ConstIterator iter = m_lines.constBegin(); iter != m_lines.constEnd(); iter++)
{ {
out << (*iter) << QLatin1String("\r\n"); stream << (*iter) << QLatin1String("\r\n");
if(out.status() != QTextStream::Status::Ok) if(stream.status() != QTextStream::Status::Ok)
{ {
file.close(); file.close();
return false; return false;
} }
} }
out.flush(); stream.flush();
if(out.status() != QTextStream::Status::Ok) if(stream.status() != QTextStream::Status::Ok)
{ {
file.close(); file.close();
return false; return false;

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 5 #define VER_X264_MINOR 5
#define VER_X264_PATCH 0 #define VER_X264_PATCH 0
#define VER_X264_BUILD 944 #define VER_X264_BUILD 945
#define VER_X264_PORTABLE_EDITION (0) #define VER_X264_PORTABLE_EDITION (0)

View File

@ -690,21 +690,7 @@ void MainWindow::saveLogFile(const QModelIndex &index)
{ {
QDir(QString("%1/logs").arg(x264_data_path())).mkpath("."); QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-")); QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
QFile outFile(logFilePath); if(!log->saveToLocalFile(logFilePath))
if(outFile.open(QIODevice::WriteOnly))
{
QTextStream outStream(&outFile);
outStream.setCodec("UTF-8");
outStream.setGenerateByteOrderMark(true);
const int rows = log->rowCount(QModelIndex());
for(int i = 0; i < rows; i++)
{
outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
}
outFile.close();
}
else
{ {
qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData()); qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
} }