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