1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef TInspectorEXE_OpenFileViewModel_H
17 #define TInspectorEXE_OpenFileViewModel_H
19 #include <Standard_Macro.hxx>
22 #pragma warning(disable : 4127) // conditional expression is constant
24 #include <QAbstractTableModel>
25 #include <QStringList>
26 #include <QItemDelegate>
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 TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
39 TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
40 : QItemDelegate (theParent), myColor(theHighlightColor) {}
43 virtual ~TInspectorEXE_OpenFileItemDelegate() {}
45 //! Draw an icon in the cell
46 //! \param thePainter a painter
47 //! \param theOption a paint options
48 //! \param theIndex a view index
49 virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
50 const QModelIndex& theIndex) const Standard_OVERRIDE;
54 QColor myColor; //!< highlight color
57 //! \class TInspectorEXE_OpenFileViewModel
58 //! Table model that visualizes container of string values (file names)
59 //! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
60 class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
66 TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
69 virtual ~TInspectorEXE_OpenFileViewModel() {}
72 //! \param theValues a container of values to fill model
73 void Init (const QStringList& theValues);
75 //! Returns content of the model index for the given role, it is obtained from internal container of values
76 //! It returns value only for DisplayRole.
77 //! \param theIndex a model index
78 //! \param theRole a view role
79 //! \return value intepreted depending on the given role
80 virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
82 //! Returns number of rows
83 //! \param theParent an index of the parent item
84 //! \return an integer value
85 virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
86 { (void)theParent; return 1; }
88 //! Returns number of columns
89 //! \param theParent an index of the parent item
90 //! \return an integer value
91 virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
92 { (void)theParent; return myValues.size(); }
96 QStringList myValues; //!< file names