Refactoring.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-03-26 17:47:27 +02:00
parent 335d4e2b81
commit 6b6d124cbb
3 changed files with 18 additions and 12 deletions

View File

@ -53,9 +53,15 @@ QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBank::VBank() VBank::VBank()
:details(QVector<VLayoutPiece>()), unsorted(QHash<int, qint64>()), big(QHash<int, qint64>()), : details(),
middle(QHash<int, qint64>()), small(QHash<int, qint64>()), layoutWidth(0), caseType(Cases::CaseDesc), unsorted(),
prepare(false), diagonal(0) big(),
middle(),
small(),
layoutWidth(0),
caseType(Cases::CaseDesc),
prepare(false),
diagonal(0)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -65,7 +71,7 @@ qreal VBank::GetLayoutWidth() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBank::SetLayoutWidth(const qreal &value) void VBank::SetLayoutWidth(qreal value)
{ {
layoutWidth = value; layoutWidth = value;
Reset(); Reset();
@ -79,14 +85,14 @@ void VBank::SetDetails(const QVector<VLayoutPiece> &details)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VBank::GetTiket() int VBank::GetNext()
{ {
if (prepare == false) if (prepare == false)
{ {
return -1; return -1;
} }
if (LeftArrange() == 0) if (LeftToArrange() == 0)
{ {
if (unsorted.isEmpty()) if (unsorted.isEmpty())
{ {
@ -245,7 +251,7 @@ int VBank::AllDetailsCount() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VBank::LeftArrange() const int VBank::LeftToArrange() const
{ {
return big.count() + middle.count() + small.count(); return big.count() + middle.count() + small.count();
} }

View File

@ -52,10 +52,10 @@ public:
VBank(); VBank();
qreal GetLayoutWidth() const; qreal GetLayoutWidth() const;
void SetLayoutWidth(const qreal &value); void SetLayoutWidth(qreal value);
void SetDetails(const QVector<VLayoutPiece> &details); void SetDetails(const QVector<VLayoutPiece> &details);
int GetTiket(); int GetNext();
VLayoutPiece GetDetail(int i) const; VLayoutPiece GetDetail(int i) const;
void Arranged(int i); void Arranged(int i);
@ -66,7 +66,7 @@ public:
void SetCaseType(Cases caseType); void SetCaseType(Cases caseType);
int AllDetailsCount() const; int AllDetailsCount() const;
int LeftArrange() const; int LeftToArrange() const;
int ArrangedCount() const; int ArrangedCount() const;
qreal GetBiggestDiagonal() const; qreal GetBiggestDiagonal() const;

View File

@ -151,7 +151,7 @@ void VLayoutGenerator::Generate()
paper.SetSaveLength(saveLength); paper.SetSaveLength(saveLength);
do do
{ {
const int index = bank->GetTiket(); const int index = bank->GetNext();
if (paper.ArrangeDetail(bank->GetDetail(index), stopGeneration)) if (paper.ArrangeDetail(bank->GetDetail(index), stopGeneration))
{ {
bank->Arranged(index); bank->Arranged(index);
@ -166,7 +166,7 @@ void VLayoutGenerator::Generate()
{ {
break; break;
} }
} while(bank->LeftArrange() > 0); } while(bank->LeftToArrange() > 0);
if (stopGeneration.load()) if (stopGeneration.load())
{ {