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 ShapeView_OpenFileViewModel_H |
17 | #define ShapeView_OpenFileViewModel_H |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Macro.hxx> |
21 | |
130eb114 |
22 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
23 | #include <QAbstractTableModel> |
24 | #include <QStringList> |
25 | #include <QItemDelegate> |
130eb114 |
26 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
27 | |
28 | class QObject; |
29 | class QPainter; |
30 | |
31 | //! \class TInspectorEXE_OpenFileItemDelegate |
32 | //! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button |
33 | class ShapeView_OpenFileItemDelegate : public QItemDelegate |
34 | { |
35 | public: |
36 | |
37 | //! Constructor |
38 | ShapeView_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlight) |
39 | : QItemDelegate (theParent), myColor(theHighlight) {} |
40 | |
41 | //! Destructor |
42 | virtual ~ShapeView_OpenFileItemDelegate() {} |
43 | |
44 | //! Draw an icon in the cell |
45 | //! \param thePainter a painter |
46 | //! \param theOption a paint options |
47 | //! \param theIndex a view index |
48 | Standard_EXPORT void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption, |
49 | const QModelIndex& theIndex) const; |
50 | |
51 | private: |
52 | |
53 | QColor myColor; //!< highlight color |
54 | }; |
55 | |
56 | //! \class TInspectorEXE_OpenFileViewModel |
57 | //! Table model that visualizes container of string values (file names) |
58 | //! Table orientation is horizontal, it has 1 row, number of columns equals to number of values |
59 | class ShapeView_OpenFileViewModel : public QAbstractTableModel |
60 | { |
61 | public: |
62 | |
63 | //! Constructor |
64 | ShapeView_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {} |
65 | |
66 | //! Destructor |
67 | virtual ~ShapeView_OpenFileViewModel() {} |
68 | |
69 | //! Store values |
70 | //! \param theValues a container of values to fill model |
71 | void Init (const QStringList& theValues); |
72 | |
73 | //! Returns content of the model index for the given role, it is obtained from internal container of values |
74 | //! It returns value only for DisplayRole. |
75 | //! \param theIndex a model index |
76 | //! \param theRole a view role |
77 | //! \return value intepreted depending on the given role |
78 | virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE; |
79 | |
80 | //! Returns number of rows |
81 | //! \param theParent an index of the parent item |
82 | //! \return an integer value |
83 | virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE |
84 | { (void)theParent; return 1; } |
85 | |
86 | //! Returns number of columns |
87 | //! \param theParent an index of the parent item |
88 | //! \return an integer value |
89 | virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE |
90 | { (void)theParent; return myValues.size(); } |
91 | |
92 | private: |
93 | |
94 | QStringList myValues; //!< file names |
95 | }; |
96 | |
97 | #endif |