Commit 6099330e authored by schurade's avatar schurade

[ADD] more work on the dataset browser

parent 06ba3fd0
# Package dependencies: # Package dependencies:
FIND_PACKAGE( Qt4 REQUIRED ) FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( Boost REQUIRED signals )
# Includes: # Includes:
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
...@@ -12,15 +13,16 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY} ...@@ -12,15 +13,16 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject # add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS SET(GUI_QT4_MOC_HDRS
WMainWindow.h WMainWindow.h
WQtDatasetBrowser.h datasetbrowser/WQtDatasetBrowser.h
WQtDSBWidget.h datasetbrowser/WQtDSBWidget.h
WQtNumberEdit.h datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
) )
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} ) 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} ) 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 @@ ...@@ -37,7 +37,7 @@
#include "WQtGLWidget.h" #include "WQtGLWidget.h"
#include "WQtRibbonMenu.h" #include "WQtRibbonMenu.h"
#include "WQtDatasetBrowser.h" #include "datasetbrowser/WQtDatasetBrowser.h"
#include "../../kernel/WKernel.h" #include "../../kernel/WKernel.h"
#include "../icons/logoIcon.xpm" #include "../icons/logoIcon.xpm"
...@@ -91,6 +91,8 @@ void WMainWindow::setupGUI( QMainWindow *MainWindow ) ...@@ -91,6 +91,8 @@ void WMainWindow::setupGUI( QMainWindow *MainWindow )
m_datasetBrowser->addSubject( "subject1" ); m_datasetBrowser->addSubject( "subject1" );
m_datasetBrowser->addDataset( 0, "mr188_t1" ); m_datasetBrowser->addDataset( 0, "mr188_t1" );
m_datasetBrowser->addDataset( 0, "mr188_evec" ); m_datasetBrowser->addDataset( 0, "mr188_evec" );
m_datasetBrowser->addDataset( 0, "mr188_t2" );
m_datasetBrowser->addDataset( 0, "mr188_rgb" );
MainWindow->setWindowTitle( QApplication::translate( "MainWindow", MainWindow->setWindowTitle( QApplication::translate( "MainWindow",
"OpenWalnut", 0, QApplication::UnicodeUTF8 ) ); "OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
......
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent ) WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent )
: 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() ...@@ -43,30 +43,30 @@ WQtDSBWidget::~WQtDSBWidget()
QPushButton* WQtDSBWidget::addPushButton( std::string label ) QPushButton* WQtDSBWidget::addPushButton( std::string label )
{ {
int row = m_layout->rowCount(); int row = m_layout.rowCount();
QPushButton* button = new QPushButton(); QPushButton* button = new QPushButton();
button->setText( QString( label.c_str() ) ); 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; return button;
} }
QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked ) 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() ); QLabel* qlabel = new QLabel( label.c_str() );
QCheckBox* checkBox = new QCheckBox(); QCheckBox* checkBox = new QCheckBox();
checkBox->setChecked( isChecked ); checkBox->setChecked( isChecked );
m_layout->addWidget( qlabel, row, 0 ); m_layout.addWidget( qlabel, row, 0 );
m_layout->addWidget( checkBox, row, 1 ); m_layout.addWidget( checkBox, row, 1 );
setLayout( m_layout ); setLayout( &m_layout );
return checkBox; return checkBox;
} }
...@@ -74,41 +74,36 @@ QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked ) ...@@ -74,41 +74,36 @@ QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked )
QLineEdit* WQtDSBWidget::addLineEdit( std::string label, std::string text ) 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() ); QLabel* qlabel = new QLabel( label.c_str() );
QLineEdit* lineEdit = new QLineEdit(); QLineEdit* lineEdit = new QLineEdit();
lineEdit->setText( QString( text.c_str() ) ); lineEdit->setText( QString( text.c_str() ) );
m_layout->addWidget( qlabel, row, 0 ); m_layout.addWidget( qlabel, row, 0 );
m_layout->addWidget( lineEdit, row, 1 ); m_layout.addWidget( lineEdit, row, 1 );
setLayout( m_layout ); setLayout( &m_layout );
return lineEdit; 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() ); QLabel* qlabel = new QLabel( label.c_str() );
QSlider* slider = new QSlider( Qt::Horizontal ); WQtSliderWithEdit* slider = new WQtSliderWithEdit();
slider->setMinimum( min );
slider->setMaximum( max );
slider->setValue( value );
WQtNumberEdit* numberEdit = new WQtNumberEdit();
m_layout->addWidget( qlabel, row, 0 ); slider->setMin( min );
m_layout->addWidget( slider, row, 1 ); slider->setMax( max );
m_layout->addWidget( numberEdit, row+1, 1 ); 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 ) ) ); setLayout( &m_layout );
connect( numberEdit, SIGNAL( signalNumber( int ) ), slider, SLOT( setValue( int ) ) );
return slider; return slider;
} }
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QLCDNumber> #include <QtGui/QLCDNumber>
#include "WQtSliderWithEdit.h"
/** /**
* TODO(schurade): Document this! * TODO(schurade): Document this!
*/ */
...@@ -72,7 +74,7 @@ public: ...@@ -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: ...@@ -81,8 +83,8 @@ public:
protected: protected:
private: private:
QGridLayout* m_layout;
QString m_name; QString m_name;
QGridLayout m_layout;
}; };
#endif // WQTDSBWIDGET_H #endif // WQTDSBWIDGET_H
...@@ -22,35 +22,54 @@ ...@@ -22,35 +22,54 @@
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include <iostream>
#include <string> #include <string>
#include <QtCore/QList> #include <QtCore/QList>
#include "../../common/WLogger.h" #include "../../../common/WLogger.h"
#include "WQtDatasetBrowser.h" #include "WQtDatasetBrowser.h"
#include "WQtNumberEdit.h"
WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent ) WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
: QDockWidget( parent ) : QDockWidget( parent )
{ {
m_panel = new QWidget( this ); 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->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_tabWidget = new QTabWidget( m_panel );
m_layout = new QVBoxLayout(); 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" ); WQtDSBWidget* tab1 = new WQtDSBWidget( "settings" );
tab1->addPushButton( "button1" ); tab1->addPushButton( "button1" );
tab1->addPushButton( "button2" ); tab1->addPushButton( "button2" );
tab1->addCheckBox( "box1:", true ); tab1->addCheckBox( "box1:", true );
tab1->addCheckBox( "box2:", false ); tab1->addCheckBox( "box2:", false );
tab1->addLineEdit( "text:", "some text" ); tab1->addLineEdit( "text:", "some text" );
tab1->addSliderInt( "slider:" , 50, 0, 100 ); WQtSliderWithEdit* slider = tab1->addSliderInt( "slider:" , 50, 0, 100 );
addTabWidgetContent( tab1 ); addTabWidgetContent( tab1 );
//========================================================================
m_layout->addWidget( m_treeWidget ); m_layout->addWidget( m_treeWidget );
m_layout->addLayout( buttonLayout );
m_layout->addWidget( m_tabWidget ); m_layout->addWidget( m_tabWidget );
m_panel->setLayout( m_layout ); m_panel->setLayout( m_layout );
...@@ -59,6 +78,8 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent ) ...@@ -59,6 +78,8 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable ); this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setWidget( m_panel ); this->setWidget( m_panel );
slider->getboostSignalObject()->connect( boost::bind( &WQtDatasetBrowser::testBoostSignal, this, _1 ) );
connectSlots(); connectSlots();
} }
...@@ -69,7 +90,9 @@ WQtDatasetBrowser::~WQtDatasetBrowser() ...@@ -69,7 +90,9 @@ WQtDatasetBrowser::~WQtDatasetBrowser()
void WQtDatasetBrowser::connectSlots() 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 ) ...@@ -98,3 +121,8 @@ void WQtDatasetBrowser::addTabWidgetContent( WQtDSBWidget* content )
{ {
m_tabWidget->addTab( content, content->getName() ); 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 @@ ...@@ -29,12 +29,12 @@
#include <QtGui/QDockWidget> #include <QtGui/QDockWidget>
#include <QtGui/QTabWidget> #include <QtGui/QTabWidget>
#include <QtGui/QTreeWidget>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include "WQtDSBWidget.h" #include "WQtDSBWidget.h"
#include "WQtSubjectTreeItem.h" #include "WQtSubjectTreeItem.h"
#include "WQtTreeWidget.h"
/** /**
* TODO(schurade): Document this! * TODO(schurade): Document this!
*/ */
...@@ -77,12 +77,19 @@ public: ...@@ -77,12 +77,19 @@ public:
*/ */
void connectSlots(); void connectSlots();
/**
*
*/
void testBoostSignal( int test );
protected: protected:
private: private:
QTreeWidget* m_treeWidget; WQtTreeWidget* m_treeWidget;
QTabWidget* m_tabWidget; QTabWidget* m_tabWidget;
QPushButton* m_downButton;
QPushButton* m_upButton;
QWidget* m_tab1; QWidget* m_tab1;
QWidget* m_tab2; QWidget* m_tab2;
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent ) WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent )
: QTreeWidgetItem( parent ) : QTreeWidgetItem( parent )
{ {
this->setCheckState( 0, Qt::Checked );
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
} }
WQtDatasetTreeItem::~WQtDatasetTreeItem() WQtDatasetTreeItem::~WQtDatasetTreeItem()
......
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
#include "WQtNumberEdit.h" #include "WQtNumberEdit.h"
WQtNumberEdit::WQtNumberEdit( QWidget* parent ) WQtNumberEdit::WQtNumberEdit( QWidget* parent )
: QLineEdit( parent ) : QLineEdit( parent ),
m_boostSignalObject()
{ {
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) ); connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
} }
...@@ -37,6 +38,7 @@ WQtNumberEdit::~WQtNumberEdit() ...@@ -37,6 +38,7 @@ WQtNumberEdit::~WQtNumberEdit()
void WQtNumberEdit::setInt( int number ) void WQtNumberEdit::setInt( int number )
{ {
setText( QString::number( number ) ); setText( QString::number( number ) );
m_boostSignalObject( number );
} }
void WQtNumberEdit::numberChanged() void WQtNumberEdit::numberChanged()
...@@ -46,10 +48,17 @@ void WQtNumberEdit::numberChanged() ...@@ -46,10 +48,17 @@ void WQtNumberEdit::numberChanged()
if ( ok ) if ( ok )
{ {
emit signalNumber( number ); emit signalNumber( number );
m_boostSignalObject( number );
} }
else else
{ {
setText( QString::number( 0 ) ); setText( QString::number( 0 ) );
emit signalNumber( 0 ); emit signalNumber( 0 );
m_boostSignalObject( 0 );
} }
} }
boost::signal1< void, int >*WQtNumberEdit::getboostSignalObject()
{
return &m_boostSignalObject;
}
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#ifndef WQTNUMBEREDIT_H #ifndef WQTNUMBEREDIT_H
#define WQTNUMBEREDIT_H #define WQTNUMBEREDIT_H
#include "signalslib.hpp"
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
/** /**
...@@ -45,6 +46,13 @@ public: ...@@ -45,6 +46,13 @@ public:
*/ */
virtual ~WQtNumberEdit(); virtual ~WQtNumberEdit();
/**
*
*/
boost::signal1< void, int >* getboostSignalObject();
public slots: public slots:
void setInt( int number ); void setInt( int number );
void numberChanged(); void numberChanged();
...@@ -55,6 +63,7 @@ signals: ...@@ -55,6 +63,7 @@ signals:
protected: protected:
private: private:
boost::signal1< void, int > m_boostSignalObject;
}; };
#endif // WQTNUMBEREDIT_H #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 )
{