File indexing completed on 2024-04-28 04:21:03

0001 // SPDX-FileCopyrightText: 2012-2020 The KPhotoAlbum Development Team
0002 // SPDX-FileCopyrightText: 2022 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 #ifndef EXIF_GRID_H
0007 #define EXIF_GRID_H
0008 
0009 #include <kpabase/FileName.h>
0010 #include <kpabase/StringSet.h>
0011 
0012 #include <QMap>
0013 #include <QScrollArea>
0014 
0015 class QLabel;
0016 
0017 using Utilities::StringSet;
0018 
0019 namespace Exif
0020 {
0021 
0022 class Grid : public QScrollArea
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit Grid(QWidget *parent);
0028     void setFileName(const DB::FileName &fileName);
0029 
0030 public Q_SLOTS:
0031     void updateSearchString(const QString &);
0032     /**
0033      * @brief setupUI sets up the scroll area for the given charset.
0034      * Usually, this slot is only indirectly called through the setFileName function,
0035      * but calling it directly can be used to change the display character set without changing the file name.
0036      * @param charset
0037      */
0038     void setupUI(const QString &charset);
0039 
0040 private:
0041     void keyPressEvent(QKeyEvent *) override;
0042     bool eventFilter(QObject *, QEvent *) override;
0043 
0044     StringSet exifGroups(const QMap<QString, QStringList> &exifInfo);
0045     QMap<QString, QStringList> itemsForGroup(const QString &group, const QMap<QString, QStringList> &exifInfo);
0046     QString groupName(const QString &exifName);
0047     QString exifNameNoGroup(const QString &fullName);
0048     void scroll(int dy);
0049     QLabel *headerLabel(const QString &title);
0050     QPair<QLabel *, QLabel *> infoLabelPair(const QString &title, const QString &value, const QPalette::ColorRole role);
0051 
0052 private Q_SLOTS:
0053     void updateWidgetSize();
0054 
0055 private:
0056     QList<QPair<QLabel *, QLabel *>> m_labels;
0057     DB::FileName m_fileName;
0058 };
0059 
0060 } // namespace Exif
0061 
0062 #endif // EXIF_GRID_H
0063 // vi:expandtab:tabstop=4 shiftwidth=4: