Changeset View
Changeset View
Standalone View
Standalone View
klipper/historymodel.h
Show All 40 Lines | 37 | public: | |||
---|---|---|---|---|---|
41 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 41 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
42 | bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; | 42 | bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; | ||
43 | QHash< int, QByteArray > roleNames() const override; | 43 | QHash< int, QByteArray > roleNames() const override; | ||
44 | bool remove(const QByteArray &uuid); | 44 | bool remove(const QByteArray &uuid); | ||
45 | 45 | | |||
46 | int maxSize() const; | 46 | int maxSize() const; | ||
47 | void setMaxSize(int size); | 47 | void setMaxSize(int size); | ||
48 | 48 | | |||
49 | bool displayImages() const; | ||||
50 | void setDisplayImages(bool show); | ||||
51 | | ||||
49 | void clear(); | 52 | void clear(); | ||
50 | void moveToTop(const QByteArray &uuid); | 53 | void moveToTop(const QByteArray &uuid); | ||
51 | void moveTopToBack(); | 54 | void moveTopToBack(); | ||
52 | void moveBackToTop(); | 55 | void moveBackToTop(); | ||
53 | 56 | | |||
54 | QModelIndex indexOf(const QByteArray &uuid) const; | 57 | QModelIndex indexOf(const QByteArray &uuid) const; | ||
55 | QModelIndex indexOf(const HistoryItem *item) const; | 58 | QModelIndex indexOf(const HistoryItem *item) const; | ||
56 | 59 | | |||
57 | void insert(QSharedPointer<HistoryItem> item); | 60 | void insert(QSharedPointer<HistoryItem> item); | ||
58 | 61 | | |||
59 | QMutex *mutex() { | 62 | QMutex *mutex() { | ||
60 | return &m_mutex; | 63 | return &m_mutex; | ||
61 | } | 64 | } | ||
62 | 65 | | |||
63 | private: | 66 | private: | ||
64 | void moveToTop(int row); | 67 | void moveToTop(int row); | ||
65 | QList<QSharedPointer<HistoryItem>> m_items; | 68 | QList<QSharedPointer<HistoryItem>> m_items; | ||
66 | int m_maxSize; | 69 | int m_maxSize; | ||
70 | bool m_displayImages; | ||||
davidedmundson: It's best to initialise this.
I know setDisplayImages will always be called by the app, but… | |||||
67 | QMutex m_mutex; | 71 | QMutex m_mutex; | ||
68 | }; | 72 | }; | ||
69 | 73 | | |||
70 | inline int HistoryModel::maxSize() const | 74 | inline int HistoryModel::maxSize() const | ||
71 | { | 75 | { | ||
72 | return m_maxSize; | 76 | return m_maxSize; | ||
73 | } | 77 | } | ||
74 | 78 | | |||
79 | inline bool HistoryModel::displayImages() const { | ||||
80 | return m_displayImages; | ||||
81 | } | ||||
82 | | ||||
83 | inline void HistoryModel::setDisplayImages(bool show) { | ||||
84 | m_displayImages = show; | ||||
85 | } | ||||
86 | | ||||
75 | Q_DECLARE_METATYPE(HistoryItemType) | 87 | Q_DECLARE_METATYPE(HistoryItemType) | ||
76 | 88 | | |||
77 | #endif | 89 | #endif |
It's best to initialise this.
I know setDisplayImages will always be called by the app, but it makes the class more re-usable and robust.