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
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
22b78f84
Commit
22b78f84
authored
Dec 02, 2009
by
Mathias Goldau
Browse files
[MERGE]
parents
85f2cc5a
8d183a94
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
20 deletions
+143
-20
src/common/WTerminalColor.cpp
src/common/WTerminalColor.cpp
+4
-3
src/common/WTerminalColor.h
src/common/WTerminalColor.h
+1
-0
src/common/test/WTerminalColor_test.h
src/common/test/WTerminalColor_test.h
+101
-0
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
+24
-16
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
+9
-1
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
+2
-0
src/gui/qt4/datasetbrowser/WQtSliderWithEdit.cpp
src/gui/qt4/datasetbrowser/WQtSliderWithEdit.cpp
+2
-0
No files found.
src/common/WTerminalColor.cpp
View file @
22b78f84
...
...
@@ -81,9 +81,10 @@ void WTerminalColor::generateControlStrings()
m_colorString
=
ss
.
str
();
ss
.
clear
();
ss
<<
cStart
<<
"[0m"
;
m_colorResetString
=
ss
.
str
();
// build reset string
std
::
ostringstream
ss2
;
ss2
<<
cStart
<<
"[0m"
;
m_colorResetString
=
ss2
.
str
();
}
#endif
}
...
...
src/common/WTerminalColor.h
View file @
22b78f84
...
...
@@ -32,6 +32,7 @@
*/
class
WTerminalColor
{
friend
class
WTerminalColorTest
;
public:
/**
...
...
src/common/test/WTerminalColor_test.h
0 → 100644
View file @
22b78f84
//---------------------------------------------------------------------------
//
// 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 WTERMINALCOLOR_TEST_H
#define WTERMINALCOLOR_TEST_H
#include <string>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include <cxxtest/TestSuite.h>
#include "../WTerminalColor.h"
/**
* Test WTerminalColor. Just some simple test to verify the control strings.
*/
class
WTerminalColorTest
:
public
CxxTest
::
TestSuite
{
public:
/**
* An instantiation should never throw an exception.
*/
void
testInstantiation
(
void
)
{
TS_ASSERT_THROWS_NOTHING
(
WTerminalColor
c
()
);
TS_ASSERT_THROWS_NOTHING
(
WTerminalColor
(
WTerminalColor
::
Bold
,
WTerminalColor
::
FGRed
,
WTerminalColor
::
BGNone
)
);
}
/**
* Test control string generated by class.
*/
void
testColorControlString
(
void
)
{
WTerminalColor
c
;
TS_ASSERT_THROWS_NOTHING
(
c
=
WTerminalColor
(
WTerminalColor
::
Bold
,
WTerminalColor
::
FGRed
,
WTerminalColor
::
BGGreen
)
);
// generate an own control string
std
::
ostringstream
ss
;
#ifdef __linux__
char
cStart
=
0x1B
;
ss
<<
cStart
<<
"["
<<
1
<<
";"
<<
31
<<
";"
<<
42
<<
"m"
;
#endif
// compare them
TS_ASSERT
(
ss
.
str
()
==
c
.
m_colorString
);
}
/**
* Test control string (reset) generated by class.
*/
void
testColorResetControlString
(
void
)
{
WTerminalColor
c
;
TS_ASSERT_THROWS_NOTHING
(
c
=
WTerminalColor
(
WTerminalColor
::
Bold
,
WTerminalColor
::
FGRed
,
WTerminalColor
::
BGGreen
)
);
// generate an own control string
std
::
ostringstream
ss
;
#ifdef __linux__
char
cStart
=
0x1B
;
ss
<<
cStart
<<
"[0m"
;
#endif
// compare them
TS_ASSERT
(
ss
.
str
()
==
c
.
m_colorResetString
);
}
/**
* Test whether the class returns empty control strings when colors are disabled.
*/
void
testColorDisabled
(
void
)
{
WTerminalColor
c
;
TS_ASSERT_THROWS_NOTHING
(
c
=
WTerminalColor
(
WTerminalColor
::
Bold
,
WTerminalColor
::
FGRed
,
WTerminalColor
::
BGGreen
)
);
c
.
setEnabled
(
false
);
TS_ASSERT
(
c
.
m_colorResetString
==
""
);
TS_ASSERT
(
c
.
m_colorString
==
""
);
}
};
#endif // WTERMINALCOLOR_TEST_H
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
View file @
22b78f84
...
...
@@ -31,8 +31,10 @@
WQtDSBWidget
::
WQtDSBWidget
(
std
::
string
name
,
QWidget
*
parent
)
:
QWidget
(
parent
),
m_name
(
name
.
c_str
()
),
m_layout
()
m_controlLayout
(),
m_pageLayout
()
{
m_pageLayout
.
addLayout
(
&
m_controlLayout
);
}
...
...
@@ -43,31 +45,31 @@ WQtDSBWidget::~WQtDSBWidget()
QPushButton
*
WQtDSBWidget
::
addPushButton
(
QString
label
)
{
int
row
=
m_
l
ayout
.
rowCount
();
int
row
=
m_
controlL
ayout
.
rowCount
();
QPushButton
*
button
=
new
QPushButton
();
button
->
setText
(
label
);
m_
l
ayout
.
addWidget
(
button
,
row
,
0
);
m_
controlL
ayout
.
addWidget
(
button
,
row
,
0
);
setLayout
(
&
m_
l
ayout
);
setLayout
(
&
m_
pageL
ayout
);
return
button
;
}
WQtCheckBox
*
WQtDSBWidget
::
addCheckBox
(
QString
label
,
bool
isChecked
)
{
int
row
=
m_
l
ayout
.
rowCount
();
int
row
=
m_
controlL
ayout
.
rowCount
();
QLabel
*
qlabel
=
new
QLabel
(
label
);
WQtCheckBox
*
checkBox
=
new
WQtCheckBox
();
checkBox
->
setName
(
label
);
checkBox
->
setChecked
(
isChecked
);
m_
l
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
l
ayout
.
addWidget
(
checkBox
,
row
,
1
);
m_
controlL
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
controlL
ayout
.
addWidget
(
checkBox
,
row
,
1
);
setLayout
(
&
m_
l
ayout
);
setLayout
(
&
m_
pageL
ayout
);
return
checkBox
;
}
...
...
@@ -75,17 +77,17 @@ WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked )
WQtLineEdit
*
WQtDSBWidget
::
addLineEdit
(
QString
label
,
QString
text
)
{
int
row
=
m_
l
ayout
.
rowCount
();
int
row
=
m_
controlL
ayout
.
rowCount
();
QLabel
*
qlabel
=
new
QLabel
(
label
);
WQtLineEdit
*
lineEdit
=
new
WQtLineEdit
();
lineEdit
->
setName
(
label
);
lineEdit
->
setText
(
text
);
m_
l
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
l
ayout
.
addWidget
(
lineEdit
,
row
,
1
);
m_
controlL
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
controlL
ayout
.
addWidget
(
lineEdit
,
row
,
1
);
setLayout
(
&
m_
l
ayout
);
setLayout
(
&
m_
pageL
ayout
);
return
lineEdit
;
}
...
...
@@ -93,7 +95,7 @@ WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text )
WQtSliderWithEdit
*
WQtDSBWidget
::
addSliderInt
(
QString
label
,
int
value
,
int
min
,
int
max
)
{
int
row
=
m_
l
ayout
.
rowCount
();
int
row
=
m_
controlL
ayout
.
rowCount
();
QLabel
*
qlabel
=
new
QLabel
(
label
);
WQtSliderWithEdit
*
slider
=
new
WQtSliderWithEdit
(
label
);
...
...
@@ -102,14 +104,20 @@ WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min
slider
->
setMax
(
max
);
slider
->
setValue
(
value
);
m_
l
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
l
ayout
.
addWidget
(
slider
,
row
,
1
);
m_
controlL
ayout
.
addWidget
(
qlabel
,
row
,
0
);
m_
controlL
ayout
.
addWidget
(
slider
,
row
,
1
);
setLayout
(
&
m_
l
ayout
);
setLayout
(
&
m_
pageL
ayout
);
return
slider
;
}
void
WQtDSBWidget
::
addSpacer
()
{
m_pageLayout
.
addStretch
();
setLayout
(
&
m_pageLayout
);
}
QString
WQtDSBWidget
::
getName
()
{
return
m_name
;
...
...
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
View file @
22b78f84
...
...
@@ -77,6 +77,13 @@ public:
*/
WQtSliderWithEdit
*
addSliderInt
(
QString
label
,
int
value
=
0
,
int
min
=
0
,
int
max
=
100
);
/**
* helper function to add a spacer at the end
*/
void
addSpacer
();
/**
* getter for m_name
*/
...
...
@@ -85,7 +92,8 @@ public:
protected:
private:
QString
m_name
;
QGridLayout
m_layout
;
QGridLayout
m_controlLayout
;
QVBoxLayout
m_pageLayout
;
};
#endif // WQTDSBWIDGET_H
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
View file @
22b78f84
...
...
@@ -184,6 +184,8 @@ void WQtDatasetBrowser::selectTreeItem()
}
}
}
tab1
->
addSpacer
();
addTabWidgetContent
(
tab1
);
}
...
...
src/gui/qt4/datasetbrowser/WQtSliderWithEdit.cpp
View file @
22b78f84
...
...
@@ -73,6 +73,8 @@ void WQtSliderWithEdit::setMax( int max )
fmax
/=
10.0
;
}
m_edit
.
setMaxLength
(
length
);
m_edit
.
setMaximumWidth
(
m_edit
.
minimumSizeHint
().
width
()
*
length
/
2
);
m_edit
.
resize
(
m_edit
.
minimumSizeHint
().
width
()
*
length
/
2
,
m_edit
.
size
().
height
()
);
}
void
WQtSliderWithEdit
::
setValue
(
int
value
)
...
...
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