Merge
--HG-- branch : feature
This commit is contained in:
commit
5b9914f409
|
@ -38,6 +38,7 @@
|
||||||
#include "core/vapplication.h"
|
#include "core/vapplication.h"
|
||||||
#include "../vmisc/undoevent.h"
|
#include "../vmisc/undoevent.h"
|
||||||
#include "../vmisc/vsettings.h"
|
#include "../vmisc/vsettings.h"
|
||||||
|
#include "../vmisc/def.h"
|
||||||
#include "undocommands/renamepp.h"
|
#include "undocommands/renamepp.h"
|
||||||
#include "core/vtooloptionspropertybrowser.h"
|
#include "core/vtooloptionspropertybrowser.h"
|
||||||
#include "options.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.
|
* @brief OptionDraw help change name of pattern piece.
|
||||||
|
@ -2844,7 +2810,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
||||||
curFile = fileName;
|
curFile = fileName;
|
||||||
qApp->getUndoStack()->setClean();
|
qApp->getUndoStack()->setClean();
|
||||||
|
|
||||||
QString shownName = strippedName(curFile);
|
QString shownName = StrippedName(curFile);
|
||||||
if (curFile.isEmpty())
|
if (curFile.isEmpty())
|
||||||
{
|
{
|
||||||
shownName = tr("untitled.val");
|
shownName = tr("untitled.val");
|
||||||
|
@ -2880,17 +2846,6 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
||||||
setWindowTitle(shownName);
|
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.
|
* @brief ReadSettings read setting for app.
|
||||||
|
@ -2963,7 +2918,7 @@ void MainWindow::UpdateRecentFileActions()
|
||||||
|
|
||||||
for (int i = 0; i < numRecentFiles; ++i)
|
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]->setText(text);
|
||||||
recentFileActs[i]->setData(files.at(i));
|
recentFileActs[i]->setData(files.at(i));
|
||||||
recentFileActs[i]->setVisible(true);
|
recentFileActs[i]->setVisible(true);
|
||||||
|
|
|
@ -266,7 +266,6 @@ private:
|
||||||
bool SavePattern(const QString &curFile, QString &error);
|
bool SavePattern(const QString &curFile, QString &error);
|
||||||
void AutoSavePattern();
|
void AutoSavePattern();
|
||||||
void setCurrentFile(const QString &fileName);
|
void setCurrentFile(const QString &fileName);
|
||||||
QString strippedName(const QString &fullFileName);
|
|
||||||
|
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
void WriteSettings();
|
void WriteSettings();
|
||||||
|
@ -305,9 +304,6 @@ private:
|
||||||
|
|
||||||
void ToggleMSync(bool toggle);
|
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());
|
bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
|
||||||
void ReopenFilesAfterCrash(QStringList &args);
|
void ReopenFilesAfterCrash(QStringList &args);
|
||||||
void DoExport(const VCommandLinePtr& expParams);
|
void DoExport(const VCommandLinePtr& expParams);
|
||||||
|
|
|
@ -100,6 +100,9 @@ public:
|
||||||
bool isFlipped;
|
bool isFlipped;
|
||||||
|
|
||||||
QString formulaLength;
|
QString formulaLength;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VArcData &operator=(const VArcData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VArcData::~VArcData()
|
VArcData::~VArcData()
|
||||||
|
|
|
@ -69,6 +69,9 @@ public:
|
||||||
|
|
||||||
/** @brief mode object created in calculation or drawing mode */
|
/** @brief mode object created in calculation or drawing mode */
|
||||||
Draw mode;
|
Draw mode;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VGObjectData &operator=(const VGObjectData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VGObjectData::~VGObjectData()
|
VGObjectData::~VGObjectData()
|
||||||
|
|
|
@ -75,6 +75,9 @@ public:
|
||||||
|
|
||||||
/** @brief _y y coordinate */
|
/** @brief _y y coordinate */
|
||||||
qreal _y;
|
qreal _y;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VPointFData &operator=(const VPointFData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VPointFData::~VPointFData()
|
VPointFData::~VPointFData()
|
||||||
|
|
|
@ -113,6 +113,9 @@ public:
|
||||||
|
|
||||||
/** @brief kCurve coefficient of curvature spline. */
|
/** @brief kCurve coefficient of curvature spline. */
|
||||||
qreal kCurve;
|
qreal kCurve;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VSplineData &operator=(const VSplineData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VSplineData::~VSplineData()
|
VSplineData::~VSplineData()
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
* @brief kCurve coefficient of curvature spline.
|
* @brief kCurve coefficient of curvature spline.
|
||||||
*/
|
*/
|
||||||
qreal kCurve;
|
qreal kCurve;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VSplinePathData &operator=(const VSplinePathData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VSplinePathData::~VSplinePathData()
|
VSplinePathData::~VSplinePathData()
|
||||||
|
|
|
@ -78,6 +78,9 @@ public:
|
||||||
|
|
||||||
/** @brief kAsm2 coefficient of length second control line. */
|
/** @brief kAsm2 coefficient of length second control line. */
|
||||||
qreal kAsm2;
|
qreal kAsm2;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VSplinePointData &operator=(const VSplinePointData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VSplinePointData::~VSplinePointData()
|
VSplinePointData::~VSplinePointData()
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
bool closed;
|
bool closed;
|
||||||
/** @brief width value seamAllowance in mm. */
|
/** @brief width value seamAllowance in mm. */
|
||||||
qreal width;
|
qreal width;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VAbstractDetailData &operator=(const VAbstractDetailData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
int paperWidth;
|
int paperWidth;
|
||||||
|
|
||||||
quint32 shift;
|
quint32 shift;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VContourData &operator=(const VContourData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -71,6 +71,9 @@ public:
|
||||||
qreal layoutWidth;
|
qreal layoutWidth;
|
||||||
|
|
||||||
bool mirror;
|
bool mirror;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -74,6 +74,9 @@ public:
|
||||||
bool rotate;
|
bool rotate;
|
||||||
int rotationIncrease;
|
int rotationIncrease;
|
||||||
bool saveLength;
|
bool saveLength;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VLayoutPaperData &operator=(const VLayoutPaperData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
// Keep synchronize all names with initialization in VTranslateVars class!!!!!
|
// Keep synchronize all names with initialization in VTranslateVars class!!!!!
|
||||||
//measurements
|
//measurements
|
||||||
|
@ -1670,3 +1671,51 @@ QString MapDiagrams(const QString &number)
|
||||||
|
|
||||||
return QString();
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -587,4 +587,8 @@ void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
||||||
QStringList SupportedLocales();
|
QStringList SupportedLocales();
|
||||||
QStringList AllGroupNames();
|
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
|
#endif // DEF_H
|
||||||
|
|
|
@ -55,6 +55,9 @@ public:
|
||||||
virtual ~VArcRadiusData() Q_DECL_OVERRIDE;
|
virtual ~VArcRadiusData() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
quint32 arcId;
|
quint32 arcId;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VArcRadiusData &operator=(const VArcRadiusData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VArcRadiusData::~VArcRadiusData()
|
VArcRadiusData::~VArcRadiusData()
|
||||||
|
|
|
@ -58,6 +58,9 @@ public:
|
||||||
|
|
||||||
quint32 id;
|
quint32 id;
|
||||||
quint32 parentId;
|
quint32 parentId;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VCurveVariableData &operator=(const VCurveVariableData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCurveVariableData::~VCurveVariableData()
|
VCurveVariableData::~VCurveVariableData()
|
||||||
|
|
|
@ -62,6 +62,9 @@ public:
|
||||||
QString formula;
|
QString formula;
|
||||||
bool formulaOk;
|
bool formulaOk;
|
||||||
VContainer data;
|
VContainer data;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VIncrementData &operator=(const VIncrementData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VIncrementData::~VIncrementData()
|
VIncrementData::~VIncrementData()
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
qreal value;
|
qreal value;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VInternalVariableData &operator=(const VInternalVariableData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VInternalVariableData::~VInternalVariableData()
|
VInternalVariableData::~VInternalVariableData()
|
||||||
|
|
|
@ -58,6 +58,9 @@ public:
|
||||||
|
|
||||||
quint32 p1Id;
|
quint32 p1Id;
|
||||||
quint32 p2Id;
|
quint32 p2Id;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VLineAngleData &operator=(const VLineAngleData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VLineAngleData::~VLineAngleData()
|
VLineAngleData::~VLineAngleData()
|
||||||
|
|
|
@ -59,6 +59,9 @@ public:
|
||||||
quint32 p1Id;
|
quint32 p1Id;
|
||||||
quint32 p2Id;
|
quint32 p2Id;
|
||||||
Unit patternUnit;
|
Unit patternUnit;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VLengthLineData &operator=(const VLengthLineData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VLengthLineData::~VLengthLineData()
|
VLengthLineData::~VLengthLineData()
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
QString gui_text;
|
QString gui_text;
|
||||||
QString _tagName;
|
QString _tagName;
|
||||||
bool formulaOk;
|
bool formulaOk;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMeasurementData &operator=(const VMeasurementData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VMeasurementData::~VMeasurementData()
|
VMeasurementData::~VMeasurementData()
|
||||||
|
|
|
@ -75,6 +75,9 @@ public:
|
||||||
|
|
||||||
qreal baseSize;
|
qreal baseSize;
|
||||||
qreal baseHeight;
|
qreal baseHeight;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VVariableData &operator=(const VVariableData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VVariableData::~VVariableData()
|
VVariableData::~VVariableData()
|
||||||
|
|
|
@ -84,6 +84,9 @@ public:
|
||||||
|
|
||||||
const VTranslateVars *trVars;
|
const VTranslateVars *trVars;
|
||||||
const Unit *patternUnit;
|
const Unit *patternUnit;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VContainerData &operator=(const VContainerData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(Q_CC_INTEL)
|
#if defined(Q_CC_INTEL)
|
||||||
|
|
|
@ -66,6 +66,9 @@ public:
|
||||||
|
|
||||||
/** @brief my bias y axis. */
|
/** @brief my bias y axis. */
|
||||||
qreal my;
|
qreal my;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VDetailData &operator=(const VDetailData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
* @brief reverse true if need reverse points list for node.
|
* @brief reverse true if need reverse points list for node.
|
||||||
*/
|
*/
|
||||||
bool reverse;
|
bool reverse;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VNodeDetailData &operator=(const VNodeDetailData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -49,7 +49,8 @@ SOURCES += \
|
||||||
tst_qmutokenparser.cpp \
|
tst_qmutokenparser.cpp \
|
||||||
tst_vmeasurements.cpp \
|
tst_vmeasurements.cpp \
|
||||||
tst_qmuparsererrormsg.cpp \
|
tst_qmuparsererrormsg.cpp \
|
||||||
tst_vlockguard.cpp
|
tst_vlockguard.cpp \
|
||||||
|
tst_misc.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
tst_vposter.h \
|
tst_vposter.h \
|
||||||
|
@ -66,7 +67,8 @@ HEADERS += \
|
||||||
tst_qmutokenparser.h \
|
tst_qmutokenparser.h \
|
||||||
tst_vmeasurements.h \
|
tst_vmeasurements.h \
|
||||||
tst_qmuparsererrormsg.h \
|
tst_qmuparsererrormsg.h \
|
||||||
tst_vlockguard.h
|
tst_vlockguard.h \
|
||||||
|
tst_misc.h
|
||||||
|
|
||||||
# Set using ccache. Function enable_ccache() defined in common.pri.
|
# Set using ccache. Function enable_ccache() defined in common.pri.
|
||||||
$$enable_ccache()
|
$$enable_ccache()
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "tst_vmeasurements.h"
|
#include "tst_vmeasurements.h"
|
||||||
#include "tst_qmuparsererrormsg.h"
|
#include "tst_qmuparsererrormsg.h"
|
||||||
#include "tst_vlockguard.h"
|
#include "tst_vlockguard.h"
|
||||||
|
#include "tst_misc.h"
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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_VMeasurements());
|
||||||
ASSERT_TEST(new TST_QmuParserErrorMsg());
|
ASSERT_TEST(new TST_QmuParserErrorMsg());
|
||||||
ASSERT_TEST(new TST_VLockGuard());
|
ASSERT_TEST(new TST_VLockGuard());
|
||||||
|
ASSERT_TEST(new TST_Misc());
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
132
src/test/ValentinaTest/tst_misc.cpp
Normal file
132
src/test/ValentinaTest/tst_misc.cpp
Normal 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);
|
||||||
|
}
|
51
src/test/ValentinaTest/tst_misc.h
Normal file
51
src/test/ValentinaTest/tst_misc.h
Normal 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
|
Loading…
Reference in New Issue
Block a user