blob: 907159993ebdecbbad6594825133208d077d3387 [file] [log] [blame]
Andreas Traczykb8b13ba2018-08-21 16:30:16 -04001/***************************************************************************
2* Copyright (C) 2017 by Savoir-faire Linux *
3* Author: Anthony LĂ©onard <anthony.leonard@savoirfairelinux.com> *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 3 of the License, or *
8* (at your option) any later version. *
9* *
10* This program is distributed in the hope that it will be useful, *
11* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13* GNU General Public License for more details. *
14* *
15* You should have received a copy of the GNU General Public License *
16* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17**************************************************************************/
18#pragma once
19
20// Qt include
21#include <QAbstractItemModel>
22
23// LRC
24#include "api/account.h"
25#include "api/conversation.h"
26#include "api/contact.h"
27
28#include "messagemodel.h"
29
30namespace lrc { namespace api { class ConversationModel; } }
31
32class SmartListModel : public QAbstractItemModel
33{
34 Q_OBJECT
35public:
36 using AccountInfo = lrc::api::account::Info;
37 using ConversationInfo = lrc::api::conversation::Info;
38 using ContactInfo = lrc::api::contact::Info;
39
40
41 enum Role {
42 DisplayName = Qt::UserRole + 1,
43 DisplayID,
44 Picture,
45 Presence,
46 URI,
47 UnreadMessagesCount,
48 LastInteractionDate,
49 LastInteraction,
50 ContactType,
51 UID,
52 ContextMenuOpen
53 };
54
55 explicit SmartListModel(const lrc::api::account::Info& acc, QObject *parent = 0);
56
57 // QAbstractItemModel
58 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
59 int columnCount(const QModelIndex &parent) const override;
60 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
61 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
62 QModelIndex parent(const QModelIndex &child) const;
63 Qt::ItemFlags flags(const QModelIndex &index) const;
64
65 bool isContextMenuOpen_{false};
66
67private:
68 const AccountInfo& acc_;
69
70};