Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
UI Elements NG
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qt QML Tricks
UI Elements NG
Commits
de945256
Commit
de945256
authored
Jun 11, 2019
by
Thomas BOUTROUE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make StackContainer inherit AbstractContainerBase and reuse API
parent
0809021b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
54 deletions
+28
-54
gui/containers/QQuickStackContainer.cpp
gui/containers/QQuickStackContainer.cpp
+24
-46
gui/containers/QQuickStackContainer.h
gui/containers/QQuickStackContainer.h
+4
-8
No files found.
gui/containers/QQuickStackContainer.cpp
View file @
de945256
#include "QQuickStackContainer.h"
#include "QQuickContainerAttachedObject.h"
#include <QtMath>
QQuickStackContainer
::
QQuickStackContainer
(
QQuickItem
*
parent
)
:
QQuick
Item
{
parent
}
:
QQuick
AbstractContainerBase
{
parent
}
{
}
void
QQuickStackContainer
::
classBegin
(
void
)
{
QQuickItem
::
classBegin
();
}
void
QQuickStackContainer
::
componentComplete
(
void
)
{
QQuickItem
::
componentComplete
();
connect
(
this
,
&
QQuickStackContainer
::
visibleChanged
,
this
,
&
QQuickStackContainer
::
polish
);
connect
(
this
,
&
QQuickStackContainer
::
widthChanged
,
this
,
&
QQuickStackContainer
::
polish
);
connect
(
this
,
&
QQuickStackContainer
::
heightChanged
,
this
,
&
QQuickStackContainer
::
polish
);
polish
();
}
void
QQuickStackContainer
::
setupHandlers
(
void
)
{
}
void
QQuickStackContainer
::
updatePolish
(
void
)
{
QQuickItem
::
updatePolish
();
int
maxChildWidth
{
0
},
maxChildHeight
{
0
};
const
QList
<
QQuickItem
*>
childrenList
{
childItems
()
};
void
QQuickStackContainer
::
relayout
(
void
)
{
int
maxChildWidth
{
0
};
int
maxChildHeight
{
0
};
int
layoutItemsCount
{
0
};
const
QList
<
QQuickItem
*>
&
childrenList
{
childItems
()
};
for
(
QQuickItem
*
childItem
:
childrenList
)
{
if
(
!
childItem
->
inherits
(
"QQuickRepeater"
))
{
if
(
qCeil
(
childItem
->
implicitWidth
())
>
maxChildWidth
)
{
maxChildWidth
=
qCeil
(
childItem
->
implicitWidth
());
}
if
(
qCeil
(
childItem
->
implicitHeight
())
>
maxChildHeight
)
{
maxChildHeight
=
qCeil
(
childItem
->
implicitHeight
());
}
}
}
setImplicitWidth
(
maxChildWidth
);
setImplicitHeight
(
maxChildHeight
);
}
void
QQuickStackContainer
::
itemChange
(
QQuickItem
::
ItemChange
change
,
const
QQuickItem
::
ItemChangeData
&
value
)
{
QQuickItem
::
itemChange
(
change
,
value
);
switch
(
int
(
change
))
{
case
ItemChildAddedChange
:
{
if
(
QQuickItem
*
child
{
value
.
item
})
{
connect
(
child
,
&
QQuickItem
::
visibleChanged
,
this
,
&
QQuickStackContainer
::
polish
,
Qt
::
UniqueConnection
);
connect
(
child
,
&
QQuickItem
::
implicitWidthChanged
,
this
,
&
QQuickStackContainer
::
polish
,
Qt
::
UniqueConnection
);
connect
(
child
,
&
QQuickItem
::
implicitHeightChanged
,
this
,
&
QQuickStackContainer
::
polish
,
Qt
::
UniqueConnection
);
polish
();
}
break
;
}
case
ItemChildRemovedChange
:
{
if
(
QQuickItem
*
child
{
value
.
item
})
{
disconnect
(
child
,
Q_NULLPTR
,
this
,
Q_NULLPTR
);
polish
();
if
(
!
childItem
->
inherits
(
REPEATER_CLASSNAME
))
{
if
(
childItem
->
isVisible
())
{
const
QQuickContainerAttachedObject
*
attached
{
getContainerAttachedObject
(
childItem
)
};
const
bool
ignored
{
(
attached
&&
attached
->
get_ignored
())
};
if
(
!
ignored
)
{
if
(
childItem
->
implicitWidth
()
>
maxChildWidth
)
{
maxChildWidth
=
qCeil
(
childItem
->
implicitWidth
());
}
if
(
childItem
->
implicitHeight
()
>
maxChildHeight
)
{
maxChildHeight
=
qCeil
(
childItem
->
implicitHeight
());
}
++
layoutItemsCount
;
}
}
break
;
}
}
setImplicitWidth
(
maxChildWidth
);
setImplicitHeight
(
maxChildHeight
);
set_layoutItemsCount
(
layoutItemsCount
);
}
gui/containers/QQuickStackContainer.h
View file @
de945256
#ifndef QQUICKSTACKCONTAINER_H
#define QQUICKSTACKCONTAINER_H
#include
<QQuickItem>
#include
"QQuickAbstractContainerBase.h"
#include "QmlPropertyHelpers.h"
class
QQuickStackContainer
:
public
QQuickItem
{
class
QQuickStackContainer
:
public
QQuickAbstractContainerBase
{
Q_OBJECT
public:
explicit
QQuickStackContainer
(
QQuickItem
*
parent
=
Q_NULLPTR
);
protected:
void
classBegin
(
void
)
Q_DECL_FINAL
;
void
componentComplete
(
void
)
Q_DECL_FINAL
;
void
updatePolish
(
void
)
Q_DECL_FINAL
;
void
itemChange
(
ItemChange
change
,
const
ItemChangeData
&
value
)
Q_DECL_FINAL
;
void
setupHandlers
(
void
)
Q_DECL_FINAL
;
void
relayout
(
void
)
Q_DECL_FINAL
;
};
#endif // QQUICKSTACKCONTAINER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment