--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2015-11-02 16:30:28 +04:00
commit 5b9914f409
29 changed files with 308 additions and 54 deletions

View File

@ -38,6 +38,7 @@
#include "core/vapplication.h"
#include "../vmisc/undoevent.h"
#include "../vmisc/vsettings.h"
#include "../vmisc/def.h"
#include "undocommands/renamepp.h"
#include "core/vtooloptionspropertybrowser.h"
#include "options.h"
@ -427,41 +428,6 @@ void MainWindow::ToggleMSync(bool toggle)
}
}
//---------------------------------------------------------------------------------------------------------------------
QString MainWindow::RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const
{
if (patternPath.isEmpty())
{
return absoluteMPath;
}
if (absoluteMPath.isEmpty() || QFileInfo(absoluteMPath).isRelative())
{
return absoluteMPath;
}
QDir dir(QFileInfo(patternPath).absoluteDir());
return dir.relativeFilePath(absoluteMPath);
}
//---------------------------------------------------------------------------------------------------------------------
QString MainWindow::AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const
{
if (patternPath.isEmpty())
{
return relativeMPath;
}
else
{
if (relativeMPath.isEmpty() || QFileInfo(relativeMPath).isAbsolute())
{
return relativeMPath;
}
return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief OptionDraw help change name of pattern piece.
@ -2844,7 +2810,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
curFile = fileName;
qApp->getUndoStack()->setClean();
QString shownName = strippedName(curFile);
QString shownName = StrippedName(curFile);
if (curFile.isEmpty())
{
shownName = tr("untitled.val");
@ -2880,17 +2846,6 @@ void MainWindow::setCurrentFile(const QString &fileName)
setWindowTitle(shownName);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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.
@ -2963,7 +2918,7 @@ void MainWindow::UpdateRecentFileActions()
for (int i = 0; i < numRecentFiles; ++i)
{
QString text = QString("&%1. %2").arg(i + 1).arg(strippedName(files.at(i)));
QString text = QString("&%1. %2").arg(i + 1).arg(StrippedName(files.at(i)));
recentFileActs[i]->setText(text);
recentFileActs[i]->setData(files.at(i));
recentFileActs[i]->setVisible(true);

View File

@ -266,7 +266,6 @@ private:
bool SavePattern(const QString &curFile, QString &error);
void AutoSavePattern();
void setCurrentFile(const QString &fileName);
QString strippedName(const QString &fullFileName);
void ReadSettings();
void WriteSettings();
@ -305,9 +304,6 @@ private:
void ToggleMSync(bool toggle);
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const;
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const;
bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
void ReopenFilesAfterCrash(QStringList &args);
void DoExport(const VCommandLinePtr& expParams);

View File

@ -100,6 +100,9 @@ public:
bool isFlipped;
QString formulaLength;
private:
VArcData &operator=(const VArcData &) Q_DECL_EQ_DELETE;
};
VArcData::~VArcData()

View File

@ -69,6 +69,9 @@ public:
/** @brief mode object created in calculation or drawing mode */
Draw mode;
private:
VGObjectData &operator=(const VGObjectData &) Q_DECL_EQ_DELETE;
};
VGObjectData::~VGObjectData()

View File

@ -75,6 +75,9 @@ public:
/** @brief _y y coordinate */
qreal _y;
private:
VPointFData &operator=(const VPointFData &) Q_DECL_EQ_DELETE;
};
VPointFData::~VPointFData()

View File

@ -113,6 +113,9 @@ public:
/** @brief kCurve coefficient of curvature spline. */
qreal kCurve;
private:
VSplineData &operator=(const VSplineData &) Q_DECL_EQ_DELETE;
};
VSplineData::~VSplineData()

View File

@ -63,6 +63,9 @@ public:
* @brief kCurve coefficient of curvature spline.
*/
qreal kCurve;
private:
VSplinePathData &operator=(const VSplinePathData &) Q_DECL_EQ_DELETE;
};
VSplinePathData::~VSplinePathData()

View File

@ -78,6 +78,9 @@ public:
/** @brief kAsm2 coefficient of length second control line. */
qreal kAsm2;
private:
VSplinePointData &operator=(const VSplinePointData &) Q_DECL_EQ_DELETE;
};
VSplinePointData::~VSplinePointData()

View File

