digiKam
metadatawidget.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 : 2006-02-22
7  * Description : a generic widget to display metadata
8  *
9  * Copyright (C) 2006-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_META_DATA_WIDGET_H
25 #define DIGIKAM_META_DATA_WIDGET_H
26 
27 // Qt includes
28 
29 #include <QWidget>
30 #include <QString>
31 #include <QUrl>
32 
33 // Local includes
34 
35 #include "dmetadata.h"
36 #include "digikam_export.h"
37 
38 namespace Digikam
39 {
40 
41 class MetadataListView;
42 
43 class DIGIKAM_EXPORT MetadataWidget : public QWidget
44 {
45  Q_OBJECT
46 
47 public:
48 
50  {
51  NONE = 0,
53  CUSTOM
54  };
55 
56 public:
57 
58  explicit MetadataWidget(QWidget* const parent, const QString& name = QString());
59  ~MetadataWidget() override;
60 
61  int getMode() const;
62  void setMode(int mode);
63 
64  QStringList getTagsFilter() const;
65  void setTagsFilter(const QStringList& list);
66 
67  QString getCurrentItemKey() const;
68  void setCurrentItemByKey(const QString& itemKey);
69 
70  void setUserAreaWidget(QWidget* const w);
71 
72 public:
73 
74  virtual QString getTagTitle(const QString& key);
75  virtual QString getTagDescription(const QString& key);
76 
77  virtual bool loadFromData(const QString& fileName,
78  const DMetadata& data = DMetadata());
79 
80  virtual bool loadFromURL(const QUrl& url) = 0;
81 
82 Q_SIGNALS:
83 
85 
86 protected Q_SLOTS:
87 
88  virtual void slotSaveMetadataToFile() = 0;
89 
90 protected:
91 
92  void enabledToolButtons(bool);
93  void setFileName(const QString& fileName);
94  MetadataListView* view() const;
95 
96  bool setMetadata(const DMetadata& data = DMetadata());
97  DMetadata* getMetadata() const;
98 
99  void setMetadataMap(const DMetadata::MetaDataMap& data = DMetadata::MetaDataMap());
100  const DMetadata::MetaDataMap& getMetadataMap();
101 
102  void setIfdList(const DMetadata::MetaDataMap& ifds, const QStringList& tagsFilter = QStringList());
103  void setIfdList(const DMetadata::MetaDataMap& ifds, const QStringList& keysFilter,
104  const QStringList& tagsFilter);
105 
106  QUrl saveMetadataToFile(const QString& caption, const QString& fileFilter);
107  bool storeMetadataToFile(const QUrl& url, const QByteArray& metaData);
108 
112  void setup();
113 
114  QString metadataToText() const;
115 
116 protected:
117 
118  virtual void buildView();
119  virtual void setMetadataEmpty();
120 
121  virtual bool decodeMetadata() = 0;
122  virtual QString getMetadataTitle() const = 0;
123 
124 private Q_SLOTS:
125 
126  void slotCopy2Clipboard();
127  void slotPrintMetadata();
128  void slotFilterChanged(QAction*);
129 
130 private:
131 
132  class Private;
133  Private* const d;
134 };
135 
136 } // namespace Digikam
137 
138 #endif // DIGIKAM_META_DATA_WIDGET_H
Definition: dmetadata.h:55
QMap< QString, QString > MetaDataMap
Definition: metaengine.h:136
Definition: metadatalistview.h:47
Definition: metadatawidget.h:44
virtual void slotSaveMetadataToFile()=0
virtual QString getMetadataTitle() const =0
TagFilters
Definition: metadatawidget.h:50
@ PHOTO
Definition: metadatawidget.h:52
virtual bool decodeMetadata()=0
virtual bool loadFromURL(const QUrl &url)=0
@ NONE
Definition: dngconverteractions.h:44
Definition: datefolderview.cpp:43