File indexing completed on 2024-11-24 04:18:34
0001 #include "temporaryfile.h" 0002 #include <QDebug> 0003 #include <QUrl> 0004 0005 TemporaryFile::TemporaryFile(QObject *parent) : QObject(parent) 0006 ,m_file(new QTemporaryFile(this)) 0007 { 0008 0009 } 0010 0011 void TemporaryFile::setData(const QByteArray &data, const QString &fileName) 0012 { 0013 // m_file->setFileName(fileName); 0014 0015 if(m_file->open()) 0016 { 0017 qDebug() << "trying to write preview data" << fileName; 0018 m_file->write(data); 0019 m_file->close(); 0020 0021 // m_file->rename(fileName); 0022 Q_EMIT fileReady(m_file->fileName()); 0023 qDebug() << "trying to write preview data" << m_file->fileName(); 0024 0025 0026 } 0027 } 0028 0029 QString TemporaryFile::url() 0030 { 0031 return QUrl::fromLocalFile(m_file->fileName()).toString(); 0032 }