Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
699bd3f6
Commit
699bd3f6
authored
Aug 13, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] - selection property widgets and selection properties can now be modified while in use.
parent
70f74c5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
59 deletions
+76
-59
src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp
src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp
+68
-59
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+8
-0
No files found.
src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp
View file @
699bd3f6
...
...
@@ -74,26 +74,8 @@ WPropertySelectionWidget::WPropertySelectionWidget( WPropSelection property, QGr
// Lists are used if the selection of multiple elements is allowed
if
(
m_selectionProperty
->
countConstraint
(
PC_SELECTONLYONE
)
!=
0
)
{
// TODO(all): how to show the icon inside a combobox?
m_combo
=
new
QComboBox
(
&
m_parameterWidgets
);
// add all items from the selection set:
WItemSelector
s
=
m_selectionProperty
->
get
();
for
(
size_t
i
=
0
;
i
<
s
.
sizeAll
();
++
i
)
{
m_combo
->
addItem
(
QString
::
fromStdString
(
s
.
atAll
(
i
).
name
)
);
// if there is an icon -> show it
if
(
s
.
atAll
(
i
).
icon
)
{
// scale the pixmap to a maximum size if larger
QPixmap
pix
=
ensureSize
(
QPixmap
(
s
.
atAll
(
i
).
icon
)
);
// set icon
m_combo
->
setItemIcon
(
i
,
QIcon
(
pix
)
);
m_combo
->
setIconSize
(
QSize
(
pix
.
width
(),
pix
.
height
()
)
);
}
}
// layout
m_layout
.
addWidget
(
m_combo
,
0
,
0
);
...
...
@@ -105,46 +87,6 @@ WPropertySelectionWidget::WPropertySelectionWidget( WPropSelection property, QGr
m_list
=
new
QListWidget
(
&
m_parameterWidgets
);
m_list
->
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
// add all items from the selection set:
WItemSelector
s
=
m_selectionProperty
->
get
();
for
(
size_t
i
=
0
;
i
<
s
.
sizeAll
();
++
i
)
{
// Create a custom widget which contains the name and description
QWidget
*
widget
=
new
QWidget
(
m_list
);
QGridLayout
*
layoutWidget
=
new
QGridLayout
();
int
column
=
0
;
// if there is an icon -> show it
if
(
s
.
atAll
(
i
).
icon
)
{
QLabel
*
icon
=
new
QLabel
();
QSizePolicy
sizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Preferred
);
// <-- scale it down
icon
->
setSizePolicy
(
sizePolicy
);
icon
->
setPixmap
(
ensureSize
(
QPixmap
(
s
.
atAll
(
i
).
icon
)
)
);
layoutWidget
->
addWidget
(
icon
,
0
,
0
,
2
,
1
);
++
column
;
}
// Add Name and Description
layoutWidget
->
addWidget
(
new
QLabel
(
"<b>"
+
QString
::
fromStdString
(
s
.
atAll
(
i
).
name
)
+
"</b>"
),
0
,
column
);
// if there is no description -> no widget added to save space
if
(
!
s
.
atAll
(
i
).
description
.
empty
()
)
{
layoutWidget
->
addWidget
(
new
QLabel
(
QString
::
fromStdString
(
s
.
atAll
(
i
).
description
)
),
1
,
column
);
}
layoutWidget
->
setSizeConstraint
(
QLayout
::
SetMaximumSize
);
widget
->
setLayout
(
layoutWidget
);
// add Item
QListWidgetItem
*
item
=
new
QListWidgetItem
();
item
->
setSizeHint
(
widget
->
sizeHint
()
);
m_list
->
addItem
(
item
);
m_list
->
setItemWidget
(
item
,
widget
);
m_list
->
setMinimumHeight
(
150
);
}
// layout
m_layout
.
addWidget
(
m_list
,
0
,
0
);
...
...
@@ -195,6 +137,27 @@ void WPropertySelectionWidget::update()
//apply selection
if
(
m_combo
)
{
disconnect
(
m_combo
,
SIGNAL
(
currentIndexChanged
(
int
)
),
this
,
SLOT
(
comboSelectionChanged
(
int
)
)
);
m_combo
->
clear
();
// add all items from the selection set:
WItemSelector
s
=
m_selectionProperty
->
get
();
for
(
size_t
i
=
0
;
i
<
s
.
sizeAll
();
++
i
)
{
m_combo
->
addItem
(
QString
::
fromStdString
(
s
.
atAll
(
i
).
name
)
);
// if there is an icon -> show it
if
(
s
.
atAll
(
i
).
icon
)
{
// scale the pixmap to a maximum size if larger
QPixmap
pix
=
ensureSize
(
QPixmap
(
s
.
atAll
(
i
).
icon
)
);
// set icon
m_combo
->
setItemIcon
(
i
,
QIcon
(
pix
)
);
m_combo
->
setIconSize
(
QSize
(
pix
.
width
(),
pix
.
height
()
)
);
}
}
// mark the currently selected item. Just take care that there might be no item selected.
if
(
s
.
size
()
==
0
)
{
...
...
@@ -205,17 +168,63 @@ void WPropertySelectionWidget::update()
// as there is the SELECTONLYONE constraint -> if something is selected, it always is the first one
m_combo
->
setCurrentIndex
(
s
.
getItemIndexOfSelected
(
0
)
);
}
connect
(
m_combo
,
SIGNAL
(
currentIndexChanged
(
int
)
),
this
,
SLOT
(
comboSelectionChanged
(
int
)
)
);
}
else
{
disconnect
(
m_list
,
SIGNAL
(
itemSelectionChanged
()
),
this
,
SLOT
(
listSelectionChanged
()
)
);
m_list
->
clearSelection
();
m_list
->
clear
();
//
select all items
//
add all items from the selection set:
WItemSelector
s
=
m_selectionProperty
->
get
();
for
(
size_t
i
=
0
;
i
<
s
.
sizeAll
();
++
i
)
{
// Create a custom widget which contains the name and description
QWidget
*
widget
=
new
QWidget
(
m_list
);
QGridLayout
*
layoutWidget
=
new
QGridLayout
();
int
column
=
0
;
// if there is an icon -> show it
if
(
s
.
atAll
(
i
).
icon
)
{
QLabel
*
icon
=
new
QLabel
();
QSizePolicy
sizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Preferred
);
// <-- scale it down
icon
->
setSizePolicy
(
sizePolicy
);
icon
->
setPixmap
(
ensureSize
(
QPixmap
(
s
.
atAll
(
i
).
icon
)
)
);
layoutWidget
->
addWidget
(
icon
,
0
,
0
,
2
,
1
);
++
column
;
}
// Add Name and Description
layoutWidget
->
addWidget
(
new
QLabel
(
"<b>"
+
QString
::
fromStdString
(
s
.
atAll
(
i
).
name
)
+
"</b>"
),
0
,
column
);
// if there is no description -> no widget added to save space
if
(
!
s
.
atAll
(
i
).
description
.
empty
()
)
{
layoutWidget
->
addWidget
(
new
QLabel
(
QString
::
fromStdString
(
s
.
atAll
(
i
).
description
)
),
1
,
column
);
}
layoutWidget
->
setSizeConstraint
(
QLayout
::
SetMaximumSize
);
widget
->
setLayout
(
layoutWidget
);
// add Item
QListWidgetItem
*
item
=
new
QListWidgetItem
();
item
->
setSizeHint
(
widget
->
sizeHint
()
);
m_list
->
addItem
(
item
);
m_list
->
setItemWidget
(
item
,
widget
);
m_list
->
setMinimumHeight
(
150
);
}
// select all items
for
(
size_t
i
=
0
;
i
<
s
.
size
();
++
i
)
{
m_list
->
item
(
s
.
getItemIndexOfSelected
(
i
)
)
->
setSelected
(
true
);
}
connect
(
m_list
,
SIGNAL
(
itemSelectionChanged
()
),
this
,
SLOT
(
listSelectionChanged
()
)
);
}
m_update
=
false
;
...
...
src/modules/template/WMTemplate.cpp
View file @
699bd3f6
...
...
@@ -565,6 +565,14 @@ void WMTemplate::moduleMain()
// Now that the trigger has the state "triggered", a time consuming operation can be done here.
debugLog
()
<<
"User triggered an important and time consuming operation."
;
// We can exchange the list used for selection properties. This of course invalidates the current user selection. You should avoid
// changing this too often and too fast as it might confuse the user.
boost
::
shared_ptr
<
WItemSelection
>
possibleSelections
=
boost
::
shared_ptr
<
WItemSelection
>
(
new
WItemSelection
()
);
possibleSelections
->
addItem
(
"Beer2"
,
"Cold and fresh."
,
template_bier_xpm
);
// NOTE: you can add XPM images here.
possibleSelections
->
addItem
(
"Steaks2"
,
"Medium please."
,
template_steak_xpm
);
possibleSelections
->
addItem
(
"Sausages2"
,
"With Sauerkraut."
,
template_wurst_xpm
);
m_aSingleSelection
->
set
(
possibleSelections
->
getSelectorFirst
()
);
// Update the output property
m_aTriggerOutput
->
set
(
WPVBaseTypes
::
PV_TRIGGER_TRIGGERED
);
...
...
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