File indexing completed on 2025-01-19 03:53:03

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-03-20
0007  * Description : a tool to export images to iNaturalist web service
0008  *
0009  * SPDX-FileCopyrightText: 2021      by Joerg Lohse <joergmlpts at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_INAT_SUGGEST_H
0016 #define DIGIKAM_INAT_SUGGEST_H
0017 
0018 // Qt includes
0019 
0020 #include <QObject>
0021 #include <QLineEdit>
0022 #include <QEvent>
0023 #include <QTreeWidget>
0024 #include <QTreeWidgetItem>
0025 #include <QTimer>
0026 #include <QList>
0027 #include <QVector>
0028 #include <QHash>
0029 
0030 // Local includes
0031 
0032 #include "inattaxon.h"
0033 #include "inattaxonedit.h"
0034 #include "inatscore.h"
0035 
0036 namespace DigikamGenericINatPlugin
0037 {
0038 
0039 class INatTalker;
0040 
0041 typedef QPair<QString, QList<Taxon> > AutoCompletions;
0042 
0043 class SuggestTaxonCompletion : public QObject
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048 
0049     explicit SuggestTaxonCompletion(TaxonEdit* const parent);
0050     ~SuggestTaxonCompletion();
0051 
0052     void setTalker(INatTalker* const talker);
0053 
0054 Q_SIGNALS:
0055 
0056     void signalTaxonSelected(const Taxon&, bool fromVision);
0057     void signalTaxonDeselected();
0058     void signalComputerVision();
0059 
0060 private Q_SLOTS:
0061 
0062     void slotDoneCompletion();
0063     void slotPreventSuggest();
0064     void slotAutoSuggest();
0065     void slotInFocus();
0066     void slotTaxonAutoCompletions(const AutoCompletions&);
0067     void slotComputerVisionResults(const ImageScores&);
0068     void slotImageLoaded(const QUrl&, const QByteArray&);
0069     void slotTextEdited(const QString&);
0070 
0071 private:
0072 
0073     bool    eventFilter(QObject* obj, QEvent* ev) override;
0074     void    showCompletion(const struct Completions&);
0075     void    taxon2Item(const Taxon&, QTreeWidgetItem*, const QString&);
0076     QString getText() const;
0077 
0078 private:
0079 
0080     class Private;
0081     Private* const d;
0082 };
0083 
0084 } // namespace DigikamGenericINatPlugin
0085 
0086 #endif // DIGIKAM_INAT_SUGGEST_H
0087