blob: 6e3d0eb12b3a91452e2154e04e4539dd0cd026a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef QRTCLIENT_TICKET_HXX
#define QRTCLIENT_TICKET_HXX
#include <QAbstractListModel>
#include <rtclient/ticket.h>
namespace RTClient {
class Ticket
{
public:
Ticket(rtclient_ticket* ticket) :
m_id{ticket->id},
m_subject{ticket->subject}
{}
unsigned int id() const { return m_id; }
QString const& subject() const { return m_subject; }
private:
unsigned int m_id;
QString m_subject;
};
class TicketList : public QAbstractListModel
{
Q_OBJECT
public:
enum TicketRoles {
IdRole = Qt::UserRole + 1,
SubjectRole
};
TicketList(QObject* parent = nullptr)
: QAbstractListModel{parent} {}
TicketList(struct rtclient_ticket** list,
QObject* parent = nullptr);
TicketList(TicketList const& list) { tickets = list.tickets; }
~TicketList() {}
int rowCount(QModelIndex const& parent
= QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole
) const Q_DECL_OVERRIDE;
protected:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
private:
QList<Ticket> tickets;
};
}
Q_DECLARE_METATYPE(RTClient::TicketList)
#endif
|