Commit 22b78f84 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents 85f2cc5a 8d183a94
......@@ -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
}
......
......@@ -32,6 +32,7 @@
*/
class WTerminalColor
{
friend class WTerminalColorTest;
public:
/**
......
//---------------------------------------------------------------------------
//
// 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
......@@ -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_layout.rowCount();
int row = m_controlLayout.rowCount();
QPushButton* button = new QPushButton();
button->setText( label );
m_layout.addWidget( button, row, 0 );
m_controlLayout.addWidget( button, row, 0 );
setLayout( &m_layout );
setLayout( &m_pageLayout );
return button;
}
WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked )
{
int row = m_layout.rowCount();
int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label );
WQtCheckBox* checkBox = new WQtCheckBox();
checkBox->setName( label );
checkBox->setChecked( isChecked );
m_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( checkBox, row, 1 );
m_controlLayout.addWidget( qlabel, row, 0 );
m_controlLayout.addWidget( checkBox, row, 1 );
setLayout( &m_layout );
setLayout( &m_pageLayout );
return checkBox;
}
......@@ -75,17 +77,17 @@ WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked )
WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text )
{
int row = m_layout.rowCount();
int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label );
WQtLineEdit* lineEdit = new WQtLineEdit();
lineEdit->setName( label );
lineEdit->setText( text );
m_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( lineEdit, row, 1 );
m_controlLayout.addWidget( qlabel, row, 0 );
m_controlLayout.addWidget( lineEdit, row, 1 );
setLayout( &m_layout );
setLayout( &m_pageLayout );
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_layout.rowCount();
int row = m_controlLayout.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_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( slider, row, 1 );
m_controlLayout.addWidget( qlabel, row, 0 );
m_controlLayout.addWidget( slider, row, 1 );
setLayout( &m_layout );
setLayout( &m_pageLayout );
return slider;
}
void WQtDSBWidget::addSpacer()
{
m_pageLayout.addStretch();
setLayout( &m_pageLayout );
}
QString WQtDSBWidget::getName()
{
return m_name;
......
......@@ -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
......@@ -184,6 +184,8 @@ void WQtDatasetBrowser::selectTreeItem()
}
}
}
tab1->addSpacer();
addTabWidgetContent( tab1 );
}
......
......@@ -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 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment