File indexing completed on 2024-04-28 04:41:51
0001 /*************************************************************************** 0002 * Copyright (C) 2018 by Emmanuel Lepage Vallee * 0003 * Author : Emmanuel Lepage Vallee <emmanuel.lepage@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 3 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0017 **************************************************************************/ 0018 #ifndef KQUICKITEMVIEWS_VIEWPORT_P_H 0019 #define KQUICKITEMVIEWS_VIEWPORT_P_H 0020 0021 // Qt 0022 class QQmlComponent; 0023 class QQmlEngine; 0024 0025 // KItemViews 0026 class Viewport; 0027 class IndexMetadata; 0028 class AbstractItemAdapter; 0029 class GeoStrategySelector; 0030 class ViewBaseItemVariables; 0031 0032 namespace StateTracker { 0033 class Content; 0034 } 0035 0036 #include <QtCore/QRectF> 0037 #include <QtCore/QModelIndex> 0038 0039 #include "statetracker/geometry_p.h" 0040 0041 /** 0042 * In order to keep the separation of concerns design goal intact, this 0043 * interface between the StateTracker::Content and Viewport internal 0044 * metadata without exposing them. 0045 */ 0046 class ViewportSync final 0047 { 0048 public: 0049 0050 /** 0051 * From the model or feedback loop 0052 */ 0053 void updateGeometry(IndexMetadata* item); 0054 0055 /** 0056 * From the widget 0057 */ 0058 void geometryUpdated(IndexMetadata* item); 0059 0060 /** 0061 * From the model or feedback loop 0062 */ 0063 void notifyRemoval(IndexMetadata* item); 0064 0065 /** 0066 * From the model or feedback loop 0067 */ 0068 void notifyInsert(IndexMetadata* item); 0069 0070 /** 0071 * From the model when the QModelIndex role change 0072 */ 0073 void notifyChange(IndexMetadata* item); 0074 0075 /** 0076 * Manually trigger the sizes and positions to be updated. 0077 */ 0078 void refreshVisible(); 0079 0080 QQmlEngine *engine(); 0081 QQmlComponent *component(); 0082 0083 IndexMetadata *metadataForIndex(const QModelIndex& idx) const; 0084 0085 Viewport *q_ptr; 0086 StateTracker::Content *m_pReflector {nullptr}; 0087 GeoStrategySelector *m_pGeoAdapter { nullptr }; 0088 std::function<AbstractItemAdapter*()> m_fFactory; 0089 0090 private: 0091 QQmlEngine *m_pEngine {nullptr}; 0092 QQmlComponent *m_pComponent {nullptr}; 0093 }; 0094 0095 #endif