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
114e16c3
Commit
114e16c3
authored
Jul 30, 2012
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE
#198
] min max can only be changed in the property-given interval
parent
3dc6aafc
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
750 additions
and
204 deletions
+750
-204
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.cpp
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.cpp
+60
-78
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.h
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.h
+23
-22
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
+78
-88
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
+47
-16
src/qt4gui/qt4/guiElements/WQtIntervalEdit.cpp
src/qt4gui/qt4/guiElements/WQtIntervalEdit.cpp
+86
-0
src/qt4gui/qt4/guiElements/WQtIntervalEdit.h
src/qt4gui/qt4/guiElements/WQtIntervalEdit.h
+456
-0
No files found.
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.cpp
View file @
114e16c3
...
...
@@ -25,62 +25,54 @@
#include <cmath>
#include <limits>
#include <sstream>
#include <iostream>
#include <string>
#include <QtGui/QInputDialog>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
#include "../guiElements/WQtIntervalEdit.h"
#include "core/common/WLogger.h"
#include "core/common/WPropertyVariable.h"
#include "WPropertyDoubleWidget.h"
#include "WPropertyDoubleWidget.moc"
const
int
WPropertyDoubleWidget
::
SliderResolution
=
10000
;
WPropertyDoubleWidget
::
WPropertyDoubleWidget
(
WPropDouble
property
,
QGridLayout
*
propertyGrid
,
QWidget
*
parent
)
:
WPropertyWidget
(
property
,
propertyGrid
,
parent
),
m_
double
Property
(
property
),
m_
integral
Property
(
property
),
m_slider
(
Qt
::
Horizontal
,
&
m_parameterWidgets
),
m_edit
(
&
m_parameterWidgets
),
m_minButton
(
&
m_parameterWidgets
),
m_maxButton
(
&
m_parameterWidgets
),
m_layout
(
&
m_parameterWidgets
),
m_layout
(),
m_vLayout
(
&
m_parameterWidgets
),
m_asText
(
&
m_informationWidgets
),
m_infoLayout
(
&
m_informationWidgets
)
m_infoLayout
(
&
m_informationWidgets
),
m_intervalEdit
(
&
m_parameterWidgets
)
{
// layout both against each other
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_minButton
);
m_minButton
.
setToolTip
(
"Set minimum of slider.
\n
Be aware that strange values can cause errors."
);
m_minButton
.
setMinimumWidth
(
5
);
m_minButton
.
setMaximumWidth
(
5
);
}
else
{
m_minButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_slider
);
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_maxButton
);
m_maxButton
.
setToolTip
(
"Set maximum of slider.
\n
Be aware that strange values can cause errors."
);
m_maxButton
.
setMinimumWidth
(
5
);
m_maxButton
.
setMaximumWidth
(
5
);
}
else
{
m_maxButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_edit
);
m_layout
.
setMargin
(
WGLOBAL_MARGIN
);
m_layout
.
setSpacing
(
WGLOBAL_SPACING
);
m_vLayout
.
setMargin
(
WGLOBAL_MARGIN
);
m_vLayout
.
setSpacing
(
WGLOBAL_SPACING
);
// add the m_layout to the vlayout
QWidget
*
layoutContainer
=
new
QWidget
();
layoutContainer
->
setLayout
(
&
m_layout
);
m_vLayout
.
addWidget
(
layoutContainer
);
// configure the interval edit
m_vLayout
.
addWidget
(
&
m_intervalEdit
);
if
(
!
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_intervalEdit
.
hide
();
}
m_parameterWidgets
.
setLayout
(
&
m_
l
ayout
);
m_parameterWidgets
.
setLayout
(
&
m_
vL
ayout
);
// Information Output ( Property Purpose = PV_PURPOSE_INFORMATION )
m_infoLayout
.
addWidget
(
&
m_asText
);
...
...
@@ -96,8 +88,8 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout*
connect
(
&
m_slider
,
SIGNAL
(
valueChanged
(
int
)
),
this
,
SLOT
(
sliderChanged
(
int
)
)
);
connect
(
&
m_edit
,
SIGNAL
(
editingFinished
()
),
this
,
SLOT
(
editChanged
()
)
);
connect
(
&
m_edit
,
SIGNAL
(
textEdited
(
const
QString
&
)
),
this
,
SLOT
(
textEdited
(
const
QString
&
)
)
);
connect
(
&
m_
maxButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
maxPress
ed
()
)
);
connect
(
&
m_
minButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
minPress
ed
()
)
);
connect
(
&
m_
intervalEdit
,
SIGNAL
(
minimumChanged
()
),
this
,
SLOT
(
minMaxUpdat
ed
()
)
);
connect
(
&
m_
intervalEdit
,
SIGNAL
(
maximumChanged
()
),
this
,
SLOT
(
minMaxUpdat
ed
()
)
);
}
WPropertyDoubleWidget
::~
WPropertyDoubleWidget
()
...
...
@@ -110,52 +102,60 @@ void WPropertyDoubleWidget::update()
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// NO, it doesn't work on Mac OS X: You won't be able to any digits in it!, So I reset it to default which should work on other platforms too
QString
valStr
=
QString
::
number
(
m_
double
Property
->
get
()
);
QString
valStr
=
QString
::
number
(
m_
integral
Property
->
get
()
);
m_edit
.
setText
(
valStr
);
// get the min constraint
WPVDouble
::
PropertyConstraintMin
minC
=
m_
double
Property
->
getMin
();
WPVDouble
::
PropertyConstraintMax
maxC
=
m_
double
Property
->
getMax
();
WPVDouble
::
PropertyConstraintMin
minC
=
m_
integral
Property
->
getMin
();
WPVDouble
::
PropertyConstraintMax
maxC
=
m_
integral
Property
->
getMax
();
bool
minMaxConstrained
=
minC
&&
maxC
;
if
(
minMaxConstrained
)
{
// setup the slider
m_slider
.
setMinimum
(
0
);
m_slider
.
setMaximum
(
100
);
m_min
=
minC
->
getMin
();
m_max
=
maxC
->
getMax
();
m_slider
.
setMaximum
(
SliderResolution
);
// update the interval edit too
m_intervalEdit
.
setAllowedMin
(
minC
->
getMin
()
);
m_intervalEdit
.
setAllowedMax
(
maxC
->
getMax
()
);
m_min
=
m_intervalEdit
.
getMin
();
m_max
=
m_intervalEdit
.
getMax
();
// updating the interval edit causes the proper values to be set in m_min and m_max
m_slider
.
setHidden
(
false
);
m_slider
.
setValue
(
toPercent
(
m_doubleProperty
->
get
()
)
);
m_intervalEdit
.
setHidden
(
false
);
m_slider
.
setValue
(
toSliderValue
(
m_integralProperty
->
get
()
)
);
}
else
{
m_slider
.
setHidden
(
true
);
m_intervalEdit
.
setHidden
(
true
);
}
// do not forget to update the label
m_asText
.
setText
(
valStr
);
}
int
WPropertyDoubleWidget
::
to
Percent
(
double
value
)
int
WPropertyDoubleWidget
::
to
SliderValue
(
double
value
)
{
return
100.0
*
(
(
value
-
m_min
)
/
(
m_max
-
m_min
)
);
int
perc
=
static_cast
<
double
>
(
SliderResolution
)
*
(
(
value
-
m_min
)
/
(
m_max
-
m_min
)
);
return
std
::
min
(
std
::
max
(
perc
,
0
),
SliderResolution
);
}
double
WPropertyDoubleWidget
::
from
Percent
(
int
perc
)
double
WPropertyDoubleWidget
::
from
SliderValue
(
int
perc
)
{
return
(
static_cast
<
double
>
(
perc
)
/
100.0
)
*
(
m_max
-
m_min
)
+
m_min
;
return
(
static_cast
<
double
>
(
perc
)
/
static_cast
<
double
>
(
SliderResolution
)
)
*
(
m_max
-
m_min
)
+
m_min
;
}
void
WPropertyDoubleWidget
::
sliderChanged
(
int
value
)
{
if
(
!
m_slider
.
isHidden
()
&&
to
Percent
(
m_double
Property
->
get
()
)
!=
value
)
if
(
!
m_slider
.
isHidden
()
&&
to
SliderValue
(
m_integral
Property
->
get
()
)
!=
value
)
{
// set to the property
invalidate
(
!
m_
doubleProperty
->
set
(
fromPercent
(
value
)
)
);
// NOTE: set automatically checks the validity of the value
invalidate
(
!
m_
integralProperty
->
set
(
fromSliderValue
(
value
)
)
);
// NOTE: set automatically checks the validity of the value
// set the value in the line edit
m_edit
.
setText
(
QString
::
number
(
m_
double
Property
->
get
()
)
);
m_edit
.
setText
(
QString
::
number
(
m_
integral
Property
->
get
()
)
);
}
}
...
...
@@ -171,10 +171,10 @@ void WPropertyDoubleWidget::editChanged()
return
;
}
// set to the property
invalidate
(
!
m_
double
Property
->
set
(
value
)
);
// NOTE: set automatically checks the validity of the value
invalidate
(
!
m_
integral
Property
->
set
(
value
)
);
// NOTE: set automatically checks the validity of the value
// update slider
m_slider
.
setValue
(
to
Percent
(
value
)
);
m_slider
.
setValue
(
to
SliderValue
(
value
)
);
}
void
WPropertyDoubleWidget
::
textEdited
(
const
QString
&
text
)
...
...
@@ -190,41 +190,23 @@ void WPropertyDoubleWidget::textEdited( const QString& text )
}
// simply check validity
invalidate
(
!
m_
double
Property
->
accept
(
value
)
);
invalidate
(
!
m_
integral
Property
->
accept
(
value
)
);
}
void
WPropertyDoubleWidget
::
maxPressed
()
void
WPropertyDoubleWidget
::
minMaxUpdated
()
{
bool
ok
;
double
newMax
=
QInputDialog
::
getDouble
(
this
,
"Setting Maximum of Slider"
,
"Maximum"
,
m_max
,
m_min
,
std
::
numeric_limits
<
double
>::
max
(),
18
,
&
ok
);
if
(
ok
)
m_min
=
m_intervalEdit
.
getMin
()
;
m_max
=
m_intervalEdit
.
getMax
();
if
(
m_min
>
m_integralProperty
->
get
()
)
{
m_max
=
newMax
;
if
(
m_doubleProperty
->
get
()
>
newMax
)
{
m_doubleProperty
->
set
(
newMax
);
m_slider
.
setValue
(
toPercent
(
newMax
)
);
}
m_doubleProperty
->
setMax
(
newMax
);
m_integralProperty
->
set
(
m_min
);
}
}
void
WPropertyDoubleWidget
::
minPressed
()
{
bool
ok
;
double
newMin
=
QInputDialog
::
getDouble
(
this
,
"Setting Minimum of Slider"
,
"Minimum"
,
m_min
,
-
std
::
numeric_limits
<
double
>::
max
(),
m_max
,
18
,
&
ok
);
if
(
ok
)
if
(
m_max
<
m_integralProperty
->
get
()
)
{
m_min
=
newMin
;
if
(
m_doubleProperty
->
get
()
<
newMin
)
{
m_doubleProperty
->
set
(
newMin
);
m_slider
.
setValue
(
toPercent
(
newMin
)
);
}
m_doubleProperty
->
setMin
(
newMin
);
m_integralProperty
->
set
(
m_max
);
}
m_slider
.
setValue
(
toSliderValue
(
m_integralProperty
->
get
()
)
);
}
src/qt4gui/qt4/controlPanel/WPropertyDoubleWidget.h
View file @
114e16c3
...
...
@@ -32,6 +32,7 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include "../guiElements/WQtIntervalEdit.h"
#include "WPropertyWidget.h"
/**
...
...
@@ -62,9 +63,9 @@ protected:
virtual
void
update
();
/**
* The
integer
property represented by this widget.
* The property represented by this widget.
*/
WPropDouble
m_
double
Property
;
WPropDouble
m_
integral
Property
;
/**
* The slider allowing modification of the integer value
...
...
@@ -77,37 +78,32 @@ protected:
QLineEdit
m_edit
;
/**
* The button bringing up the dialog for modifying min of the slider
*/
QToolButton
m_minButton
;
/**
* The button bringing up the dialog for modifying max of the slider
* Layout used to position the label and the checkbox
*/
Q
ToolButton
m_maxButton
;
Q
HBoxLayout
m_layout
;
/**
* Layout used to
position the label and the checkbox
* Layout used to
combine the property widgets with the WQtIntervalEdit.
*/
Q
HBoxLayout
m_l
ayout
;
Q
VBoxLayout
m_vL
ayout
;
/**
* Converts a given value to a
percentag
e between m_min and m_max.
* Converts a given value to a
slider valu
e between m_min and m_max.
*
* \param value the value.
*
* \return the percentage.
*/
int
to
Percent
(
double
value
);
int
to
SliderValue
(
double
value
);
/**
* Converts the given
percentag
e to the real double value using m_min and m_max.
* Converts the given
slider valu
e to the real double value using m_min and m_max.
*
* \param perc the percentage.
*
* \return the real double value.
*/
double
from
Percent
(
int
perc
);
double
from
SliderValue
(
int
perc
);
/**
* The current minimum value.
...
...
@@ -129,6 +125,16 @@ protected:
*/
QHBoxLayout
m_infoLayout
;
/**
* The edit for the interval.
*/
WQtIntervalEdit
<
double
,
double
>
m_intervalEdit
;
/**
* Resolution of the slider.
*/
const
static
int
SliderResolution
;
private:
public
slots
:
...
...
@@ -152,14 +158,9 @@ public slots:
void
textEdited
(
const
QString
&
text
);
/**
* Called when the maxMin button is pressed to open maxMinDialog.
*/
void
maxPressed
();
/**
* Called when the maxMin button is pressed to open maxMinDialog.
* Called whenever the interval edit changes.
*/
void
min
Press
ed
();
void
min
MaxUpdat
ed
();
};
#endif // WPROPERTYDOUBLEWIDGET_H
...
...
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
View file @
114e16c3
...
...
@@ -22,64 +22,57 @@
//
//---------------------------------------------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <sstream>
#include <iostream>
#include <string>
#include <QtGui/QInputDialog>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
#include "../guiElements/WQtIntervalEdit.h"
#include "core/common/WLogger.h"
#include "core/common/WPropertyVariable.h"
#include "WPropertyIntWidget.h"
#include "WPropertyIntWidget.moc"
const
int
WPropertyIntWidget
::
SliderResolution
=
10000
;
WPropertyIntWidget
::
WPropertyIntWidget
(
WPropInt
property
,
QGridLayout
*
propertyGrid
,
QWidget
*
parent
)
:
WPropertyWidget
(
property
,
propertyGrid
,
parent
),
m_intProperty
(
property
),
m_int
egral
Property
(
property
),
m_slider
(
Qt
::
Horizontal
,
&
m_parameterWidgets
),
m_edit
(
&
m_parameterWidgets
),
m_minButton
(
&
m_parameterWidgets
),
m_maxButton
(
&
m_parameterWidgets
),
m_layout
(
&
m_parameterWidgets
),
m_layout
(),
m_vLayout
(
&
m_parameterWidgets
),
m_asText
(
&
m_informationWidgets
),
m_infoLayout
(
&
m_informationWidgets
)
m_infoLayout
(
&
m_informationWidgets
),
m_intervalEdit
(
&
m_parameterWidgets
)
{
// layout both against each other
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_minButton
);
m_minButton
.
setToolTip
(
"Set minimum of slider.
\n
Be aware that strange values can cause errors."
);
m_minButton
.
setMinimumWidth
(
5
);
m_minButton
.
setMaximumWidth
(
5
);
}
else
{
m_minButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_slider
);
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_maxButton
);
m_maxButton
.
setToolTip
(
"Set maximum of slider.
\n
Be aware that strange values can cause errors."
);
m_maxButton
.
setMinimumWidth
(
5
);
m_maxButton
.
setMaximumWidth
(
5
);
}
else
{
m_maxButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_edit
);
m_layout
.
setMargin
(
WGLOBAL_MARGIN
);
m_layout
.
setSpacing
(
WGLOBAL_SPACING
);
m_parameterWidgets
.
setLayout
(
&
m_layout
);
m_vLayout
.
setMargin
(
WGLOBAL_MARGIN
);
m_vLayout
.
setSpacing
(
WGLOBAL_SPACING
);
// add the m_layout to the vlayout
QWidget
*
layoutContainer
=
new
QWidget
();
layoutContainer
->
setLayout
(
&
m_layout
);
m_vLayout
.
addWidget
(
layoutContainer
);
// configure the interval edit
m_vLayout
.
addWidget
(
&
m_intervalEdit
);
if
(
!
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_intervalEdit
.
hide
();
}
m_parameterWidgets
.
setLayout
(
&
m_vLayout
);
// Information Output ( Property Purpose = PV_PURPOSE_INFORMATION )
m_infoLayout
.
addWidget
(
&
m_asText
);
...
...
@@ -95,8 +88,8 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
connect
(
&
m_slider
,
SIGNAL
(
valueChanged
(
int
)
),
this
,
SLOT
(
sliderChanged
(
int
)
)
);
connect
(
&
m_edit
,
SIGNAL
(
editingFinished
()
),
this
,
SLOT
(
editChanged
()
)
);
connect
(
&
m_edit
,
SIGNAL
(
textEdited
(
const
QString
&
)
),
this
,
SLOT
(
textEdited
(
const
QString
&
)
)
);
connect
(
&
m_
maxButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
maxPress
ed
()
)
);
connect
(
&
m_
minButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
minPress
ed
()
)
);
connect
(
&
m_
intervalEdit
,
SIGNAL
(
minimumChanged
()
),
this
,
SLOT
(
minMaxUpdat
ed
()
)
);
connect
(
&
m_
intervalEdit
,
SIGNAL
(
maximumChanged
()
),
this
,
SLOT
(
minMaxUpdat
ed
()
)
);
}
WPropertyIntWidget
::~
WPropertyIntWidget
()
...
...
@@ -108,43 +101,61 @@ void WPropertyIntWidget::update()
{
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// Same as in WPropertyDouble.cpp: This does not work as expected on Mac OS X => reset to default
// set the initial values
QString
valStr
=
QString
::
number
(
m_intProperty
->
get
()
);
// NO, it doesn't work on Mac OS X: You won't be able to any digits in it!, So I reset it to default which should work on other platforms too
QString
valStr
=
QString
::
number
(
m_integralProperty
->
get
()
);
m_edit
.
setText
(
valStr
);
// get the min constraint
WPVInt
::
PropertyConstraintMin
minC
=
m_intProperty
->
getMin
();
WPVInt
::
PropertyConstraintMax
maxC
=
m_intProperty
->
getMax
();
// get the min constraint
WPVInt
::
PropertyConstraintMin
minC
=
m_int
egral
Property
->
getMin
();
WPVInt
::
PropertyConstraintMax
maxC
=
m_int
egral
Property
->
getMax
();
bool
minMaxConstrained
=
minC
&&
maxC
;
if
(
minMaxConstrained
)
{
m_slider
.
setHidden
(
false
);
m_slider
.
setMinimum
(
minC
->
getMin
()
);
m_slider
.
setMaximum
(
maxC
->
getMax
()
);
m_slider
.
setValue
(
m_intProperty
->
get
()
);
// setup the slider
m_slider
.
setMinimum
(
0
);
m_slider
.
setMaximum
(
SliderResolution
);
m_edit
.
setMaximumWidth
(
fontMetrics
().
width
(
QString
::
number
(
-
(
maxC
->
getMax
()
-
minC
->
getMin
()
)
)
)
+
5
);
// update the interval edit too
m_intervalEdit
.
setAllowedMin
(
minC
->
getMin
()
);
m_intervalEdit
.
setAllowedMax
(
maxC
->
getMax
()
);
m_min
=
m_intervalEdit
.
getMin
();
m_max
=
m_intervalEdit
.
getMax
();
// updating the interval edit causes the proper values to be set in m_min and m_max
m_slider
.
setHidden
(
false
);
m_intervalEdit
.
setHidden
(
false
);
m_slider
.
setValue
(
toSliderValue
(
m_integralProperty
->
get
()
)
);
}
else
{
m_slider
.
setHidden
(
true
);
m_intervalEdit
.
setHidden
(
true
);
}
// do not forget to update the label
m_asText
.
setText
(
valStr
);
}
int
WPropertyIntWidget
::
toSliderValue
(
double
value
)
{
int
perc
=
static_cast
<
double
>
(
SliderResolution
)
*
(
(
value
-
m_min
)
/
(
m_max
-
m_min
)
);
return
std
::
min
(
std
::
max
(
perc
,
0
),
SliderResolution
);
}
double
WPropertyIntWidget
::
fromSliderValue
(
int
perc
)
{
return
(
static_cast
<
double
>
(
perc
)
/
static_cast
<
double
>
(
SliderResolution
)
)
*
(
m_max
-
m_min
)
+
m_min
;
}
void
WPropertyIntWidget
::
sliderChanged
(
int
value
)
{
if
(
!
m_slider
.
isHidden
()
)
if
(
!
m_slider
.
isHidden
()
&&
toSliderValue
(
m_integralProperty
->
get
()
)
!=
value
)
{
// set the value in the line edit
m_edit
.
setText
(
QString
::
number
(
value
)
);
// set to the property
invalidate
(
!
m_intProperty
->
set
(
value
)
);
// NOTE: set automatically checks the validity of the value
invalidate
(
!
m_integralProperty
->
set
(
fromSliderValue
(
value
)
)
);
// NOTE: set automatically checks the validity of the value
// set the value in the line edit
m_edit
.
setText
(
QString
::
number
(
m_integralProperty
->
get
()
)
);
}
}
...
...
@@ -158,12 +169,11 @@ void WPropertyIntWidget::editChanged()
invalidate
();
return
;
}
// set to the property
invalidate
(
!
m_integralProperty
->
set
(
value
)
);
// NOTE: set automatically checks the validity of the value
// update slider
m_slider
.
setValue
(
value
);
// set to the property
invalidate
(
!
m_intProperty
->
set
(
value
)
);
// NOTE: set automatically checks the validity of the value
m_slider
.
setValue
(
toSliderValue
(
value
)
);
}
void
WPropertyIntWidget
::
textEdited
(
const
QString
&
text
)
...
...
@@ -178,43 +188,23 @@ void WPropertyIntWidget::textEdited( const QString& text )
}
// simply check validity
invalidate
(
!
m_intProperty
->
accept
(
value
)
);
invalidate
(
!
m_int
egral
Property
->
accept
(
value
)
);
}
void
WPropertyIntWidget
::
m
axPress
ed
()
void
WPropertyIntWidget
::
m
inMaxUpdat
ed
()
{
bool
ok
;
int
min
=
m_intProperty
->
getMin
()
->
getMin
();
int
max
=
m_intProperty
->
getMax
()
->
getMax
();
int
newMax
=
QInputDialog
::
getInt
(
this
,
"Setting Maximum of Slider"
,
"Maximum"
,
max
,
min
,
std
::
numeric_limits
<
int
>::
max
(),
1
,
&
ok
);
if
(
ok
)
m_min
=
m_intervalEdit
.
getMin
();
m_max
=
m_intervalEdit
.
getMax
();
if
(
m_min
>
m_integralProperty
->
get
()
)
{
if
(
m_intProperty
->
get
()
>
newMax
)
{
m_intProperty
->
set
(
newMax
);
m_slider
.
setValue
(
newMax
);
}
m_slider
.
setMaximum
(
newMax
);
m_intProperty
->
setMax
(
newMax
);
m_integralProperty
->
set
(
m_min
);
}
}
void
WPropertyIntWidget
::
minPressed
()
{
bool
ok
;
int
min
=
m_intProperty
->
getMin
()
->
getMin
();
int
max
=
m_intProperty
->
getMax
()
->
getMax
();
int
newMin
=
QInputDialog
::
getInt
(
this
,
"Setting Minimum of Slider"
,
"Minimum"
,
min
,
-
std
::
numeric_limits
<
int
>::
max
(),
max
,
1
,
&
ok
);
if
(
ok
)
if
(
m_max
<
m_integralProperty
->
get
()
)
{
if
(
m_intProperty
->
get
()
<
newMin
)
{
m_intProperty
->
set
(
newMin
);
m_slider
.
setValue
(
newMin
);
}
m_slider
.
setMinimum
(
newMin
);
m_intProperty
->
setMin
(
newMin
);
m_integralProperty
->
set
(
m_max
);
}
m_slider
.
setValue
(
toSliderValue
(
m_integralProperty
->
get
()
)
);
}
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
View file @
114e16c3
...
...
@@ -27,11 +27,12 @@
#include <string>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include "../guiElements/WQtIntervalEdit.h"
#include "WPropertyWidget.h"
/**
...
...
@@ -62,9 +63,9 @@ protected:
virtual
void
update
();
/**
* The
integer
property represented by this widget.
* The property represented by this widget.
*/
WPropInt
m_intProperty
;
WPropInt
m_int
egral
Property
;
/**
* The slider allowing modification of the integer value
...
...
@@ -77,19 +78,42 @@ protected:
QLineEdit
m_edit
;
/**
*
The button bringing up the dialog for modifying min of the slider
*
Layout used to position the label and the checkbox
*/
Q
ToolButton
m_minButton
;
Q
HBoxLayout
m_layout
;
/**
*
The button bringing