on 551c708 help sign in
unity8/plugins/DashViews/horizontaljournal.h
67 lines 2.3 kB history raw
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 */
17#ifndef HORIZONTALJOURNAL_H
18#define HORIZONTALJOURNAL_H
20#include "abstractdashview.h"
22 /** A horizontal journal is a view that creates delegates
23 * based on a model and layouts them one after the other
24 * in the same row until there is no more free space for the next item
25 * and so that item is layouted in the next row
26 *
27 * All delegates are forced to rowHeight if they don't have it.
28 */
29 class HorizontalJournal : public AbstractDashView
31 Q_OBJECT
33 Q_PROPERTY(qreal rowHeight READ rowHeight WRITE setRowHeight NOTIFY rowHeightChanged)
35friend class HorizontalJournalTest;
37public:
38 HorizontalJournal();
40 qreal rowHeight() const;
41 void setRowHeight(qreal rowHeight);
43Q_SIGNALS:
44 void rowHeightChanged();
46private:
47 void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
48 void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
49 bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
50 void addItemToView(int modelIndex, QQuickItem *item) override;
51 void cleanupExistingItems() override;
52 void calculateImplicitHeight() override;
53 void doRelayout() override;
54 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
55#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
56 void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) override;
57#else
58 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
59#endif
61 int m_firstVisibleIndex;
62 QList<QQuickItem*> m_visibleItems;
63 QMap<int, double> m_lastInRowIndexPosition;
64 int m_rowHeight;
65};
67#endif