From ed844c1c82141799abb2f33526b80cd800be4e76 Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 12:06:36 +0300 Subject: [PATCH 1/7] Alwayse show scrollbars for scene. --HG-- branch : develop --- src/app/mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 47155b812..25d8742fa 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -67,6 +67,8 @@ MainWindow::MainWindow(QWidget *parent) connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); view = new VMainGraphicsView(); ui->LayoutView->addWidget(view); + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setScene(currentScene); sceneDraw->setTransform(view->transform()); From f99b571c6ec594b7dee4031750991bddf7f15566 Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 12:27:02 +0300 Subject: [PATCH 2/7] Move documentation to cpp file. --HG-- branch : develop --- src/app/mainwindow.cpp | 329 ++++++++++++++++++++++++++++++++++++++++ src/app/mainwindow.h | 332 +---------------------------------------- 2 files changed, 331 insertions(+), 330 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 25d8742fa..5a37b66b5 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -47,6 +47,10 @@ #include //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MainWindow constructor. + * @param parent parent widget. + */ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool), currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr), @@ -96,6 +100,9 @@ MainWindow::MainWindow(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionNewDraw add to scene new pattern peace. + */ void MainWindow::ActionNewDraw() { QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); @@ -185,6 +192,9 @@ void MainWindow::ActionNewDraw() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief OptionDraw help change name of pattern peace. + */ void MainWindow::OptionDraw() { const QString activDraw = doc->GetNameActivDraw(); @@ -204,6 +214,14 @@ void MainWindow::OptionDraw() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetToolButton set tool and show dialog. + * @param checked true if tool button checked. + * @param t tool type. + * @param cursor path tool cursor icon. + * @param toolTip first tooltipe. + * @param closeDialogSlot function what handle after close dialog. + */ template void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot) @@ -233,6 +251,10 @@ void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString & } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialog handle close dialog + * @param result result working dialog. + */ template void MainWindow::ClosedDialog(int result) { @@ -245,6 +267,10 @@ void MainWindow::ClosedDialog(int result) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolEndLine handler tool endLine. + * @param checked true - button checked. + */ void MainWindow::ToolEndLine(bool checked) { SetToolButton(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), @@ -252,12 +278,20 @@ void MainWindow::ToolEndLine(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogEndLine actions after closing DialogEndLine. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogEndLine(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolLine handler tool line. + * @param checked true - button checked. + */ void MainWindow::ToolLine(bool checked) { SetToolButton(checked, Valentina::LineTool, ":/cursor/line_cursor.png", tr("Select first point"), @@ -265,12 +299,20 @@ void MainWindow::ToolLine(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogLine actions after closing DialogLine. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogLine(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolAlongLine handler tool alongLine. + * @param checked true - button checked. + */ void MainWindow::ToolAlongLine(bool checked) { SetToolButton(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png", @@ -278,12 +320,20 @@ void MainWindow::ToolAlongLine(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogAlongLine actions after closing DialogAlongLine. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogAlongLine(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolShoulderPoint handler tool shoulderPoint. + * @param checked true - button checked. + */ void MainWindow::ToolShoulderPoint(bool checked) { SetToolButton(checked, Valentina::ShoulderPointTool, ":/cursor/shoulder_cursor.png", @@ -291,12 +341,20 @@ void MainWindow::ToolShoulderPoint(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogShoulderPoint actions after closing DialogShoulderPoint. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogShoulderPoint(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolNormal handler tool normal. + * @param checked true - button checked. + */ void MainWindow::ToolNormal(bool checked) { SetToolButton(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png", @@ -304,12 +362,20 @@ void MainWindow::ToolNormal(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogNormal actions after closing DialogNormal. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogNormal(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBisector handler tool bisector. + * @param checked true - button checked. + */ void MainWindow::ToolBisector(bool checked) { SetToolButton(checked, Valentina::BisectorTool, ":/cursor/bisector_cursor.png", @@ -317,12 +383,20 @@ void MainWindow::ToolBisector(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogBisector actions after closing DialogBisector. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogBisector(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolLineIntersect handler tool lineIntersect. + * @param checked true - button checked. + */ void MainWindow::ToolLineIntersect(bool checked) { SetToolButton(checked, Valentina::LineIntersectTool, ":/cursor/intersect_cursor.png", @@ -330,12 +404,20 @@ void MainWindow::ToolLineIntersect(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogLineIntersect actions after closing DialogLineIntersect. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogLineIntersect(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolSpline handler tool spline. + * @param checked true - button checked. + */ void MainWindow::ToolSpline(bool checked) { SetToolButton(checked, Valentina::SplineTool, ":/cursor/spline_cursor.png", @@ -343,12 +425,20 @@ void MainWindow::ToolSpline(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogSpline actions after closing DialogSpline. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogSpline(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutSpline handler tool CutSpline. + * @param checked true - button is checked + */ void MainWindow::ToolCutSpline(bool checked) { SetToolButton(checked, Valentina::CutSplineTool, ":/cursor/spline_cut_point_cursor.png", @@ -356,12 +446,20 @@ void MainWindow::ToolCutSpline(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogCutSpline actions after closing DialogCutSpline. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogCutSpline(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolArc handler tool arc. + * @param checked true - button checked. + */ void MainWindow::ToolArc(bool checked) { SetToolButton(checked, Valentina::ArcTool, ":/cursor/arc_cursor.png", @@ -369,12 +467,20 @@ void MainWindow::ToolArc(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogArc actions after closing DialogArc. + * @param result result of dialog working.. + */ void MainWindow::ClosedDialogArc(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolSplinePath handler tool splinePath. + * @param checked true - button checked. + */ void MainWindow::ToolSplinePath(bool checked) { SetToolButton(checked, Valentina::SplinePathTool, ":/cursor/splinepath_cursor.png", @@ -382,12 +488,20 @@ void MainWindow::ToolSplinePath(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogSplinePath actions after closing DialogSplinePath. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogSplinePath(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutSplinePath handler tool CutSplinePath. + * @param checked true - button is checked + */ void MainWindow::ToolCutSplinePath(bool checked) { SetToolButton(checked, Valentina::CutSplinePathTool, @@ -396,12 +510,20 @@ void MainWindow::ToolCutSplinePath(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogCutSplinePath actions after closing DialogCutSplinePath. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogCutSplinePath(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolPointOfContact handler tool pointOfContact. + * @param checked true - button checked. + */ void MainWindow::ToolPointOfContact(bool checked) { SetToolButton(checked, Valentina::PointOfContact, ":/cursor/pointcontact_cursor.png", @@ -409,12 +531,20 @@ void MainWindow::ToolPointOfContact(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogPointOfContact actions after closing DialogPointOfContact. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogPointOfContact(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolDetail handler tool detail. + * @param checked true - button checked. + */ void MainWindow::ToolDetail(bool checked) { SetToolButton(checked, Valentina::DetailTool, "://cursor/new_detail_cursor.png", @@ -422,6 +552,10 @@ void MainWindow::ToolDetail(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogDetail actions after closing DialogDetail. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogDetail(int result) { if (result == QDialog::Accepted) @@ -433,6 +567,10 @@ void MainWindow::ClosedDialogDetail(int result) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolHeight handler tool height. + * @param checked true - button checked. + */ void MainWindow::ToolHeight(bool checked) { SetToolButton(checked, Valentina::Height, ":/cursor/height_cursor.png", tr("Select base point"), @@ -440,12 +578,20 @@ void MainWindow::ToolHeight(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogHeight actions after closing DialogHeight. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogHeight(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolTriangle handler tool triangle. + * @param checked true - button checked. + */ void MainWindow::ToolTriangle(bool checked) { SetToolButton(checked, Valentina::Triangle, ":/cursor/triangle_cursor.png", @@ -453,12 +599,20 @@ void MainWindow::ToolTriangle(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogTriangle actions after closing DialogTriangle. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogTriangle(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolPointOfIntersection handler tool pointOfIntersection. + * @param checked true - button checked. + */ void MainWindow::ToolPointOfIntersection(bool checked) { SetToolButton(checked, Valentina::PointOfIntersection, @@ -467,12 +621,20 @@ void MainWindow::ToolPointOfIntersection(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogPointOfIntersection actions after closing DialogPointOfIntersection. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogPointOfIntersection(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolUnionDetails handler tool unionDetails. + * @param checked true - button checked. + */ void MainWindow::ToolUnionDetails(bool checked) { SetToolButton(checked, Valentina::UnionDetails, ":/cursor/union_cursor.png", @@ -482,6 +644,10 @@ void MainWindow::ToolUnionDetails(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogUnionDetails actions after closing DialogUnionDetails. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogUnionDetails(int result) { ClosedDialog(result); @@ -489,6 +655,10 @@ void MainWindow::ClosedDialogUnionDetails(int result) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutArc handler tool cutArc. + * @param checked true - button checked. + */ void MainWindow::ToolCutArc(bool checked) { SetToolButton(checked, Valentina::CutArcTool, ":/cursor/arc_cut_cursor.png", tr("Select arc"), @@ -496,12 +666,19 @@ void MainWindow::ToolCutArc(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogCutArc actions after closing DialogCutArc. + * @param result result of dialog working. + */ void MainWindow::ClosedDialogCutArc(int result) { ClosedDialog(result); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief About show widows about. + */ void MainWindow::About() { DialogAboutApp * about_dialog = new DialogAboutApp(this); @@ -510,18 +687,28 @@ void MainWindow::About() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AboutQt show widows aboutQt. + */ void MainWindow::AboutQt() { QMessageBox::aboutQt(this, tr("About Qt")); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool.Tip show tools tooltip. + * @param toolTip tooltip text. + */ void MainWindow::ShowToolTip(const QString &toolTip) { helpLabel->setText(toolTip); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief tableClosed handle after close layout window. + */ void MainWindow::tableClosed() { show(); @@ -546,6 +733,10 @@ void MainWindow::PatternProperties() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief showEvent handle after show window. + * @param event show event. + */ void MainWindow::showEvent( QShowEvent *event ) { QMainWindow::showEvent( event ); @@ -566,6 +757,10 @@ void MainWindow::showEvent( QShowEvent *event ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle after close window. + * @param event close event. + */ void MainWindow::closeEvent(QCloseEvent *event) { if (MaybeSave()) @@ -580,6 +775,9 @@ void MainWindow::closeEvent(QCloseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBarOption enable option toolbar. + */ void MainWindow::ToolBarOption() { if (qApp->patternType() == Pattern::Standard) @@ -616,6 +814,9 @@ void MainWindow::ToolBarOption() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBarDraws enable draw toolbar. + */ void MainWindow::ToolBarDraws() { QLabel *labelPtternPieceName = new QLabel(tr("Pattern Piece: ")); @@ -667,6 +868,10 @@ void MainWindow::InitToolButtons() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief currentDrawChanged change active pattern peace. + * @param index index in combobox. + */ void MainWindow::currentDrawChanged( int index ) { if (index != -1) @@ -687,6 +892,10 @@ void MainWindow::currentDrawChanged( int index ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseMove save mouse position and show user. + * @param scenePos position mouse. + */ void MainWindow::mouseMove(const QPointF &scenePos) { QString string = QString("%1, %2").arg(static_cast(qApp->fromPixel(scenePos.x()))) @@ -698,6 +907,9 @@ void MainWindow::mouseMove(const QPointF &scenePos) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CanselTool cansel tool. + */ void MainWindow::CancelTool() { delete dialogTool; @@ -812,6 +1024,9 @@ void MainWindow::CancelTool() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowTool enable arrow tool. + */ void MainWindow::ArrowTool() { CancelTool(); @@ -823,12 +1038,19 @@ void MainWindow::ArrowTool() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionAroowTool set arrow tool. Cansel tool what was before. + */ void MainWindow::ActionAroowTool() { ArrowTool(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key event. + */ void MainWindow::keyPressEvent ( QKeyEvent * event ) { switch (event->key()) @@ -843,6 +1065,9 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveCurrentScene save scene options before set another. + */ void MainWindow::SaveCurrentScene() { /*Save transform*/ @@ -855,6 +1080,9 @@ void MainWindow::SaveCurrentScene() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RestoreCurrentScene restore scene options after change. + */ void MainWindow::RestoreCurrentScene() { /*Set transform for current scene*/ @@ -867,6 +1095,10 @@ void MainWindow::RestoreCurrentScene() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionDraw show draw scene. + * @param checked true - button checked. + */ void MainWindow::ActionDraw(bool checked) { if (checked) @@ -900,6 +1132,10 @@ void MainWindow::ActionDraw(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionDetails show details scene. + * @param checked true - button checked. + */ void MainWindow::ActionDetails(bool checked) { if (checked) @@ -935,6 +1171,10 @@ void MainWindow::ActionDetails(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveAs save as pattern file. + * @return true for successes saving. + */ bool MainWindow::SaveAs() { QString filters(tr("Pattern files (*.val)")); @@ -962,6 +1202,10 @@ bool MainWindow::SaveAs() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Save save pattern file. + * @return true for successes saving. + */ bool MainWindow::Save() { if (curFile.isEmpty()) @@ -982,6 +1226,9 @@ bool MainWindow::Save() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Open ask user select pattern file. + */ void MainWindow::Open() { if (MaybeSave()) @@ -1008,6 +1255,9 @@ void MainWindow::Open() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Options config dialog. + */ void MainWindow::Options() { ConfigDialog dlg(this); @@ -1018,6 +1268,9 @@ void MainWindow::Options() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear reset to default window. + */ void MainWindow::Clear() { setCurrentFile(""); @@ -1040,6 +1293,9 @@ void MainWindow::Clear() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewPattern create new empty pattern. + */ void MainWindow::NewPattern() { QProcess *v = new QProcess(this); @@ -1048,6 +1304,9 @@ void MainWindow::NewPattern() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief haveChange enable action save if we have unsaved change. + */ void MainWindow::PatternWasModified() { setWindowModified(doc->isPatternModified()); @@ -1055,6 +1314,10 @@ void MainWindow::PatternWasModified() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedSize change new size value. + * @param text value size. + */ void MainWindow::ChangedSize(const QString & text) { qint32 size = text.toInt(); @@ -1063,6 +1326,10 @@ void MainWindow::ChangedSize(const QString & text) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedGrowth change new height value. + * @param text value height. + */ void MainWindow::ChangedHeight(const QString &text) { qint32 growth = text.toInt(); @@ -1071,6 +1338,10 @@ void MainWindow::ChangedHeight(const QString &text) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetEnableWidgets enable action button. + * @param enable enable value. + */ void MainWindow::SetEnableWidgets(bool enable) { ui->actionSaveAs->setEnabled(enable); @@ -1086,6 +1357,10 @@ void MainWindow::SetEnableWidgets(bool enable) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionTable show table with variables. + * @param checked true - button checked. + */ void MainWindow::ActionTable(bool checked) { if (checked) @@ -1102,6 +1377,9 @@ void MainWindow::ActionTable(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedActionTable actions after closing table with variables. + */ void MainWindow::ClosedActionTable() { ui->actionTable->setChecked(false); @@ -1110,6 +1388,10 @@ void MainWindow::ClosedActionTable() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionHistory show tool history. + * @param checked true - button checked. + */ void MainWindow::ActionHistory(bool checked) { if (checked) @@ -1127,6 +1409,10 @@ void MainWindow::ActionHistory(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionLayout begin creation layout. + * @param checked true - button checked. + */ void MainWindow::ActionLayout(bool checked) { Q_UNUSED(checked); @@ -1145,6 +1431,9 @@ void MainWindow::ActionLayout(bool checked) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedActionHistory actions after closing history window with variables. + */ void MainWindow::ClosedActionHistory() { ui->actionHistory->setChecked(false); @@ -1152,6 +1441,10 @@ void MainWindow::ClosedActionHistory() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetEnableTool enable button. + * @param enable enable value. + */ void MainWindow::SetEnableTool(bool enable) { bool drawTools = false; @@ -1189,6 +1482,9 @@ void MainWindow::SetEnableTool(bool enable) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MinimumScrollBar set scroll bar to minimum. + */ void MainWindow::MinimumScrollBar() { QScrollBar *horScrollBar = view->horizontalScrollBar(); @@ -1198,6 +1494,11 @@ void MainWindow::MinimumScrollBar() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SavePattern save pattern file. + * @param fileName pattern file name. + * @return true if all is good. + */ bool MainWindow::SavePattern(const QString &fileName) { QFileInfo tempInfo(fileName); @@ -1214,6 +1515,9 @@ bool MainWindow::SavePattern(const QString &fileName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AutoSavePattern start safe saving. + */ void MainWindow::AutoSavePattern() { if (curFile.isEmpty() == false && doc->isPatternModified() == true) @@ -1227,6 +1531,11 @@ void MainWindow::AutoSavePattern() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentFile the function is called to reset the state of a few variables when a file + * is loaded or saved, or when the user starts editing a new file (in which case fileName is empty). + * @param fileName file name. + */ void MainWindow::setCurrentFile(const QString &fileName) { curFile = fileName; @@ -1258,11 +1567,20 @@ void MainWindow::setCurrentFile(const QString &fileName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief strippedName the function call around curFile to exclude the path to the file. + * @param fullFileName full path to the file. + * @return file name. + */ QString MainWindow::strippedName(const QString &fullFileName) { return QFileInfo(fullFileName).fileName(); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ReadSettings read setting for app. + */ void MainWindow::ReadSettings() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), @@ -1274,6 +1592,9 @@ void MainWindow::ReadSettings() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief WriteSettings save setting for app. + */ void MainWindow::WriteSettings() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), @@ -1283,6 +1604,10 @@ void MainWindow::WriteSettings() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MaybeSave The function is called to save pending changes. + * @return returns true in all cases, except when the user clicks Cancel. + */ bool MainWindow::MaybeSave() { if (doc->isPatternModified()) @@ -1439,6 +1764,10 @@ MainWindow::~MainWindow() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LoadPattern open pattern file. + * @param fileName name of file. + */ void MainWindow::LoadPattern(const QString &fileName) { try diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 9a8f8407f..dfeb43174 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -51,315 +51,71 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - /** - * @brief MainWindow constructor. - * @param parent parent widget. - */ - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - /** - * @brief LoadPattern open pattern file. - * @param fileName name of file. - */ + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); void LoadPattern(const QString &curFile); public slots: - /** - * @brief mouseMove save mouse position and show user. - * @param scenePos position mouse. - */ void mouseMove(const QPointF &scenePos); - /** - * @brief ActionAroowTool set arrow tool. Cansel tool what was before. - */ void ActionAroowTool(); - /** - * @brief ActionDraw show draw scene. - * @param checked true - button checked. - */ void ActionDraw(bool checked); - /** - * @brief ActionDetails show details scene. - * @param checked true - button checked. - */ void ActionDetails(bool checked); - /** - * @brief ActionNewDraw add to scene new pattern peace. - */ void ActionNewDraw(); - /** - * @brief SaveAs save as pattern file. - * @return true for successes saving. - */ bool SaveAs(); - /** - * @brief Save save pattern file. - * @return true for successes saving. - */ bool Save(); - /** - * @brief Open ask user select pattern file. - */ void Open(); - /** - * @brief Options config dialog. - */ void Options(); - /** - * @brief NewPattern create new empty pattern. - */ void NewPattern(); - /** - * @brief ActionTable show table with variables. - * @param checked true - button checked. - */ void ActionTable(bool checked); - /** - * @brief ActionHistory show tool history. - * @param checked true - button checked. - */ void ActionHistory(bool checked); - /** - * @brief ActionLayout begin creation layout. - * @param checked true - button checked. - */ void ActionLayout(bool checked); - /** - * @brief currentDrawChanged change active pattern peace. - * @param index index in combobox. - */ void currentDrawChanged( int index ); - /** - * @brief OptionDraw help change name of pattern peace. - */ void OptionDraw(); - /** - * @brief haveChange enable action save if we have unsaved change. - */ void PatternWasModified(); - /** - * @brief ChangedSize change new size value. - * @param text value size. - */ void ChangedSize(const QString &text); - /** - * @brief ChangedGrowth change new height value. - * @param text value height. - */ void ChangedHeight(const QString & text); - /** - * @brief ClosedActionTable actions after closing table with variables. - */ void ClosedActionTable(); - /** - * @brief ClosedActionHistory actions after closing history window with variables. - */ void ClosedActionHistory(); - /** - * @brief ToolEndLine handler tool endLine. - * @param checked true - button checked. - */ void ToolEndLine(bool checked); - /** - * @brief ToolLine handler tool line. - * @param checked true - button checked. - */ void ToolLine(bool checked); - /** - * @brief ToolAlongLine handler tool alongLine. - * @param checked true - button checked. - */ void ToolAlongLine(bool checked); - /** - * @brief ToolShoulderPoint handler tool shoulderPoint. - * @param checked true - button checked. - */ void ToolShoulderPoint(bool checked); - /** - * @brief ToolNormal handler tool normal. - * @param checked true - button checked. - */ void ToolNormal(bool checked); - /** - * @brief ToolBisector handler tool bisector. - * @param checked true - button checked. - */ void ToolBisector(bool checked); - /** - * @brief ToolLineIntersect handler tool lineIntersect. - * @param checked true - button checked. - */ void ToolLineIntersect(bool checked); - /** - * @brief ToolSpline handler tool spline. - * @param checked true - button checked. - */ void ToolSpline(bool checked); - /** - * @brief ToolCutSpline handler tool CutSpline. - * @param checked true - button is checked - */ void ToolCutSpline(bool checked); - /** - * @brief ToolArc handler tool arc. - * @param checked true - button checked. - */ void ToolArc(bool checked); - /** - * @brief ToolSplinePath handler tool splinePath. - * @param checked true - button checked. - */ void ToolSplinePath(bool checked); - /** - * @brief ToolCutSplinePath handler tool CutSplinePath. - * @param checked true - button is checked - */ void ToolCutSplinePath(bool checked); - /** - * @brief ToolPointOfContact handler tool pointOfContact. - * @param checked true - button checked. - */ void ToolPointOfContact(bool checked); - /** - * @brief ToolDetail handler tool detail. - * @param checked true - button checked. - */ void ToolDetail(bool checked); - /** - * @brief ToolHeight handler tool height. - * @param checked true - button checked. - */ void ToolHeight(bool checked); - /** - * @brief ToolTriangle handler tool triangle. - * @param checked true - button checked. - */ void ToolTriangle(bool checked); - /** - * @brief ToolPointOfIntersection handler tool pointOfIntersection. - * @param checked true - button checked. - */ void ToolPointOfIntersection(bool checked); - /** - * @brief ToolUnionDetails handler tool unionDetails. - * @param checked true - button checked. - */ void ToolUnionDetails(bool checked); - /** - * @brief ToolCutArc handler tool cutArc. - * @param checked true - button checked. - */ void ToolCutArc(bool checked); - /** - * @brief ClosedDialogEndLine actions after closing DialogEndLine. - * @param result result of dialog working. - */ void ClosedDialogEndLine(int result); - /** - * @brief ClosedDialogLine actions after closing DialogLine. - * @param result result of dialog working. - */ void ClosedDialogLine(int result); - /** - * @brief ClosedDialogAlongLine actions after closing DialogAlongLine. - * @param result result of dialog working. - */ void ClosedDialogAlongLine(int result); - /** - * @brief ClosedDialogShoulderPoint actions after closing DialogShoulderPoint. - * @param result result of dialog working. - */ void ClosedDialogShoulderPoint(int result); - /** - * @brief ClosedDialogNormal actions after closing DialogNormal. - * @param result result of dialog working. - */ void ClosedDialogNormal(int result); - /** - * @brief ClosedDialogBisector actions after closing DialogBisector. - * @param result result of dialog working. - */ void ClosedDialogBisector(int result); - /** - * @brief ClosedDialogLineIntersect actions after closing DialogLineIntersect. - * @param result result of dialog working. - */ void ClosedDialogLineIntersect(int result); - /** - * @brief ClosedDialogSpline actions after closing DialogSpline. - * @param result result of dialog working. - */ void ClosedDialogSpline(int result); - /** - * @brief ClosedDialogArc actions after closing DialogArc. - * @param result result of dialog working.. - */ void ClosedDialogArc(int result); - /** - * @brief ClosedDialogSplinePath actions after closing DialogSplinePath. - * @param result result of dialog working. - */ void ClosedDialogSplinePath(int result); - /** - * @brief ClosedDialogCutSplinePath actions after closing DialogCutSplinePath. - * @param result result of dialog working. - */ void ClosedDialogCutSplinePath(int result); - /** - * @brief ClosedDialogPointOfContact actions after closing DialogPointOfContact. - * @param result result of dialog working. - */ void ClosedDialogPointOfContact(int result); - /** - * @brief ClosedDialogDetail actions after closing DialogDetail. - * @param result result of dialog working. - */ void ClosedDialogDetail(int result); - /** - * @brief ClosedDialogHeight actions after closing DialogHeight. - * @param result result of dialog working. - */ void ClosedDialogHeight(int result); - /** - * @brief ClosedDialogTriangle actions after closing DialogTriangle. - * @param result result of dialog working. - */ void ClosedDialogTriangle(int result); - /** - * @brief ClosedDialogPointOfIntersection actions after closing DialogPointOfIntersection. - * @param result result of dialog working. - */ void ClosedDialogPointOfIntersection(int result); - /** - * @brief ClosedDialogUnionDetails actions after closing DialogUnionDetails. - * @param result result of dialog working. - */ void ClosedDialogUnionDetails(int result); - /** - * @brief ClosedDialogCutSpline actions after closing DialogCutSpline. - * @param result result of dialog working. - */ void ClosedDialogCutSpline(int result); - /** - * @brief ClosedDialogCutArc actions after closing DialogCutArc. - * @param result result of dialog working. - */ void ClosedDialogCutArc(int result); - /** - * @brief About show widows about. - */ void About(); - /** - * @brief AboutQt show widows aboutQt. - */ void AboutQt(); - /** - * @brief ShowTool highlight tool.Tip show tools tooltip. - * @param toolTip tooltip text. - */ void ShowToolTip(const QString &toolTip); - /** - * @brief tableClosed handle after close layout window. - */ void tableClosed(); void OpenRecentFile(); void PatternProperties(); @@ -371,24 +127,9 @@ signals: */ void ModelChosen(QVector listDetails, const QString &curFile, const QString &description); protected: - /** - * @brief keyPressEvent handle key press events. - * @param event key event. - */ virtual void keyPressEvent ( QKeyEvent * event ); - /** - * @brief showEvent handle after show window. - * @param event show event. - */ virtual void showEvent( QShowEvent *event ); - /** - * @brief closeEvent handle after close window. - * @param event close event. - */ virtual void closeEvent( QCloseEvent * event ); - /** - * @brief Clear reset to default window. - */ void Clear(); private: Q_DISABLE_COPY(MainWindow) @@ -467,96 +208,27 @@ private: QAction *recentFileActs[MaxRecentFiles]; QAction *separatorAct; QTimer *autoSaveTimer; - /** - * @brief ToolBarOption enable option toolbar. - */ void ToolBarOption(); - /** - * @brief ToolBarDraws enable draw toolbar. - */ void ToolBarDraws(); void InitToolButtons(); - /** - * @brief CanselTool cansel tool. - */ void CancelTool(); - /** - * @brief ArrowTool enable arrow tool. - */ void ArrowTool(); - /** - * @brief SetEnableWidgets enable action button. - * @param enable enable value. - */ void SetEnableWidgets(bool enable); - /** - * @brief SetEnableTool enable button. - * @param enable enable value. - */ void SetEnableTool(bool enable); - /** - * @brief SaveCurrentScene save scene options before set another. - */ void SaveCurrentScene(); - /** - * @brief RestoreCurrentScene restore scene options after change. - */ void RestoreCurrentScene(); template - /** - * @brief SetToolButton set tool and show dialog. - * @param checked true if tool button checked. - * @param t tool type. - * @param cursor path tool cursor icon. - * @param toolTip first tooltipe. - * @param closeDialogSlot function what handle after close dialog. - */ void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot); - /** - * @brief MinimumScrollBar set scroll bar to minimum. - */ void MinimumScrollBar(); template - /** - * @brief ClosedDialog handle close dialog - * @param result result working dialog. - */ void ClosedDialog(int result); - /** - * @brief SavePattern save pattern file. - * @param fileName pattern file name. - * @return true if all is good. - */ bool SavePattern(const QString &curFile); - /** - * @brief AutoSavePattern start safe saving. - */ void AutoSavePattern(); - /** - * @brief setCurrentFile the function is called to reset the state of a few variables when a file - * is loaded or saved, or when the user starts editing a new file (in which case fileName is empty). - * @param fileName file name. - */ void setCurrentFile(const QString &fileName); - /** - * @brief strippedName the function call around curFile to exclude the path to the file. - * @param fullFileName full path to the file. - * @return file name. - */ QString strippedName(const QString &fullFileName); - /** - * @brief ReadSettings read setting for app. - */ void ReadSettings(); - /** - * @brief WriteSettings save setting for app. - */ void WriteSettings(); - /** - * @brief MaybeSave The function is called to save pending changes. - * @return returns true in all cases, except when the user clicks Cancel. - */ bool MaybeSave(); void UpdateRecentFileActions(); void CreateMenus(); From 1501eb77eb87696947aa445338327d2e003dfa7f Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 13:08:16 +0300 Subject: [PATCH 3/7] Remember last open file path. --HG-- branch : develop --- src/app/mainwindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 5a37b66b5..f9ee3c4b8 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1234,14 +1234,19 @@ void MainWindow::Open() if (MaybeSave()) { QString filter(tr("Pattern files (*.val)")); + //Get list last open files + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + QStringList files = settings.value("recentFileList").toStringList(); QString dir; - if (curFile.isEmpty()) + if (files.isEmpty()) { dir = QDir::homePath(); } else { - dir = QFileInfo(curFile).absolutePath(); + //Absolute path to last open file + dir = QFileInfo(files.first()).absolutePath(); } QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter); if (fileName.isEmpty() == false) From 6b4067ee1b1d146cac79fb9ab1f94e1d4e04603f Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 17:58:25 +0300 Subject: [PATCH 4/7] Support local separator for numbers in formulas. Fix bug in translation formula. --HG-- branch : develop --- src/app/container/calculator.cpp | 8 +- src/app/widgets/vapplication.cpp | 219 ++++++++++++++++++++++--------- src/app/widgets/vapplication.h | 16 ++- 3 files changed, 177 insertions(+), 66 deletions(-) diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index 5dd5666b3..238616e74 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -49,6 +49,9 @@ Calculator::Calculator(const VContainer *data) DefinePostfixOprt(cm_Oprt, CmUnit); DefinePostfixOprt(mm_Oprt, MmUnit); DefinePostfixOprt(in_Oprt, InchUnit); + + SetArgSep(','); + SetDecSep('.'); } //--------------------------------------------------------------------------------------------------------------------- @@ -65,7 +68,7 @@ Calculator::Calculator(const QString &formula, bool fromUser) DefinePostfixOprt(qApp->PostfixOperator(mm_Oprt), MmUnit); DefinePostfixOprt(qApp->PostfixOperator(in_Oprt), InchUnit); - QLocale loc = QLocale(); + QLocale loc = QLocale::system(); SetDecSep(loc.decimalPoint().toLatin1()); SetThousandsSep(loc.groupSeparator().toLatin1()); SetArgSep(';'); @@ -75,6 +78,9 @@ Calculator::Calculator(const QString &formula, bool fromUser) DefinePostfixOprt(cm_Oprt, CmUnit); DefinePostfixOprt(mm_Oprt, MmUnit); DefinePostfixOprt(in_Oprt, InchUnit); + + SetArgSep(','); + SetDecSep('.'); } SetExpr(formula); diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index 132fa6835..6718e9b1f 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -1505,7 +1505,7 @@ void VApplication::InitPostfixOperators() } //--------------------------------------------------------------------------------------------------------------------- -bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const QString &token) const +bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const { QMap::const_iterator i = measurements.constBegin(); while (i != measurements.constEnd()) @@ -1513,6 +1513,7 @@ bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const if(token == i.value().translate()) { newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); return true; } ++i; @@ -1521,7 +1522,7 @@ bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const } //--------------------------------------------------------------------------------------------------------------------- -bool VApplication::VariablesFromUser(QString &newFormula, int position, const QString &token) const +bool VApplication::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const { QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) @@ -1529,6 +1530,9 @@ bool VApplication::VariablesFromUser(QString &newFormula, int position, const QS if(token.indexOf( i.value().translate() ) == 0) { newFormula.replace(position, i.value().translate().length(), i.key()); + QString newToken = token; + newToken.replace(0, i.value().translate().length(), i.key()); + bias = token.length() - newToken.length(); return true; } ++i; @@ -1537,7 +1541,7 @@ bool VApplication::VariablesFromUser(QString &newFormula, int position, const QS } //--------------------------------------------------------------------------------------------------------------------- -bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token) const +bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, int &bias) const { QMap::const_iterator i = postfixOperators.constBegin(); while (i != postfixOperators.constEnd()) @@ -1545,6 +1549,7 @@ bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, c if(token == i.value().translate()) { newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); return true; } ++i; @@ -1553,7 +1558,7 @@ bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, c } //--------------------------------------------------------------------------------------------------------------------- -bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QString &token) const +bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const { QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) @@ -1561,6 +1566,7 @@ bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QS if(token == i.value().translate()) { newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); return true; } ++i; @@ -1569,7 +1575,7 @@ bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QS } //--------------------------------------------------------------------------------------------------------------------- -bool VApplication::VariablesToUser(QString &newFormula, int position, const QString &token) const +bool VApplication::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const { QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) @@ -1577,6 +1583,10 @@ bool VApplication::VariablesToUser(QString &newFormula, int position, const QStr if(token.indexOf( i.key() ) == 0) { newFormula.replace(position, i.key().length(), i.value().translate()); + + QString newToken = token; + newToken.replace(0, i.key().length(), i.value().translate()); + bias = token.length() - newToken.length(); return true; } ++i; @@ -1584,6 +1594,37 @@ bool VApplication::VariablesToUser(QString &newFormula, int position, const QStr return false; } +void VApplication::CorrectionsPositions(int position, int bias, QMap &tokens, + QMap &numbers) +{ + if(bias == 0) + { + return; + } + + BiasTokens(position, bias, tokens); + BiasTokens(position, bias, numbers); +} + +void VApplication::BiasTokens(int position, int bias, QMap &tokens) const +{ + QMap newTokens; + QMap::const_iterator i = tokens.constBegin(); + while (i != tokens.constEnd()) + { + if(i.key()<= position) + { + newTokens.insert(i.key(), i.value()); + } + else + { + newTokens.insert(i.key()-bias, i.value()); + } + ++i; + } + tokens = newTokens; +} + //--------------------------------------------------------------------------------------------------------------------- void VApplication::setPatternUnit(const Valentina::Units &patternUnit) { @@ -1610,7 +1651,8 @@ QString VApplication::VarToUser(const QString &var) const } QString newVar = var; - if(VariablesToUser(newVar, 0, var)) + int bias = 0; + if(VariablesToUser(newVar, 0, var, bias)) { return newVar; } @@ -1621,22 +1663,23 @@ QString VApplication::VarToUser(const QString &var) const QString VApplication::VarFromUser(const QString &var) const { QString newVar = var; - if(MeasurementsFromUser(newVar, 0, var)) + int bias = 0; + if(MeasurementsFromUser(newVar, 0, var, bias)) { return newVar; } - if(VariablesFromUser(newVar, 0, var)) + if(VariablesFromUser(newVar, 0, var, bias)) { return newVar; } - if(PostfixOperatorsFromUser(newVar, 0, var)) + if(PostfixOperatorsFromUser(newVar, 0, var, bias)) { return newVar; } - if(FunctionsFromUser(newVar, 0, var)) + if(FunctionsFromUser(newVar, 0, var, bias)) { return newVar; } @@ -1696,58 +1739,84 @@ QString VApplication::FormulaFromUser(const QString &formula) return newFormula; } - QMap::const_iterator i = tokens.constBegin(); - while (i != tokens.constEnd()) + QList tKeys = tokens.keys(); + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) { - if(MeasurementsFromUser(newFormula, i.key(), i.value())) + int bias = 0; + if(MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { - ++i; + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if(VariablesFromUser(newFormula, i.key(), i.value())) + if(VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { - ++i; + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if(PostfixOperatorsFromUser(newFormula, i.key(), i.value())) + if(PostfixOperatorsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { - ++i; + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if(FunctionsFromUser(newFormula, i.key(), i.value())) + if(FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { - ++i; + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - ++i; } - QLocale loc = QLocale(); + QLocale loc = QLocale::system(); if(loc != QLocale(QLocale::C)) { - QMap::const_iterator i = numbers.constBegin(); - while (i != numbers.constEnd()) + QList nKeys = numbers.keys(); + QList nValues = numbers.values(); + for (int i = 0; i < tKeys.size(); ++i) { - QLocale::setDefault(QLocale::C); bool ok = false; - qreal d = QString(i.value()).toDouble(&ok); - if(ok == false) + qreal d = loc.toDouble(nValues.at(i), &ok); + if (ok == false) { - qDebug()<<"Can't convert to double token"< numbers; try { - Calculator cal(formula); + Calculator cal(formula, false); tokens = cal.GetTokens(); numbers = cal.GetNumbers(); } @@ -1778,61 +1847,91 @@ QString VApplication::FormulaToUser(const QString &formula) return newFormula; } - QMap::const_iterator i = tokens.constBegin(); - while (i != tokens.constEnd()) + QList tKeys = tokens.keys(); + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) { - if (measurements.contains(i.value())) + if (measurements.contains(tValues.at(i))) { - newFormula.replace(i.key(), i.value().length(), measurements.value(i.value()).translate()); - ++i; + newFormula.replace(tKeys.at(i), tValues.at(i).length(), measurements.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - measurements.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if (functions.contains(i.value())) + if (functions.contains(tValues.at(i))) { - newFormula.replace(i.key(), i.value().length(), functions.value(i.value()).translate()); - ++i; + newFormula.replace(tKeys.at(i), tValues.at(i).length(), functions.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - functions.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if (postfixOperators.contains(i.value())) + if (postfixOperators.contains(tValues.at(i))) { - newFormula.replace(i.key(), i.value().length(), postfixOperators.value(i.value()).translate()); - ++i; + newFormula.replace(tKeys.at(i), tValues.at(i).length(), postfixOperators.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - postfixOperators.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - if(VariablesToUser(newFormula, i.key(), i.value())) + int bias = 0; + if(VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { - ++i; + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } continue; } - } - QLocale loc = QLocale(); + QLocale loc = QLocale::system(); if(loc != QLocale::C) { - QMap::const_iterator i = numbers.constBegin(); - while (i != numbers.constEnd()) + QList nKeys = numbers.keys(); + QList nValues = numbers.values(); + for (int i = 0; i < tKeys.size(); ++i) { + QLocale loc = QLocale(QLocale::C); bool ok = false; - qreal d = QString(i.value()).toDouble(&ok); + qreal d = loc.toDouble(nValues.at(i), &ok); if(ok == false) { - qDebug()<<"Can't convert to double token"< &tokens, + QMap &numbers); + void BiasTokens(int position, int bias, QMap &tokens) const; + }; inline Valentina::Units VApplication::patternUnit() const From e4e993c3359a51b6170b8552148a3cfb82969f8d Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 19:00:35 +0300 Subject: [PATCH 5/7] Show formula value according to locale settings. --HG-- branch : develop --- src/app/dialogs/tools/dialogtool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index e49c4933b..d051e2d03 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -336,7 +336,8 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) Calculator cal(data); const qreal result = cal.EvalFormula(formula); - label->setText(QString().setNum(result)); + QLocale loc = QLocale::system(); + label->setText(loc.toString(result)); flag = true; palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); emit ToolTip(""); From 278b673cd4c4e18c1b87480415d7507850a232e5 Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 19:12:41 +0300 Subject: [PATCH 6/7] Set window title for toolbars main window. --HG-- branch : develop --- src/app/mainwindow.ui | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index ce4f28639..e3bdbaa57 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -47,7 +47,7 @@ 0 0 - 144 + 150 150 @@ -302,7 +302,7 @@ 0 0 - 100 + 150 58 @@ -378,7 +378,7 @@ 0 0 - 100 + 150 104 @@ -579,7 +579,7 @@ 0 0 - 100 + 150 58 @@ -703,6 +703,9 @@ + + Toolbar files + TopToolBarArea @@ -719,7 +722,7 @@ true - toolBar + ToolBar modes TopToolBarArea @@ -733,7 +736,7 @@ - toolBar_2 + Toolbar pattern TopToolBarArea @@ -745,7 +748,7 @@ - toolBar_3 + Toolbar options BottomToolBarArea From 59ce4e3bc2dd0f5f029fa42649e86c7e248759eb Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 27 May 2014 20:40:00 +0300 Subject: [PATCH 7/7] Deb file association. --HG-- branch : develop --- dist/valentina.desktop | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/valentina.desktop b/dist/valentina.desktop index 79f109d82..820161857 100644 --- a/dist/valentina.desktop +++ b/dist/valentina.desktop @@ -1,10 +1,13 @@ [Desktop Entry] Type=Application Name=Valentina +Exec=valentina %U +Version=1.0 +Encoding=UTF-8 GenericName=Pattern making program Comment=Open source project of creating a pattern making program, whose allow create and modeling patterns of clothing Icon=valentina -Exec=valentina +Terminal=false +MimeType=text/val; Categories=Graphics;VectorGraphics;2DGraphics; -Version=1.0 Name[uk]=valentina