14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef VInspector_ItemHistoryRoot_H |
17 | #define VInspector_ItemHistoryRoot_H |
18 | |
19 | #include <Standard.hxx> |
0cb512c0 |
20 | #include <inspector/VInspector_ItemBase.hxx> |
21 | #include <inspector/VInspector_ItemHistoryTypeInfo.hxx> |
22 | #include <inspector/VInspector_CallBackMode.hxx> |
14bbbdcb |
23 | |
24 | class VInspector_ItemHistoryRoot; |
25 | typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryRoot> VInspector_ItemHistoryRootPtr; |
26 | |
27 | //! \class VInspector_ItemHistoryRoot |
28 | //! Item in history tree model. Has container of VInspector_ItemHistoryTypeInfo. Each element is a child item. |
29 | //! Parent item is NULL, children are ItemHistoryType items |
30 | class VInspector_ItemHistoryRoot : public VInspector_ItemBase |
31 | { |
32 | |
33 | public: |
34 | |
35 | //! Creates an item wrapped by a shared pointer |
36 | static VInspector_ItemHistoryRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) |
37 | { return VInspector_ItemHistoryRootPtr (new VInspector_ItemHistoryRoot (theParent, theRow, theColumn)); } |
38 | |
39 | //! Destructor |
40 | virtual ~VInspector_ItemHistoryRoot() Standard_OVERRIDE {}; |
41 | |
42 | //! Sets maximum count of history elements in internal container. |
43 | //! \param theSize a size value |
44 | void SetHistoryTypesMaxAmount (const int theSize) { myInfoMaxSize = theSize; } |
45 | |
46 | //! Appends new history element into internal container. If the container already has maximum number |
47 | //! of values, the first container is removed. |
48 | //! \param theMode a type of the element |
49 | //! \param theInfo a history information element |
50 | Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo); |
51 | |
52 | //! Returns history item information for the child item |
53 | //! \param theChildRowIndex a child index |
54 | Standard_EXPORT const VInspector_ItemHistoryTypeInfo& GetTypeInfo (const int theChildRowIndex); |
55 | |
56 | protected: |
57 | |
58 | //! Return data value for the role. It should be reimplemented in child |
59 | //! \param theRole a value role |
60 | //! \return the value |
61 | virtual QVariant initValue(const int theRole) const; |
62 | |
63 | //! \return number of children. It should be reimplemented in child |
64 | virtual int initRowCount() const Standard_OVERRIDE { return myInfoMap.size(); } |
65 | |
66 | //! Creates a child item in the given position. |
67 | //! \param theRow the child row position |
68 | //! \param theColumn the child column position |
69 | //! \return the created item |
70 | virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; |
71 | |
72 | private: |
73 | |
74 | //! Constructor |
75 | //! param theParent a parent item |
76 | VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn); |
77 | |
78 | private: |
79 | |
80 | QMap<int, VInspector_ItemHistoryTypeInfo> myInfoMap; //!< container of whole callback info, bounded by maximum size value |
81 | int myFirstIndex; //!< the first index in the information map, the first index is incremented if max value of container is achieved |
82 | int myLastIndex; //!< the last index in the information map, is incremented when new element is added |
83 | int myInfoMaxSize; //!< maximum number of elements in information map |
84 | }; |
85 | |
86 | #endif |