File indexing completed on 2024-04-21 16:12:19
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> 0003 0004 #pragma once 0005 0006 #include <QAbstractListModel> 0007 0008 #include "bugzillaintegration/duplicatefinderjob.h" 0009 #include "bugzillaintegration/libbugzilla/models/bug.h" 0010 0011 class BugzillaManager; 0012 class ReportInterface; 0013 0014 class DuplicateModel : public QAbstractListModel 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(bool searching MEMBER m_searching NOTIFY searchingChanged) 0018 Q_PROPERTY(bool atEnd MEMBER m_atEnd NOTIFY atEndChanged) 0019 public: 0020 enum class Role { 0021 Title = Qt::UserRole + 1, 0022 Number, 0023 Object, 0024 }; 0025 Q_ENUM(Role) 0026 0027 using QAbstractListModel::QAbstractListModel; 0028 0029 Q_PROPERTY(BugzillaManager *manager MEMBER m_manager WRITE setManager NOTIFY managerChanged) 0030 BugzillaManager *m_manager = nullptr; 0031 Q_SIGNAL void managerChanged(); 0032 void setManager(BugzillaManager *manager); 0033 0034 Q_PROPERTY(ReportInterface *iface MEMBER m_reportInterface NOTIFY reportInterfaceChanged) 0035 ReportInterface *m_reportInterface = nullptr; 0036 Q_SIGNAL void reportInterfaceChanged(); 0037 0038 Q_SIGNAL void searchingChanged(); 0039 Q_SIGNAL void atEndChanged(); 0040 0041 Q_INVOKABLE void searchBugs(const QStringList &products, const QString &severity, const QString &comment); 0042 0043 [[nodiscard]] int rowCount(const QModelIndex &parent) const override; 0044 [[nodiscard]] QVariant data(const QModelIndex &index, int intRole) const override; 0045 [[nodiscard]] QHash<int, QByteArray> roleNames() const override; 0046 0047 private: 0048 void searchFinished(const QList<Bugzilla::Bug::Ptr> &list); 0049 void analyzedDuplicates(KJob *j); 0050 0051 int m_offset = 0; 0052 bool m_atEnd = false; 0053 QList<Bugzilla::Bug::Ptr> m_list; 0054 bool m_searching = false; 0055 int m_foundDuplicate = false; 0056 DuplicateFinderJob::Result m_result; 0057 };