X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_GeoreferencementDlg.cxx;h=8c31879e395bac82e8ab9b183d5ee86365150462;hb=d6e19029f8b41f295db878e9aecf451c2edda4af;hp=45b8d55a95deb8035cb2a2aa69358c9dbf8a092d;hpb=f0688b4c39fcc3e49c2b58a90724b9c1c84f1337;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx index 45b8d55a..8c31879e 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx @@ -19,6 +19,7 @@ #include "HYDROGUI_GeoreferencementDlg.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_LineEditDoubleValidator.h" #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include @@ -67,64 +67,6 @@ HYDROGUI_GeoreferencementDlg::ProfileGeoData::ProfileGeoData( } } -//! Custom item delegate (line edit with double validator) -class HYDROGUI_GeoreferencementDlg::Delegate : public QItemDelegate -{ -public: - Delegate( QObject* = 0 ); - - QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, - const QModelIndex& ) const; - - void setEditorData( QWidget*, const QModelIndex& ) const; - void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const; -}; - -HYDROGUI_GeoreferencementDlg::Delegate::Delegate( QObject* theParent ) - : QItemDelegate( theParent ) -{ -} - -QWidget* HYDROGUI_GeoreferencementDlg::Delegate::createEditor( - QWidget* theParent, const QStyleOptionViewItem& theOption, - const QModelIndex& theIndex ) const -{ - QWidget* anEditor = 0; - - if ( theIndex.column() > 0 ) { - QLineEdit* aLineEdit = new QLineEdit( theParent ); - QDoubleValidator* aDoubleValidator = new QDoubleValidator(); - aDoubleValidator->setNotation( QDoubleValidator::StandardNotation ); - aDoubleValidator->setDecimals( 2 ); - aLineEdit->setValidator( aDoubleValidator ); - anEditor = aLineEdit; - } else { - anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex ); - } - - return anEditor; -} - -void HYDROGUI_GeoreferencementDlg::Delegate::setEditorData( - QWidget* theEditor, const QModelIndex& theIndex ) const -{ - if ( QLineEdit* aLineEdit = dynamic_cast( theEditor ) ) { - aLineEdit->setText( theIndex.data( Qt::EditRole ).toString() ); - } else { - QItemDelegate::setEditorData( theEditor, theIndex ); - } -} - -void HYDROGUI_GeoreferencementDlg::Delegate::setModelData( - QWidget* theEditor, QAbstractItemModel* theModel, const QModelIndex& theIndex) const -{ - if ( QLineEdit* aLineEdit = dynamic_cast( theEditor ) ) { - theModel->setData( theIndex, aLineEdit->text() ); - } else { - QItemDelegate::setModelData( theEditor, theModel, theIndex ); - } -} - HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ), myIsModified( false ) { @@ -153,7 +95,7 @@ HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* the // Table myTable = new QTableWidget( mainFrame() ); - myTable->setItemDelegate( new Delegate( this ) ); + myTable->setItemDelegate( new HYDROGUI_LineEditDoubleValidator( this ) ); myTable->verticalHeader()->setVisible( false ); myTable->setSelectionBehavior( QAbstractItemView::SelectItems ); myTable->setSelectionMode( QAbstractItemView::SingleSelection );