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
deb927b0
Commit
deb927b0
authored
Apr 09, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] - basic structure for automatically updating properties
parent
8bef783e
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
191 additions
and
27 deletions
+191
-27
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp
+12
-6
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp
+6
-2
src/gui/qt4/datasetbrowser/WPropertyColorWidget.h
src/gui/qt4/datasetbrowser/WPropertyColorWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp
+13
-8
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp
+6
-1
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp
+15
-9
src/gui/qt4/datasetbrowser/WPropertyIntWidget.h
src/gui/qt4/datasetbrowser/WPropertyIntWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp
src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp
+7
-1
src/gui/qt4/datasetbrowser/WPropertyStringWidget.h
src/gui/qt4/datasetbrowser/WPropertyStringWidget.h
+5
-0
src/gui/qt4/datasetbrowser/WPropertyWidget.h
src/gui/qt4/datasetbrowser/WPropertyWidget.h
+5
-0
src/gui/qt4/events/WEventTypes.h
src/gui/qt4/events/WEventTypes.h
+2
-0
src/gui/qt4/events/WPropertyChangedEvent.cpp
src/gui/qt4/events/WPropertyChangedEvent.cpp
+39
-0
src/gui/qt4/events/WPropertyChangedEvent.h
src/gui/qt4/events/WPropertyChangedEvent.h
+55
-0
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+1
-0
No files found.
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp
View file @
deb927b0
...
...
@@ -36,15 +36,14 @@ WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* prope
{
// initialize members
m_button
.
setCheckable
(
true
);
m_checkbox
.
setChecked
(
m_boolProperty
->
get
()
);
m_button
.
setChecked
(
m_boolProperty
->
get
()
);
update
();
// layout both against each other
m_button
.
setVisible
(
asButton
);
m_checkbox
.
setVisible
(
!
asButton
);
m_layout
.
addWidget
(
asButton
?
static_cast
<
QWidget
*
>
(
&
m_button
)
:
static_cast
<
QWidget
*
>
(
&
m_checkbox
)
);
m_button
.
setVisible
(
m_
asButton
);
m_checkbox
.
setVisible
(
!
m_
asButton
);
m_layout
.
addWidget
(
m_
asButton
?
static_cast
<
QWidget
*
>
(
&
m_button
)
:
static_cast
<
QWidget
*
>
(
&
m_checkbox
)
);
if
(
asButton
)
if
(
m_
asButton
)
{
m_layout
.
setContentsMargins
(
1
,
1
,
1
,
1
);
}
...
...
@@ -60,6 +59,13 @@ WPropertyBoolWidget::~WPropertyBoolWidget()
// cleanup
}
void
WPropertyBoolWidget
::
update
()
{
// simply set the new state
m_checkbox
.
setChecked
(
m_boolProperty
->
get
()
);
m_button
.
setChecked
(
m_boolProperty
->
get
()
);
}
QPushButton
*
WPropertyBoolWidget
::
getButton
()
{
return
&
m_button
;
...
...
src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h
View file @
deb927b0
...
...
@@ -66,6 +66,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The boolean property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp
View file @
deb927b0
...
...
@@ -47,8 +47,7 @@ WPropertyColorWidget::WPropertyColorWidget( WPropColor property, QGridLayout* pr
m_layout
.
addWidget
(
&
m_button
);
// set the initial values
m_button
.
setPalette
(
QPalette
(
toQColor
(
m_colorProperty
->
get
()
)
)
);
update
();
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_button
,
SIGNAL
(
released
()
),
this
,
SLOT
(
buttonReleased
()
)
);
...
...
@@ -59,6 +58,11 @@ WPropertyColorWidget::~WPropertyColorWidget()
// cleanup
}
void
WPropertyColorWidget
::
update
()
{
m_button
.
setPalette
(
QPalette
(
toQColor
(
m_colorProperty
->
get
()
)
)
);
}
QColor
WPropertyColorWidget
::
toQColor
(
WColor
color
)
{
QColor
tmp
;
...
...
src/gui/qt4/datasetbrowser/WPropertyColorWidget.h
View file @
deb927b0
...
...
@@ -56,6 +56,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The integer property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp
View file @
deb927b0
...
...
@@ -44,6 +44,19 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout*
// layout both against each other
m_layout
.
addWidget
(
&
m_spin
);
update
();
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_spin
,
SIGNAL
(
editingFinished
()
),
this
,
SLOT
(
spinChanged
()
)
);
}
WPropertyDoubleWidget
::~
WPropertyDoubleWidget
()
{
// cleanup
}
void
WPropertyDoubleWidget
::
update
()
{
// get the min constraint
WPVDouble
::
PropertyConstraintMin
minC
=
m_doubleProperty
->
getMin
();
double
min
=
0.0
;
...
...
@@ -84,14 +97,6 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout*
// set the initial values
m_spin
.
setValue
(
m_doubleProperty
->
get
()
);
m_spin
.
setSingleStep
(
(
max
-
min
)
/
100.0
);
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_spin
,
SIGNAL
(
editingFinished
()
),
this
,
SLOT
(
spinChanged
()
)
);
}
WPropertyDoubleWidget
::~
WPropertyDoubleWidget
()
{
// cleanup
}
void
WPropertyDoubleWidget
::
spinChanged
()
...
...
src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h
View file @
deb927b0
...
...
@@ -56,6 +56,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The integer property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp
View file @
deb927b0
...
...
@@ -51,7 +51,7 @@ WPropertyFilenameWidget::WPropertyFilenameWidget( WPropFilename property, QGridL
m_button
.
setSizePolicy
(
QSizePolicy
::
Ignored
,
QSizePolicy
::
Preferred
);
// set the initial values
m_button
.
setText
(
QString
::
fromStdString
(
m_fnProperty
->
get
().
file_string
()
)
);
update
(
);
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_button
,
SIGNAL
(
released
()
),
this
,
SLOT
(
buttonReleased
()
)
);
...
...
@@ -62,6 +62,11 @@ WPropertyFilenameWidget::~WPropertyFilenameWidget()
// cleanup
}
void
WPropertyFilenameWidget
::
update
()
{
m_button
.
setText
(
QString
::
fromStdString
(
m_fnProperty
->
get
().
file_string
()
)
);
}
void
WPropertyFilenameWidget
::
buttonReleased
()
{
QString
path
;
...
...
src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h
View file @
deb927b0
...
...
@@ -56,6 +56,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The filename property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp
View file @
deb927b0
...
...
@@ -50,6 +50,21 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
m_layout
.
addWidget
(
&
m_slider
);
m_layout
.
addWidget
(
&
m_edit
);
update
();
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_slider
,
SIGNAL
(
valueChanged
(
int
)
),
this
,
SLOT
(
sliderChanged
(
int
)
)
);
connect
(
&
m_edit
,
SIGNAL
(
returnPressed
()
),
this
,
SLOT
(
editChanged
()
)
);
connect
(
&
m_edit
,
SIGNAL
(
textEdited
(
const
QString
&
)
),
this
,
SLOT
(
textEdited
(
const
QString
&
)
)
);
}
WPropertyIntWidget
::~
WPropertyIntWidget
()
{
// cleanup
}
void
WPropertyIntWidget
::
update
()
{
// get the min constraint
WPVInt
::
PropertyConstraintMin
minC
=
m_intProperty
->
getMin
();
int
min
=
0
;
...
...
@@ -102,15 +117,6 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
m_edit
.
setText
(
QString
(
boost
::
lexical_cast
<
std
::
string
>
(
m_intProperty
->
get
()
).
c_str
()
)
);
m_slider
.
setValue
(
m_intProperty
->
get
()
);
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_slider
,
SIGNAL
(
valueChanged
(
int
)
),
this
,
SLOT
(
sliderChanged
(
int
)
)
);
connect
(
&
m_edit
,
SIGNAL
(
returnPressed
()
),
this
,
SLOT
(
editChanged
()
)
);
connect
(
&
m_edit
,
SIGNAL
(
textEdited
(
const
QString
&
)
),
this
,
SLOT
(
textEdited
(
const
QString
&
)
)
);
}
WPropertyIntWidget
::~
WPropertyIntWidget
()
{
// cleanup
}
void
WPropertyIntWidget
::
sliderChanged
(
int
value
)
...
...
src/gui/qt4/datasetbrowser/WPropertyIntWidget.h
View file @
deb927b0
...
...
@@ -57,6 +57,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The integer property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp
View file @
deb927b0
...
...
@@ -45,7 +45,7 @@ WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout*
m_layout
.
addWidget
(
&
m_edit
);
// set the initial values
m_edit
.
setText
(
QString
(
m_stringProperty
->
get
().
c_str
()
)
);
update
(
);
// connect the modification signal of the edit and slider with our callback
connect
(
&
m_edit
,
SIGNAL
(
returnPressed
()
),
this
,
SLOT
(
editChanged
()
)
);
...
...
@@ -57,6 +57,11 @@ WPropertyStringWidget::~WPropertyStringWidget()
// cleanup
}
void
WPropertyStringWidget
::
update
()
{
m_edit
.
setText
(
QString
(
m_stringProperty
->
get
().
c_str
()
)
);
}
void
WPropertyStringWidget
::
editChanged
()
{
std
::
string
value
=
m_edit
.
text
().
toStdString
();
...
...
@@ -71,3 +76,4 @@ void WPropertyStringWidget::textEdited( const QString& text )
invalidate
(
!
m_stringProperty
->
accept
(
value
)
);
}
src/gui/qt4/datasetbrowser/WPropertyStringWidget.h
View file @
deb927b0
...
...
@@ -57,6 +57,11 @@ public:
protected:
/**
* Called whenever the widget should update.
*/
virtual
void
update
();
/**
* The integer property represented by this widget.
*/
...
...
src/gui/qt4/datasetbrowser/WPropertyWidget.h
View file @
deb927b0
...
...
@@ -82,6 +82,11 @@ public:
protected:
/**
* Called whenever the widget should update itself.
*/
virtual
void
update
()
=
0
;
/**
* The property handled by the widget.
*/
...
...
src/gui/qt4/events/WEventTypes.h
View file @
deb927b0
...
...
@@ -48,6 +48,8 @@
// when a subject signals a newly registered data set
#define WQT_UPDATE_TEXTURE_SORTER_EVENT QEvent::User + 5
// when a property changes
#define WQT_PROPERTY_CHANGED_EVENT QEvent::User + 6
#endif // WEVENTTYPES_H
src/gui/qt4/events/WPropertyChangedEvent.cpp
0 → 100644
View file @
deb927b0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WEventTypes.h"
#include "WPropertyChangedEvent.h"
WPropertyChangedEvent
::
WPropertyChangedEvent
()
:
QEvent
(
static_cast
<
QEvent
::
Type
>
(
WQT_PROPERTY_CHANGED_EVENT
)
)
{
// initialize members
}
WPropertyChangedEvent
::~
WPropertyChangedEvent
()
{
// cleanup
}
src/gui/qt4/events/WPropertyChangedEvent.h
0 → 100644
View file @
deb927b0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYCHANGEDEVENT_H
#define WPROPERTYCHANGEDEVENT_H
#include <boost/shared_ptr.hpp>
#include <QtCore/QEvent>
/**
* Event signalling a new module has been associated with the root container in the kernel. Please note that it is possible that
* the module is already marked as "ready" while processing this event due to the multithreading.
*/
class
WPropertyChangedEvent
:
public
QEvent
{
public:
/**
* Creates a new event instance denoting that a property has changed.
*/
WPropertyChangedEvent
();
/**
* Destructor.
*/
virtual
~
WPropertyChangedEvent
();
protected:
private:
};
#endif // WPROPERTYCHANGEDEVENT_H
src/modules/template/WMTemplate.cpp
View file @
deb927b0
...
...
@@ -188,6 +188,7 @@ void WMTemplate::properties()
// You even can add one property multiple times to different groups:
m_group2
->
addProperty
(
m_aColor
);
m_group1a
->
addProperty
(
m_aDouble
);
m_group1a
->
addProperty
(
m_enableFeature
);
// How can the values of the properties be changed? You can take a look at moduleMain where this is shown. For short: m_anInteger->set( 2 )
// and m_anInteger->get().
...
...
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