xlsxmediafile.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // xlsxmediafile.cpp
  2. #include <QtGlobal>
  3. #include <QCryptographicHash>
  4. #include "xlsxmediafile_p.h"
  5. QT_BEGIN_NAMESPACE_XLSX
  6. MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
  7. : m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType)
  8. , m_index(0), m_indexValid(false)
  9. {
  10. m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
  11. }
  12. MediaFile::MediaFile(const QString &fileName)
  13. :m_fileName(fileName), m_index(0), m_indexValid(false)
  14. {
  15. }
  16. void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
  17. {
  18. m_contents = bytes;
  19. m_suffix = suffix;
  20. m_mimeType = mimeType;
  21. m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
  22. m_indexValid = false;
  23. }
  24. void MediaFile::setFileName(const QString &name)
  25. {
  26. m_fileName = name;
  27. }
  28. QString MediaFile::fileName() const
  29. {
  30. return m_fileName;
  31. }
  32. QString MediaFile::suffix() const
  33. {
  34. return m_suffix;
  35. }
  36. QString MediaFile::mimeType() const
  37. {
  38. return m_mimeType;
  39. }
  40. QByteArray MediaFile::contents() const
  41. {
  42. return m_contents;
  43. }
  44. int MediaFile::index() const
  45. {
  46. return m_index;
  47. }
  48. bool MediaFile::isIndexValid() const
  49. {
  50. return m_indexValid;
  51. }
  52. void MediaFile::setIndex(int idx)
  53. {
  54. m_index = idx;
  55. m_indexValid = true;
  56. }
  57. QByteArray MediaFile::hashKey() const
  58. {
  59. return m_hashKey;
  60. }
  61. QT_END_NAMESPACE_XLSX