Connected signal cellChanged to slot cellChanged in table of increments.
Before conversion toDouble replace "," to ".". --HG-- branch : develop
This commit is contained in:
parent
4d6179d3e2
commit
3bda5f6208
|
@ -26,6 +26,7 @@
|
||||||
#include "widgets/doubledelegate.h"
|
#include "widgets/doubledelegate.h"
|
||||||
#include "container/vincrementtablerow.h"
|
#include "container/vincrementtablerow.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include "exception/vexception.h"
|
||||||
|
|
||||||
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
||||||
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc){
|
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc){
|
||||||
|
@ -41,6 +42,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
|
||||||
FillIncrementTable();
|
FillIncrementTable();
|
||||||
FillLengthLines();
|
FillLengthLines();
|
||||||
|
|
||||||
|
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::cellChanged);
|
||||||
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
|
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
|
||||||
connect(ui->toolButtonRemove, &QPushButton::clicked, this,
|
connect(ui->toolButtonRemove, &QPushButton::clicked, this,
|
||||||
&DialogIncrements::clickedToolButtonRemove);
|
&DialogIncrements::clickedToolButtonRemove);
|
||||||
|
@ -365,8 +367,8 @@ void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, q
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
|
void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
|
||||||
QTableWidgetItem *item;
|
QTableWidgetItem *item = 0;
|
||||||
QTableWidgetItem *itemName;
|
QTableWidgetItem *itemName = 0;
|
||||||
qint64 id;
|
qint64 id;
|
||||||
QDomElement domElement;
|
QDomElement domElement;
|
||||||
switch(column) {
|
switch(column) {
|
||||||
|
@ -386,8 +388,14 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
|
||||||
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
|
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
|
||||||
domElement = doc->elementById(QString().setNum(id));
|
domElement = doc->elementById(QString().setNum(id));
|
||||||
if(domElement.isElement()){
|
if(domElement.isElement()){
|
||||||
domElement.setAttribute("base", item->text().toDouble());
|
bool ok = false;
|
||||||
emit FullUpdateTree();
|
qreal value = item->text().toDouble(&ok);
|
||||||
|
if(ok){
|
||||||
|
domElement.setAttribute("base", value);
|
||||||
|
emit FullUpdateTree();
|
||||||
|
} else {
|
||||||
|
throw VException(tr("Can't convert toDouble value."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
|
@ -29,38 +29,37 @@ namespace Ui {
|
||||||
class DialogIncrements;
|
class DialogIncrements;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DialogIncrements : public DialogTool
|
class DialogIncrements : public DialogTool{
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
|
DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
|
||||||
~DialogIncrements();
|
~DialogIncrements();
|
||||||
public slots:
|
public slots:
|
||||||
void clickedToolButtonAdd();
|
void clickedToolButtonAdd();
|
||||||
void clickedToolButtonRemove();
|
void clickedToolButtonRemove();
|
||||||
void cellChanged ( qint32 row, qint32 column );
|
void cellChanged ( qint32 row, qint32 column );
|
||||||
void FullUpdateFromFile();
|
void FullUpdateFromFile();
|
||||||
virtual void DialogAccepted();
|
virtual void DialogAccepted();
|
||||||
signals:
|
signals:
|
||||||
void FullUpdateTree();
|
void FullUpdateTree();
|
||||||
void haveLiteChange();
|
void haveLiteChange();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogIncrements)
|
Q_DISABLE_COPY(DialogIncrements)
|
||||||
Ui::DialogIncrements *ui;
|
Ui::DialogIncrements *ui;
|
||||||
VContainer *data; // need because we must change data
|
VContainer *data; // need because we must change data
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
void InitialStandartTable();
|
void InitialStandartTable();
|
||||||
void InitialIncrementTable();
|
void InitialIncrementTable();
|
||||||
void InitialLinesTable();
|
void InitialLinesTable();
|
||||||
void InitialSplinesTable();
|
void InitialSplinesTable();
|
||||||
void InitialArcsTable();
|
void InitialArcsTable();
|
||||||
void FillStandartTable();
|
void FillStandartTable();
|
||||||
void FillIncrementTable();
|
void FillIncrementTable();
|
||||||
void FillLengthLines();
|
void FillLengthLines();
|
||||||
void FillLengthSplines();
|
void FillLengthSplines();
|
||||||
void FillLengthArcs();
|
void FillLengthArcs();
|
||||||
void AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
|
void AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
|
||||||
QString description);
|
QString description);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGINCREMENTS_H
|
#endif // DIALOGINCREMENTS_H
|
||||||
|
|
|
@ -53,10 +53,8 @@
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent,
|
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */,
|
||||||
const QStyleOptionViewItem &/* option */,
|
const QModelIndex &/* index */) const{
|
||||||
const QModelIndex &/* index */) const
|
|
||||||
{
|
|
||||||
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
||||||
editor->setMinimum(-1000.0);
|
editor->setMinimum(-1000.0);
|
||||||
editor->setMaximum(1000.0);
|
editor->setMaximum(1000.0);
|
||||||
|
@ -64,18 +62,15 @@
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSpinBoxDelegate::setEditorData(QWidget *editor,
|
void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const{
|
||||||
const QModelIndex &index) const
|
qreal value = index.model()->data(index, Qt::EditRole).toDouble();
|
||||||
{
|
|
||||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
|
||||||
|
|
||||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||||
spinBox->setValue(value);
|
spinBox->setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const{
|
||||||
{
|
|
||||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||||
spinBox->interpretText();
|
spinBox->interpretText();
|
||||||
qreal value = spinBox->value();
|
qreal value = spinBox->value();
|
||||||
|
@ -84,7 +79,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor,
|
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor,
|
||||||
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
|
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const{
|
||||||
{
|
|
||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QStri
|
||||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString parametr = GetParametrString(domElement, name);
|
QString parametr = GetParametrString(domElement, name);
|
||||||
qreal param = parametr.toDouble(&ok);
|
qreal param = parametr.replace(",", ".").toDouble(&ok);
|
||||||
if(ok == false){
|
if(ok == false){
|
||||||
throw VExceptionConversionError(tr("Can't convert toDouble parameter"), name);
|
throw VExceptionConversionError(tr("Can't convert toDouble parameter"), name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user