WQtDSBWidget.cpp 2.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
//---------------------------------------------------------------------------
//
// 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 <string>

#include "WQtNumberEdit.h"

#include "WQtDSBWidget.h"

WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent  )
    : QWidget( parent ),
33 34
    m_name( name.c_str() ),
    m_layout()
35 36 37 38 39 40 41 42 43 44 45
{
}


WQtDSBWidget::~WQtDSBWidget()
{
}


QPushButton* WQtDSBWidget::addPushButton( std::string label )
{
46
    int row = m_layout.rowCount();
47 48 49 50

    QPushButton* button = new QPushButton();
    button->setText( QString( label.c_str() ) );

51
    m_layout.addWidget( button, row, 0 );
52

53
    setLayout( &m_layout );
54 55 56 57 58 59
    return button;
}


QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked )
{
60
    int row = m_layout.rowCount();
61 62 63 64 65
    QLabel* qlabel = new QLabel( label.c_str() );

    QCheckBox* checkBox = new QCheckBox();
    checkBox->setChecked( isChecked );

66 67
    m_layout.addWidget( qlabel, row, 0 );
    m_layout.addWidget( checkBox, row, 1 );
68

69
    setLayout( &m_layout );
70 71 72 73 74 75 76

    return checkBox;
}


QLineEdit* WQtDSBWidget::addLineEdit( std::string label, std::string text )
{
77
    int row = m_layout.rowCount();
78 79 80 81 82
    QLabel* qlabel = new QLabel( label.c_str() );

    QLineEdit* lineEdit = new QLineEdit();
    lineEdit->setText( QString( text.c_str() ) );

83 84
    m_layout.addWidget( qlabel, row, 0 );
    m_layout.addWidget( lineEdit, row, 1 );
85

86
    setLayout( &m_layout );
87 88 89 90 91

    return lineEdit;
}


92
WQtSliderWithEdit* WQtDSBWidget::addSliderInt( std::string label, int value, int min, int max )
93
{
94
    int row = m_layout.rowCount();
95 96
    QLabel* qlabel = new QLabel( label.c_str() );

97
    WQtSliderWithEdit* slider = new WQtSliderWithEdit();
98

99 100 101
    slider->setMin( min );
    slider->setMax( max );
    slider->setValue( value );
102

103 104
    m_layout.addWidget( qlabel, row, 0 );
    m_layout.addWidget( slider, row, 1 );
105

106
    setLayout( &m_layout );
107 108 109 110 111 112 113 114

    return slider;
}

QString WQtDSBWidget::getName()
{
    return m_name;
}