comparison src/xlsx/xlsxmediafile.cpp @ 1:93d3106bb9a4

Add qt xlsx library
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 22 Mar 2016 10:38:08 +0100
parents
children
comparison
equal deleted inserted replaced
0:49cd5cc0b072 1:93d3106bb9a4
1 /****************************************************************************
2 ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
3 ** All right reserved.
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining
6 ** a copy of this software and associated documentation files (the
7 ** "Software"), to deal in the Software without restriction, including
8 ** without limitation the rights to use, copy, modify, merge, publish,
9 ** distribute, sublicense, and/or sell copies of the Software, and to
10 ** permit persons to whom the Software is furnished to do so, subject to
11 ** the following conditions:
12 **
13 ** The above copyright notice and this permission notice shall be
14 ** included in all copies or substantial portions of the Software.
15 **
16 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 **
24 ****************************************************************************/
25
26 #include "xlsxmediafile_p.h"
27 #include <QCryptographicHash>
28
29 namespace QXlsx {
30
31 MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
32 : m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType)
33 , m_index(0), m_indexValid(false)
34 {
35 m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
36 }
37
38 MediaFile::MediaFile(const QString &fileName)
39 :m_fileName(fileName), m_index(0), m_indexValid(false)
40 {
41
42 }
43
44 void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
45 {
46 m_contents = bytes;
47 m_suffix = suffix;
48 m_mimeType = mimeType;
49 m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
50 m_indexValid = false;
51 }
52
53 void MediaFile::setFileName(const QString &name)
54 {
55 m_fileName = name;
56 }
57
58 QString MediaFile::fileName() const
59 {
60 return m_fileName;
61 }
62
63 QString MediaFile::suffix() const
64 {
65 return m_suffix;
66 }
67
68 QString MediaFile::mimeType() const
69 {
70 return m_mimeType;
71 }
72
73 QByteArray MediaFile::contents() const
74 {
75 return m_contents;
76 }
77
78 int MediaFile::index() const
79 {
80 return m_index;
81 }
82
83 bool MediaFile::isIndexValid() const
84 {
85 return m_indexValid;
86 }
87
88 void MediaFile::setIndex(int idx)
89 {
90 m_index = idx;
91 m_indexValid = true;
92 }
93
94 QByteArray MediaFile::hashKey() const
95 {
96 return m_hashKey;
97 }
98
99 } // namespace QXlsx
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)