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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2007-09-12
 * Description : Metadata info containers
 *
 * SPDX-FileCopyrightText: 2007-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 * SPDX-FileCopyrightText: 2009-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

// Local includes

#include "metadatainfo.h"

namespace Digikam
{

bool IptcCoreContactInfo::isNull() const
{
    return (
            city.isNull()          &&
            country.isNull()       &&
            address.isNull()       &&
            postalCode.isNull()    &&
            provinceState.isNull() &&
            email.isNull()         &&
            phone.isNull()         &&
            webUrl.isNull()
           );
}

bool IptcCoreContactInfo::isEmpty() const
{
    return (
            city.isEmpty()          &&
            country.isEmpty()       &&
            address.isEmpty()       &&
            postalCode.isEmpty()    &&
            provinceState.isEmpty() &&
            email.isEmpty()         &&
            phone.isEmpty()         &&
            webUrl.isEmpty()
           );
}

bool IptcCoreContactInfo::operator==(const IptcCoreContactInfo& t) const
{
    bool b1 = (city          == t.city);
    bool b2 = (country       == t.country);
    bool b3 = (address       == t.address);
    bool b4 = (postalCode    == t.postalCode);
    bool b5 = (provinceState == t.provinceState);
    bool b6 = (email         == t.email);
    bool b7 = (phone         == t.phone);
    bool b8 = (webUrl        == t.webUrl);

    return (b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8);
}

void IptcCoreContactInfo::merge(const IptcCoreContactInfo& t, bool merge)<--- Shadow argument
{
    if (!merge || (!t.city.isEmpty() && city.isEmpty()))
    {
        city = t.city;
    }

    if (!merge || (!t.country.isEmpty() && country.isEmpty()))
    {
        country = t.country;
    }

    if (!merge || (!t.address.isEmpty() && address.isEmpty()))
    {
        address = t.address;
    }

    if (!merge || (!t.postalCode.isEmpty() && postalCode.isEmpty()))
    {
        postalCode = t.postalCode;
    }

    if (!merge || (!t.provinceState.isEmpty() && provinceState.isEmpty()))
    {
        provinceState = t.provinceState;
    }

    if (!merge || (!t.email.isEmpty() && email.isEmpty()))
    {
        email = t.email;
    }

    if (!merge || (!t.phone.isEmpty() && phone.isEmpty()))
    {
        phone = t.phone;
    }

    if (!merge || (!t.webUrl.isEmpty() && webUrl.isEmpty()))
    {
        webUrl = t.webUrl;
    }
}

QDebug operator<<(QDebug dbg, const IptcCoreContactInfo& inf)
{
    dbg.nospace() << "IptcCoreContactInfo::city: "
                  << inf.city << ", ";
    dbg.nospace() << "IptcCoreContactInfo::country: "
                  << inf.country << ", ";
    dbg.nospace() << "IptcCoreContactInfo::address: "
                  << inf.address << ", ";
    dbg.nospace() << "IptcCoreContactInfo::postalCode: "
                  << inf.postalCode << ", ";
    dbg.nospace() << "IptcCoreContactInfo::provinceState: "
                  << inf.provinceState << ", ";
    dbg.nospace() << "IptcCoreContactInfo::email: "
                  << inf.email << ", ";
    dbg.nospace() << "IptcCoreContactInfo::phone: "
                  << inf.phone << ", ";
    dbg.nospace() << "IptcCoreContactInfo::webUrl: "
                  << inf.webUrl;

    return dbg.space();
}

// -------------------------------------------------------------------------

bool IptcCoreLocationInfo::isEmpty() const
{
    return (
            country.isEmpty()       &&
            countryCode.isEmpty()   &&
            provinceState.isEmpty() &&
            city.isEmpty()          &&
            location.isEmpty()
           );
}

bool IptcCoreLocationInfo::isNull() const
{
    return (
            country.isNull()       &&
            countryCode.isNull()   &&
            provinceState.isNull() &&
            city.isNull()          &&
            location.isNull()
           );
}

bool IptcCoreLocationInfo::operator==(const IptcCoreLocationInfo& t) const
{
    bool b1 = (country       == t.country);
    bool b2 = (countryCode   == t.countryCode);
    bool b3 = (provinceState == t.provinceState);
    bool b4 = (city          == t.city);
    bool b5 = (location      == t.location);

    return (b1 && b2 && b3 && b4 && b5);
}

void IptcCoreLocationInfo::merge(const IptcCoreLocationInfo& t, bool merge)<--- Shadow argument
{
    if (!merge || (!t.country.isEmpty() && country.isEmpty()))
    {
        country = t.country;
    }

    if (!merge || (!t.countryCode.isEmpty() && countryCode.isEmpty()))
    {
        countryCode = t.countryCode;
    }

    if (!merge || (!t.provinceState.isEmpty() && provinceState.isEmpty()))
    {
        provinceState = t.provinceState;
    }

    if (!merge || (!t.city.isEmpty() && city.isEmpty()))
    {
        city = t.city;
    }

    if (!merge || (!t.location.isEmpty() && location.isEmpty()))
    {
        location = t.location;
    }
}

QDebug operator<<(QDebug dbg, const IptcCoreLocationInfo& inf)
{
    dbg.nospace() << "IptcCoreLocationInfo::country: "
                  << inf.country << ", ";
    dbg.nospace() << "IptcCoreLocationInfo::countryCode: "
                  << inf.countryCode << ", ";
    dbg.nospace() << "IptcCoreLocationInfo::provinceState: "
                  << inf.provinceState << ", ";
    dbg.nospace() << "IptcCoreLocationInfo::city: "
                  << inf.city << ", ";
    dbg.nospace() << "IptcCoreLocationInfo::location: "
                  << inf.location;

    return dbg.space();
}

} // namespace Digikam