OpenWalnut  1.5.0dev
WQtRoiHeaderTreeItem.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <memory>
26 #include <string>
27 
28 #include <QApplication>
29 #include <QListWidgetItem>
30 #include <QScrollArea>
31 #include <QVBoxLayout>
32 #include <QWidgetAction>
33 #include <QtCore/QList>
34 
35 #include "../WMainWindow.h"
36 #include "../WQtGui.h"
37 #include "../guiElements/WScaleLabel.h"
38 #include "WQtRoiHeaderTreeItem.h"
39 #include "WQtRoiTreeItem.h"
40 #include "WTreeItemTypes.h"
41 
43  QTreeWidgetItem( parent, ROIHEADER )
44 {
45  setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
46 
47 
48  // create nice widget
49  m_itemWidget = new QWidget( );
50  QHBoxLayout* containerLayout = new QHBoxLayout();
51  m_itemWidget->setLayout( containerLayout );
52 
53  // create a slider for the for the texture
54  QWidget* labelContainer = new QWidget( m_itemWidget );
55  QHBoxLayout* labelContainerLayout = new QHBoxLayout();
56  labelContainer->setLayout( labelContainerLayout );
57 
58  WScaleLabel* l = new WScaleLabel( QString::fromStdString( "ROIs" ), 5, labelContainer );
59  l->setTextInteractionFlags( Qt::NoTextInteraction );
60  l->setToolTip( "Define a selection of fibers using ROIs which are interpreted as logical formula." );
61  labelContainerLayout->addWidget( l );
62 
63  // style
64  QPalette palette;
65  QColor defaultCol = palette.window().color();
66 
67  // label color
68  QColor labelCol = defaultCol.darker( 120 );
69 
70  l->setStyleSheet( "background-color:" + labelCol.name() + ";" );
71  labelContainer->setStyleSheet( "background-color:" + labelCol.name() + ";" );
72 
73  // fill layout
74  containerLayout->addWidget( labelContainer );
75  labelContainerLayout->setContentsMargins( 5, 2, 0, 2 );
76  labelContainerLayout->setSpacing( 0 );
77 
78  // compact layout
79  containerLayout->setContentsMargins( 0, 2, 0, 2 );
80  containerLayout->setSpacing( 0 );
81 
82  // prefer stretching the label
83  containerLayout->setStretchFactor( labelContainer, 100 );
84 
85  // widget size constraints and policies
86  m_itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
87 }
88 
90 {
91 }
92 
93 WQtBranchTreeItem* WQtRoiHeaderTreeItem::addBranch( std::shared_ptr< WRMBranch> branch )
94 {
95  WQtBranchTreeItem* rti = new WQtBranchTreeItem( this, branch );
96  return rti;
97 }
98 
100 {
101  return m_itemWidget;
102 }
103 
This class represents a ROI branch in the tree widget.
virtual ~WQtRoiHeaderTreeItem()
destructor
QWidget * m_itemWidget
Widget representing the item.
WQtRoiHeaderTreeItem(QTreeWidget *parent)
constructor
QWidget * getWidget() const
Create a representation widget for this item.
WQtBranchTreeItem * addBranch(std::shared_ptr< WRMBranch > branch)
Add new branch to the tree view.
Special Label that can shrink and expand in a layout.
Definition: WScaleLabel.h:37