1 #ifndef CSM_WORLD_INFOTABLEPROXYMODEL_HPP
2 #define CSM_WORLD_INFOTABLEPROXYMODEL_HPP
3 
4 #include <QHash>
5 
6 #include "idtableproxymodel.hpp"
7 #include "columns.hpp"
8 #include "universalid.hpp"
9 
10 namespace CSMWorld
11 {
12     class IdTableBase;
13 
14     class InfoTableProxyModel : public IdTableProxyModel
15     {
16             Q_OBJECT
17 
18             UniversalId::Type mType;
19             Columns::ColumnId mInfoColumnId;
20             ///< Contains ID for Topic or Journal ID
21             int mInfoColumnIndex;
22             int mLastAddedSourceRow;
23 
24             mutable QHash<QString, int> mFirstRowCache;
25 
26             int getFirstInfoRow(int currentRow) const;
27             ///< Finds the first row with the same topic (journal entry) as in \a currentRow
28             ///< \a currentRow is a row of the source model.
29 
30         public:
31             InfoTableProxyModel(UniversalId::Type type, QObject *parent = nullptr);
32 
33             void setSourceModel(QAbstractItemModel *sourceModel) override;
34 
35         protected:
36             bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
37 
38         protected slots:
39             void sourceRowsInserted(const QModelIndex &parent, int start, int end) override;
40             void sourceRowsRemoved(const QModelIndex &parent, int start, int end) override;
41             void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) override;
42     };
43 }
44 
45 #endif
46