diff --git a/core/libs/dimg/history/dimagehistory.cpp b/core/libs/dimg/history/dimagehistory.cpp index da2634ad3f..f49586c1b3 100644 --- a/core/libs/dimg/history/dimagehistory.cpp +++ b/core/libs/dimg/history/dimagehistory.cpp @@ -1,796 +1,801 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2010-06-02 * Description : class for manipulating modifications changeset for non-destruct. editing * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #include "dimagehistory.h" // Qt includes #include #include #include #include #include #include // Local includes #include "digikam_debug.h" namespace Digikam { class Q_DECL_HIDDEN DImageHistory::Private : public QSharedData { public: explicit Private() { } QList entries; }; // ----------------------------------------------------------------------------------------------- class Q_DECL_HIDDEN PrivateSharedNull : public QSharedDataPointer { public: PrivateSharedNull() : QSharedDataPointer(new DImageHistory::Private) { } }; Q_GLOBAL_STATIC(PrivateSharedNull, imageHistoryPrivSharedNull) // ----------------------------------------------------------------------------------------------- DImageHistory::DImageHistory() : d(*imageHistoryPrivSharedNull) { } DImageHistory::DImageHistory(const DImageHistory& other) { d = other.d; } DImageHistory::~DImageHistory() { } DImageHistory& DImageHistory::operator=(const DImageHistory& other) { d = other.d; + return *this; } bool DImageHistory::isNull() const { - return d == *imageHistoryPrivSharedNull; + return (d == *imageHistoryPrivSharedNull); } bool DImageHistory::isEmpty() const { return d->entries.isEmpty(); } bool DImageHistory::isValid() const { if (d->entries.isEmpty()) { return false; } - else if (d->entries.count() == 1 && - d->entries.first().referredImages.count() == 1 && + else if ((d->entries.count() == 1) && + (d->entries.first().referredImages.count() == 1) && d->entries.first().referredImages.first().isCurrentFile()) { return false; } else { foreach (const Entry& e, d->entries) { if (!e.action.isNull()) { return true; } foreach (const HistoryImageId& id, e.referredImages) { if (id.isValid() && !id.isCurrentFile()) { return true; } } } } return false; } int DImageHistory::size() const { return d->entries.size(); } static bool operator==(const DImageHistory::Entry& e1, const DImageHistory::Entry& e2) { - return e1.action == e2.action && - e1.referredImages == e2.referredImages; + return ((e1.action == e2.action) && + (e1.referredImages == e2.referredImages)); } bool DImageHistory::operator==(const DImageHistory& other) const { - return d->entries == other.d->entries; + return (d->entries == other.d->entries); } bool DImageHistory::operator<(const Digikam::DImageHistory& other) const { if (d->entries.size() < other.size()) { return true; } return false; } bool DImageHistory::operator>(const Digikam::DImageHistory& other) const { if (d->entries.size() > other.size()) { return true; } return false; } QList &DImageHistory::entries() { return d->entries; } const QList &DImageHistory::entries() const { return d->entries; } DImageHistory::Entry& DImageHistory::operator[](int i) { return d->entries[i]; } const DImageHistory::Entry& DImageHistory::operator[](int i) const { return d->entries.at(i); } DImageHistory& DImageHistory::operator<<(const FilterAction& action) { if (action.isNull()) { return *this; } Entry entry; entry.action = action; d->entries << entry; //qCDebug(DIGIKAM_DIMG_LOG) << "Entry added, total count " << d->entries.count(); + return *this; } DImageHistory& DImageHistory::operator<<(const HistoryImageId& id) { appendReferredImage(id); + return *this; } void DImageHistory::appendReferredImage(const HistoryImageId& id) { insertReferredImage(d->entries.size() - 1, id); } void DImageHistory::insertReferredImage(int index, const HistoryImageId& id) { if (!id.isValid()) { qCWarning(DIGIKAM_DIMG_LOG) << "Attempt to add an invalid HistoryImageId"; return; } index = qBound(0, index, d->entries.size() - 1); if (id.isCurrentFile()) { // enforce to have exactly one Current id adjustReferredImages(); } if (d->entries.isEmpty()) { d->entries << Entry(); } d->entries[index].referredImages << id; } void DImageHistory::removeLast() { if (!d->entries.isEmpty()) { d->entries.removeLast(); } } const FilterAction& DImageHistory::action(int i) const { return d->entries.at(i).action; } QList DImageHistory::allActions() const { QList actions; foreach (const Entry& entry, d->entries) { if (!entry.action.isNull()) { actions << entry.action; } } return actions; } int DImageHistory::actionCount() const { int count = 0; foreach (const Entry& entry, d->entries) { if (!entry.action.isNull()) { ++count; } } return count; } bool DImageHistory::hasActions() const { foreach (const Entry& entry, d->entries) { if (!entry.action.isNull()) { return true; } } return false; } QList &DImageHistory::referredImages(int i) { return d->entries[i].referredImages; } const QList &DImageHistory::referredImages(int i) const { return d->entries.at(i).referredImages; } QList DImageHistory::allReferredImages() const { QList ids; foreach (const Entry& entry, d->entries) { ids << entry.referredImages; } return ids; } bool DImageHistory::hasReferredImages() const { foreach (const Entry& entry, d->entries) { if (!entry.referredImages.isEmpty()) { return true; } } return false; } bool DImageHistory::hasReferredImageOfType(HistoryImageId::Type type) const { foreach (const Entry& entry, d->entries) { foreach (const HistoryImageId& id, entry.referredImages) { if (id.m_type == type) { return true; } } } return false; } bool DImageHistory::hasCurrentReferredImage() const { return hasReferredImageOfType(HistoryImageId::Current); } bool DImageHistory::hasOriginalReferredImage() const { return hasReferredImageOfType(HistoryImageId::Original); } QList DImageHistory::referredImagesOfType(HistoryImageId::Type type) const { QList ids; foreach (const Entry& entry, d->entries) { foreach (const HistoryImageId& id, entry.referredImages) { if (id.m_type == type) { ids << id; } } } return ids; } HistoryImageId DImageHistory::currentReferredImage() const { foreach (const Entry& entry, d->entries) { foreach (const HistoryImageId& id, entry.referredImages) { if (id.isCurrentFile()) { return id; } } } return HistoryImageId(); } HistoryImageId DImageHistory::originalReferredImage() const { foreach (const Entry& entry, d->entries) { foreach (const HistoryImageId& id, entry.referredImages) { if (id.isOriginalFile()) { return id; } } } return HistoryImageId(); } void DImageHistory::clearReferredImages() { - for (int i=0; ientries.size(); ++i) + for (int i = 0 ; i < d->entries.size() ; ++i) { d->entries[i].referredImages.clear(); } } void DImageHistory::adjustReferredImages() { - for (int i=0; ientries.size(); ++i) + for (int i = 0 ; i < d->entries.size() ; ++i) { Entry& entry = d->entries[i]; - for (int e=0; eentries.size(); ++i) + for (int i = 0 ; i < d->entries.size() ; ++i) { Entry& entry = d->entries[i]; - for (int e=0; eentries.size(); ++i) + for (int i = 0 ; i < d->entries.size() ; ++i) { Entry& entry = d->entries[i]; - for (int e=0; eentries.size(); ++i) + for (int i = 0 ; i < d->entries.size() ; ++i) { Entry& entry = d->entries[i]; - for (int e=0; e& params = step.action.parameters(); if (!params.isEmpty()) { QList keys = params.keys(); std::sort(keys.begin(), keys.end()); foreach (const QString& key, keys) { QHash::const_iterator it; - for (it = params.find(key); it != params.end() && it.key() == key; ++it) + for (it = params.find(key) ; it != params.end() && it.key() == key ; ++it) { stream.writeStartElement(QLatin1String("param")); stream.writeAttribute(QLatin1String("name"), key); stream.writeAttribute(QLatin1String("value"), it.value().toString()); stream.writeEndElement(); //param } } } stream.writeEndElement(); //params stream.writeEndElement(); //filter } if (!step.referredImages.isEmpty()) { foreach (const HistoryImageId& imageId, step.referredImages) { if (!imageId.isValid()) { continue; } if (imageId.isCurrentFile()) { continue; } stream.writeStartElement(QLatin1String("file")); if (!imageId.m_uuid.isNull()) { stream.writeAttribute(QLatin1String("uuid"), imageId.m_uuid); } if (imageId.isOriginalFile()) { stream.writeAttribute(QLatin1String("type"), QLatin1String("original")); } else if (imageId.isSourceFile()) { stream.writeAttribute(QLatin1String("type"), QLatin1String("source")); } stream.writeStartElement(QLatin1String("fileParams")); if (!imageId.m_fileName.isNull()) { stream.writeAttribute(QLatin1String("fileName"), imageId.m_fileName); } if (!imageId.m_filePath.isNull()) { stream.writeAttribute(QLatin1String("filePath"), imageId.m_filePath); } if (!imageId.m_uniqueHash.isNull()) { stream.writeAttribute(QLatin1String("fileHash"), imageId.m_uniqueHash); } if (imageId.m_fileSize) { stream.writeAttribute(QLatin1String("fileSize"), QString::number(imageId.m_fileSize)); } if (imageId.isOriginalFile() && !imageId.m_creationDate.isNull()) { stream.writeAttribute(QLatin1String("creationDate"), imageId.m_creationDate.toString(Qt::ISODate)); } stream.writeEndElement(); //fileParams stream.writeEndElement(); //file } } } stream.writeEndElement(); //history stream.writeEndDocument(); //qCDebug(DIGIKAM_DIMG_LOG) << xmlHistory; return xmlHistory; } DImageHistory DImageHistory::fromXml(const QString& xml) //DImageHistory { //qCDebug(DIGIKAM_DIMG_LOG) << "Parsing image history XML"; DImageHistory h; if (xml.isEmpty()) { return h; } QXmlStreamReader stream(xml); if (!stream.readNextStartElement()) { return h; } if (stream.name() != QLatin1String("history")) { return h; } QString originalUUID; QDateTime originalCreationDate; while (stream.readNextStartElement()) { if (stream.name() == QLatin1String("file")) { //qCDebug(DIGIKAM_DIMG_LOG) << "Parsing file tag"; HistoryImageId imageId(stream.attributes().value(QLatin1String("uuid")).toString()); if (stream.attributes().value(QLatin1String("type")) == QLatin1String("original")) { imageId.m_type = HistoryImageId::Original; } else if (stream.attributes().value(QLatin1String("type")) == QLatin1String("source")) { imageId.m_type = HistoryImageId::Source; } else { imageId.m_type = HistoryImageId::Intermediate; } while (stream.readNextStartElement()) { if (stream.name() == QLatin1String("fileParams")) { imageId.setFileName(stream.attributes().value(QLatin1String("fileName")).toString()); imageId.setPath(stream.attributes().value(QLatin1String("filePath")).toString()); QString date = stream.attributes().value(QLatin1String("creationDate")).toString(); if (!date.isNull()) { imageId.setCreationDate(QDateTime::fromString(date, Qt::ISODate)); } QString size = stream.attributes().value(QLatin1String("fileSize")).toString(); if (stream.attributes().hasAttribute(QLatin1String("fileHash")) && !size.isNull()) { imageId.setUniqueHash(stream.attributes().value(QLatin1String("fileHash")).toString(), size.toInt()); } stream.skipCurrentElement(); } else { stream.skipCurrentElement(); } } if (imageId.isOriginalFile()) { - originalUUID = imageId.m_uuid; + originalUUID = imageId.m_uuid; originalCreationDate = imageId.m_creationDate; } else { imageId.m_originalUUID = originalUUID; if (imageId.m_creationDate.isNull()) { imageId.m_creationDate = originalCreationDate; } } if (imageId.isValid()) { h << imageId; } } else if (stream.name() == QLatin1String("filter")) { //qCDebug(DIGIKAM_DIMG_LOG) << "Parsing filter tag"; FilterAction::Category c = FilterAction::ComplexFilter; QStringRef categoryString = stream.attributes().value(QLatin1String("filterCategory")); - if (categoryString == QLatin1String("reproducible")) + if (categoryString == QLatin1String("reproducible")) { c = FilterAction::ReproducibleFilter; } else if (categoryString == QLatin1String("complex")) { c = FilterAction::ComplexFilter; } else if (categoryString == QLatin1String("documentedHistory")) { c = FilterAction::DocumentedHistory; } FilterAction action(stream.attributes().value(QLatin1String("filterName")).toString(), stream.attributes().value(QLatin1String("filterVersion")).toString().toInt(), c); action.setDisplayableName(stream.attributes().value(QLatin1String("filterDisplayName")).toString()); if (stream.attributes().value(QLatin1String("branch")) == QLatin1String("true")) { action.addFlag(FilterAction::ExplicitBranch); } while (stream.readNextStartElement()) { if (stream.name() == QLatin1String("params")) { while (stream.readNextStartElement()) { if (stream.name() == QLatin1String("param") && stream.attributes().hasAttribute(QLatin1String("name"))) { action.addParameter(stream.attributes().value(QLatin1String("name")).toString(), stream.attributes().value(QLatin1String("value")).toString()); stream.skipCurrentElement(); } else { stream.skipCurrentElement(); } } } else { stream.skipCurrentElement(); } } h << action; } else { stream.skipCurrentElement(); } } if (stream.hasError()) { //TODO: error handling qCDebug(DIGIKAM_DIMG_LOG) << "An error occurred during parsing: " << stream.errorString(); } //qCDebug(DIGIKAM_DIMG_LOG) << "Parsing done"; return h; } } // namespace digikam diff --git a/core/libs/dimg/history/dimagehistory.h b/core/libs/dimg/history/dimagehistory.h index d550dadb01..c5ddd7ea1a 100644 --- a/core/libs/dimg/history/dimagehistory.h +++ b/core/libs/dimg/history/dimagehistory.h @@ -1,220 +1,226 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2010-06-02 * Description : class for manipulating modifications changeset for non-destruct. editing * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #ifndef DIGIKAM_DIMAGE_HISTORY_H #define DIGIKAM_DIMAGE_HISTORY_H // Qt includes #include #include #include #include #include #include #include #include // Local includes #include "digikam_export.h" #include "filteraction.h" #include "historyimageid.h" namespace Digikam { class DIGIKAM_EXPORT DImageHistory { public: class Entry { public: /** * A DImageHistory is a list of entries. * * Each entry has one action. The action can be null, * but it shall be null only if it is the action of the first * entry, with the "Original" as referred image, * representing the action of digitization. * * There can be zero, one or any number * of referred images per entry. * A referred image is a file in the state after the action is applied. */ FilterAction action; QList referredImages; }; public: DImageHistory(); DImageHistory(const DImageHistory& other); ~DImageHistory(); DImageHistory& operator=(const DImageHistory& other); /** * A history is null if it is constructed with the default constructor */ - bool isNull() const; + bool isNull() const; /** * A history is considered empty if there are no entries. */ - bool isEmpty() const; + bool isEmpty() const; /** * A history is a valid history (telling something about the past), * if the history is not empty, and there is at least one * referred image other than the "Current" entry, * or there is a valid action. */ - bool isValid() const; + bool isValid() const; /// Returns the number of entries - int size() const; + int size() const; - bool operator==(const DImageHistory& other) const; - bool operator!=(const DImageHistory& other) const { return !operator==(other); } - bool operator<(const DImageHistory& other) const; - bool operator>(const DImageHistory& other) const; + bool operator==(const DImageHistory& other) const; + bool operator!=(const DImageHistory& other) const + { + return !operator==(other); + } + bool operator<(const DImageHistory& other) const; + bool operator>(const DImageHistory& other) const; /** * Appends a new filter action to the history. */ DImageHistory& operator<<(const FilterAction& action); /** * Appends a new referred image, representing the current state * of the history. * If you add an id of type Current, adjustReferredImages() will be called. */ DImageHistory& operator<<(const HistoryImageId& imageId); void appendReferredImage(const HistoryImageId& id); void insertReferredImage(int entryIndex, const HistoryImageId& id); /// Removes the last entry from the history void removeLast(); /** * Access entries. * There are size() entries. */ QList& entries(); - const QList& entries() const; + const QList& entries() const; Entry& operator[](int i); - const Entry& operator[](int i) const; + const Entry& operator[](int i) const; /** * Access actions. * * There is one action per entry, * but the action may be null. */ /// Returns if there is any non-null action - bool hasActions() const; - bool hasFilters() const { return hasActions(); } + bool hasActions() const; + bool hasFilters() const + { + return hasActions(); + } /// Returns the number of non-null actions - int actionCount() const; + int actionCount() const; /// Gets all actions which are not null - QList allActions() const; - const FilterAction& action(int i) const; + QList allActions() const; + const FilterAction& action(int i) const; /** * Access referred images */ QList& referredImages(int i); - const QList& referredImages(int i) const; - QList allReferredImages() const; - HistoryImageId currentReferredImage() const; - HistoryImageId originalReferredImage() const; - QList referredImagesOfType(HistoryImageId::Type type) const; - bool hasReferredImages() const; - bool hasReferredImageOfType(HistoryImageId::Type type) const; - bool hasCurrentReferredImage() const; - bool hasOriginalReferredImage() const; + const QList& referredImages(int i) const; + QList allReferredImages() const; + HistoryImageId currentReferredImage() const; + HistoryImageId originalReferredImage() const; + QList referredImagesOfType(HistoryImageId::Type type) const; + bool hasReferredImages() const; + bool hasReferredImageOfType(HistoryImageId::Type type) const; + bool hasCurrentReferredImage() const; + bool hasOriginalReferredImage() const; /** * Edit referred images */ /// Remove all referredImages, leaving the entries list untouched void clearReferredImages(); /** * Adjusts the type of a Current HistoryImageId: * If it is the first entry, it becomes Original, * if it is in an intermediate entry, it becomes Intermediate, * if in the last entry, it stays current. */ void adjustReferredImages(); /// Changes the UUID of the current (last added current) referred image void adjustCurrentUuid(const QString& uuid); /** * Remove file path entries pointing to the given absolute path * from any referred images. This is useful when said file * is about to be overwritten. * All other HistoryImageId fields remain unchanged, no HistoryImageId is removed. * path: directory path, without filename. */ void purgePathFromReferredImages(const QString& path, const QString& fileName); /** * Change file path entries of the current referred image */ void moveCurrentReferredImage(const QString& newPath, const QString& newFileName); /** - * Serialize to and from XML. + * Serialize toand from XML. * * Note: The "Current" entry is skipped when writing to XML, * so make sure the file into the metadata of which you write the XML, * is the file marked as "Current" in this history. */ - QString toXml() const; + QString toXml() const; static DImageHistory fromXml(const QString& xml); public: // Set as public there because of PrivateSharedNull class Private; private: QSharedDataPointer d; }; } // namespace Digikam Q_DECLARE_METATYPE(Digikam::DImageHistory) #endif // DIGIKAM_DIMAGE_HISTORY_H diff --git a/core/libs/dimg/history/filteraction.cpp b/core/libs/dimg/history/filteraction.cpp index 6650d1e74c..8ae02d82c9 100644 --- a/core/libs/dimg/history/filteraction.cpp +++ b/core/libs/dimg/history/filteraction.cpp @@ -1,173 +1,175 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2010-06-02 * Description : class that holds list of applied filters to image * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #include "filteraction.h" namespace Digikam { FilterAction::FilterAction() : m_category(ReproducibleFilter), m_version(0) { } FilterAction::FilterAction(const QString& identifier, int version, FilterAction::Category category) : m_category(category), m_identifier(identifier), m_version(version) { } bool FilterAction::isNull() const { return m_identifier.isEmpty(); } bool FilterAction::operator==(const FilterAction& other) const { - return m_identifier == other.m_identifier && - m_version == other.m_version && - m_category == other.m_category && - m_description == other.m_description && - m_displayableName == other.m_displayableName && - m_params == other.m_params; + return ( + (m_identifier == other.m_identifier) && + (m_version == other.m_version) && + (m_category == other.m_category) && + (m_description == other.m_description) && + (m_displayableName == other.m_displayableName) && + (m_params == other.m_params) + ); } FilterAction::Category FilterAction::category() const { return m_category; } QString FilterAction::identifier() const { return m_identifier; } int FilterAction::version() const { return m_version; } QString FilterAction::description() const { return m_description; } void FilterAction::setDescription(const QString& description) { m_description = description; } QString FilterAction::displayableName() const { return m_displayableName; } void FilterAction::setDisplayableName(const QString& displayableName) { m_displayableName = displayableName; } FilterAction::Flags FilterAction::flags() const { return m_flags; } void FilterAction::setFlags(Flags flags) { m_flags = flags; } void FilterAction::addFlag(Flags flags) { m_flags |= flags; } void FilterAction::removeFlag(Flags flags) { m_flags &= ~flags; } bool FilterAction::hasParameters() const { return !m_params.isEmpty(); } const QHash &FilterAction::parameters() const { return m_params; } QHash &FilterAction::parameters() { return m_params; } bool FilterAction::hasParameter(const QString& key) const { return m_params.contains(key); } const QVariant FilterAction::parameter(const QString& key) const { return m_params.value(key); } QVariant& FilterAction::parameter(const QString& key) { return m_params[key]; } void FilterAction::setParameter(const QString& key, const QVariant& value) { m_params.insert(key, value); } void FilterAction::addParameter(const QString& key, const QVariant& value) { m_params.insertMulti(key, value); } void FilterAction::addParameters(const QHash& params) { m_params = m_params.unite(params); } void FilterAction::setParameters(const QHash& params) { m_params = params; } void FilterAction::removeParameters(const QString& key) { m_params.remove(key); } void FilterAction::clearParameters() { m_params.clear(); } } // namespace Digikam diff --git a/core/libs/dimg/history/filteraction.h b/core/libs/dimg/history/filteraction.h index 81fef272c5..2a55809af3 100644 --- a/core/libs/dimg/history/filteraction.h +++ b/core/libs/dimg/history/filteraction.h @@ -1,186 +1,195 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2010-06-02 * Description : class that holds list of applied filters to image * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #ifndef DIGIKAM_FILTER_ACTION_H #define DIGIKAM_FILTER_ACTION_H // Qt includes #include #include #include #include // Local includes #include "digikam_export.h" namespace Digikam { class DIGIKAM_EXPORT FilterAction { public: enum Category { - // Do not change existing values, they are written to XML in files! - /** When given the set of stored parameters and the original data, - * an identical result will be produced. */ + /** + * NOTE: Do not change existing values, they are written to XML in files! + */ + + /** + * When given the set of stored parameters and the original data, + * an identical result will be produced. + */ ReproducibleFilter = 0, /** - * The operation is documented and a number of parameters may be known, - * but the identical result cannot be reproduced. - * It may be possible to produce a sufficiently similar result. + * The operation is documented and a number of parameters may be known, + * but the identical result cannot be reproduced. + * It may be possible to produce a sufficiently similar result. */ ComplexFilter = 1, - /** The source images are known, a textual description may be added, - * but there is no way to automatically replay + /** + * The source images are known, a textual description may be added, + * but there is no way to automatically replay */ DocumentedHistory = 2, CategoryFirst = ReproducibleFilter, CategoryLast = DocumentedHistory }; enum Flag { - /** The editing step of this filter action explicitly branches from the parent. - * This is an optional hint that the result is meant as a new version. + /** + * The editing step of this filter action explicitly branches from the parent. + * This is an optional hint that the result is meant as a new version. */ ExplicitBranch = 1 << 0 }; Q_DECLARE_FLAGS(Flags, Flag) public: FilterAction(); FilterAction(const QString& identifier, int version, Category category = ReproducibleFilter); - bool isNull() const; + bool isNull() const; - bool operator==(const FilterAction& other) const; + bool operator==(const FilterAction& other) const; - Category category() const; + Category category() const; /** * Returns a technical identifier for the filter used to produce this action. * Can include a namespace. Example: digikam:charcoal */ - QString identifier() const; + QString identifier() const; /** * Returns the version (>= 1) of the filter used to produce this action. * When a filter / tool is found by the identifier, it can decide * by the version if it supports this action and which parameters it expects. */ - int version() const; + int version() const; /** * Returns a description / comment for this action. * In the case of DocumentedHistory, this may be the most useful value. */ - QString description() const; + QString description() const; void setDescription(const QString& description); - QString displayableName() const; + QString displayableName() const; void setDisplayableName(const QString& displayableName); - Flags flags() const; + Flags flags() const; void setFlags(Flags flags); void addFlag(Flags flags); void removeFlag(Flags flags); /** * Access parameters. * A parameters is a key -> value pair. * Keys need not be unique, but you can decide to use unique keys. * There are accessors for both contexts. */ - bool hasParameters() const; - const QHash& parameters() const; + bool hasParameters() const; + const QHash& parameters() const; QHash& parameters(); bool hasParameter(const QString& key) const; const QVariant parameter(const QString& key) const; QVariant& parameter(const QString& key); - /// Returns parameter converted from QVariant to given type + /** + * Returns parameter converted from QVariant to given type + */ template - T parameter(const QString& key) const + T parameter(const QString& key) const { return parameter(key).value(); } /** * Read parameter with a default value: * If there is a parameter for the given key, return it converted * from QVariant to the template type. * If there is no parameter, return the given default value. */ template - T parameter(const QString& key, const T& defaultValue) const + T parameter(const QString& key, const T& defaultValue) const { QVariant var = parameter(key); return (var.isValid()) ? var.value() : defaultValue; } /// Sets parameter, removing all other values for the same key void setParameter(const QString& key, const QVariant& value); /// Adds a parameter, possibly keeping existing parameters with the same key. void addParameter(const QString& key, const QVariant& value); /// Removes all parameters for key void removeParameters(const QString& key); /// Clear all parameters void clearParameters(); /// Adds a set of parameters void addParameters(const QHash& params); /// Replaces parameters void setParameters(const QHash& params); protected: // Note: Value class, do not create a d-pointer Category m_category; Flags m_flags; QString m_identifier; int m_version; QString m_description; QString m_displayableName; QHash m_params; }; } // namespace Digikam Q_DECLARE_METATYPE(Digikam::FilterAction) Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::FilterAction::Flags) #endif // DIGIKAM_FILTER_ACTION_H diff --git a/core/libs/dimg/history/historyimageid.cpp b/core/libs/dimg/history/historyimageid.cpp index 55cc0ea699..742e9ba59a 100644 --- a/core/libs/dimg/history/historyimageid.cpp +++ b/core/libs/dimg/history/historyimageid.cpp @@ -1,178 +1,182 @@ /* ============================================================ * * 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 * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #include "historyimageid.h" // Qt includes #include #include namespace Digikam { HistoryImageId::HistoryImageId() : m_type(InvalidType), m_fileSize(0) { } HistoryImageId::HistoryImageId(const QString& uuid, Type type) : m_type(type), m_uuid(uuid), m_fileSize(0) { } void HistoryImageId::setType(HistoryImageId::Type type) { m_type = type; } void HistoryImageId::setUuid(const QString& uuid) { m_uuid = uuid; } void HistoryImageId::setFileName(const QString& fileName) { m_fileName = fileName; } void HistoryImageId::setCreationDate(const QDateTime& creationDate) { m_creationDate = creationDate; } void HistoryImageId::setPathOnDisk(const QString& filePath) { - QUrl url = QUrl::fromLocalFile(filePath); + QUrl url = QUrl::fromLocalFile(filePath); m_filePath = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile() + QLatin1Char('/'); } void HistoryImageId::setPath(const QString& path) { m_filePath = path; if (!m_filePath.endsWith(QLatin1Char('/'))) { m_filePath += QLatin1Char('/'); } } void HistoryImageId::setUniqueHash(const QString& uniqueHash, qlonglong fileSize) { m_uniqueHash = uniqueHash; m_fileSize = fileSize; } bool HistoryImageId::isValid() const { - return (m_type != InvalidType) - && (!m_uuid.isEmpty() || !m_fileName.isEmpty()); + 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; + return (m_filePath + m_fileName); } bool HistoryImageId::hasFileOnDisk() const { - return !m_filePath.isEmpty() && !m_fileName.isEmpty(); + 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; + 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; + 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 diff --git a/core/libs/dimg/history/historyimageid.h b/core/libs/dimg/history/historyimageid.h index b47f73ba9b..ed77bb2622 100644 --- a/core/libs/dimg/history/historyimageid.h +++ b/core/libs/dimg/history/historyimageid.h @@ -1,182 +1,187 @@ /* ============================================================ * * 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 * * Copyright (C) 2010 by Marcel Wiesweg * Copyright (C) 2010 by Martin Klapetek * * 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 2, 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. * * ============================================================ */ #ifndef DIGIKAM_HISTORY_IMAGE_ID_H #define DIGIKAM_HISTORY_IMAGE_ID_H // Qt includes #include #include #include // Local includes #include "digikam_export.h" namespace Digikam { class DIGIKAM_EXPORT HistoryImageId { public: enum Type { InvalidType = 0, /** * The original file (typically created by a camera) */ Original = 1 << 0, /** * A file created during the editing the history, * between the original file and the current file. */ Intermediate = 1 << 1, /** * When a file is created from multiple files, there can be no direct * original (panorama) but multiple sources, or one direct original * and some other, additional source files. * To record source files outside of the direct history, this type is used. */ Source = 1 << 2, /** * The "current" file. This is a special entry: It refers to the file from * which this history was read. It need not be written to the file, * because it describes the file itself. There is typically * exactly one current entry if the history is associated with an image; * there can be no current entry. */ Current = 1 << 3 }; /** * Note: In this class, the Type is used as a simple enum, * but it is also prepared for usage as flags. */ Q_DECLARE_FLAGS(Types, Type) public: /// Creates an invalid HistoryImageId HistoryImageId(); /// Creates an id with the given UUID and type explicit HistoryImageId(const QString& uuid, Type type = Current); /// A valid id needs at least a valid type and a UUID or a filename - bool isValid() const; + bool isValid() const; - Type type() const; + Type type() const; - bool isOriginalFile() const + bool isOriginalFile() const { - return type() == Original; + return (type() == Original); } - bool isSourceFile() const + bool isSourceFile() const { - return type() == Source; + return (type() == Source); } - bool isIntermediateFile() const + bool isIntermediateFile() const { - return type() == Intermediate; + return (type() == Intermediate); } - bool isCurrentFile() const + bool isCurrentFile() const { - return type() == Current; + return (type() == Current); } - bool operator==(const HistoryImageId& other) const; + bool operator==(const HistoryImageId& other) const; void setType(HistoryImageId::Type type); void setUuid(const QString& uuid); void setFileName(const QString& fileName); void setCreationDate(const QDateTime& creationDate); void setPathOnDisk(const QString& filePath); void setPath(const QString& path); void setUniqueHash(const QString& uniqueHash, qlonglong fileSize); - bool hasFileOnDisk() const; + bool hasFileOnDisk() const; - ///If a file on disk is referenced: Returns the path, without filename, with a trailing slash - QString path() const; + /// If a file on disk is referenced: Returns the path, without filename, with a trailing slash + QString path() const; /// If a file on disk is referenced: Returns the full file path (folder + filename) - QString filePath() const; + QString filePath() const; - bool hasFileName() const; + bool hasFileName() const; /// If a file on disk is referenced: Returns the file name (without folder) - QString fileName() const; + QString fileName() const; - bool hasUuid() const; - QString uuid() const; - bool hasCreationDate() const; - QDateTime creationDate() const; - bool hasUniqueHashIdentifier() const; - QString uniqueHash() const; - qlonglong fileSize() const; - QString originalUuid() const; + bool hasUuid() const; + QString uuid() const; + bool hasCreationDate() const; + QDateTime creationDate() const; + bool hasUniqueHashIdentifier() const; + QString uniqueHash() const; + qlonglong fileSize() const; + QString originalUuid() const; public: /// Type of this History Image Id Type m_type; /** * A unique identifier for the referred file. This id shall be changed each time * the image is edited. */ QString m_uuid; /// The filename of the referred file QString m_fileName; + /// The creationDate of the original image QDateTime m_creationDate; + /// The path of the referred file (NOTE: without file name!, including trailing slash) QString m_filePath; + /// The uniqueHash of the referred file QString m_uniqueHash; + /// The file size of the referred file qlonglong m_fileSize; + /** * A unique identifier designating the _original image_ from which the referred * image was created. Typically, this is a RAW or JPEG created by the camera in * the moment of taking the photograph. */ QString m_originalUUID; }; } // namespace Digikam Q_DECLARE_METATYPE(Digikam::HistoryImageId) Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::HistoryImageId::Types) #endif // DIGIKAM_HISTORY_IMAGE_ID_H diff --git a/project/bundles/mxe/config.sh b/project/bundles/mxe/config.sh index 4662cd3f5e..7b7a7087c3 100644 --- a/project/bundles/mxe/config.sh +++ b/project/bundles/mxe/config.sh @@ -1,77 +1,77 @@ #!/bin/bash # Copyright (c) 2013-2020 by Gilles Caulier # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. ######################################################################## # Absolute path where are downloaded all tarballs to compile. DOWNLOAD_DIR="`pwd`/temp.dwnld" # Absolute path where are compiled all tarballs BUILDING_DIR="`pwd`/temp.build" #------------------------------------------------------------------------------------------- # MXE configuration #------------ # IMPORTANT: Target Windows architecture to build installer. Possible values: 32 or 64 bits. -MXE_ARCHBITS=64 +MXE_ARCHBITS=32 #------------ if [[ $MXE_ARCHBITS == 32 ]]; then # Windows 32 bits shared MXE_BUILD_TARGETS="i686-w64-mingw32.shared" MXE_BUILDROOT="`pwd`/build.win32" elif [[ $MXE_ARCHBITS == 64 ]]; then # Windows 64 bits shared MXE_BUILD_TARGETS="x86_64-w64-mingw32.shared" MXE_BUILDROOT="`pwd`/build.win64" else echo "Unsupported or wrong target Windows architecture: $MXE_ARCHBITS bits." exit -1 fi echo "Target Windows architecture: $MXE_ARCHBITS bits." MXE_GIT_URL="https://github.com/mxe/mxe.git" MXE_GIT_REVISION=master MXE_INSTALL_PREFIX=${MXE_BUILDROOT}/usr/${MXE_BUILD_TARGETS}/ MXE_TOOLCHAIN=${MXE_INSTALL_PREFIX}/share/cmake/mxe-conf.cmake #------------------------------------------------------------------------------------------- # URL to git repository to checkout digiKam source code DK_GITURL="git@invent.kde.org:kde/digikam.git" # digiKam tarball information. DK_URL="http://download.kde.org/stable/digikam" # Location to build source code. DK_BUILDTEMP=~/dktemp # digiKam tag version from git. Official tarball do not include extra shared libraries. # The list of tags can be listed with this url: https://quickgit.kde.org/?p=digikam.git&a=tags # If you want to package current implemntation from git, use "master" as tag. #DK_VERSION=v6.4.0 DK_VERSION=master #DK_VERSION=development/dplugins # Installer sub version to differentiates newer updates of the installer itself, even if the underlying application hasn’t changed. #DK_EPOCH="-01" # Epoch with time-stamp for pre-release bundle in ISO format DK_EPOCH="-`date "+%Y%m%dT%H%M%S"`" # Installer will include or not digiKam debug symbols DK_DEBUG=1 # Sign bundles with GPG. Passphrase must be hosted in ~/.gnupg/dkorg-gpg-pwd.txt DK_SIGN=0 # Upload automatically bundle to files.kde.org (pre-release only). DK_UPLOAD=1 DK_UPLOADURL="digikam@milonia.kde.org" DK_UPLOADDIR="/srv/archives/files/digikam/"