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 #include <TInspectorEXE_OpenFileViewModel.hxx>
18 #include <QApplication>
23 const int ICON_SIZE = 40;
25 // =======================================================================
28 // =======================================================================
29 void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
30 const QModelIndex& theIndex) const
33 if (theOption.state & QStyle::State_MouseOver)
34 thePainter->fillRect (theOption.rect, myColor);
36 // action icon for all indices before the last one
37 QIcon anIcon (":/icons/folder_import.png");
38 QSize anIconSize (ICON_SIZE, ICON_SIZE);
39 int aWidth = theOption.rect.width();
40 int aCenter = aWidth / 2.;
41 int aHalf = anIconSize.width() / 2.;
42 int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
43 thePainter->drawPixmap (QRect (theOption.rect.left() + (aCenter - aHalf),
44 theOption.rect.top() + aMargin,
47 anIcon.pixmap(anIconSize.width(), anIconSize.height()));
49 QItemDelegate::paint (thePainter, theOption, theIndex);
52 // =======================================================================
55 // =======================================================================
56 void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
61 // =======================================================================
64 // =======================================================================
65 QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
69 case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
70 case Qt::ToolTipRole: return myValues[theIndex.column()];
71 case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);