@ -63,6 +63,9 @@ public:
bool closed;
/** @brief width value seamAllowance in mm. */
qreal width;
private:
VAbstractDetailData &operator=(const VAbstractDetailData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -65,6 +65,9 @@ public:
int paperWidth;
quint32 shift;
private:
VContourData &operator=(const VContourData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -71,6 +71,9 @@ public:
qreal layoutWidth;
bool mirror;
private:
VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -74,6 +74,9 @@ public:
bool rotate;
int rotationIncrease;
bool saveLength;
private:
VLayoutPaperData &operator=(const VLayoutPaperData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -31,6 +31,7 @@
#include "../vpatterndb/vtranslatevars.h"
#include <QComboBox>
#include <QDir>
// Keep synchronize all names with initialization in VTranslateVars class!!!!!
//measurements
@ -1670,3 +1671,51 @@ QString MapDiagrams(const QString &number)
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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)
{
return QFileInfo(fullFileName).fileName();
}
//---------------------------------------------------------------------------------------------------------------------
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath)
{
if (patternPath.isEmpty())
{
return absoluteMPath;
}
if (absoluteMPath.isEmpty() || QFileInfo(absoluteMPath).isRelative())
{
return absoluteMPath;
}
QDir dir(QFileInfo(patternPath).absoluteDir());
return dir.relativeFilePath(absoluteMPath);
}
//---------------------------------------------------------------------------------------------------------------------
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
{
if (patternPath.isEmpty())
{
return relativeMPath;
}
else
{
if (relativeMPath.isEmpty() || QFileInfo(relativeMPath).isAbsolute())
{
return relativeMPath;
}
return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
}
return QString();// should never reach
}

View File

@ -587,4 +587,8 @@ void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
QStringList SupportedLocales();
QStringList AllGroupNames();
QString StrippedName(const QString &fullFileName);
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath);
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath);
#endif // DEF_H

View File

@ -55,6 +55,9 @@ public:
virtual ~VArcRadiusData() Q_DECL_OVERRIDE;
quint32 arcId;
private:
VArcRadiusData &operator=(const VArcRadiusData &) Q_DECL_EQ_DELETE;
};
VArcRadiusData::~VArcRadiusData()

View File

@ -58,6 +58,9 @@ public:
quint32 id;
quint32 parentId;
private:
VCurveVariableData &operator=(const VCurveVariableData &) Q_DECL_EQ_DELETE;
};
VCurveVariableData::~VCurveVariableData()

View File

@ -62,6 +62,9 @@ public:
QString formula;
bool formulaOk;
VContainer data;
private:
VIncrementData &operator=(const VIncrementData &) Q_DECL_EQ_DELETE;
};
VIncrementData::~VIncrementData()

View File

@ -57,6 +57,9 @@ public:
qreal value;
QString name;
private:
VInternalVariableData &operator=(const VInternalVariableData &) Q_DECL_EQ_DELETE;
};
VInternalVariableData::~VInternalVariableData()

View File

@ -58,6 +58,9 @@ public:
quint32 p1Id;
quint32 p2Id;
private:
VLineAngleData &operator=(const VLineAngleData &) Q_DECL_EQ_DELETE;
};
VLineAngleData::~VLineAngleData()

View File

@ -59,6 +59,9 @@ public:
quint32 p1Id;
quint32 p2Id;
Unit patternUnit;
private:
VLengthLineData &operator=(const VLengthLineData &) Q_DECL_EQ_DELETE;
};
VLengthLineData::~VLengthLineData()

View File

@ -65,6 +65,9 @@ public:
QString gui_text;
QString _tagName;
bool formulaOk;
private:
VMeasurementData &operator=(const VMeasurementData &) Q_DECL_EQ_DELETE;
};
VMeasurementData::~VMeasurementData()

View File

@ -75,6 +75,9 @@ public:
qreal baseSize;
qreal baseHeight;
private:
VVariableData &operator=(const VVariableData &) Q_DECL_EQ_DELETE;
};
VVariableData::~VVariableData()

View File

@ -84,6 +84,9 @@ public:
const VTranslateVars *trVars;
const Unit *patternUnit;
private:
VContainerData &operator=(const VContainerData &) Q_DECL_EQ_DELETE;
};
#if defined(Q_CC_INTEL)

View File

@ -66,6 +66,9 @@ public:
/** @brief my bias y axis. */
qreal my;
private:
VDetailData &operator=(const VDetailData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -79,6 +79,9 @@ public:
* @brief reverse true if need reverse points list for node.
*/
bool reverse;
private:
VNodeDetailData &operator=(const VNodeDetailData &) Q_DECL_EQ_DELETE;
};
#ifdef Q_CC_GNU

View File

@ -49,7 +49,8 @@ SOURCES += \
tst_qmutokenparser.cpp \
tst_vmeasurements.cpp \
tst_qmuparsererrormsg.cpp \
tst_vlockguard.cpp
tst_vlockguard.cpp \
tst_misc.cpp
HEADERS += \
tst_vposter.h \
@ -66,7 +67,8 @@ HEADERS += \
tst_qmutokenparser.h \
tst_vmeasurements.h \
tst_qmuparsererrormsg.h \
tst_vlockguard.h
tst_vlockguard.h \
tst_misc.h
# Set using ccache. Function enable_ccache() defined in common.pri.
$$enable_ccache()

View File

