blob: a37cbb126c7e5249e8827eebc703f37875070045 [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
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
54 explicit SmartListModel(const lrc::api::account::Info& acc, QObject *parent = 0);
55
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 Traczyk43c08232018-10-31 13:42:09 -040064 // hack for context menu highlight retention
65 bool isContextMenuOpen{ false };
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040066
67private:
68 const AccountInfo& acc_;
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040069};