Commit 8bf29901 authored by Michael Reeves's avatar Michael Reeves

refactor setPixmaps

Move remaining setPixmaps functionallity to MergeFileInfos.
rename to updateAge no longer does aything else
parent a15fec6f
......@@ -441,3 +441,37 @@ bool MergeFileInfos::fastFileComparison(
bEqual = true;
return bEqual;
}
void MergeFileInfos::updateAge()
{
if(isDirA() || isDirB() || isDirC())
{
setAgeA(eNotThere);
setAgeB(eNotThere);
setAgeC(eNotThere);
e_Age age = eNew;
if(existsInC())
{
setAgeC((e_Age)age);
if(m_bEqualAC) setAgeA((e_Age)age);
if(m_bEqualBC) setAgeB((e_Age)age);
age = eMiddle;
}
if(existsInB() && getAgeB() == eNotThere)
{
setAgeB((e_Age)age);
if(m_bEqualAB) setAgeA((e_Age)age);
age = eOld;
}
if(existsInA() && getAgeA() == eNotThere)
{
setAgeA((e_Age)age);
}
if(getAgeA() != eOld && getAgeB() != eOld && getAgeC() != eOld)
{
if(getAgeA() == eMiddle) setAgeA(eOld);
if(getAgeB() == eMiddle) setAgeB(eOld);
if(getAgeC() == eMiddle) setAgeC(eOld);
}
}
}
......@@ -126,18 +126,19 @@ class MergeFileInfos
inline void setOpStatus(const e_OperationStatus eOpStatus) { m_eOpStatus = eOpStatus; }
inline e_Age getAgeA() const { return m_ageA; }
inline void setAgeA(const e_Age inAge) { m_ageA = inAge; }
inline e_Age getAgeB() const { return m_ageB; }
inline void setAgeB(const e_Age inAge) { m_ageB = inAge; }
inline e_Age getAgeC() const { return m_ageC; }
inline void setAgeC(const e_Age inAge) { m_ageC = inAge; }
bool compareFilesAndCalcAges(QStringList& errors, Options* const pOptions, DirectoryMergeWindow* pDMW);
bool compareFilesAndCalcAges(QStringList& errors, Options* const pOptions, DirectoryMergeWindow* pDMW);
void updateAge();
private:
bool fastFileComparison(FileAccess& fi1, FileAccess& fi2, bool& bError, QString& status, Options* const pOptions);
inline void setAgeA(const e_Age inAge) { m_ageA = inAge; }
inline void setAgeB(const e_Age inAge) { m_ageB = inAge; }
inline void setAgeC(const e_Age inAge) { m_ageC = inAge; }
MergeFileInfos* m_pParent;
QList<MergeFileInfos*> m_children;
......
......@@ -194,8 +194,6 @@ class DirectoryMergeWindow::DirectoryMergeWindowPrivate : public QAbstractItemMo
}
MergeFileInfos* rootMFI() const { return m_pRoot; }
static void setPixmaps(MergeFileInfos& mfi, bool);
Options* m_pOptions;
void calcDirStatus(bool bThreeDirs, const QModelIndex& mi,
......@@ -1277,40 +1275,6 @@ void DirectoryMergeWindow::DirectoryMergeWindowPrivate::setAllMergeOperations(e_
}
}
void DirectoryMergeWindow::DirectoryMergeWindowPrivate::setPixmaps(MergeFileInfos& mfi, bool)
{
if(mfi.isDirA() || mfi.isDirB() || mfi.isDirC())
{
mfi.setAgeA(eNotThere);
mfi.setAgeB(eNotThere);
mfi.setAgeC(eNotThere);
int age = eNew;
if(mfi.existsInC())
{
mfi.setAgeC((e_Age)age);
if(mfi.m_bEqualAC) mfi.setAgeA((e_Age)age);
if(mfi.m_bEqualBC) mfi.setAgeB((e_Age)age);
++age;
}
if(mfi.existsInB() && mfi.getAgeB() == eNotThere)
{
mfi.setAgeB((e_Age)age);
if(mfi.m_bEqualAB) mfi.setAgeA((e_Age)age);
++age;
}
if(mfi.existsInA() && mfi.getAgeA() == eNotThere)
{
mfi.setAgeA((e_Age)age);
}
if(mfi.getAgeA() != eOld && mfi.getAgeB() != eOld && mfi.getAgeC() != eOld)
{
if(mfi.getAgeA() == eMiddle) mfi.setAgeA(eOld);
if(mfi.getAgeB() == eMiddle) mfi.setAgeB(eOld);
if(mfi.getAgeC() == eMiddle) mfi.setAgeC(eOld);
}
}
}
QModelIndex DirectoryMergeWindow::DirectoryMergeWindowPrivate::nextSibling(const QModelIndex& mi)
{
QModelIndex miParent = mi.parent();
......@@ -1366,8 +1330,6 @@ void DirectoryMergeWindow::DirectoryMergeWindowPrivate::prepareListView(Progress
q->setRootIsDecorated(true);
bool bCheckC = isThreeWay();
t_fileMergeMap::iterator j;
int nrOfFiles = m_fileMergeMap.size();
int currentIdx = 1;
......@@ -1419,7 +1381,7 @@ void DirectoryMergeWindow::DirectoryMergeWindowPrivate::prepareListView(Progress
// // Equality for parent dirs is set in updateFileVisibilities()
}
setPixmaps(mfi, bCheckC);
mfi.updateAge();
}
if(errors.size() > 0)
......@@ -2994,7 +2956,7 @@ void DirectoryMergeWindow::updateFileVisibilities()
}
if(bChange)
DirectoryMergeWindow::DirectoryMergeWindowPrivate::setPixmaps(*pMFI, bThreeDirs);
pMFI->updateAge();
}
bool bExistsEverywhere = pMFI->existsInA() && pMFI->existsInB() && (pMFI->existsInC() || !bThreeDirs);
int existCount = int(pMFI->existsInA()) + int(pMFI->existsInB()) + int(pMFI->existsInC());
......@@ -3030,7 +2992,7 @@ void DirectoryMergeWindow::updateFileVisibilities()
}
if(bChange)
DirectoryMergeWindow::DirectoryMergeWindowPrivate::setPixmaps(*p2, bThreeDirs);
p2->updateAge();
else
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment