7
#include "docviewerFile.h"
12
import org.docviewer.file 1.0
20
path: "the/path/of/file"
23
do.something(mimetype);
28
anchors.centerIn: parent
29
text: helloType.helloworld
36
DocviewerFile::DocviewerFile(QObject *parent) :
41
DocviewerFile::~DocviewerFile() {
45
void DocviewerFile::setPath(QString p) {
50
this->path = QFileInfo(QDir::currentPath(), p).absoluteFilePath();
58
void DocviewerFile::open() {
65
/**Get info of the file**/
69
lastmodified = file.lastModified();
70
emit lastmodifiedChanged();
73
QStringList mimeTypeCommand;
74
mimeTypeCommand << "-ib" << path;
76
mimeTypeProcess = new QProcess();
78
this->connect(mimeTypeProcess, SIGNAL(readyReadStandardOutput()), SLOT(s_readMimeType()));
79
this->connect(mimeTypeProcess, SIGNAL(finished(int)), SLOT(s_finished(int)));
81
mimeTypeProcess->start("file", mimeTypeCommand);
95
void DocviewerFile::s_readMimeType()
97
mimetype = mimeTypeProcess->readAllStandardOutput();
98
mimetype = mimetype.left(mimetype.size()-1);
101
void DocviewerFile::s_finished(int exitCode)
104
mimetype = "Unknown";
105
emit mimetypeChanged();