File indexing completed on 2024-05-12 04:43:05

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_PROXIMITY_P_H
0019 #define KQUICKITEMVIEWS_PROXIMITY_P_H
0020 
0021 #include <QtCore/QRectF>
0022 #include <QtCore/QModelIndexList>
0023 
0024 #include <private/indexmetadata_p.h>
0025 
0026 class ProximityPrivate;
0027 
0028 namespace StateTracker {
0029 
0030 class Index;
0031 
0032 /**
0033  * Track if the elements next to this one are loaded.
0034  *
0035  * This tries to prevent accidental "holes" with unloaded elements between
0036  * two visible ones.
0037  *
0038  * This state tracker doesn't know about what's loaded and what's not. To
0039  * make it work, it is important to send all relevent events otherwise it will
0040  * go out of sync and start doing useless model queries (but hopefully nothing
0041  * worst).
0042  */
0043 class Proximity
0044 {
0045 public:
0046     explicit Proximity(IndexMetadata *q, StateTracker::Index *self);
0047 
0048     enum class State {
0049         UNKNOWN , /*!< The information is not availablr           */
0050         LOADED  , /*!< The edges are valid                        */
0051         MOVED   , /*!< It was valid, but some elements moved      */
0052         UNLOADED, /*!< It is known that some edges are not loaded */
0053     };
0054 
0055     void performAction(IndexMetadata::ProximityAction a, Qt::Edge e);
0056 
0057     bool canLoadMore(Qt::Edge e);
0058 
0059     QModelIndexList getNext(Qt::Edge e);
0060 
0061 private:
0062     ProximityPrivate *d_ptr;
0063 };
0064 
0065 }
0066 
0067 #endif