File indexing completed on 2024-05-12 05:12:44

0001 /*
0002     SPDX-FileCopyrightText: 2008 Stephen Kelly <steveire@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <Akonadi/ChangeRecorder>
0010 #include <Akonadi/EntityTreeModel>
0011 
0012 #include <QSortFilterProxyModel>
0013 
0014 using namespace Akonadi;
0015 
0016 class AkonadiBrowserModel : public EntityTreeModel
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit AkonadiBrowserModel(ChangeRecorder *monitor, QObject *parent = nullptr);
0021     ~AkonadiBrowserModel() override;
0022 
0023     enum ItemDisplayMode { GenericMode, MailMode, ContactsMode, CalendarMode };
0024 
0025     void setItemDisplayMode(ItemDisplayMode itemDisplayMode);
0026     ItemDisplayMode itemDisplayMode() const;
0027 
0028     QVariant entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const override;
0029 
0030     QVariant entityData(const Item &item, int column, int role) const override;
0031     QVariant entityData(const Collection &collection, int column, int role) const override;
0032 
0033     int entityColumnCount(HeaderGroup headerGroup) const override;
0034 
0035     class State;
0036 
0037 Q_SIGNALS:
0038     void columnsChanged();
0039 
0040 private:
0041     State *m_currentState = nullptr;
0042     State *m_genericState = nullptr;
0043     State *m_mailState = nullptr;
0044     State *m_contactsState = nullptr;
0045     State *m_calendarState = nullptr;
0046 
0047     ItemDisplayMode m_itemDisplayMode = GenericMode;
0048 };
0049 
0050 class AkonadiBrowserSortModel : public QSortFilterProxyModel
0051 {
0052     Q_OBJECT
0053 public:
0054     explicit AkonadiBrowserSortModel(AkonadiBrowserModel *browserModel, QObject *parent = nullptr);
0055     ~AkonadiBrowserSortModel() override;
0056 
0057 protected:
0058     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
0059 
0060 private:
0061     AkonadiBrowserModel *const mBrowserModel;
0062 };