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>
21 #include <Standard_WarningsDisable.hxx>
22 #include <QAbstractTableModel>
23 #include <QStringList>
24 #include <QItemDelegate>
25 #include <Standard_WarningsRestore.hxx>
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
38 TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
39 : QItemDelegate (theParent), myColor(theHighlightColor) {}
42 virtual ~TInspectorEXE_OpenFileItemDelegate() {}
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;
53 QColor myColor; //!< highlight color
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
65 TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
68 virtual ~TInspectorEXE_OpenFileViewModel() {}
71 //! \param theValues a container of values to fill model
72 void Init (const QStringList& theValues);
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;
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; }
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(); }
95 QStringList myValues; //!< file names