Return selected names. Add them to the table.
--HG-- branch : feature
This commit is contained in:
parent
bff2731a7e
commit
dcbfc2240d
|
@ -64,6 +64,31 @@ DialogMDataBase::~DialogMDataBase()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogMDataBase::GetNewNames() const
|
||||||
|
{
|
||||||
|
if (selectMode)
|
||||||
|
{
|
||||||
|
QStringList newNames;
|
||||||
|
QTreeWidgetItemIterator it(ui->treeWidget,
|
||||||
|
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked );
|
||||||
|
while (*it)
|
||||||
|
{
|
||||||
|
const QString name = (*it)->data(0, Qt::UserRole).toString();
|
||||||
|
if (not list.contains(name))
|
||||||
|
{
|
||||||
|
newNames.append(name);
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
return newNames;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
|
void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
explicit DialogMDataBase(QWidget *parent = 0);
|
explicit DialogMDataBase(QWidget *parent = 0);
|
||||||
~DialogMDataBase();
|
~DialogMDataBase();
|
||||||
|
|
||||||
|
QStringList GetNewNames() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void UpdateChecks(QTreeWidgetItem *item, int column);
|
void UpdateChecks(QTreeWidgetItem *item, int column);
|
||||||
void ShowDescription(QTreeWidgetItem *item, int column);
|
void ShowDescription(QTreeWidgetItem *item, int column);
|
||||||
|
|
|
@ -645,9 +645,6 @@ void TMainWindow::Fx()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::AddCustom()
|
void TMainWindow::AddCustom()
|
||||||
{
|
{
|
||||||
ui->tableWidget->setFocus(Qt::OtherFocusReason);
|
|
||||||
ui->tableWidget->blockSignals(true);
|
|
||||||
|
|
||||||
qint32 num = 1;
|
qint32 num = 1;
|
||||||
QString name;
|
QString name;
|
||||||
do
|
do
|
||||||
|
@ -661,7 +658,6 @@ void TMainWindow::AddCustom()
|
||||||
if (ui->tableWidget->currentRow() == -1)
|
if (ui->tableWidget->currentRow() == -1)
|
||||||
{
|
{
|
||||||
currentRow = ui->tableWidget->rowCount();
|
currentRow = ui->tableWidget->rowCount();
|
||||||
ui->tableWidget->insertRow( currentRow );
|
|
||||||
m->AddEmpty(name);
|
m->AddEmpty(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -673,7 +669,6 @@ void TMainWindow::AddCustom()
|
||||||
|
|
||||||
RefreshData();
|
RefreshData();
|
||||||
|
|
||||||
ui->tableWidget->blockSignals(false);
|
|
||||||
ui->tableWidget->selectRow(currentRow);
|
ui->tableWidget->selectRow(currentRow);
|
||||||
|
|
||||||
MeasurementsWasSaved(false);
|
MeasurementsWasSaved(false);
|
||||||
|
@ -685,7 +680,48 @@ void TMainWindow::AddKnown()
|
||||||
DialogMDataBase *dialog = new DialogMDataBase(m->ListKnown(), this);
|
DialogMDataBase *dialog = new DialogMDataBase(m->ListKnown(), this);
|
||||||
if (dialog->exec() == QDialog::Accepted)
|
if (dialog->exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
qint32 currentRow;
|
||||||
|
|
||||||
|
const QStringList list = dialog->GetNewNames();
|
||||||
|
if (ui->tableWidget->currentRow() == -1)
|
||||||
|
{
|
||||||
|
currentRow = ui->tableWidget->rowCount() + list.size() - 1;
|
||||||
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
if (mType == MeasurementsType::Individual)
|
||||||
|
{
|
||||||
|
m->AddEmpty(list.at(i), qApp->TrVars()->MFormula(list.at(i)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m->AddEmpty(list.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentRow = ui->tableWidget->currentRow() + list.size();
|
||||||
|
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0);
|
||||||
|
QString after = nameField->text();
|
||||||
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
if (mType == MeasurementsType::Individual)
|
||||||
|
{
|
||||||
|
m->AddEmptyAfter(after, list.at(i), qApp->TrVars()->MFormula(list.at(i)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m->AddEmptyAfter(after, list.at(i));
|
||||||
|
}
|
||||||
|
after = list.at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshData();
|
||||||
|
|
||||||
|
ui->tableWidget->selectRow(currentRow);
|
||||||
|
|
||||||
|
MeasurementsWasSaved(false);
|
||||||
}
|
}
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,18 +104,18 @@ void VMeasurements::setXMLContent(const QString &fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::AddEmpty(const QString &name)
|
void VMeasurements::AddEmpty(const QString &name, const QString &formula)
|
||||||
{
|
{
|
||||||
const QDomElement element = MakeEmpty(name);
|
const QDomElement element = MakeEmpty(name, formula);
|
||||||
|
|
||||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||||
list.at(0).appendChild(element);
|
list.at(0).appendChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::AddEmptyAfter(const QString &after, const QString &name)
|
void VMeasurements::AddEmptyAfter(const QString &after, const QString &name, const QString &formula)
|
||||||
{
|
{
|
||||||
const QDomElement element = MakeEmpty(name);
|
const QDomElement element = MakeEmpty(name, formula);
|
||||||
const QDomElement sibling = FindM(after);
|
const QDomElement sibling = FindM(after);
|
||||||
|
|
||||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||||
|
@ -622,7 +622,7 @@ qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qrea
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VMeasurements::MakeEmpty(const QString &name)
|
QDomElement VMeasurements::MakeEmpty(const QString &name, const QString &formula)
|
||||||
{
|
{
|
||||||
QDomElement element = createElement(TagMeasurement);
|
QDomElement element = createElement(TagMeasurement);
|
||||||
|
|
||||||
|
@ -636,7 +636,14 @@ QDomElement VMeasurements::MakeEmpty(const QString &name)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetAttribute(element, AttrValue, QString("0"));
|
if (formula.isEmpty())
|
||||||
|
{
|
||||||
|
SetAttribute(element, AttrValue, QString("0"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAttribute(element, AttrValue, formula);
|
||||||
|
}
|
||||||
SetAttribute(element, AttrDescription, QString(""));
|
SetAttribute(element, AttrDescription, QString(""));
|
||||||
SetAttribute(element, AttrFullName, QString(""));
|
SetAttribute(element, AttrFullName, QString(""));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ public:
|
||||||
|
|
||||||
void setXMLContent(const QString &fileName);
|
void setXMLContent(const QString &fileName);
|
||||||
|
|
||||||
void AddEmpty(const QString &name);
|
void AddEmpty(const QString &name, const QString &formula = QString());
|
||||||
void AddEmptyAfter(const QString &after, const QString &name);
|
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
|
||||||
void Remove(const QString &name);
|
void Remove(const QString &name);
|
||||||
void MoveUp(const QString &name);
|
void MoveUp(const QString &name);
|
||||||
void MoveDown(const QString &name);
|
void MoveDown(const QString &name);
|
||||||
|
@ -133,7 +133,7 @@ private:
|
||||||
|
|
||||||
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
|
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
|
||||||
|
|
||||||
QDomElement MakeEmpty(const QString &name);
|
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
||||||
QDomElement FindM(const QString &name) const;
|
QDomElement FindM(const QString &name) const;
|
||||||
MeasurementsType ReadType() const;
|
MeasurementsType ReadType() const;
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,12 @@ QString VTranslateVars::MNumber(const QString &measurement) const
|
||||||
return numbers.value(measurement);
|
return numbers.value(measurement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VTranslateVars::MFormula(const QString &measurement) const
|
||||||
|
{
|
||||||
|
return formulas.value(measurement);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VTranslateVars::GuiText(const QString &measurement) const
|
QString VTranslateVars::GuiText(const QString &measurement) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
|
|
||||||
QString MToUser(const QString &measurement) const;
|
QString MToUser(const QString &measurement) const;
|
||||||
QString MNumber(const QString &measurement) const;
|
QString MNumber(const QString &measurement) const;
|
||||||
|
QString MFormula(const QString &measurement) const;
|
||||||
QString GuiText(const QString &measurement) const;
|
QString GuiText(const QString &measurement) const;
|
||||||
QString Description(const QString &measurement) const;
|
QString Description(const QString &measurement) const;
|
||||||
QString PostfixOperator(const QString &name) const;
|
QString PostfixOperator(const QString &name) const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user