digiKam
dbinaryiface.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 : 2009-12-23
7  * Description : Autodetect binary program and version
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2012-2016 by Benjamin Girault <benjamin dot girault at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) 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_DBINARY_IFACE_H
25 #define DIGIKAM_DBINARY_IFACE_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QStringList>
31 #include <QPushButton>
32 #include <QLabel>
33 #include <QLineEdit>
34 #include <QSet>
35 #include <QGridLayout>
36 #include <QUrl>
37 
38 // Local includes
39 
40 #include "digikam_export.h"
41 
42 namespace Digikam
43 {
44 
45 class DIGIKAM_EXPORT DBinaryIface : public QObject
46 {
47  Q_OBJECT
48 
49 public:
50 
51  DBinaryIface(const QString& binaryName,
52  const QString& projectName,
53  const QString& url,
54  const QString& pluginName,
55  const QStringList& args = QStringList(),
56  const QString& desc = QString()
57  );
58  DBinaryIface(const QString& binaryName,
59  const QString& minimalVersion,
60  const QString& header,
61  const int headerLine,
62  const QString& projectName,
63  const QString& url,
64  const QString& pluginName,
65  const QStringList& args = QStringList(),
66  const QString& desc = QString()
67  );
68  ~DBinaryIface() override;
69 
70 public:
71 
72  bool isFound() const { return m_isFound; }
73  const QString& version() const;
74  bool versionIsRight() const;
75  bool versionIsRight(const float) const;
76  inline bool isValid() const { return (m_isFound && versionIsRight()); }
77  inline bool developmentVersion() const { return m_developmentVersion; }
78  const QString& description() const { return m_description; }
79 
80  virtual void setup(const QString& prev = QString());
81  virtual bool checkDir() { return checkDirForPath(m_pathDir); }
82  virtual bool checkDirForPath(const QString& path);
83  virtual bool recheckDirectories();
84 
85  virtual QString path(const QString& dir) const;
86  virtual QString path() const { return path(m_pathDir); }
87  virtual QString directory() const { return m_pathDir; }
88  virtual QString baseName() const { return m_binaryBaseName; }
89  virtual QString minimalVersion() const { return m_minimalVersion; }
90 
91 
92  virtual QUrl url() const { return m_url; }
93  virtual QString projectName() const { return m_projectName; }
94 
95  static QString goodBaseName(const QString& b);
96 
97 public Q_SLOTS:
98 
99  virtual void slotNavigateAndCheck();
100  virtual void slotAddPossibleSearchDirectory(const QString& dir);
101  virtual void slotAddSearchDirectory(const QString& dir);
102 
103 Q_SIGNALS:
104 
105  void signalSearchDirectoryAdded(const QString& dir);
107 
108 protected:
109 
110  QString findHeader(const QStringList& output, const QString& header) const;
111  virtual bool parseHeader(const QString& output);
112  void setVersion(QString& version);
113 
114  virtual QString readConfig();
115  virtual void writeConfig();
116 
117 protected:
118 
119  const bool m_checkVersion;
120  const QString m_headerStarts;
121  const int m_headerLine;
122  const QString m_minimalVersion;
123  const QString m_configGroup;
124  const QString m_binaryBaseName;
125  const QStringList m_binaryArguments;
126  const QString m_projectName;
127  const QUrl m_url;
128 
129  bool m_isFound;
131 
132  QString m_version;
133  QString m_pathDir;
134  QString m_description;
135 
136  QFrame* m_pathWidget;
137  QLabel* m_binaryLabel;
138  QLabel* m_versionLabel;
139  QPushButton* m_pathButton;
141  QLineEdit* m_lineEdit;
142  QLabel* m_statusIcon;
143 
144  QSet<QString> m_searchPaths;
145 
146 private:
147 
148  // Disabled
149  explicit DBinaryIface(QObject*);
150 };
151 
152 } // namespace Digikam
153 
154 #endif // DIGIKAM_DBINARY_IFACE_H
Definition: dbinaryiface.h:46
virtual QUrl url() const
Definition: dbinaryiface.h:92
QSet< QString > m_searchPaths
Definition: dbinaryiface.h:144
const bool m_checkVersion
Definition: dbinaryiface.h:119
bool isValid() const
Definition: dbinaryiface.h:76
QLabel * m_versionLabel
Definition: dbinaryiface.h:138
QLabel * m_binaryLabel
Definition: dbinaryiface.h:137
void signalSearchDirectoryAdded(const QString &dir)
virtual QString baseName() const
Definition: dbinaryiface.h:88
const QString & description() const
Definition: dbinaryiface.h:78
virtual bool checkDir()
Definition: dbinaryiface.h:81
virtual QString directory() const
Definition: dbinaryiface.h:87
const QString m_configGroup
Definition: dbinaryiface.h:123
const QString m_projectName
Definition: dbinaryiface.h:126
const QString m_minimalVersion
Definition: dbinaryiface.h:122
QFrame * m_pathWidget
Definition: dbinaryiface.h:136
bool isFound() const
Definition: dbinaryiface.h:72
QLabel * m_downloadButton
Definition: dbinaryiface.h:140
virtual QString projectName() const
Definition: dbinaryiface.h:93
bool m_isFound
Definition: dbinaryiface.h:129
bool developmentVersion() const
Definition: dbinaryiface.h:77
QString m_description
Definition: dbinaryiface.h:134
QLabel * m_statusIcon
Definition: dbinaryiface.h:142
virtual QString path() const
Definition: dbinaryiface.h:86
QPushButton * m_pathButton
Definition: dbinaryiface.h:139
const QString m_binaryBaseName
Definition: dbinaryiface.h:124
const QStringList m_binaryArguments
Definition: dbinaryiface.h:125
const int m_headerLine
Definition: dbinaryiface.h:121
QString m_version
Definition: dbinaryiface.h:132
const QString m_headerStarts
Definition: dbinaryiface.h:120
QLineEdit * m_lineEdit
Definition: dbinaryiface.h:141
const QUrl m_url
Definition: dbinaryiface.h:127
bool m_developmentVersion
Definition: dbinaryiface.h:130
virtual QString minimalVersion() const
Definition: dbinaryiface.h:89
QString m_pathDir
Definition: dbinaryiface.h:133
Definition: datefolderview.cpp:43