1/*
2 SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef RBREPOSITORIESMODEL_H
8#define RBREPOSITORIESMODEL_H
9
10#include <KJob>
11#include <QAbstractListModel>
12#include <QUrl>
13
14class RepositoriesModel : public QAbstractListModel
15{
16 Q_OBJECT
17 Q_PROPERTY(QUrl server READ server WRITE setServer)
18public:
19 RepositoriesModel(QObject *parent = nullptr);
20
21 int rowCount(const QModelIndex &parent) const override;
22 QVariant data(const QModelIndex &index, int role) const override;
23
24 void refresh();
25
26 QUrl server() const
27 {
28 return m_server;
29 }
30 void setServer(const QUrl &server)
31 {
32 if (m_server != server) {
33 m_server = server;
34 refresh();
35 }
36 }
37
38 void receivedProjects(KJob *j);
39 Q_SCRIPTABLE int findRepository(const QString &name);
40
41Q_SIGNALS:
42 void repositoriesChanged();
43
44private:
45 struct Value {
46 QVariant name;
47 QVariant path;
48 bool operator<(const Value &v1) const
49 {
50 return name.toString() < v1.name.toString();
51 }
52 };
53 QList<Value> m_values;
54 QUrl m_server;
55};
56
57#endif
58

source code of purpose/src/plugins/reviewboard/quick/rbrepositoriesmodel.h