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_MODELITEM_P_H 0019 #define KQUICKITEMVIEWS_MODELITEM_P_H 0020 0021 #include <private/statetracker/index_p.h> 0022 #include <private/indexmetadata_p.h> 0023 0024 class Viewport; 0025 0026 namespace StateTracker { 0027 0028 class Content; 0029 0030 /** 0031 * Hold the metadata associated with the QModelIndex. 0032 */ 0033 struct ModelItem final : public StateTracker::Index 0034 { 0035 friend class ::IndexMetadata; //access the state machine 0036 0037 explicit ModelItem(Viewport *v); 0038 virtual ~ModelItem() {} 0039 0040 enum class State { 0041 NEW = 0, /*!< During creation, not part of the tree yet */ 0042 BUFFER = 1, /*!< Not in the viewport, but close */ 0043 REMOVED = 2, /*!< Currently in a removal transaction */ 0044 REACHABLE = 3, /*!< The [grand]parent of visible indexes */ 0045 VISIBLE = 4, /*!< The element is visible on screen */ 0046 ERROR = 5, /*!< Something went wrong */ 0047 DANGLING = 6, /*!< Being destroyed */ 0048 MOVING = 7, /*!< Currently undergoing a move operation */ 0049 }; 0050 0051 typedef bool(ModelItem::*StateF)(); 0052 0053 0054 StateTracker::ModelItem* load(Qt::Edge e) const; 0055 0056 // Getter 0057 IndexMetadata::EdgeType isTopEdge () const; 0058 IndexMetadata::EdgeType isBottomEdge() const; 0059 State state() const; 0060 0061 // Mutator 0062 void rebuildState(); 0063 0064 //TODO refactor once the class are split 0065 virtual void remove(bool reparent = false) override; 0066 0067 private: 0068 // Actions 0069 bool nothing(); 0070 bool error (); 0071 bool show (); 0072 bool hide (); 0073 bool remove2(); 0074 bool attach (); 0075 bool detach (); 0076 bool refresh(); 0077 bool move (); 0078 bool destroy(); 0079 bool reset (); 0080 0081 // Attributes 0082 State m_State {State::BUFFER}; 0083 0084 static const State m_fStateMap [8][8]; 0085 static const StateF m_fStateMachine[8][8]; 0086 0087 StateTracker::Content* q_ptr; 0088 }; 0089 0090 } 0091 0092 #endif