digiKam
exiftoolparser.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2020-11-28
7  * Description : ExifTool process stream parser.
8  *
9  * Copyright (C) 2020-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_EXIFTOOL_PARSER_H
25 #define DIGIKAM_EXIFTOOL_PARSER_H
26 
27 // Qt Core
28 
29 #include <QFileInfo>
30 #include <QVariant>
31 #include <QHash>
32 #include <QObject>
33 #include <QString>
34 #include <QByteArray>
35 #include <QProcess>
36 
37 // Local includes
38 
39 #include "digikam_export.h"
40 #include "exiftoolprocess.h"
41 #include "metaengine.h"
42 
43 namespace Digikam
44 {
45 
46 class DIGIKAM_EXPORT ExifToolParser : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51 
97  typedef QHash<QString, QVariantList> ExifToolData;
98 
99 public:
100 
101  //---------------------------------------------------------------------------------------------
103 
104 
105  explicit ExifToolParser(QObject* const parent);
106  ~ExifToolParser();
107 
108  void setExifToolProgram(const QString& path);
109 
110  QString currentPath() const;
111  ExifToolData currentData() const;
112  QString currentErrorString() const;
113 
117  bool exifToolAvailable() const;
118 
120 
121 public:
122 
123  //---------------------------------------------------------------------------------------------
125 
126 
131  bool load(const QString& path, bool async = false);
132 
137  bool loadChunk(const QString& path);
138 
146  bool applyChanges(const QString& path, const ExifToolData& newTags);
147 
154  bool applyChanges(const QString& path, const QString& exvTempFile);
155 
160  bool readableFormats();
161 
166  bool writableFormats();
167 
172  bool translationsList();
173 
179  bool tagsDatabase();
180 
185  bool version();
186 
194  bool copyTags(const QString& src,
195  const QString& dst,
196  unsigned char copyOps,
197  unsigned char writeModes = ExifToolProcess::ALL_MODES);
198 
203  bool translateTags(const QString& path, unsigned char transOps);
204 
206 
207 Q_SIGNALS:
208 
210 
211 private Q_SLOTS:
212 
213  //---------------------------------------------------------------------------------------------
215 
216 
217  void slotCmdCompleted(int cmdAction,
218  int execTime,
219  const QByteArray& cmdOutputChannel,
220  const QByteArray& cmdErrorChannel);
221 
222  void slotErrorOccurred(int cmdAction, QProcess::ProcessError error);
223 
224  void slotFinished(int cmdAction, int exitCode, QProcess::ExitStatus exitStatus);
225 
226 public:
227 
231  void setOutputStream(int cmdAction,
232  const QByteArray& cmdOutputChannel,
233  const QByteArray& cmdErrorChannel);
234 
238  static MetaEngine::TagsMap tagsDbToOrderedMap(const ExifToolData& tagsDb);
239 
240 private:
241 
242  void printExifToolOutput(const QByteArray& stdOut);
243 
245 
246 private Q_SLOTS:
247 
248  void slotMetaEngineSettingsChanged();
249 
250 private:
251 
252  class Private;
253  Private* const d;
254 };
255 
256 } // namespace Digikam
257 
258 #endif // DIGIKAM_EXIFTOOL_PARSER_H
Definition: exiftoolparser_p.h:58
Definition: exiftoolparser.h:47
QHash< QString, QVariantList > ExifToolData
Definition: exiftoolparser.h:97
@ ALL_MODES
Definition: exiftoolprocess.h:91
QMap< QString, QStringList > TagsMap
Definition: metaengine.h:151
Definition: datefolderview.cpp:43