Commit c6e6e38b by Mathias Goldau

[CLEAN] Now several c_str() conversions replaced with QString::fromStdString()…

[CLEAN] Now several c_str() conversions replaced with QString::fromStdString() since Qt itself should know best on how to convert those formats, also removed several casts and finally some zombie files, not used except in CMakeLists and by them self (corresponding .cpp), so now it should be a bit faster in compiling without those zombies...
parent d06a1345
......@@ -12,14 +12,14 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtConfigWidget.h
WQtConfigWidget.h
WQtNavGLWidget.h
WQtCombinerToolbar.h
guiElements/WQtPushButton.h
guiElements/WQtModuleOneToOneCombinerAction.h
guiElements/WQtPropertyBoolAction.h
datasetbrowser/WPropertyWidget.h
datasetbrowser/WPropertyBoolWidget.h
datasetbrowser/WPropertyBoolWidget.h
datasetbrowser/WPropertyIntWidget.h
datasetbrowser/WPropertyDoubleWidget.h
datasetbrowser/WPropertyStringWidget.h
......@@ -30,10 +30,6 @@ SET(GUI_QT4_MOC_HDRS
datasetbrowser/WPropertyPositionWidget.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtLineEdit.h
datasetbrowser/WQtSliderWithEdit.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtNumberEditDouble.h
datasetbrowser/WQtTreeWidget.h
datasetbrowser/WQtTreeItem.h
datasetbrowser/WQtTextureSorter.h
......
......@@ -102,7 +102,7 @@ void WPropertyIntWidget::update()
// Same as in WPropertyDouble.cpp: This does not work as expected on Mac OS X => reset to default
// set the initial values
QString valStr = QString( boost::lexical_cast< std::string >( m_intProperty->get() ).c_str() );
QString valStr = QString::number( m_intProperty->get() );
m_edit.setText( valStr );
m_slider.setValue( m_intProperty->get() );
......@@ -113,7 +113,7 @@ void WPropertyIntWidget::update()
void WPropertyIntWidget::sliderChanged( int value )
{
// set the value in the line edit
m_edit.setText( QString( boost::lexical_cast< std::string >( value ).c_str() ) );
m_edit.setText( QString::number( value ) );
// set to the property
invalidate( !m_intProperty->set( value ) ); // NOTE: set automatically checks the validity of the value
......
......@@ -68,7 +68,7 @@ WPropertyStringWidget::~WPropertyStringWidget()
void WPropertyStringWidget::update()
{
QString val = QString( m_stringProperty->get().c_str() );
QString val = QString::fromStdString( m_stringProperty->get() );
m_edit.setText( val );
m_asText.setText( val );
}
......
......@@ -43,8 +43,7 @@ WQtRoiTreeItem* WQtBranchTreeItem::addRoiItem( boost::shared_ptr< WRMROIRepresen
{
WQtRoiTreeItem* rti = new WQtRoiTreeItem( this, roi, ROI );
std::string name = "ROI";
rti->setText( 0, QString( name.c_str() ) );
rti->setText( 0, QString( "ROI" ) );
return rti;
}
......
......@@ -37,30 +37,25 @@
#include "../../../common/WLogger.h"
#include "../../../common/WPreferences.h"
#include "../../../dataHandler/WDataSet.h"
#include "../../../kernel/modules/data/WMData.h"
#include "../../../kernel/WKernel.h"
#include "../../../kernel/WModule.h"
#include "../../../kernel/WModuleCombiner.h"
#include "../../../kernel/WModuleCombinerTypes.h"
#include "../../../kernel/WModuleFactory.h"
#include "../../../kernel/modules/data/WMData.h"
#include "../events/WEventTypes.h"
#include "../events/WModuleAssocEvent.h"
#include "../events/WModuleConnectEvent.h"
#include "../events/WModuleDeleteEvent.h"
#include "../events/WModuleDisconnectEvent.h"
#include "../events/WModuleReadyEvent.h"
#include "../events/WModuleRemovedEvent.h"
#include "../events/WModuleConnectEvent.h"
#include "../events/WModuleDisconnectEvent.h"
#include "../events/WRoiAssocEvent.h"
#include "../events/WRoiRemoveEvent.h"
#include "../WMainWindow.h"
#include "../WQt4Gui.h"
#include "../WQtCombinerActionList.h"
#include "WQtBranchTreeItem.h"
#include "WQtNumberEdit.h"
#include "WQtNumberEditDouble.h"
#include "WQtTextureSorter.h"
#include "WQtDatasetBrowser.h"
#include "WQtTextureSorter.h"
WQtDatasetBrowser::WQtDatasetBrowser( WMainWindow* parent )
: QDockWidget( "Control Panel", parent ),
......@@ -187,11 +182,9 @@ void WQtDatasetBrowser::addToolbar( QToolBar* tb )
WQtSubjectTreeItem* WQtDatasetBrowser::addSubject( std::string name )
{
WQtSubjectTreeItem* subject = new WQtSubjectTreeItem( m_moduleTreeWidget );
subject->setText( 0, QString( name.c_str() ) );
subject->setToolTip( 0, QString( ( std::string( "" )
+ "All data and modules that are children of this tree item belong to the subject \""
+ name
+ "\"." ).c_str() ) );
subject->setText( 0, QString::fromStdString( name ) );
subject->setToolTip( 0, QString::fromStdString( "All data and modules that are children of this tree item belong to the subject \"" +
name + "\"." ) );
return subject;
}
......
//---------------------------------------------------------------------------
//
// 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 "WQtLineEdit.h"
WQtLineEdit::WQtLineEdit()
: QLineEdit()
{
m_name = QString( "" );
connect( this, SIGNAL( returnPressed() ), this, SLOT( emitStateChanged() ) );
}
WQtLineEdit::~WQtLineEdit()
{
}
void WQtLineEdit::setName( QString name )
{
m_name = name;
}
void WQtLineEdit::emitStateChanged()
{
emit lineEditStateChanged( m_name, this->text() );
}
//---------------------------------------------------------------------------
//
// 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 WQTLINEEDIT_H
#define WQTLINEEDIT_H
#include <string>
#include <QtGui/QLineEdit>
/**
* implements a QLineEdit with a boost signal
*/
class WQtLineEdit : public QLineEdit
{
Q_OBJECT
public:
/**
* standard constructor
*/
WQtLineEdit();
/**
* destructor
*/
virtual ~WQtLineEdit();
/**
* Setter for name.
*
* \param name the new name for the line edit
*/
void setName( QString name );
private:
/**
* Name of the edit and its value.
*/
QString m_name;
public slots:
/**
* Value of the edit field changed.
*/
void emitStateChanged();
signals:
/**
* Signal a state change in the line edit.
*
* \param name name of the line edit.
* \param text new text inside the edit field.
*/
void lineEditStateChanged( QString name, QString text );
};
#endif // WQTLINEEDIT_H
......@@ -41,8 +41,6 @@ WQtModuleTreeItem* WQtModuleHeaderTreeItem::addModuleItem( boost::shared_ptr< WM
{
WQtModuleTreeItem* ds = new WQtModuleTreeItem( this, module );
std::string name = module->getName();
ds->setText( 0, QString( name.c_str() ) );
ds->setText( 0, QString::fromStdString( module->getName() ) );
return ds;
}
//---------------------------------------------------------------------------
//
// 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"
WQtNumberEdit::WQtNumberEdit( QWidget* parent )
: QLineEdit( parent )
{
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
}
WQtNumberEdit::~WQtNumberEdit()
{
}
void WQtNumberEdit::setInt( int number )
{
setText( QString::number( number ) );
}
void WQtNumberEdit::numberChanged()
{
bool ok;
int number = text().toInt( &ok, 10 );
if ( ok )
{
emit signalNumber( number );
}
else
{
setText( QString::number( 0 ) );
emit signalNumber( 0 );
}
}
//---------------------------------------------------------------------------
//
// 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 WQTNUMBEREDIT_H
#define WQTNUMBEREDIT_H
#include <string>
#include <QtGui/QLineEdit>
/**
* a QLineEdit modified to deal only with integer numbers
*/
class WQtNumberEdit : public QLineEdit
{
Q_OBJECT
public:
/**
* Default constructor
*
* \param parent The parent widget of this widget, i.e. the widget that manages it.
*/
explicit WQtNumberEdit( QWidget* parent = 0 );
/**
* destructor
*/
virtual ~WQtNumberEdit();
public slots:
/**
* Set the value of the number edit.
*
* \param number the new number of the number edit.
*/
void setInt( int number );
/**
* Slot getting called whenever the value of the edit changed.
*/
void numberChanged();
signals:
/**
* Signals a new value of the edit
*
* \param value the new value.
*/
void signalNumber( int value );
protected:
private:
};
#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 <string>
#include "WQtNumberEditDouble.h"
WQtNumberEditDouble::WQtNumberEditDouble( QString name, QWidget* parent )
: QLineEdit( parent ),
m_name( name )
{
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
}
WQtNumberEditDouble::~WQtNumberEditDouble()
{
}
void WQtNumberEditDouble::setName( QString name )
{
m_name = name;
}
void WQtNumberEditDouble::setDouble( double number )
{
setText( QString::number( number ) );
emit signalNumberWithName( m_name, number );
}
void WQtNumberEditDouble::numberChanged()
{
bool ok;
double number = text().toDouble( &ok );
if ( ok )
{
emit signalNumberWithName( m_name, number );
}
else
{
setText( QString::number( 0 ) );
emit signalNumberWithName( m_name, 0 );
}
}
//---------------------------------------------------------------------------
//
// 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 WQTNUMBEREDITDOUBLE_H
#define WQTNUMBEREDITDOUBLE_H
#include <string>
#include <QtGui/QLineEdit>
/**
* a QLineEdit modified to deal only with double numbers
*/
class WQtNumberEditDouble : public QLineEdit
{
Q_OBJECT
public:
/**
* Default constructor, that connects the slot of the edit.
*
* \param name The name of teh widget
* \param parent The widget managing this widget
*/
explicit WQtNumberEditDouble( QString name, QWidget* parent = 0 );
/**
* setter for name.
*
* \param name The new name for the widget
*/
void setName( QString name );
/**
* destructor
*/
virtual ~WQtNumberEditDouble();
public slots:
/**
* Sets the edit field to a certain number.
*
* \param number The double to be put into the field.
*/
void setDouble( double number );
/**
* Updated the number in the lineEdit if the number has changed.
*/
void numberChanged();
signals:
/**
* Signal to distribute the number set in the lineEdit.
*
* \param name name of the edit field.
* \param number new value of the edit field.
*/
void signalNumberWithName( QString name, double number );
protected:
private:
/**
* Name if the value.
*/
QString m_name;
};
#endif // WQTNUMBEREDITDOUBLE_H
......@@ -24,10 +24,9 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtRoiTreeItem.h"
#include "WQtRoiHeaderTreeItem.h"
#include "WQtRoiTreeItem.h"
#include "WTreeItemTypes.h"
WQtRoiHeaderTreeItem::WQtRoiHeaderTreeItem( QTreeWidget * parent ) :
QTreeWidgetItem( parent, ROIHEADER )
......@@ -42,7 +41,7 @@ WQtRoiHeaderTreeItem::~WQtRoiHeaderTreeItem()
WQtBranchTreeItem* WQtRoiHeaderTreeItem::addBranch( boost::shared_ptr< WRMBranch> branch )
{
WQtBranchTreeItem* rti = new WQtBranchTreeItem( this, branch );
std::string name = "Branch";
rti->setText( 0, QString( name.c_str() ) );
rti->setText( 0, QString( "Branch" ) );
return rti;
}
//---------------------------------------------------------------------------
//
// 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 "../../../common/WPropertyVariable.h"
#include "WQtSliderWithEdit.h"
WQtSliderWithEdit::WQtSliderWithEdit( boost::shared_ptr< WPropertyBase > property, QWidget* parent )
: QWidget( parent ),
m_slider( Qt::Horizontal ),
m_edit(),
m_layout()
{
m_name = QString( property->getName().c_str() );
m_layout.addWidget( &m_slider );
m_layout.addWidget( &m_edit );
m_edit.resize( m_edit.minimumSizeHint().width() , m_edit.size().height() );
m_edit.setMaximumWidth( m_edit.minimumSizeHint().width() );
setLayout( &m_layout );
connect( &m_slider, SIGNAL( valueChanged( int ) ), &m_edit, SLOT( setInt( int ) ) );
connect( &m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( emitValue() ) );
connect( &m_edit, SIGNAL( signalNumber( int ) ), &m_slider, SLOT( setValue( int ) ) );
}
WQtSliderWithEdit::~WQtSliderWithEdit()
{
}
void WQtSliderWithEdit::setName( QString name )
{
m_name = name;
}
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 );
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 )
{
m_slider.setValue( value );
emit signalNumberWithName( m_name, value );
}
void WQtSliderWithEdit::emitValue()
{
emit signalNumberWithName( m_name, m_slider.value() );
}
//---------------------------------------------------------------------------
//
// 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 <string>
#include "WQtNumberEdit.h"
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
#include "WPropertyWidget.h"
/**
* container widget for a slider with a connected number edit
*/
class WQtSliderWithEdit : public QWidget
{
Q_OBJECT
public:
/**
* default constructor
* \param property the property to handle
* \param parent the widget that is the parent of this widget and thus manages it.
*/
explicit WQtSliderWithEdit( boost::shared_ptr< WPropertyBase > property, QWidget* parent = 0 );
/**
* destructor
*/
virtual ~WQtSliderWithEdit();
/**
* Setter for name.
*
* \param name the new name for the GUI element.
*/
void setName( QString name );
/**
* Setter for min value.
*
* \param min the new minimum value.
*/
void setMin( int min );
/**
* Setter for max value.
*
* \param max the new maximum value.
*/
void setMax( int max );
/**
* Setter for current value.
*
* \param value the new current value.