harbour-seaprint/src/mimer.cpp

67 lines
1.8 KiB
C++
Raw Normal View History

#include "mimer.h"
2022-05-29 16:54:11 +03:00
#include <QDebug>
2021-03-04 23:49:27 +03:00
const QString Mimer::OctetStream = "application/octet-stream";
const QString Mimer::PDF = "application/pdf";
const QString Mimer::Postscript = "application/postscript";
const QString Mimer::PWG = "image/pwg-raster";
const QString Mimer::URF = "image/urf";
const QString Mimer::PNG = "image/png";
const QString Mimer::GIF = "image/gif";
const QString Mimer::JPEG = "image/jpeg";
const QString Mimer::TIFF = "image/tiff";
2022-05-29 16:54:11 +03:00
const QString Mimer::SVG = "image/svg+xml";
2022-05-26 12:57:16 +03:00
const QString Mimer::RBMP = "image/reverse-encoding-bmp";
2021-03-04 23:49:27 +03:00
2021-03-06 00:26:22 +03:00
const QString Mimer::DOC = "application/msword";
const QString Mimer::DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
const QString Mimer::RTF = "text/rtf";
2021-03-06 14:59:47 +03:00
const QString Mimer::RTF_APP = "application/rtf";
2021-03-06 00:26:22 +03:00
const QString Mimer::ODT = "application/vnd.oasis.opendocument.text";
2021-06-12 17:54:17 +03:00
const QString Mimer::PPT = "application/vnd.ms-powerpoint";
const QString Mimer::PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
const QString Mimer::ODP = "application/vnd.oasis.opendocument.presentation";
2021-03-06 00:26:22 +03:00
2021-06-12 13:45:58 +03:00
const QString Mimer::Plaintext = "text/plain";
const QStringList Mimer::RasterFormats = {PWG, URF};
2021-06-12 17:54:17 +03:00
const QStringList Mimer::OfficeFormats = {DOC, DOCX, RTF, RTF_APP, ODT, PPT, PPTX, ODP};
2021-03-04 23:49:27 +03:00
Mimer::Mimer()
{
}
Mimer* Mimer::m_Instance = 0;
Mimer* Mimer::instance()
{
static QMutex mutex;
if (!m_Instance)
{
mutex.lock();
if (!m_Instance)
m_Instance = new Mimer;
mutex.unlock();
}
return m_Instance;
}
QString Mimer::get_type(QString filename) {
2022-05-29 16:54:11 +03:00
QString type = _db.mimeTypeForFile(filename).name();
qDebug() << "MimeType:" << type;
2023-02-17 23:29:12 +03:00
if(type == PDF || type == Postscript || type == Plaintext || isImage(type) || isOffice(type))
{
return type;
}
else
{
return "";
}
}