File indexing completed on 2025-03-09 03:58:50
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-11-24 0007 * Description : Batch Tool utils. 0008 * 0009 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "batchtoolutils.h" 0016 0017 // Qt includes 0018 0019 #include <QFileInfo> 0020 0021 // Local includes 0022 0023 #include "batchtoolsfactory.h" 0024 0025 namespace Digikam 0026 { 0027 0028 BatchToolSet::BatchToolSet() 0029 : index (-1), 0030 version(0), 0031 group (BatchTool::BaseTool) 0032 { 0033 } 0034 0035 bool BatchToolSet::operator==(const BatchToolSet& set) const 0036 { 0037 return ( 0038 (index == set.index) && 0039 (version == set.version) && 0040 (name == set.name ) && 0041 (group == set.group) 0042 ); 0043 } 0044 0045 QDebug operator<<(QDebug dbg, const BatchToolSet& s) 0046 { 0047 dbg.nospace() << "BatchToolSet::"; 0048 dbg.nospace() << "index: " << s.index << ", "; 0049 dbg.nospace() << "version: " << s.version << ", "; 0050 dbg.nospace() << "name: " << s.name << ", "; 0051 dbg.nospace() << "group: " << s.group << ", "; 0052 dbg.nospace() << "settings: " << s.settings; 0053 0054 return dbg.space(); 0055 } 0056 0057 // --------------------------------------------------------------------------------------------- 0058 0059 QString AssignedBatchTools::targetSuffix(bool* const extSet) const 0060 { 0061 QString suffix; 0062 0063 Q_FOREACH (const BatchToolSet& set, m_toolsList) 0064 { 0065 BatchTool* const tool = BatchToolsFactory::instance()->findTool(set.name, set.group); 0066 0067 if (tool) 0068 { 0069 QString s = tool->outputSuffix(); 0070 0071 if (!s.isEmpty()) 0072 { 0073 suffix = s; 0074 0075 if (extSet != nullptr) 0076 { 0077 *extSet = true; 0078 } 0079 } 0080 } 0081 } 0082 0083 if (suffix.isEmpty()) 0084 { 0085 if (extSet != nullptr) 0086 { 0087 *extSet = false; 0088 } 0089 0090 return (QFileInfo(m_itemUrl.fileName()).suffix()); 0091 } 0092 0093 return suffix; 0094 } 0095 0096 } // namespace Digikam