1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2006-04-19
7  * Description : A tab to display general item information
8  *
9  * Copyright (C) 2006-2021 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_ITEM_PROPERTIES_TAB_H
25 #define DIGIKAM_ITEM_PROPERTIES_TAB_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QColor>
31 #include <QUrl>
32 #include <QFileInfo>
33 
34 // Local includes
35 
36 #include "dexpanderbox.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT ItemPropertiesTab : public DExpanderBox
43 {
44     Q_OBJECT
45 
46 public:
47 
48     explicit ItemPropertiesTab(QWidget* const parent);
49     ~ItemPropertiesTab() override;
50 
51     void setCurrentURL(const QUrl& url = QUrl());
52 
53     void setPhotoInfoDisable(const bool b);
54     void setVideoInfoDisable(const bool b);
55     void showOrHideCaptionAndTags();
56 
57     void setFileModifiedDate(const QString& str);
58     void setFileSize(const QString& str);
59     void setFileOwner(const QString& str);
60     void setFilePermissions(const QString& str);
61 
62     void setItemDimensions(const QString& str);
63     void setImageRatio(const QString& str);
64     void setImageMime(const QString& str);
65     void setImageBitDepth(const QString& str);
66     void setImageColorMode(const QString& str);
67     void setHasSidecar(const QString& str);
68 
69     void setPhotoMake(const QString& str);
70     void setPhotoModel(const QString& str);
71     void setPhotoDateTime(const QString& str);
72     void setPhotoLens(const QString& str);
73     void setPhotoAperture(const QString& str);
74     void setPhotoFocalLength(const QString& str);
75     void setPhotoExposureTime(const QString& str);
76     void setPhotoSensitivity(const QString& str);
77     void setPhotoExposureMode(const QString& str);
78     void setPhotoFlash(const QString& str);
79     void setPhotoWhiteBalance(const QString& str);
80 
81     void setVideoAspectRatio(const QString& str);
82     void setVideoAudioBitRate(const QString& str);
83     void setVideoAudioChannelType(const QString& str);
84     void setVideoAudioCodec(const QString& str);
85     void setVideoDuration(const QString& str);
86     void setVideoFrameRate(const QString& str);
87     void setVideoVideoCodec(const QString& str);
88 
89     void setCaption(const QString& str);
90     void setPickLabel(int pickId);
91     void setColorLabel(int colorId);
92     void setRating(int rating);
93     void setTags(const QStringList& tagPaths, const QStringList& tagNames = QStringList());
94 
95     /**
96      * Shortens the tag paths by sorting and then cutting identical paths from the second
97      * and following paths (only the first item gives the full path).
98      * If you want to retain information about which tag path is sorted where,
99      * you can optionally give a QVariant list. This list shall contain an identifier
100      * for the tag path at the same index and will be resorted as the returned list.
101      */
102     static QStringList shortenedTagPaths(const QStringList& tagPaths, QList<QVariant>* identifiers = nullptr);
103 
104     /**
105      * This methods shortens make an model camera info to prevent bloating GUI
106      * See bug #265231 for details.
107      */
108     static void shortenedMakeInfo(QString& make);
109     static void shortenedModelInfo(QString& model);
110 
111     /**
112      * Write a string with aspect ratio information formatted
113      */
114     static bool aspectRatioToString(int width, int height, QString& arString);
115 
116     /**
117      * Return file permissions string.
118      */
119     static QString permissionsString(const QFileInfo& fi);
120 
121     /**
122      * Return an human readable string of file size in 'bytes'.
123      * If 'si' is true, a decade of bytes is interpreted on base of 1000 byte, else 1024.
124      */
125     static QString humanReadableBytesCount(qint64 bytes, bool si = false);
126 
127 private:
128 
129     static double doubleToHumanReadableFraction(double val, long* num, long* den, long maxden = 2);
130 
131 private:
132 
133     class Private;
134     Private* const d;
135 };
136 
137 } // namespace Digikam
138 
139 #endif // DIGIKAM_ITEM_PROPERTIES_TAB_H
140