Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
df8a8a5e
Commit
df8a8a5e
authored
Jan 04, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added class UBWidgetList
parent
b8240514
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
184 additions
and
0 deletions
+184
-0
Sankore_3.1.pro
Sankore_3.1.pro
+2
-0
UBWidgetList.cpp
src/customWidgets/UBWidgetList.cpp
+133
-0
UBWidgetList.h
src/customWidgets/UBWidgetList.h
+44
-0
customWidgets.pri
src/customWidgets/customWidgets.pri
+5
-0
No files found.
Sankore_3.1.pro
View file @
df8a8a5e
...
@@ -53,6 +53,7 @@ include(src/desktop/desktop.pri)
...
@@ -53,6 +53,7 @@ include(src/desktop/desktop.pri)
include
(
src
/
web
/
web
.
pri
)
include
(
src
/
web
/
web
.
pri
)
include
(
src
/
softwareupdate
/
softwareupdate
.
pri
)
include
(
src
/
softwareupdate
/
softwareupdate
.
pri
)
include
(
src
/
transition
/
transition
.
pri
)
include
(
src
/
transition
/
transition
.
pri
)
include
(
src
/
customWidgets
/
customWidgets
.
pri
)
DEPENDPATH
+=
src
/
pdf
-
merger
DEPENDPATH
+=
src
/
pdf
-
merger
INCLUDEPATH
+=
src
/
pdf
-
merger
INCLUDEPATH
+=
src
/
pdf
-
merger
...
@@ -398,3 +399,4 @@ INSTALLS = UB_ETC \
...
@@ -398,3 +399,4 @@ INSTALLS = UB_ETC \
UB_THIRDPARTY_INTERACTIVE
UB_THIRDPARTY_INTERACTIVE
OTHER_FILES +=
OTHER_FILES +=
src/customWidgets/UBWidgetList.cpp
0 → 100644
View file @
df8a8a5e
#include <QDebug>
#include "UBWidgetList.h"
UBWidgetList
::
UBWidgetList
(
QWidget
*
parent
,
eWidgetListOrientation
orientation
,
const
char
*
name
)
:
QScrollArea
(
parent
)
,
mpLayout
(
NULL
)
,
mpContainer
(
NULL
)
,
mMargin
(
5
)
,
mpEmptyLabel
(
NULL
)
{
setObjectName
(
name
);
mOrientation
=
orientation
;
mpContainer
=
new
QWidget
(
this
);
mWidgets
.
clear
();
if
(
eWidgetListOrientation_Vertical
==
orientation
){
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
mpLayout
=
new
QVBoxLayout
(
mpContainer
);
mpContainer
->
resize
(
width
(),
mpContainer
->
height
());
}
else
{
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
mpLayout
=
new
QHBoxLayout
(
mpContainer
);
mpContainer
->
resize
(
mpContainer
->
width
(),
height
());
}
mpLayout
->
setContentsMargins
(
margin
(),
margin
(),
margin
(),
margin
());
mpContainer
->
setLayout
(
mpLayout
);
setWidget
(
mpContainer
);
}
UBWidgetList
::~
UBWidgetList
()
{
if
(
NULL
!=
mpEmptyLabel
){
delete
mpEmptyLabel
;
mpEmptyLabel
=
NULL
;
}
if
(
NULL
!=
mpLayout
){
delete
mpLayout
;
mpLayout
=
NULL
;
}
if
(
NULL
!=
mpContainer
){
delete
mpContainer
;
mpContainer
=
NULL
;
}
}
void
UBWidgetList
::
addWidget
(
QWidget
*
widget
)
{
if
(
NULL
!=
mpLayout
){
updateSize
(
true
,
widget
);
mpLayout
->
addWidget
(
widget
);
mWidgets
<<
widget
;
}
}
void
UBWidgetList
::
removeWidget
(
QWidget
*
widget
)
{
if
(
NULL
!=
mpLayout
){
mpLayout
->
removeWidget
(
widget
);
mWidgets
.
remove
(
mWidgets
.
indexOf
(
widget
));
updateSize
(
false
,
widget
);
widget
->
setVisible
(
false
);
}
}
void
UBWidgetList
::
updateSize
(
bool
widgetAdded
,
QWidget
*
widget
)
{
float
scaleFactor
;
int
newWidgetWidth
;
int
newWidgetHeight
;
if
(
eWidgetListOrientation_Vertical
==
mOrientation
){
scaleFactor
=
(
float
)
widget
->
width
()
/
(
float
)
mpContainer
->
width
();
}
else
{
scaleFactor
=
(
float
)
widget
->
height
()
/
(
float
)
mpContainer
->
height
();
}
newWidgetWidth
=
widget
->
width
()
*
scaleFactor
;
newWidgetHeight
=
widget
->
height
()
*
scaleFactor
;
widget
->
resize
(
newWidgetWidth
,
newWidgetHeight
);
// Now we have to update the container
if
(
eWidgetListOrientation_Vertical
==
mOrientation
){
if
(
widgetAdded
){
mpContainer
->
resize
(
mpContainer
->
width
(),
mpContainer
->
height
()
+
newWidgetHeight
);
}
else
{
mpContainer
->
resize
(
mpContainer
->
width
(),
mpContainer
->
height
()
-
newWidgetHeight
);
}
}
else
{
if
(
widgetAdded
){
mpContainer
->
resize
(
mpContainer
->
width
()
+
newWidgetWidth
,
mpContainer
->
height
());
}
else
{
mpContainer
->
resize
(
mpContainer
->
width
()
-
newWidgetWidth
,
mpContainer
->
height
());
}
}
}
void
UBWidgetList
::
resizeEvent
(
QResizeEvent
*
ev
)
{
if
(
ev
->
oldSize
().
width
()
>=
0
&&
ev
->
oldSize
().
height
()
>=
0
){
float
scale
;
if
(
eWidgetListOrientation_Vertical
==
mOrientation
){
scale
=
(
float
)
ev
->
size
().
width
()
/
(
float
)
ev
->
oldSize
().
width
();
updateAllWidgetsize
(
scale
);
mpContainer
->
resize
(
width
()
-
2
,
mpContainer
->
height
()
*
scale
);
}
else
{
scale
=
(
float
)
ev
->
size
().
height
()
/
(
float
)
ev
->
oldSize
().
height
();
updateAllWidgetsize
(
scale
);
mpContainer
->
resize
(
mpContainer
->
width
()
*
scale
,
height
()
-
2
);
}
}
}
void
UBWidgetList
::
updateAllWidgetsize
(
float
scale
)
{
for
(
int
i
=
0
;
i
<
mWidgets
.
size
();
i
++
){
mWidgets
.
at
(
i
)
->
resize
(
mWidgets
.
at
(
i
)
->
width
()
*
scale
,
mWidgets
.
at
(
i
)
->
height
()
*
scale
);
}
}
void
UBWidgetList
::
setMargin
(
int
margin
)
{
mMargin
=
margin
;
}
int
UBWidgetList
::
margin
()
{
return
mMargin
;
}
// TODO : - add onHover 'delete' button
// - add empty label
src/customWidgets/UBWidgetList.h
0 → 100644
View file @
df8a8a5e
#ifndef UBWIDGETLIST_H
#define UBWIDGETLIST_H
#include <QWidget>
#include <QScrollArea>
#include <QLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QVector>
#include <QLabel>
typedef
enum
{
eWidgetListOrientation_Vertical
,
eWidgetListOrientation_Horizontal
}
eWidgetListOrientation
;
class
UBWidgetList
:
public
QScrollArea
{
Q_OBJECT
public
:
UBWidgetList
(
QWidget
*
parent
=
0
,
eWidgetListOrientation
orientation
=
eWidgetListOrientation_Vertical
,
const
char
*
name
=
"UBWidgetList"
);
~
UBWidgetList
();
void
addWidget
(
QWidget
*
widget
);
void
removeWidget
(
QWidget
*
widget
);
void
setMargin
(
int
margin
);
int
margin
();
protected
:
void
resizeEvent
(
QResizeEvent
*
ev
);
private
:
void
updateSize
(
bool
widgetAdded
,
QWidget
*
widget
);
void
updateAllWidgetsize
(
float
scale
);
QLayout
*
mpLayout
;
QWidget
*
mpContainer
;
eWidgetListOrientation
mOrientation
;
int
mMargin
;
QVector
<
QWidget
*>
mWidgets
;
QLabel
*
mpEmptyLabel
;
};
#endif // UBWIDGETLIST_H
src/customWidgets/customWidgets.pri
0 → 100644
View file @
df8a8a5e
HEADERS += src/customWidgets/UBWidgetList.h
SOURCES += src/customWidgets/UBWidgetList.cpp
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