1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2010-06-02
 * Description : class holding properties of referenced files used in non-dest. editing
 *
 * SPDX-FileCopyrightText: 2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

#include "historyimageid.h"

// Qt includes

#include <QFileInfo>
#include <QUrl>

namespace Digikam
{

HistoryImageId::HistoryImageId(const QString& uuid, Type type)
    : m_type(type),
      m_uuid(uuid)
{
}

void HistoryImageId::setType(HistoryImageId::Type type)<--- Shadow argument
{
    m_type = type;
}

void HistoryImageId::setUuid(const QString& uuid)<--- Shadow argument
{
    m_uuid = uuid;
}

void HistoryImageId::setFileName(const QString& fileName)<--- Shadow argument
{
    m_fileName = fileName;
}

void HistoryImageId::setCreationDate(const QDateTime& creationDate)<--- Shadow argument
{
    m_creationDate = creationDate;
}

void HistoryImageId::setPathOnDisk(const QString& filePath)<--- Shadow argument
{
    QUrl url   = QUrl::fromLocalFile(filePath);
    m_filePath = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile() + QLatin1Char('/');
}

void HistoryImageId::setPath(const QString& path)<--- Shadow argument
{
    m_filePath = path;

    if (!m_filePath.endsWith(QLatin1Char('/')))
    {
        m_filePath += QLatin1Char('/');
    }
}

void HistoryImageId::setUniqueHash(const QString& uniqueHash, qlonglong fileSize)<--- Shadow argument<--- Shadow argument
{
    m_uniqueHash = uniqueHash;
    m_fileSize   = fileSize;
}

bool HistoryImageId::isValid() const
{
    return (
            (m_type != InvalidType) &&
            (!m_uuid.isEmpty() || !m_fileName.isEmpty())
           );
}

HistoryImageId::Type HistoryImageId::type() const
{
    return m_type;
}

QString HistoryImageId::path() const
{
    return m_filePath;
}

QString HistoryImageId::filePath() const
{
    return (m_filePath + m_fileName);
}

bool HistoryImageId::hasFileOnDisk() const
{
    return (!m_filePath.isEmpty() && !m_fileName.isEmpty());
}

bool HistoryImageId::hasFileName() const
{
    return !m_fileName.isEmpty();
}

QString HistoryImageId::fileName() const
{
    return m_fileName;
}

bool HistoryImageId::hasUuid() const
{
    return !m_uuid.isEmpty();
}

QString HistoryImageId::uuid() const
{
    return m_uuid;
}

bool HistoryImageId::hasCreationDate() const
{
    return m_creationDate.isValid();
}

QDateTime HistoryImageId::creationDate() const
{
    return m_creationDate;
}

bool HistoryImageId::hasUniqueHashIdentifier() const
{
    return (!m_uniqueHash.isEmpty() && m_fileSize);
}

QString HistoryImageId::uniqueHash() const
{
    return m_uniqueHash;
}

qlonglong HistoryImageId::fileSize() const
{
    return m_fileSize;
}

QString HistoryImageId::originalUuid() const
{
    return m_originalUUID;
}

bool HistoryImageId::operator==(const HistoryImageId& other) const
{
    return (
            (m_uuid         == other.m_uuid)           &&
            (m_type         == other.m_type)           &&
            (m_fileName     == other.m_fileName)       &&
            (m_filePath     == other.m_filePath)       &&
            (m_creationDate == other.m_creationDate)   &&
            (m_uniqueHash   == other.m_uniqueHash)     &&
            (m_fileSize     == other.m_fileSize)       &&
            (m_originalUUID == other.m_originalUUID)
           );
}

} // namespace Digikam