1#include <IssuesList.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
12IssuesList::IssuesList(const QSharedPointer<GitServerCache> &gitServerCache, QWidget *parent)
13 : AGitServerItemList(gitServerCache, parent)
14{
15 mHeaderTitle->setText(tr("Issues"));
16
17 connect(mGitServerCache.get(), &GitServerCache::issuesReceived, this,
18 [this]() { onIssuesReceived(mGitServerCache->getIssues()); });
19
20 onIssuesReceived(mGitServerCache->getIssues());
21}
22
23void IssuesList::refreshData()
24{
25 mGitServerCache->getApi()->requestIssues();
26}
27
28void IssuesList::onIssuesReceived(const QVector<Issue> &issues)
29{
30 QVector<IssueItem *> items;
31
32 for (auto &issue : issues)
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("Issues (%1)").arg(items.count()));
40
41 createContent(items);
42}
43