1#include <PrList.h>
2
3#include <IssueItem.h>
4#include <IRestApi.h>
5#include <GitServerCache.h>
6
7#include <QLabel>
8#include <QIcon>
9
10using namespace GitServer;
11
12PrList::PrList(const QSharedPointer<GitServerCache> &gitServerCache, QWidget *parent)
13 : AGitServerItemList(gitServerCache, parent)
14{
15 mHeaderTitle->setText(tr("Pull Requests"));
16
17 connect(mGitServerCache.get(), &GitServerCache::prReceived, this,
18 [this]() { onPullRequestsReceived(mGitServerCache->getPullRequests()); });
19
20 onPullRequestsReceived(mGitServerCache->getPullRequests());
21}
22
23void PrList::refreshData()
24{
25 mGitServerCache->getApi()->requestPullRequests();
26}
27
28void PrList::onPullRequestsReceived(const QVector<PullRequest> &pr)
29{
30 QVector<IssueItem *> items;
31
32 for (auto &issue : pr)
33 {
34 const auto issueItem = new IssueItem(issue);
35 connect(issueItem, &IssueItem::selected, this, &AGitServerItemList::selected);
36 items.append(issueItem);
37 }
38
39 mHeaderTitle->setText(tr("Pull Requests (%1)").arg(items.count()));
40
41 createContent(items);
42}
43