@ -41,6 +41,7 @@
#include "tst_vmeasurements.h"
#include "tst_qmuparsererrormsg.h"
#include "tst_vlockguard.h"
#include "tst_misc.h"
int main(int argc, char** argv)
{
@ -68,6 +69,7 @@ int main(int argc, char** argv)
ASSERT_TEST(new TST_VMeasurements());
ASSERT_TEST(new TST_QmuParserErrorMsg());
ASSERT_TEST(new TST_VLockGuard());
ASSERT_TEST(new TST_Misc());
return status;
}

View File

@ -0,0 +1,132 @@
/************************************************************************
**
** @file tst_misc.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 10, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "tst_misc.h"
#include "../vmisc/def.h"
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_Misc::TST_Misc(QObject *parent)
:QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_Misc::TestRelativeFilePath_data()
{
QTest::addColumn<QString>("patternPath");
QTest::addColumn<QString>("absoluteMPath");
QTest::addColumn<QString>("output");
QTest::newRow("Measurements one level above")
<< "/home/user/patterns/pattern.val" << "/home/user/measurements/m.vit" << "../measurements/m.vit";
QTest::newRow("Measurements one level under")
<< "/home/user/patterns/pattern.val" << "/home/user/patterns/measurements/m.vit" << "measurements/m.vit";
QTest::newRow("Measurements in the same folder")
<< "/home/user/patterns/pattern.val" << "/home/user/patterns/m.vit" << "m.vit";
QTest::newRow("Path to measurements is empty")
<< "/home/user/patterns/pattern.val" << "" << "";
QTest::newRow("Path to a pattern file is empty. Ablosute measurements path.")
<< "" << "/home/user/patterns/m.vit" << "/home/user/patterns/m.vit";
QTest::newRow("Path to a pattern file is empty. Relative measurements path.")
<< "" << "measurements/m.vit" << "measurements/m.vit";
QTest::newRow("Relative measurements path.")
<< "/home/user/patterns/pattern.val" << "../measurements/m.vit" << "../measurements/m.vit";
QTest::newRow("Both paths are empty") << "" << "" << "";
QTest::newRow("Path to measurements is relative")
<< "/home/user/patterns/pattern.val" << "m.vit" << "m.vit";
QTest::newRow("Absolute pattern path.") << "/home/user/patterns" << "m.vit" << "m.vit";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_Misc::TestRelativeFilePath()
{
QFETCH(QString, patternPath);
QFETCH(QString, absoluteMPath);
QFETCH(QString, output);
const QString result = RelativeMPath(patternPath, absoluteMPath);
QCOMPARE(output, result);
}
//---------------------------------------------------------------------------------------------------------------------
void TST_Misc::TestAbsoluteFilePath_data()
{
QTest::addColumn<QString>("patternPath");
QTest::addColumn<QString>("relativeMPath");
QTest::addColumn<QString>("output");
QTest::newRow("Measurements one level above")
<< "/home/user/patterns/pattern.val" << "../measurements/m.vit" << "/home/user/measurements/m.vit";
QTest::newRow("Measurements one level under")
<< "/home/user/patterns/pattern.val" << "measurements/m.vit" << "/home/user/patterns/measurements/m.vit";
QTest::newRow("Measurements in the same folder")
<< "/home/user/patterns/pattern.val" << "m.vit" << "/home/user/patterns/m.vit";
QTest::newRow("Path to measurements is empty")
<< "/home/user/patterns/pattern.val" << "" << "";
QTest::newRow("Path to a pattern file is empty. Ablosute measurements path.")
<< "" << "/home/user/patterns/m.vit" << "/home/user/patterns/m.vit";
QTest::newRow("Path to a pattern file is empty. Relative measurements path.")
<< "" << "measurements/m.vit" << "measurements/m.vit";
QTest::newRow("Relative measurements path.")
<< "/home/user/patterns/pattern.val" << "../measurements/m.vit" << "/home/user/measurements/m.vit";
QTest::newRow("Both paths are empty") << "" << "" << "";
QTest::newRow("Path to measurements is relative")
<< "/home/user/patterns/pattern.val" << "m.vit" << "/home/user/patterns/m.vit";
QTest::newRow("Absolute pattern path.") << "/home/user/patterns" << "m.vit" << "/home/user/m.vit";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_Misc::TestAbsoluteFilePath()
{
QFETCH(QString, patternPath);
QFETCH(QString, relativeMPath);
QFETCH(QString, output);
const QString result = AbsoluteMPath(patternPath, relativeMPath);
QCOMPARE(output, result);
}

View File

@ -0,0 +1,51 @@
/************************************************************************
**
** @file tst_misc.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 10, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef TST_MISC_H
#define TST_MISC_H
#include <QObject>
class TST_Misc :public QObject
{
Q_OBJECT
public:
explicit TST_Misc(QObject *parent = nullptr);
private slots:
void TestRelativeFilePath_data();
void TestRelativeFilePath();
void TestAbsoluteFilePath_data();
void TestAbsoluteFilePath();
private:
Q_DISABLE_COPY(TST_Misc)
};
#endif // TST_MISC_H