Seamly2D
Code documentation
vpropertytreeview.cpp
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vpropertytreeview.cpp
4  ** @author hedgeware <internal(at)hedgeware.net>
5  ** @date
6  **
7  ** @brief
8  ** @copyright
9  ** All rights reserved. This program and the accompanying materials
10  ** are made available under the terms of the GNU Lesser General Public License
11  ** (LGPL) version 2.1 which accompanies this distribution, and is available at
12  ** http://www.gnu.org/licenses/lgpl-2.1.html
13  **
14  ** This library is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  ** Lesser General Public License for more details.
18  **
19  *************************************************************************/
20 
21 #include "vpropertytreeview.h"
22 
23 #include <QAbstractItemView>
24 #include <QFlags>
25 
26 #include "vpropertydelegate.h"
27 #include "vpropertymodel.h"
28 #include "vpropertytreeview_p.h"
29 
31  : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
32 {
33  init();
34 }
35 
37  : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
38 {
39  init();
40 
41  if (model)
42  {
43  setModel(model);
44  }
45 }
46 
48  : QTreeView(parent), d_ptr(d)
49 {
50  if (init_)
51  {
52  init();
53  }
54 }
55 
57 {
58  delete d_ptr;
59 }
60 
61 
62 void VPE::VPropertyTreeView::setRowHeight(int height, bool add_to_standard)
63 {
64  d_ptr->PropertyDelegate->setRowHeight(height, add_to_standard);
65 }
66 
68 {
69  setAlternatingRowColors(true);
70  setUniformRowHeights(true);
71  d_ptr->PropertyDelegate = new VPropertyDelegate(this);
72  setItemDelegate(d_ptr->PropertyDelegate);
73 
74  setSelectionMode(QTreeView::SingleSelection);
75  setSelectionBehavior(QTreeView::SelectRows);
76  setRootIsDecorated(true);
77 
78  setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
79 }
This is the base model for managing all the properties and passing them to the view.
void setRowHeight(int height=0, bool add_to_standard=false)
Sets the height for each row. Set this to 0 in order to let the standard delegate decide.
virtual ~VPropertyTreeView() Q_DECL_OVERRIDE
Destructor.
virtual void init()
This method is called by the constructors to initialize the view.
VPropertyTreeView(QWidget *parent=nullptr)
Default constructor.