/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef HORIZONTALJOURNAL_H #define HORIZONTALJOURNAL_H #include "abstractdashview.h" /** A horizontal journal is a view that creates delegates * based on a model and layouts them one after the other * in the same row until there is no more free space for the next item * and so that item is layouted in the next row * * All delegates are forced to rowHeight if they don't have it. */ class HorizontalJournal : public AbstractDashView { Q_OBJECT Q_PROPERTY(qreal rowHeight READ rowHeight WRITE setRowHeight NOTIFY rowHeightChanged) friend class HorizontalJournalTest; public: HorizontalJournal(); qreal rowHeight() const; void setRowHeight(qreal rowHeight); Q_SIGNALS: void rowHeightChanged(); private: void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override; void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override; bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override; void addItemToView(int modelIndex, QQuickItem *item) override; void cleanupExistingItems() override; void calculateImplicitHeight() override; void doRelayout() override; void updateItemCulling(qreal visibleFromY, qreal visibleToY) override; #if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0)) void processModelRemoves(const QVector &removes) override; #else void processModelRemoves(const QVector &removes) override; #endif int m_firstVisibleIndex; QList m_visibleItems; QMap m_lastInRowIndexPosition; int m_rowHeight; }; #endif