0029684: Configuration: modification of build Inspector tool standalone on occt
[occt.git] / tools / TInspectorEXE / TInspectorEXE_OpenFileViewModel.hxx
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 TInspectorEXE_OpenFileViewModel_H
17 #define TInspectorEXE_OpenFileViewModel_H
18
19 #include <Standard_Macro.hxx>
20
21 #include <Standard_WarningsDisable.hxx>
22 #include <QAbstractTableModel>
23 #include <QStringList>
24 #include <QItemDelegate>
25 #include <Standard_WarningsRestore.hxx>
26
27 class QObject;
28 class QPainter;
29
30 //! \class TInspectorEXE_OpenFileItemDelegate
31 //! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
32 class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
33 {
34
35 public:
36
37   //! Constructor
38   TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
39   : QItemDelegate (theParent), myColor(theHighlightColor) {}
40
41   //! Destructor
42   virtual ~TInspectorEXE_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   virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
49                       const QModelIndex& theIndex) const Standard_OVERRIDE;
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 TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
60 {
61
62 public:
63
64   //! Constructor
65   TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
66
67   //! Destructor
68   virtual ~TInspectorEXE_OpenFileViewModel() {}
69
70   //! Store values
71   //! \param theValues a container of values to fill model
72   void Init (const QStringList& theValues);
73
74   //! Returns content of the model index for the given role, it is obtained from internal container of values
75   //! It returns value only for DisplayRole.
76   //! \param theIndex a model index
77   //! \param theRole a view role
78   //! \return value intepreted depending on the given role
79   virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
80
81   //! Returns number of rows
82   //! \param theParent an index of the parent item
83   //! \return an integer value
84   virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
85   { (void)theParent; return 1; }
86
87   //! Returns number of columns
88   //! \param theParent an index of the parent item
89   //! \return an integer value
90   virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
91   { (void)theParent; return myValues.size(); }
92
93 private:
94
95   QStringList myValues; //!< file names
96 };
97
98 #endif