blob: 08e36a119085e0ba29b68a03ccfbdf7a95e7238a [file] [log] [blame]
Andreas Traczykb8b13ba2018-08-21 16:30:16 -04001/***************************************************************************
Sébastien Blin68abac92019-01-02 17:41:31 -05002* Copyright (C) 2017-2019 by Savoir-faire Linux *
3* Author: Anthony L�onard <anthony.leonard@savoirfairelinux.com> *
Andreas Traczykb8b13ba2018-08-21 16:30:16 -04004* *
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
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040028namespace lrc { namespace api { class ConversationModel; } }
29
30class SmartListModel : public QAbstractItemModel
31{
32 Q_OBJECT
33public:
34 using AccountInfo = lrc::api::account::Info;
35 using ConversationInfo = lrc::api::conversation::Info;
36 using ContactInfo = lrc::api::contact::Info;
37
38
39 enum Role {
40 DisplayName = Qt::UserRole + 1,
41 DisplayID,
42 Picture,
43 Presence,
44 URI,
45 UnreadMessagesCount,
46 LastInteractionDate,
47 LastInteraction,
Andreas Traczyk43c08232018-10-31 13:42:09 -040048 LastInteractionType,
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040049 ContactType,
50 UID,
51 ContextMenuOpen
52 };
53
Andreas Traczyk6b5ad3e2019-01-02 17:04:36 -050054 explicit SmartListModel(const std::string& accId, QObject *parent = 0);
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040055
56 // QAbstractItemModel
57 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
58 int columnCount(const QModelIndex &parent) const override;
59 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
60 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
61 QModelIndex parent(const QModelIndex &child) const;
62 Qt::ItemFlags flags(const QModelIndex &index) const;
63
Andreas Traczyk6b5ad3e2019-01-02 17:04:36 -050064 void setAccount(const std::string& accId);
65
Andreas Traczyk43c08232018-10-31 13:42:09 -040066 // hack for context menu highlight retention
67 bool isContextMenuOpen{ false };
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040068
69private:
Andreas Traczyk6b5ad3e2019-01-02 17:04:36 -050070 std::string accId_;
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040071};