Unity 8
verticaljournal.h
1 /*
2  * Copyright (C) 2013 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef VERTICALJOURNAL_H
18 #define VERTICALJOURNAL_H
19 
20 #include "abstractdashview.h"
21 
54 class VerticalJournal : public AbstractDashView
55 {
56  Q_OBJECT
57 
58  Q_PROPERTY(qreal columnWidth READ columnWidth WRITE setColumnWidth NOTIFY columnWidthChanged)
59 
60 friend class VerticalJournalTest;
61 
62 public:
64 
65  qreal columnWidth() const;
66  void setColumnWidth(qreal columnWidth);
67 
68 protected:
69  void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
70 
71 Q_SIGNALS:
72  void columnWidthChanged();
73 
74 private:
75  class ViewItem
76  {
77  public:
78  ViewItem(QQuickItem *item, int modelIndex) : m_item(item), m_modelIndex(modelIndex) {}
79  qreal x() const { return m_item->x(); }
80  qreal y() const { return m_item->y(); }
81  qreal height() const { return m_item->height(); }
82  bool operator<(const ViewItem v) const { return m_modelIndex < v.m_modelIndex; }
83 
84  QQuickItem *m_item;
85  int m_modelIndex;
86  };
87 
88  void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
89  void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
90  bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
91  void addItemToView(int modelIndex, QQuickItem *item) override;
92  void cleanupExistingItems() override;
93  void calculateImplicitHeight() override;
94  void doRelayout() override;
95  void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
96  void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) override;
97 
98  QVector<QList<ViewItem>> m_columnVisibleItems;
99  QHash<int, int> m_indexColumnMap;
100  int m_columnWidth;
101 };
102 
103 #endif