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 DFBrowserPane_TableView_H 17 #define DFBrowserPane_TableView_H 18 19 #include <Standard.hxx> 20 21 #include <Standard_WarningsDisable.hxx> 22 #include <QWidget> 23 #include <QMap> 24 #include <Standard_WarningsRestore.hxx> 25 26 class QTableView; 27 class QAbstractTableModel; 28 29 //! \class DFBrowserPane_TableView 30 //! \brief The widget that contains table view with some settings: 31 //! - table grid is hidden 32 //! - vertical header is hidden 33 //! - stretch last column by horizontal 34 //! - default width of columns. 35 class DFBrowserPane_TableView : public QWidget 36 { 37 public: 38 39 //! Constructor 40 Standard_EXPORT DFBrowserPane_TableView (QWidget* theParent, 41 const QMap<int, int>& theDefaultColumnWidths = QMap<int, int>()); 42 //! Destructor ~DFBrowserPane_TableView()43 virtual ~DFBrowserPane_TableView() {} 44 45 //! Sets model into table view. After, set column widths for view 46 Standard_EXPORT void SetModel (QAbstractTableModel* theModel); 47 48 //! Returns the current table view GetTableView() const49 QTableView* GetTableView() const { return myTableView; } 50 51 //! Set horizontal header shown or hidden 52 //! \param theVisible visibility flag 53 Standard_EXPORT void SetVisibleHorizontalHeader (const bool& theVisible); 54 55 //! Updates table view height to contain the given number of rows only 56 //! \param theCount a row count 57 //! \param theView a table view, which size will be changed 58 //! \param theScroll flag whether add scroll height to size 59 Standard_EXPORT static void SetFixedRowCount (const int theCount, QTableView* theView, const bool theScroll = false); 60 61 //! Returns names of selected items in the view 62 //! \param theView a table view 63 //! \param theColumnId a column index 64 //! \return container of strings 65 Standard_EXPORT static QStringList GetSelectedColumnValues (QTableView* theTable, const int theColumnId); 66 67 private: 68 69 QTableView* myTableView; //!< the current table view 70 QMap<int, int> myDefaultColumnWidths; //!< container of default widths of columns 71 }; 72 73 #endif 74