From da8e2c55f9d3b4a9e6415c9e541f817e9187b583 Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 4 Oct 2013 19:51:03 +0300 Subject: [PATCH] Field formula set focus when we add new variable to formula. --HG-- branch : develop --- dialogs/dialogarc.cpp | 2 +- dialogs/dialogdetail.cpp | 4 +-- dialogs/dialoghistory.cpp | 60 ++++++++++++++++++------------------ dialogs/dialogincrements.cpp | 42 ++++++++++++------------- dialogs/dialogtool.cpp | 18 ++++++----- 5 files changed, 64 insertions(+), 62 deletions(-) diff --git a/dialogs/dialogarc.cpp b/dialogs/dialogarc.cpp index 7f77b419c..2cfea8689 100644 --- a/dialogs/dialogarc.cpp +++ b/dialogs/dialogarc.cpp @@ -153,7 +153,7 @@ void DialogArc::ValChenged(int row){ QListWidgetItem *item = ui->listWidget->item( row ); if(ui->radioButtonLineAngles->isChecked()){ QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text())) - .arg("Значення кута лінії."); + .arg(tr("Value angle of line.")); ui->labelDescription->setText(desc); return; } diff --git a/dialogs/dialogdetail.cpp b/dialogs/dialogdetail.cpp index fc5a36543..3d26e18c5 100644 --- a/dialogs/dialogdetail.cpp +++ b/dialogs/dialogdetail.cpp @@ -59,7 +59,7 @@ void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){ NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour); break; default: - qWarning()<<"Get wrong scene object. Ignore."; + qWarning()<show(); @@ -120,7 +120,7 @@ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, No break; } default: - qWarning()<<"Get wrong tools. Ignore."; + qWarning()<GetPoint(tool.getId()).name()); + record = QString(tr("%1 - Base point")).arg(data->GetPoint(tool.getId()).name()); break; case Tool::EndLineTool: domElement = doc->elementById(QString().setNum(tool.getId())); if(domElement.isElement()){ basePointId = domElement.attribute("basePoint", "").toLongLong(); } - record = QString("%1_%2 - Відрізок з точки %1 до точки %2").arg(data->GetPoint(basePointId).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(), + data->GetPoint(tool.getId()).name()); break; case Tool::LineTool: domElement = doc->elementById(QString().setNum(tool.getId())); @@ -163,8 +163,8 @@ QString DialogHistory::Record(const VToolRecord &tool){ firstPointId = domElement.attribute("firstPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong(); } - record = QString("%1_%2 - Лінія з точки %1 до точки %2").arg(data->GetPoint(firstPointId).name(), - data->GetPoint(secondPointId).name()); + record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(), + data->GetPoint(secondPointId).name()); break; case Tool::AlongLineTool: domElement = doc->elementById(QString().setNum(tool.getId())); @@ -172,12 +172,12 @@ QString DialogHistory::Record(const VToolRecord &tool){ basePointId = domElement.attribute("firstPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong(); } - record = QString("%3 - Точка на відрізку %1_%2").arg(data->GetPoint(basePointId).name(), - data->GetPoint(secondPointId).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(), + data->GetPoint(secondPointId).name(), + data->GetPoint(tool.getId()).name()); break; case Tool::ShoulderPointTool: - record = QString("%1 - Плечева точка").arg(data->GetPoint(tool.getId()).name()); + record = QString(tr("%1 - Point of soulder")).arg(data->GetPoint(tool.getId()).name()); break; case Tool::NormalTool: domElement = doc->elementById(QString().setNum(tool.getId())); @@ -185,9 +185,9 @@ QString DialogHistory::Record(const VToolRecord &tool){ basePointId = domElement.attribute("firstPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong(); } - record = QString("%3 - Перпендикуляр до відрузку %1_%2").arg(data->GetPoint(basePointId).name(), - data->GetPoint(secondPointId).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%3 - Normal to line %1_%2")).arg(data->GetPoint(basePointId).name(), + data->GetPoint(secondPointId).name(), + data->GetPoint(tool.getId()).name()); break; case Tool::BisectorTool: domElement = doc->elementById(QString().setNum(tool.getId())); @@ -196,10 +196,10 @@ QString DialogHistory::Record(const VToolRecord &tool){ basePointId = domElement.attribute("secondPoint", "").toLongLong(); thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); } - record = QString("%4 - Бісектриса кута %1_%2_%3").arg(data->GetPoint(firstPointId).name(), - data->GetPoint(basePointId).name(), - data->GetPoint(thirdPointId).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%4 - Bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(), + data->GetPoint(basePointId).name(), + data->GetPoint(thirdPointId).name(), + data->GetPoint(tool.getId()).name()); break; case Tool::LineIntersectTool: domElement = doc->elementById(QString().setNum(tool.getId())); @@ -209,28 +209,28 @@ QString DialogHistory::Record(const VToolRecord &tool){ p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); p2Line2 = domElement.attribute("p2Line2", "").toLongLong(); } - record = QString("%5 - Точка перетину відрузку %1_%2 і %3_%4").arg(data->GetPoint(p1Line1).name(), - data->GetPoint(p2Line1).name(), - data->GetPoint(p1Line2).name(), - data->GetPoint(p2Line2).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%5 - Point of intersection lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(), + data->GetPoint(p2Line1).name(), + data->GetPoint(p1Line2).name(), + data->GetPoint(p2Line2).name(), + data->GetPoint(tool.getId()).name()); break; case Tool::SplineTool:{ VSpline spl = data->GetSpline(tool.getId()); - record = QString("Сплайн %1_%2").arg(data->GetPoint(spl.GetP1()).name(), + record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(), data->GetPoint(spl.GetP4()).name()); } break; case Tool::ArcTool:{ VArc arc = data->GetArc(tool.getId()); - record = QString("Дуга з центром в точці %1").arg(data->GetPoint(arc.GetCenter()).name()); + record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name()); } break; case Tool::SplinePathTool:{ VSplinePath splPath = data->GetSplinePath(tool.getId()); QVector points = splPath.GetSplinePath(); if(points.size() != 0 ){ - record = QString("Шлях сплайну %1").arg(data->GetPoint(points[0].P()).name()); + record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name()); for(qint32 i = 1; i< points.size(); ++i){ QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name()); record.append(name); @@ -245,13 +245,13 @@ QString DialogHistory::Record(const VToolRecord &tool){ firstPointId = domElement.attribute("firstPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong(); } - record = QString("%4 - Точка дотику дуги з центром в точці %1 і відрізку %2_%3").arg(data->GetPoint(center).name(), - data->GetPoint(firstPointId).name(), - data->GetPoint(secondPointId).name(), - data->GetPoint(tool.getId()).name()); + record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg(data->GetPoint(center).name(), + data->GetPoint(firstPointId).name(), + data->GetPoint(secondPointId).name(), + data->GetPoint(tool.getId()).name()); break; default: - qWarning()<<"Get wrong tool type. Ignore."; + qWarning()<tableWidget->setSortingEnabled(false); ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); - ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Інструмент")); + ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool"))); } void DialogHistory::ShowPoint(){ diff --git a/dialogs/dialogincrements.cpp b/dialogs/dialogincrements.cpp index f26012fd1..7ea38338c 100644 --- a/dialogs/dialogincrements.cpp +++ b/dialogs/dialogincrements.cpp @@ -261,7 +261,7 @@ void DialogIncrements::clickedToolButtonAdd(){ qint32 num = 1; QString name; do{ - name = QString("Позначення %1").arg(num); + name = QString(tr("Denotation %1")).arg(num); num++; }while(data->IncrementTableContains(name)); @@ -269,7 +269,7 @@ void DialogIncrements::clickedToolButtonAdd(){ qreal base = 0; qreal ksize = 0; qreal kgrowth = 0; - QString description = QString("Опис"); + QString description = QString(tr("Description")); VIncrementTableRow incrementRow = VIncrementTableRow(id, base, ksize, kgrowth, description); data->AddIncrementTableRow(name, incrementRow); @@ -302,7 +302,7 @@ void DialogIncrements::clickedToolButtonAdd(){ item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 4, item); - item = new QTableWidgetItem("Опис"); + item = new QTableWidgetItem(tr("Description")); item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 5, item); @@ -428,37 +428,37 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){ void DialogIncrements::InitialStandartTable(){ ui->tableWidgetStandart->setSortingEnabled(false); - ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Позначення"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Розрах. знач."))); - ui->tableWidgetStandart->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Базове знач."))); - ui->tableWidgetStandart->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("В розмірі"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("В рості"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Опис"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Base value"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth"))); + ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); } void DialogIncrements::InitialIncrementTable(){ ui->tableWidgetIncrement->setSortingEnabled(false); - ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Позначення"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Розрах. знач."))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Базове знач."))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("В розмірі"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("В рості"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Опис"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Base value"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth"))); + ui->tableWidgetIncrement->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); } void DialogIncrements::InitialLinesTable(){ - ui->tableWidgetLines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Лінія"))); - ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Довжина"))); + ui->tableWidgetLines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Line"))); + ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); } void DialogIncrements::InitialSplinesTable(){ - ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Лінія"))); - ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Довжина"))); + ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve"))); + ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); } void DialogIncrements::InitialArcsTable(){ - ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Лінія"))); - ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Довжина"))); + ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc"))); + ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); } void DialogIncrements::DialogAccepted(){ diff --git a/dialogs/dialogtool.cpp b/dialogs/dialogtool.cpp index f5641e33c..c997d9812 100644 --- a/dialogs/dialogtool.cpp +++ b/dialogs/dialogtool.cpp @@ -52,7 +52,7 @@ void DialogTool::showEvent(QShowEvent *event){ if(isInitialized){ return; } - isInitialized = true;//перший показ вікна вже відбувся + isInitialized = true;//first show windows are held } void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ @@ -69,7 +69,7 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ } } else { if(idDetail <= 0){ - qWarning()<<"Wrong details id."<GetDetail(idDetail); @@ -93,12 +93,12 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ void DialogTool::FillComboBoxTypeLine(QComboBox *box) const{ QStringList list; - list<<"Лінія"<<"Без лінії"; + list<addItems(list); } QString DialogTool::GetTypeLine(const QComboBox *box) const{ - if(box->currentText()=="Лінія"){ + if(box->currentText()==tr("Line")){ return QString("hair"); } else { return QString("none"); @@ -107,13 +107,13 @@ QString DialogTool::GetTypeLine(const QComboBox *box) const{ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value){ if(value == "hair"){ - qint32 index = box->findText("Лінія"); + qint32 index = box->findText(tr("Line")); if(index != -1){ box->setCurrentIndex(index); } } if(value == "none"){ - qint32 index = box->findText("Без лінії"); + qint32 index = box->findText(tr("No line")); if(index != -1){ box->setCurrentIndex(index); } @@ -140,6 +140,7 @@ void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget){ QListWidgetItem *item = listWidget->currentItem(); QString val = item->text(); lineEdit->setText(lineEdit->text().append(val)); + lineEdit->setFocus(); } void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){ @@ -164,7 +165,7 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) QString errorMsg; qreal result = cal.eval(edit->text(),&errorMsg); if(!errorMsg.isEmpty()){ - label->setText("Помилка."); + label->setText(tr("Error")); flag = false; } else { label->setText(QString().setNum(result)); @@ -303,6 +304,7 @@ void DialogTool::PutVal(QListWidgetItem *item){ Q_CHECK_PTR(lineEditFormula); QString val = item->text(); lineEditFormula->setText(lineEditFormula->text().append(val)); + lineEditFormula->setFocus(); } void DialogTool::ValChenged(int row){ @@ -343,7 +345,7 @@ void DialogTool::ValChenged(int row){ } if(radioButtonLengthLine->isChecked()){ QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text())) - .arg("Довжина лінії"); + .arg(tr("Line length")); labelDescription->setText(desc); return; }