QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskMainView.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskMainView.h"
7#include "QskQuick.h"
8
9/*
10 This code is a placeholder implementation until we know
11 what kind of features we actually want to have
12 */
13class QskMainView::PrivateData
14{
15 public:
16 QPointer< QskControl > header;
17 QPointer< QskControl > body;
18 QPointer< QskControl > footer;
19};
20
21QskMainView::QskMainView( QQuickItem* parent )
22 : Inherited( Qt::Vertical, parent )
23 , m_data( new PrivateData )
24{
25 setAutoAddChildren( false );
26 setSpacing( 0 );
27 setPanel( true );
28
29 setFlag( QQuickItem::ItemIsFocusScope, true );
30 setTabFence( true );
31 setFocusPolicy( Qt::StrongFocus );
32}
33
34QskMainView::~QskMainView()
35{
36}
37
38QskControl* QskMainView::header() const
39{
40 return m_data->header;
41}
42
43void QskMainView::setHeader( QskControl* header )
44{
45 if ( header == m_data->header )
46 return;
47
48 delete m_data->header;
49 m_data->header = header;
50
51 if( header )
52 {
53 header->setSection( QskAspect::Header );
54 insertItem( 0, header );
55 }
56}
57
58QskControl* QskMainView::body() const
59{
60 return m_data->body;
61}
62
63void QskMainView::setBody( QskControl* body )
64{
65 if ( body == m_data->body )
66 return;
67
68 delete m_data->body;
69 m_data->body = body;
70
71 if( body )
72 {
73 body->setSection( QskAspect::Body );
74 insertItem( 1, body );
75 }
76}
77
78QskControl* QskMainView::footer() const
79{
80 return m_data->footer;
81}
82
83void QskMainView::setFooter( QskControl* footer )
84{
85 if ( footer == m_data->footer )
86 return;
87
88 delete m_data->footer;
89 m_data->footer = footer;
90
91 if( footer )
92 {
93 footer->setSection( QskAspect::Footer );
94 insertItem( 2, footer );
95 }
96}
97
98void QskMainView::focusInEvent( QFocusEvent* event )
99{
100 Inherited::focusInEvent( event );
101
102 if ( isFocusScope() && ( scopedFocusItem() == nullptr ) )
103 {
104 if ( auto focusItem = nextItemInFocusChain( true ) )
105 {
106 if ( !qskIsItemInDestructor( focusItem )
107 && qskIsAncestorOf( this, focusItem ) )
108 {
109 focusItem->setFocus( true );
110 }
111 }
112 }
113}
114
115#include "moc_QskMainView.cpp"
Base class of all controls.
Definition QskControl.h:23