#include <QTableWidget>
#include <QTableWidgetItem>
-//#include <QDoubleSpinBox>
+
#include <QtxDoubleSpinBox.h>
const double DBL_MINIMUM = -10000000.;
int aColumnId = theIndex.column();
if ( aColumnId == 2 || aColumnId == 3 ) {
QDoubleSpinBox* aSpin = new QtxDoubleSpinBox( theParent );
- aSpin->setDecimals( 6 );
+ aSpin->setDecimals( 2 );
aSpin->setRange( DBL_MINIMUM, DBL_MAXIMUM );
anEditor = aSpin;
}
void CurveCreator_TableItemDelegate::setEditorData( QWidget* theEditor,
const QModelIndex& theIndex ) const
{
- QTableWidget* aTableWidget = dynamic_cast<QTableWidget*>( parent() );
- QTableWidgetItem* anItem = aTableWidget ? dynamic_cast<QTableWidgetItem*>
- ( aTableWidget->item( theIndex.row(), theIndex.column() ) ) : 0;
int aColumnId = theIndex.column();
- if ( anItem && ( aColumnId == 2 || aColumnId == 3 ) ) {
+ if ( aColumnId == 2 || aColumnId == 3 ) {
QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
- double aValue = anItem->data( Qt::UserRole ).toDouble();
if ( aDblSpin ) {
+ double aValue = theIndex.model()->data( theIndex, Qt::EditRole ).toDouble();
aDblSpin->setValue( aValue );
}
}
QAbstractItemModel* theModel,
const QModelIndex& theIndex ) const
{
- QTableWidget* aTableWidget = dynamic_cast<QTableWidget*>( parent() );
- QTableWidgetItem* anItem = aTableWidget ? dynamic_cast<QTableWidgetItem*>
- ( aTableWidget->item( theIndex.row(), theIndex.column() ) ) : 0;
-
int aColumnId = theIndex.column();
- if ( anItem && ( aColumnId == 2 || aColumnId == 3 ) ) {
+ if ( aColumnId == 2 || aColumnId == 3 ) {
QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
if ( aDblSpin ) {
double aValue = aDblSpin->value();
- anItem->setData( Qt::UserRole, aValue );
+ theModel->setData( theIndex, aValue, Qt::UserRole);
}
}
else
anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
anItem->setData( Qt::UserRole, aPointId );
setItem( aRowId, 1, anItem );
-
- anItem = new QTableWidgetItem( QString::number( theX ) );
+
+ anItem = new QTableWidgetItem( QString::number( theX, 'f', 2 ) );
anItem->setData( Qt::UserRole, theX );
setItem( aRowId, 2, anItem );
- anItem = new QTableWidgetItem( QString::number( theY ) );
+ anItem = new QTableWidgetItem( QString::number( theY, 'f', 2 ) );
anItem->setData( Qt::UserRole, theY );
setItem( aRowId, 3, anItem );
}
#include "HYDROGUI_GeoreferencementDlg.h"
+#include "HYDROGUI_Tool.h"
+
#include <GEOMUtils.hxx>
#include <OCCViewer_ViewWindow.h>
if ( theIndex.column() > 0 ) {
QLineEdit* aLineEdit = new QLineEdit( theParent );
- aLineEdit->setValidator( new QDoubleValidator( aLineEdit ) );
+ QDoubleValidator* aDoubleValidator = new QDoubleValidator();
+ aDoubleValidator->setNotation( QDoubleValidator::StandardNotation );
+ aDoubleValidator->setDecimals( 2 );
+ aLineEdit->setValidator( aDoubleValidator );
anEditor = aLineEdit;
} else {
anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
ProfileGeoData aGeoData = theMap.value( aProfileName );
QString aXg, anYg, aXd, anYd;
if ( !aGeoData.isEmpty ) {
- aXg = getString( aGeoData.Xg );
- anYg = getString( aGeoData.Yg );
- aXd = getString( aGeoData.Xd );
- anYd = getString( aGeoData.Yd );
+ aXg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xg );
+ anYg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yg );
+ aXd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xd );
+ anYd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yd );
}
// Insert row with the data
int aColumnX = aColumn < 3 ? 1 : 3;
int aColumnY = aColumnX + 1;
- myTable->item( aRow, aColumnX )->setText( getString( aPnt.X() ) );
- myTable->item( aRow, aColumnY )->setText( getString( aPnt.Y() ) );
-}
-
-QString HYDROGUI_GeoreferencementDlg::getString( const double theNumber ) const
-{
- return QString::number( theNumber, 'g', 12 );
+ QString aXStr = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
+ QString anYStr = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+ myTable->item( aRow, aColumnX )->setText( aXStr );
+ myTable->item( aRow, aColumnY )->setText( anYStr );
}
void HYDROGUI_GeoreferencementDlg::onDataChanged()