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 Q_SIGNALS:
69  void columnWidthChanged();
70 
71 private:
72  class ViewItem
73  {
74  public:
75  ViewItem(QQuickItem *item, int modelIndex) : m_item(item), m_modelIndex(modelIndex) {}
76  qreal x() const { return m_item->x(); }
77  qreal y() const { return m_item->y(); }
78  qreal height() const { return m_item->height(); }
79  bool operator<(const ViewItem &v) const { return m_modelIndex < v.m_modelIndex; }
80 
81  QQuickItem *m_item;
82  int m_modelIndex;
83  };
84 
85  void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
86  void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
87  bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
88  void addItemToView(int modelIndex, QQuickItem *item) override;
89  void cleanupExistingItems() override;
90  void calculateImplicitHeight() override;
91  void doRelayout() override;
92  void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
93  void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) override;
94 
95  QVector<QList<ViewItem>> m_columnVisibleItems;
96  QHash<int, int> m_indexColumnMap;
97  int m_columnWidth;
98 };
99 
100 #endif