Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
vite
Commits
10c85cad
Commit
10c85cad
authored
Feb 06, 2014
by
Mathieu Faverge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize add_line
parent
96eac179
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
109 deletions
+49
-109
src/interface/Settings_window.cpp
src/interface/Settings_window.cpp
+47
-97
src/interface/Settings_window.hpp
src/interface/Settings_window.hpp
+2
-12
No files found.
src/interface/Settings_window.cpp
View file @
10c85cad
...
...
@@ -208,39 +208,11 @@ void Settings_window::fill_table(const string &palette_name) {
for
(
it
=
colors_settings
.
begin
();
it
!=
colors_settings
.
end
();
++
it
)
{
add_state_line
(
states_table
,
row
,
it
->
first
,
it
->
second
,
p
->
is_visible
(
it
->
first
));
add_table_line
(
states_table
,
SLOT
(
state_color_changed
(
const
QColor
&
)),
row
,
it
->
first
,
it
->
second
,
p
->
is_visible
(
it
->
first
));
}
}
void
Settings_window
::
add_state_line
(
QTableWidget
*
table
,
int
&
row
,
string
st_name
,
Color
*
c
,
bool
checked
)
{
/* Name */
QTableWidgetItem
*
name
=
new
QTableWidgetItem
(
st_name
.
c_str
());
name
->
setFlags
(
Qt
::
ItemIsEnabled
);
/* Color */
QtColorPicker
*
color_widget
=
new
QtColorPicker
();
color_widget
->
setStandardColors
();
if
(
c
)
{
color_widget
->
setCurrentColor
(
QColor
(
c
->
get_red
()
*
255
,
c
->
get_green
()
*
255
,
c
->
get_blue
()
*
255
));
}
else
{
// \todo check the default color value -> put this in Palette as static member
color_widget
->
setCurrentColor
(
QColor
(
0
,
244
,
222
));
}
color_widget
->
setColorDialogEnabled
(
true
);
connect
(
color_widget
,
SIGNAL
(
colorChanged
(
const
QColor
&
)),
this
,
SLOT
(
state_color_changed
(
const
QColor
&
)));
/* Visible */
QCheckBox
*
cb
=
new
QCheckBox
();
cb
->
setChecked
(
checked
);
table
->
insertRow
(
row
);
table
->
setItem
(
row
,
0
,
name
);
table
->
setCellWidget
(
row
,
1
,
color_widget
);
table
->
setCellWidget
(
row
,
2
,
cb
);
row
++
;
}
void
Settings_window
::
on_palette_list_currentIndexChanged
(
const
QString
&
text
)
{
_changed
=
true
;
fill_table
(
text
.
toStdString
());
...
...
@@ -350,7 +322,8 @@ void Settings_window::on_reload_states_btn_clicked(){
for
(
map
<
string
,
Color
*>::
iterator
it
=
colors
.
begin
()
;
it
!=
colors
.
end
()
;
++
it
)
{
add_state_line
(
states_table
,
row
,
(
*
it
).
first
.
c_str
(),
(
*
it
).
second
,
true
);
add_table_line
(
states_table
,
SLOT
(
state_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
.
c_str
(),
(
*
it
).
second
,
true
);
}
}
...
...
@@ -442,6 +415,37 @@ void Settings_window::link_types_color_changed(const QColor &qc) {
color_changed
(
"link_types"
,
link_types_table
,
qc
);
}
void
Settings_window
::
add_table_line
(
QTableWidget
*
table
,
const
char
*
slot
,
int
&
row
,
std
::
string
st_name
,
Color
*
c
,
bool
checked
)
{
/* Name */
QTableWidgetItem
*
name
=
new
QTableWidgetItem
(
st_name
.
c_str
());
name
->
setFlags
(
Qt
::
ItemIsEnabled
);
/* Color */
QtColorPicker
*
color_widget
=
new
QtColorPicker
();
color_widget
->
setStandardColors
();
if
(
c
)
{
color_widget
->
setCurrentColor
(
QColor
(
c
->
get_red
()
*
255
,
c
->
get_green
()
*
255
,
c
->
get_blue
()
*
255
));
}
else
{
// \todo check the default color value -> put this in Palette as static member
color_widget
->
setCurrentColor
(
QColor
(
255
,
255
,
255
));
}
color_widget
->
setColorDialogEnabled
(
false
);
connect
(
color_widget
,
SIGNAL
(
colorChanged
(
const
QColor
&
)),
this
,
slot
);
/* Visible */
QCheckBox
*
cb
=
new
QCheckBox
();
cb
->
setChecked
(
checked
);
table
->
insertRow
(
row
);
table
->
setItem
(
row
,
0
,
name
);
table
->
setCellWidget
(
row
,
1
,
color_widget
);
table
->
setCellWidget
(
row
,
2
,
cb
);
row
++
;
}
/*************************/
/****** Types tab. ******/
/*************************/
...
...
@@ -475,7 +479,8 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
color
=
(
Color
*
)((
*
it
).
second
->
get_extra_fields
()
->
find
(
string
(
"Color"
))
->
second
);
}
add_event_type_line
(
event_types_table
,
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
add_table_line
(
event_types_table
,
SLOT
(
event_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
}
}
else
{
// Look for the state/color pairs in Session.
...
...
@@ -483,43 +488,14 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
for
(
map
<
string
,
Color
*>::
iterator
it
=
colors
.
begin
()
;
it
!=
colors
.
end
()
;
++
it
)
{
add_event_type_line
(
event_types_table
,
row
,
(
*
it
).
first
,
(
*
it
).
second
,
p
->
is_visible
((
*
it
).
first
));
add_table_line
(
event_types_table
,
SLOT
(
event_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
,
(
*
it
).
second
,
p
->
is_visible
((
*
it
).
first
));
}
}
}
void
Settings_window
::
add_event_type_line
(
QTableWidget
*
table
,
int
&
row
,
std
::
string
st_name
,
Color
*
c
,
bool
checked
)
{
/* Name */
QTableWidgetItem
*
name
=
new
QTableWidgetItem
(
st_name
.
c_str
());
name
->
setFlags
(
Qt
::
ItemIsEnabled
);
/* Color */
QtColorPicker
*
color_widget
=
new
QtColorPicker
();
color_widget
->
setStandardColors
();
if
(
c
)
{
color_widget
->
setCurrentColor
(
QColor
(
c
->
get_red
()
*
255
,
c
->
get_green
()
*
255
,
c
->
get_blue
()
*
255
));
}
else
{
// \todo check the default color value -> put this in Palette as static member
color_widget
->
setCurrentColor
(
QColor
(
255
,
255
,
255
));
}
color_widget
->
setColorDialogEnabled
(
false
);
connect
(
color_widget
,
SIGNAL
(
colorChanged
(
const
QColor
&
)),
this
,
SLOT
(
event_types_color_changed
(
const
QColor
&
)));
/* Visible */
QCheckBox
*
cb
=
new
QCheckBox
();
cb
->
setChecked
(
checked
);
table
->
insertRow
(
row
);
table
->
setItem
(
row
,
0
,
name
);
table
->
setCellWidget
(
row
,
1
,
color_widget
);
table
->
setCellWidget
(
row
,
2
,
cb
);
row
++
;
}
void
Settings_window
::
fill_link_types_table
(
const
string
&
palette_name
)
{
Session
&
S
=
Session
::
getSession
();
...
...
@@ -549,7 +525,8 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
}
add_link_type_line
(
link_types_table
,
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
add_table_line
(
link_types_table
,
SLOT
(
link_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
}
}
...
...
@@ -558,7 +535,8 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
for
(
map
<
string
,
Color
*>::
iterator
it
=
colors
.
begin
()
;
it
!=
colors
.
end
()
;
++
it
)
{
add_link_type_line
(
link_types_table
,
row
,
(
*
it
).
first
,
(
*
it
).
second
,
p
->
is_visible
((
*
it
).
first
));
add_table_line
(
link_types_table
,
SLOT
(
link_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
,
(
*
it
).
second
,
p
->
is_visible
((
*
it
).
first
));
}
}
...
...
@@ -566,36 +544,6 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
}
void
Settings_window
::
add_link_type_line
(
QTableWidget
*
table
,
int
&
row
,
string
st_name
,
Color
*
c
,
bool
checked
)
{
/* Name */
QTableWidgetItem
*
name
=
new
QTableWidgetItem
(
st_name
.
c_str
());
name
->
setFlags
(
Qt
::
ItemIsEnabled
);
/* Color */
QtColorPicker
*
color_widget
=
new
QtColorPicker
();
color_widget
->
setStandardColors
();
if
(
c
)
{
color_widget
->
setCurrentColor
(
QColor
(
c
->
get_red
()
*
255
,
c
->
get_green
()
*
255
,
c
->
get_blue
()
*
255
));
}
else
{
// \todo check the default color value -> put this in Palette as static member
color_widget
->
setCurrentColor
(
QColor
(
255
,
255
,
255
));
}
color_widget
->
setColorDialogEnabled
(
false
);
connect
(
color_widget
,
SIGNAL
(
colorChanged
(
const
QColor
&
)),
this
,
SLOT
(
link_types_color_changed
(
const
QColor
&
)));
/* Visible */
QCheckBox
*
cb
=
new
QCheckBox
();
cb
->
setChecked
(
checked
);
table
->
insertRow
(
row
);
table
->
setItem
(
row
,
0
,
name
);
table
->
setCellWidget
(
row
,
1
,
color_widget
);
table
->
setCellWidget
(
row
,
2
,
cb
);
row
++
;
}
void
Settings_window
::
on_event_types_palette_list_currentIndexChanged
(
const
QString
&
text
)
{
_changed
=
true
;
fill_event_types_table
(
text
.
toStdString
());
...
...
@@ -631,7 +579,8 @@ void Settings_window::on_reload_link_types_palette_btn_clicked() {
}
add_link_type_line
(
link_types_table
,
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
add_table_line
(
link_types_table
,
SLOT
(
link_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
}
}
...
...
@@ -661,7 +610,8 @@ void Settings_window::on_reload_event_types_palette_btn_clicked() {
}
add_event_type_line
(
event_types_table
,
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
add_table_line
(
event_types_table
,
SLOT
(
event_types_color_changed
(
const
QColor
&
)),
row
,
(
*
it
).
first
.
to_string
(),
color
,
true
);
}
}
...
...
src/interface/Settings_window.hpp
View file @
10c85cad
...
...
@@ -81,12 +81,6 @@ private:
*/
void
fill_table
(
const
std
::
string
&
palette_name
);
/*!
* \brief Fill a new row to the state table.
* row is incremented at the end of the function.
*/
void
add_state_line
(
QTableWidget
*
table
,
int
&
row
,
std
::
string
st_name
,
Color
*
c
,
bool
checked
=
true
);
/*!
* \brief Reload the general tab.
*/
...
...
@@ -105,18 +99,14 @@ private:
/*!
* \brief add an event type to the table
*/
void
add_event_type_line
(
QTableWidget
*
table
,
int
&
,
std
::
string
,
Color
*
,
bool
);
void
add_table_line
(
QTableWidget
*
table
,
const
char
*
slot
,
int
&
,
std
::
string
,
Color
*
,
bool
);
/*!
* \brief Fill the link types table
*/
void
fill_link_types_table
(
const
std
::
string
&
text
);
/*!
* \brief add a link type to the table
*/
void
add_link_type_line
(
QTableWidget
*
table
,
int
&
,
std
::
string
,
Color
*
,
bool
);
/*!
* \brief add a palette to the list, for a given type
*/
...
...
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