Commit 7698015e authored by Karel Slaný's avatar Karel Slaný

Removed icon column from files database.

parent 4ae34b4d
......@@ -89,7 +89,6 @@ TRANSLATIONS_FILES += \
SOURCES += \
src/accounts.cpp \
src/auxiliaries/attachment_helper.cpp \
src/auxiliaries/email_helper.cpp \
src/datovka_shared/gov_services/helper.cpp \
src/datovka_shared/gov_services/service/gov_mv_crr_vbh.cpp \
......@@ -211,7 +210,6 @@ SOURCES += \
HEADERS += \
src/accounts.h \
src/auxiliaries/attachment_helper.h \
src/auxiliaries/email_helper.h \
src/common.h \
src/datovka_shared/gov_services/helper.h \
......
/*
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#include <QFileInfo>
#include <QSet>
#include "src/auxiliaries/attachment_helper.h"
/*
* There is list of know file extension sufixes. For these we have png images.
*/
const QSet<QString> knowExp = QSet<QString> () <<
"avi" << "bmp" << "doc" << "docx" << "dwg" << "gif" << "html" <<
"htm" << "jpeg" << "jpg" << "mpeg" << "mpg" << "mp3" << "ods" <<
"odt" << "pdf" << "png" << "ppt" << "pptx" << "rtf" << "tiff" <<
"txt" << "wav" << "xls" << "xlsx" << "xml" << "zfo";
QString getAttachmentFileIconFromFileExtension(const QString &fileName)
{
QString img("qrc:/fileicons/fileicon_blank.png");
QFileInfo fi(fileName);
QString ext = fi.suffix();
ext = ext.toLower();
if (!ext.isNull()) {
if (knowExp.contains(ext)) {
img = "qrc:/fileicons/fileicon_" + ext + ".png";
}
}
return img;
}
/*
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#pragma once
#include <QString>
/*!
* @brief Get attachment icon from attachment file extension.
*
* @param[in] fileName Attachment filename with extension.
* @return Attachment icon filename string.
*/
QString getAttachmentFileIconFromFileExtension(const QString &fileName);
......@@ -24,9 +24,9 @@
#include <QDesktopServices>
#include <QFileInfo>
#include <QQmlEngine>
#include <QStringBuilder>
#include "ios/src/url_opener.h"
#include "src/auxiliaries/attachment_helper.h"
#include "src/auxiliaries/email_helper.h"
#include "src/common.h"
#include "src/crypto/crypto.h"
......@@ -118,7 +118,18 @@ void Files::deleteExpiredFilesFromDbs(int days)
QString Files::getAttachmentFileIcon(const QString &fileName)
{
return getAttachmentFileIconFromFileExtension(fileName);
/* List of know file extension sufixes. For these we have png images. */
static const QSet<QString> knowExp(QSet<QString> () <<
"avi" << "bmp" << "doc" << "docx" << "dwg" << "gif" << "html" <<
"htm" << "jpeg" << "jpg" << "mpeg" << "mpg" << "mp3" << "ods" <<
"odt" << "pdf" << "png" << "ppt" << "pptx" << "rtf" << "tiff" <<
"txt" << "wav" << "xls" << "xlsx" << "xml" << "zfo");
const QString ext(QFileInfo(fileName).suffix().toLower());
if ((!ext.isEmpty()) && knowExp.contains(ext)) {
return QStringLiteral("qrc:/fileicons/fileicon_") % ext % QStringLiteral(".png");
}
return QStringLiteral("qrc:/fileicons/fileicon_blank.png");
}
qint64 Files::getAttachmentSizeInBytes(const QString &filePath)
......
......@@ -23,7 +23,6 @@
#include <QFileInfo>
#include "src/auxiliaries/attachment_helper.h"
#include "src/datovka_shared/isds/message_interface.h"
#include "src/datovka_shared/isds/type_conversion.h"
#include "src/datovka_shared/isds/types.h"
......
......@@ -319,8 +319,7 @@ namespace FlsTbl {
{"dmFileMetaType", DB_TEXT},
{"dmEncodedContent", DB_TEXT},
{"_dmFileSize", DB_INTEGER},
{"_dmDownloadDate", DB_DATETIME},
{"_icon", DB_TEXT}
{"_dmDownloadDate", DB_DATETIME}
/*
* PRIMARY KEY (id),
* FOREIGN KEY(dmID) REFERENCES messages ("dmID")
......@@ -349,8 +348,7 @@ namespace FlsTbl {
{"dmFileMetaType", {DB_TEXT, ""}},
{"dmEncodedContent", {DB_TEXT, ""}},
{"_dmFileSize", {DB_INTEGER, ""}},
{"_dmDownloadDate", {DB_DATETIME, ""}},
{"_icon", {DB_TEXT, ""}}
{"_dmDownloadDate", {DB_DATETIME, ""}}
};
} /* namespace FlsTbl */
SQLiteTbl flsTbl(FlsTbl::tabName, FlsTbl::knownAttrs, FlsTbl::attrProps,
......
......@@ -29,7 +29,6 @@
#include <QSqlQuery>
#include <QSqlRecord>
#include "src/auxiliaries/attachment_helper.h"
#include "src/common.h"
#include "src/datovka_shared/isds/type_conversion.h"
#include "src/datovka_shared/log/log.h"
......@@ -249,17 +248,17 @@ bool FileDb::insertUpdateFileIntoDb(qint64 dmId, const Isds::Document &document)
"dmFileGuid = :dmFileGuid, dmMimeType = :dmMimeType, "
"dmFormat = :dmFormat, dmFileMetaType = :dmFileMetaType, "
"dmEncodedContent = :dmEncodedContent, _dmFileSize = :_dmFileSize, "
"_dmDownloadDate = :_dmDownloadDate, _icon = :_icon "
"_dmDownloadDate = :_dmDownloadDate "
"WHERE id = :id";
} else {
queryStr = "INSERT INTO files ("
"dmID, dmFileDescr, dmUpFileGuid, dmFileGuid, dmMimeType, "
"dmFormat, dmFileMetaType, dmEncodedContent, _dmFileSize, "
"_dmDownloadDate, _icon"
"_dmDownloadDate"
") VALUES ("
":dmID, :dmFileDescr, :dmUpFileGuid, :dmFileGuid, :dmMimeType, "
":dmFormat, :dmFileMetaType, :dmEncodedContent, :_dmFileSize, "
":_dmDownloadDate, :_icon)";
":_dmDownloadDate)";
}
if (!query.prepare(queryStr)) {
......@@ -280,8 +279,6 @@ bool FileDb::insertUpdateFileIntoDb(qint64 dmId, const Isds::Document &document)
query.bindValue(":_dmFileSize", document.binaryContent().size());
query.bindValue(":_dmDownloadDate",
QDate::currentDate().toString(DATE_DB_FORMAT));
query.bindValue(":_icon",
getAttachmentFileIconFromFileExtension(document.fileDescr()));
if (-1 != id) {
query.bindValue(":id", id);
}
......@@ -481,8 +478,8 @@ bool fileSizeColMakeInt(FileDb &fDb, QSqlDatabase &db)
}
queryStr = "INSERT INTO files "
"(id, dmID, dmFileDescr, dmUpFileGuid, dmFileGuid, dmMimeType, dmFormat, dmFileMetaType, dmEncodedContent, _dmFileSize, _dmDownloadDate, _icon) "
"SELECT id, dmID, dmFileDescr, dmUpFileGuid, dmFileGuid, dmMimeType, dmFormat, dmFileMetaType, dmEncodedContent, null, _dmDownloadDate, _icon "
"(id, dmID, dmFileDescr, dmUpFileGuid, dmFileGuid, dmMimeType, dmFormat, dmFileMetaType, dmEncodedContent, _dmFileSize, _dmDownloadDate) "
"SELECT id, dmID, dmFileDescr, dmUpFileGuid, dmFileGuid, dmMimeType, dmFormat, dmFileMetaType, dmEncodedContent, null, _dmDownloadDate "
"FROM _files_old";
if (!query.prepare(queryStr) || !query.exec()) {
logErrorNL("Cannot prepare or execute SQL query: %s",
......
......@@ -23,7 +23,6 @@
#include <QThread>
#include "src/auxiliaries/attachment_helper.h"
#include "src/datovka_shared/log/log.h"
#include "src/global.h"
#include "src/net/db_wrapper.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment