Commit 6099330e authored by schurade's avatar schurade
Browse files

[ADD] more work on the dataset browser

parent 06ba3fd0
# Package dependencies:
FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( Boost REQUIRED signals )
# Includes:
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
......@@ -12,15 +13,16 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtDatasetBrowser.h
WQtDSBWidget.h
WQtNumberEdit.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
)
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
FILE(GLOB GUI_QT4_SRC "*.cpp")
FILE(GLOB GUI_QT4_SRC "*.cpp" "datasetbrowser/*cpp" )
ADD_LIBRARY( guiqt4 SHARED ${GUI_QT4_SRC} ${GUI_QT4_MOC_SRCS} )
TARGET_LINK_LIBRARIES( guiqt4 common gui ge kernel ${QT_LIBS} )
TARGET_LINK_LIBRARIES( guiqt4 common gui ge kernel ${QT_LIBS} ${Boost_LIBRARIES})
......@@ -37,7 +37,7 @@
#include "WQtGLWidget.h"
#include "WQtRibbonMenu.h"
#include "WQtDatasetBrowser.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
#include "../../kernel/WKernel.h"
#include "../icons/logoIcon.xpm"
......@@ -91,6 +91,8 @@ void WMainWindow::setupGUI( QMainWindow *MainWindow )
m_datasetBrowser->addSubject( "subject1" );
m_datasetBrowser->addDataset( 0, "mr188_t1" );
m_datasetBrowser->addDataset( 0, "mr188_evec" );
m_datasetBrowser->addDataset( 0, "mr188_t2" );
m_datasetBrowser->addDataset( 0, "mr188_rgb" );
MainWindow->setWindowTitle( QApplication::translate( "MainWindow",
"OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
......
......@@ -30,9 +30,9 @@
WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent )
: QWidget( parent ),
m_name( name.c_str() )
m_name( name.c_str() ),
m_layout()
{
m_layout = new QGridLayout();
}
......@@ -43,30 +43,30 @@ WQtDSBWidget::~WQtDSBWidget()
QPushButton* WQtDSBWidget::addPushButton( std::string label )
{
int row = m_layout->rowCount();
int row = m_layout.rowCount();
QPushButton* button = new QPushButton();
button->setText( QString( label.c_str() ) );
m_layout->addWidget( button, row, 0 );
m_layout.addWidget( button, row, 0 );
setLayout( m_layout );
setLayout( &m_layout );
return button;
}
QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked )
{
int row = m_layout->rowCount();
int row = m_layout.rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QCheckBox* checkBox = new QCheckBox();
checkBox->setChecked( isChecked );
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( checkBox, row, 1 );
m_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( checkBox, row, 1 );
setLayout( m_layout );
setLayout( &m_layout );
return checkBox;
}
......@@ -74,41 +74,36 @@ QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked )
QLineEdit* WQtDSBWidget::addLineEdit( std::string label, std::string text )
{
int row = m_layout->rowCount();
int row = m_layout.rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QLineEdit* lineEdit = new QLineEdit();
lineEdit->setText( QString( text.c_str() ) );
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( lineEdit, row, 1 );
m_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( lineEdit, row, 1 );
setLayout( m_layout );
setLayout( &m_layout );
return lineEdit;
}
QSlider* WQtDSBWidget::addSliderInt( std::string label, int value, int min, int max )
WQtSliderWithEdit* WQtDSBWidget::addSliderInt( std::string label, int value, int min, int max )
{
int row = m_layout->rowCount();
int row = m_layout.rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QSlider* slider = new QSlider( Qt::Horizontal );
slider->setMinimum( min );
slider->setMaximum( max );
slider->setValue( value );
WQtNumberEdit* numberEdit = new WQtNumberEdit();
WQtSliderWithEdit* slider = new WQtSliderWithEdit();
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( slider, row, 1 );
m_layout->addWidget( numberEdit, row+1, 1 );
slider->setMin( min );
slider->setMax( max );
slider->setValue( value );
setLayout( m_layout );
m_layout.addWidget( qlabel, row, 0 );
m_layout.addWidget( slider, row, 1 );
connect( slider, SIGNAL( valueChanged( int ) ), numberEdit, SLOT( setInt( int ) ) );
connect( numberEdit, SIGNAL( signalNumber( int ) ), slider, SLOT( setValue( int ) ) );
setLayout( &m_layout );
return slider;
}
......
......@@ -36,6 +36,8 @@
#include <QtGui/QWidget>
#include <QtGui/QLCDNumber>
#include "WQtSliderWithEdit.h"
/**
* TODO(schurade): Document this!
*/
......@@ -72,7 +74,7 @@ public:
/**
*
*/
QSlider* addSliderInt( std::string label = "", int value = 0, int min = 0, int max = 100 );
WQtSliderWithEdit* addSliderInt( std::string label = "", int value = 0, int min = 0, int max = 100 );
/**
*
......@@ -81,8 +83,8 @@ public:
protected:
private:
QGridLayout* m_layout;
QString m_name;
QGridLayout m_layout;
};
#endif // WQTDSBWIDGET_H
......@@ -22,35 +22,54 @@
//
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <QtCore/QList>
#include "../../common/WLogger.h"
#include "../../../common/WLogger.h"
#include "WQtDatasetBrowser.h"
#include "WQtNumberEdit.h"
WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
: QDockWidget( parent )
{
m_panel = new QWidget( this );
m_treeWidget = new QTreeWidget( m_panel );
m_treeWidget = new WQtTreeWidget( m_panel );
m_treeWidget->setHeaderLabel( QString( "Dataset Browser" ) );
m_treeWidget->setDragEnabled( true );
m_treeWidget->viewport()->setAcceptDrops( true );
m_treeWidget->setDropIndicatorShown( true );
m_treeWidget->setDragDropMode( QAbstractItemView::InternalMove );
m_tabWidget = new QTabWidget( m_panel );
m_layout = new QVBoxLayout();
QHBoxLayout* buttonLayout = new QHBoxLayout();
m_downButton = new QPushButton();
m_downButton->setText( QString( "down" ) );
m_upButton = new QPushButton();
m_upButton->setText( QString( "up" ) );
buttonLayout->addWidget( m_downButton );
buttonLayout->addWidget( m_upButton );
//========================================================================
// TODO(Schurade): only for testing, will be removed soon
WQtDSBWidget* tab1 = new WQtDSBWidget( "settings" );
tab1->addPushButton( "button1" );
tab1->addPushButton( "button2" );
tab1->addCheckBox( "box1:", true );
tab1->addCheckBox( "box2:", false );
tab1->addLineEdit( "text:", "some text" );
tab1->addSliderInt( "slider:" , 50, 0, 100 );
WQtSliderWithEdit* slider = tab1->addSliderInt( "slider:" , 50, 0, 100 );
addTabWidgetContent( tab1 );
//========================================================================
m_layout->addWidget( m_treeWidget );
m_layout->addLayout( buttonLayout );
m_layout->addWidget( m_tabWidget );
m_panel->setLayout( m_layout );
......@@ -59,6 +78,8 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setWidget( m_panel );
slider->getboostSignalObject()->connect( boost::bind( &WQtDatasetBrowser::testBoostSignal, this, _1 ) );
connectSlots();
}
......@@ -69,7 +90,9 @@ WQtDatasetBrowser::~WQtDatasetBrowser()
void WQtDatasetBrowser::connectSlots()
{
connect( m_treeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( selectTreeItem() ) );
connect( m_treeWidget, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( selectTreeItem() ) );
connect( m_upButton, SIGNAL( pressed() ), m_treeWidget, SLOT( moveTreeItemUp() ) );
connect( m_downButton, SIGNAL( pressed() ), m_treeWidget, SLOT( moveTreeItemDown() ) );
}
......@@ -98,3 +121,8 @@ void WQtDatasetBrowser::addTabWidgetContent( WQtDSBWidget* content )
{
m_tabWidget->addTab( content, content->getName() );
}
void WQtDatasetBrowser::testBoostSignal( int test )
{
std::cout << "huhu ich bin ein boost signal: " << test << std::endl;
}
......@@ -29,12 +29,12 @@
#include <QtGui/QDockWidget>
#include <QtGui/QTabWidget>
#include <QtGui/QTreeWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include "WQtDSBWidget.h"
#include "WQtSubjectTreeItem.h"
#include "WQtTreeWidget.h"
/**
* TODO(schurade): Document this!
*/
......@@ -77,12 +77,19 @@ public:
*/
void connectSlots();
/**
*
*/
void testBoostSignal( int test );
protected:
private:
QTreeWidget* m_treeWidget;
WQtTreeWidget* m_treeWidget;
QTabWidget* m_tabWidget;
QPushButton* m_downButton;
QPushButton* m_upButton;
QWidget* m_tab1;
QWidget* m_tab2;
......
......@@ -27,6 +27,8 @@
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent )
: QTreeWidgetItem( parent )
{
this->setCheckState( 0, Qt::Checked );
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
}
WQtDatasetTreeItem::~WQtDatasetTreeItem()
......
......@@ -25,7 +25,8 @@
#include "WQtNumberEdit.h"
WQtNumberEdit::WQtNumberEdit( QWidget* parent )
: QLineEdit( parent )
: QLineEdit( parent ),
m_boostSignalObject()
{
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
}
......@@ -37,6 +38,7 @@ WQtNumberEdit::~WQtNumberEdit()
void WQtNumberEdit::setInt( int number )
{
setText( QString::number( number ) );
m_boostSignalObject( number );
}
void WQtNumberEdit::numberChanged()
......@@ -46,10 +48,17 @@ void WQtNumberEdit::numberChanged()
if ( ok )
{
emit signalNumber( number );
m_boostSignalObject( number );
}
else
{
setText( QString::number( 0 ) );
emit signalNumber( 0 );
m_boostSignalObject( 0 );
}
}
boost::signal1< void, int >*WQtNumberEdit::getboostSignalObject()
{
return &m_boostSignalObject;
}
......@@ -25,6 +25,7 @@
#ifndef WQTNUMBEREDIT_H
#define WQTNUMBEREDIT_H
#include "signalslib.hpp"
#include <QtGui/QLineEdit>
/**
......@@ -45,6 +46,13 @@ public:
*/
virtual ~WQtNumberEdit();
/**
*
*/
boost::signal1< void, int >* getboostSignalObject();
public slots:
void setInt( int number );
void numberChanged();
......@@ -55,6 +63,7 @@ signals:
protected:
private:
boost::signal1< void, int > m_boostSignalObject;
};
#endif // WQTNUMBEREDIT_H
//---------------------------------------------------------------------------
//
// 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 "WQtSliderWithEdit.h"
WQtSliderWithEdit::WQtSliderWithEdit( QWidget* parent )
: QWidget( parent ),
m_slider( Qt::Horizontal ),
m_edit(),
m_layout()
{
m_layout.addWidget( &m_slider );
m_layout.addWidget( &m_edit );
m_edit.resize( 10, m_edit.size().height() );
m_edit.setMaximumWidth( 25 );
setLayout( &m_layout );
connect( &m_slider, SIGNAL( valueChanged( int ) ), &m_edit, SLOT( setInt( int ) ) );
connect( &m_edit, SIGNAL( signalNumber( int ) ), &m_slider, SLOT( setValue( int ) ) );
}
WQtSliderWithEdit::~WQtSliderWithEdit()
{
}
void WQtSliderWithEdit::setMin( int min )
{
m_slider.setMinimum( min );
}
void WQtSliderWithEdit::setMax( int max )
{
m_slider.setMaximum( max );
int length = 1;
float fmax = static_cast<float>( max );
while ( ( fmax / 10 ) >= 1.0 )
{
++length;
fmax /= 10.0;
}
m_edit.setMaxLength( length );
}
void WQtSliderWithEdit::setValue( int value )
{
m_slider.setValue( value );
}
boost::signal1< void, int >*WQtSliderWithEdit::getboostSignalObject()
{
return m_edit.getboostSignalObject();
}
//---------------------------------------------------------------------------
//
// 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 WQTSLIDERWITHEDIT_H
#define WQTSLIDERWITHEDIT_H
#include "signalslib.hpp"
#include "WQtNumberEdit.h"
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
/**
* TODO(schurade): Document this!
*/
class WQtSliderWithEdit : public QWidget
{
public:
explicit WQtSliderWithEdit( QWidget* parent = 0 );
virtual ~WQtSliderWithEdit();
/**
*
*/
boost::signal1< void, int >* getboostSignalObject();
void setMin( int min );
void setMax( int max );
void setValue( int value );
protected:
private:
QSlider m_slider;
WQtNumberEdit m_edit;
QHBoxLayout m_layout;
};
#endif // WQTSLIDERWITHEDIT_H
//---------------------------------------------------------------------------
//
// 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 "WQtTreeWidget.h"
#include "WQtSubjectTreeItem.h"
WQtTreeWidget::WQtTreeWidget( QWidget* parent )
: QTreeWidget( parent )
{
invisibleRootItem()->setFlags( Qt::ItemIsEnabled );
setSelectionMode( QAbstractItemView::SingleSelection );
}
WQtTreeWidget::~WQtTreeWidget()
{
}
void WQtTreeWidget::moveTreeItemDown()
{
QTreeWidgetItem *parent = currentItem()->parent();
int index;
if ( parent )
{
index = parent->indexOfChild( currentItem() );
if ( index < parent->childCount() - 1 )
{
WQtSubjectTreeItem* subject = reinterpret_cast<WQtSubjectTreeItem*>( topLevelItem( 0 ) );
WQtDatasetTreeItem* ci = reinterpret_cast<WQtDatasetTreeItem*>( parent->takeChild( index ) );
subject->insertChild( index + 1, ci );
clearSelection();
setCurrentItem( ci );
ci->setSelected( true );
}
}
}
void WQtTreeWidget::moveTreeItemUp()
{
QTreeWidgetItem *parent = currentItem()->parent();
int index;
if ( parent )
{
index = parent->indexOfChild( currentItem() );
if ( index > 0 )
{
WQtSubjectTreeItem* subject = reinterpret_cast<WQtSubjectTreeItem*>( topLevelItem( 0 ) );
WQtDatasetTreeItem* ci = reinterpret_cast<WQtDatasetTreeItem*>( parent->takeChild( index ) );
subject->insertChild( index - 1, ci );
clearSelection();
setCurrentItem( ci );
ci->setSelected( true );
}
}
}
//---------------------------------------------------------------------------
//
// 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