Commit 59d3e2f8 authored by Joachim Eibl's avatar Joachim Eibl
Browse files

- Optimized memory usage in DirectoryMergeWindow and FileAccess.

git-svn-id: c8aa9fed-2811-0410-8543-893ada326672
parent 7db7b499
......@@ -14,6 +14,7 @@
* (at your option) any later version. *
* *
#include "stable.h"
#include <stdio.h>
#include <cstdlib>
......@@ -288,6 +289,11 @@ const char* SourceData::getBuf() const
return m_normalData.m_pBuf;
const QString& SourceData::getText() const
return m_normalData.m_unicodeBuf;
bool SourceData::isText()
return m_normalData.m_bIsText;
......@@ -2067,12 +2073,11 @@ void calcDiff( const T* p1, int size1, const T* p2, int size2, DiffList& diffLis
void fineDiff(
bool fineDiff(
Diff3LineList& diff3LineList,
int selector,
const LineData* v1,
const LineData* v2,
bool& bTextsTotalEqual
const LineData* v2
// Finetuning: Diff each line with deltas
......@@ -2081,7 +2086,7 @@ void fineDiff(
Diff3LineList::iterator i;
int k1=0;
int k2=0;
bTextsTotalEqual = true;
bool bTextsTotalEqual = true;
int listSize = diff3LineList.size();
int listIdx = 0;
for( i= diff3LineList.begin(); i!= diff3LineList.end(); ++i)
......@@ -2140,6 +2145,7 @@ void fineDiff(
return bTextsTotalEqual;
......@@ -175,13 +175,13 @@ public:
nofUnsolvedConflicts=0; nofSolvedConflicts=0;
bool bBinaryAEqC;
bool bBinaryBEqC;
bool bBinaryAEqB;
bool bBinaryAEqC : 1;
bool bBinaryBEqC : 1;
bool bBinaryAEqB : 1;
bool bTextAEqC;
bool bTextBEqC;
bool bTextAEqB;
bool bTextAEqC : 1;
bool bTextBEqC : 1;
bool bTextAEqB : 1;
int nofUnsolvedConflicts;
int nofSolvedConflicts;
......@@ -251,6 +251,7 @@ public:
int getSizeLines() const;
int getSizeBytes() const;
const char* getBuf() const;
const QString& getText() const;
const LineData* getLineDataForDisplay() const;
const LineData* getLineDataForDiff() const;
......@@ -422,12 +423,11 @@ public:
void fineDiff(
bool fineDiff(
Diff3LineList& diff3LineList,
int selector,
const LineData* v1,
const LineData* v2,
bool& bTextsTotalEqual
const LineData* v2
This diff is collapsed.
......@@ -52,74 +52,17 @@ enum e_MergeOperation
eConflictingAges // Equal age but files are not!
class DirMergeItem;
enum e_Age { eNew, eMiddle, eOld, eNotThere, eAgeEnd };
class MergeFileInfos
MergeFileInfos(){ m_bEqualAB=false; m_bEqualAC=false; m_bEqualBC=false;
m_pDMI=0; m_pParent=0;
m_bDirA=false; m_bDirB=false; m_bDirC=false;
m_bLinkA=false; m_bLinkB=false; m_bLinkC=false;
m_bOperationComplete=false; m_bSimOpComplete = false;
m_ageA = eNotThere; m_ageB=eNotThere; m_ageC=eNotThere;
m_bConflictingAges=false; }
bool operator>( const MergeFileInfos& );
QString m_subPath;
bool m_bExistsInA;
bool m_bExistsInB;
bool m_bExistsInC;
bool m_bEqualAB;
bool m_bEqualAC;
bool m_bEqualBC;
DirMergeItem* m_pDMI;
MergeFileInfos* m_pParent;
e_MergeOperation m_eMergeOperation;
void setMergeOperation( e_MergeOperation eMOp, bool bRecursive=true );
bool m_bDirA;
bool m_bDirB;
bool m_bDirC;
bool m_bLinkA;
bool m_bLinkB;
bool m_bLinkC;
bool m_bOperationComplete;
bool m_bSimOpComplete;
e_Age m_ageA;
e_Age m_ageB;
e_Age m_ageC;
bool m_bConflictingAges; // Equal age but files are not!
FileAccess m_fileInfoA;
FileAccess m_fileInfoB;
FileAccess m_fileInfoC;
class MergeFileInfos;
TotalDiffStatus m_totalDiffStatus;
class DirMergeItem : public QTreeWidgetItem
DirMergeItem( QTreeWidget* pParent, const QString&, MergeFileInfos*);
DirMergeItem( DirMergeItem* pParent, const QString&, MergeFileInfos*);
MergeFileInfos* m_pMFI;
virtual bool operator<( const QTreeWidgetItem& other ) const;
//virtual void paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align );
void init(MergeFileInfos* pMFI);
class DirectoryMergeWindow : public QTreeWidget
class DirectoryMergeWindow : public QTreeView
DirectoryMergeWindow( QWidget* pParent, OptionDialog* pOptions, KIconLoader* pIconLoader );
void setDirectoryMergeInfo(DirectoryMergeInfo* p){ m_pDirectoryMergeInfo=p; }
void setDirectoryMergeInfo(DirectoryMergeInfo* p);
bool init(
FileAccess& dirA,
FileAccess& dirB,
......@@ -129,10 +72,10 @@ public:
bool bReload = false
bool isFileSelected();
bool isDirectoryMergeInProgress() { return m_bRealMergeStarted; }
bool isDirectoryMergeInProgress();
int totalColumnWidth();
bool isSyncMode() { return m_bSyncMode; }
bool isScanning() { return m_bScanning; }
bool isSyncMode();
bool isScanning();
void initDirectoryMergeActions( QObject* pKDiff3App, KActionCollection* ac );
void updateAvailabilities( bool bDirCompare, bool bDiffWindowVisible,
KToggleAction* chooseA, KToggleAction* chooseB, KToggleAction* chooseC );
......@@ -143,10 +86,10 @@ public:
virtual void focusInEvent( QFocusEvent* e );
virtual void focusOutEvent( QFocusEvent* e );
virtual void contextMenuEvent( QContextMenuEvent* e );
QString getDirNameA(){ return m_dirA.prettyAbsPath(); }
QString getDirNameB(){ return m_dirB.prettyAbsPath(); }
QString getDirNameC(){ return m_dirC.prettyAbsPath(); }
QString getDirNameDest(){ return m_dirDest.prettyAbsPath(); }
QString getDirNameA();
QString getDirNameB();
QString getDirNameC();
QString getDirNameDest();
public slots:
void reload();
......@@ -194,138 +137,21 @@ public slots:
void slotSaveMergeState();
void slotLoadMergeState();
class DirMergeItemDelegate;
void mergeContinue( bool bStart, bool bVerbose );
void prepareListView(ProgressProxy& pp);
void calcSuggestedOperation( MergeFileInfos& mfi, e_MergeOperation eDefaultOperation );
void setAllMergeOperations( e_MergeOperation eDefaultOperation );
friend class MergeFileInfos;
bool canContinue();
void prepareMergeStart( QTreeWidgetItem* pBegin, QTreeWidgetItem* pEnd, bool bVerbose );
bool executeMergeOperation( MergeFileInfos& mfi, bool& bSingleFileMerge );
void scanDirectory( const QString& dirName, t_DirectoryList& dirList );
void scanLocalDirectory( const QString& dirName, t_DirectoryList& dirList );
void fastFileComparison( FileAccess& fi1, FileAccess& fi2,
bool& bEqual, bool& bError, QString& status );
void compareFilesAndCalcAges( MergeFileInfos& mfi );
QString fullNameA( const MergeFileInfos& mfi )
{ return mfi.m_bExistsInA ? mfi.m_fileInfoA.absoluteFilePath() : m_dirA.absoluteFilePath() + "/" + mfi.m_subPath; }
QString fullNameB( const MergeFileInfos& mfi )
{ return mfi.m_bExistsInB ? mfi.m_fileInfoB.absoluteFilePath() : m_dirB.absoluteFilePath() + "/" + mfi.m_subPath; }
QString fullNameC( const MergeFileInfos& mfi )
{ return mfi.m_bExistsInC ? mfi.m_fileInfoC.absoluteFilePath() : m_dirC.absoluteFilePath() + "/" + mfi.m_subPath; }
QString fullNameDest( const MergeFileInfos& mfi )
{ if ( m_dirDestInternal.prettyAbsPath() == m_dirC.prettyAbsPath() ) return fullNameC(mfi);
else if ( m_dirDestInternal.prettyAbsPath() == m_dirB.prettyAbsPath() ) return fullNameB(mfi);
else return m_dirDestInternal.absoluteFilePath() + "/" + mfi.m_subPath;
bool copyFLD( const QString& srcName, const QString& destName );
bool deleteFLD( const QString& name, bool bCreateBackup );
bool makeDir( const QString& name, bool bQuiet=false );
bool renameFLD( const QString& srcName, const QString& destName );
bool mergeFLD( const QString& nameA,const QString& nameB,const QString& nameC,
const QString& nameDest, bool& bSingleFileMerge );
FileAccess m_dirA;
FileAccess m_dirB;
FileAccess m_dirC;
FileAccess m_dirDest;
FileAccess m_dirDestInternal;
QString m_dirMergeStateFilename;
std::map<QString, MergeFileInfos> m_fileMergeMap;
bool m_bFollowDirLinks;
bool m_bFollowFileLinks;
bool m_bSimulatedMergeStarted;
bool m_bRealMergeStarted;
bool m_bError;
bool m_bSyncMode;
bool m_bDirectoryMerge; // if true, then merge is the default operation, otherwise it's diff.
bool m_bCaseSensitive;
bool m_bUnfoldSubdirs;
bool m_bSkipDirStatus;
bool m_bScanning; // true while in init()
OptionDialog* m_pOptions;
KIconLoader* m_pIconLoader;
DirectoryMergeInfo* m_pDirectoryMergeInfo;
StatusInfo* m_pStatusInfo;
typedef std::list<DirMergeItem*> MergeItemList;
MergeItemList m_mergeItemList;
MergeItemList::iterator m_currentItemForOperation;
DirMergeItem* m_pSelection1Item;
int m_selection1Column;
DirMergeItem* m_pSelection2Item;
int m_selection2Column;
DirMergeItem* m_pSelection3Item;
int m_selection3Column;
void selectItemAndColumn(DirMergeItem* pDMI, int c, bool bContextMenu);
friend class DirMergeItem;
KAction* m_pDirStartOperation;
KAction* m_pDirRunOperationForCurrentItem;
KAction* m_pDirCompareCurrent;
KAction* m_pDirMergeCurrent;
KAction* m_pDirRescan;
KAction* m_pDirChooseAEverywhere;
KAction* m_pDirChooseBEverywhere;
KAction* m_pDirChooseCEverywhere;
KAction* m_pDirAutoChoiceEverywhere;
KAction* m_pDirDoNothingEverywhere;
KAction* m_pDirFoldAll;
KAction* m_pDirUnfoldAll;
KToggleAction* m_pDirShowIdenticalFiles;
KToggleAction* m_pDirShowDifferentFiles;
KToggleAction* m_pDirShowFilesOnlyInA;
KToggleAction* m_pDirShowFilesOnlyInB;
KToggleAction* m_pDirShowFilesOnlyInC;
KToggleAction* m_pDirSynchronizeDirectories;
KToggleAction* m_pDirChooseNewerFiles;
KAction* m_pDirCompareExplicit;
KAction* m_pDirMergeExplicit;
KAction* m_pDirCurrentDoNothing;
KAction* m_pDirCurrentChooseA;
KAction* m_pDirCurrentChooseB;
KAction* m_pDirCurrentChooseC;
KAction* m_pDirCurrentMerge;
KAction* m_pDirCurrentDelete;
KAction* m_pDirCurrentSyncDoNothing;
KAction* m_pDirCurrentSyncCopyAToB;
KAction* m_pDirCurrentSyncCopyBToA;
KAction* m_pDirCurrentSyncDeleteA;
KAction* m_pDirCurrentSyncDeleteB;
KAction* m_pDirCurrentSyncDeleteAAndB;
KAction* m_pDirCurrentSyncMergeToA;
KAction* m_pDirCurrentSyncMergeToB;
KAction* m_pDirCurrentSyncMergeToAAndB;
KAction* m_pDirSaveMergeState;
KAction* m_pDirLoadMergeState;
void startDiffMerge(QString fn1,QString fn2, QString fn3, QString ofn, QString,QString,QString,TotalDiffStatus*);
void checkIfCanContinue( bool* pbContinue );
void updateAvailabilities();
void statusBarMessage( const QString& msg );
protected slots:
void onDoubleClick( QTreeWidgetItem* lvi );
void onCurrentChanged(QTreeWidgetItem*);
void onDoubleClick( const QModelIndex& );
void onExpanded();
void currentChanged( const QModelIndex & current, const QModelIndex & previous ); // override
class Data;
friend class Data;
Data* d;
class DirMergeItemDelegate;
friend class DirMergeItemDelegate;
class DirectoryMergeInfo : public QFrame
This diff is collapsed.
......@@ -26,6 +26,7 @@
bool wildcardMultiMatch( const QString& wildcard, const QString& testString, bool bCaseSensitive );
class t_DirectoryList;
class QFileInfo;
class FileAccess
......@@ -33,6 +34,8 @@ public:
FileAccess( const QString& name, bool bWantToWrite=false ); // name: local file or dirname or url (when supported)
FileAccess(const FileAccess& other);
const FileAccess& operator=(const FileAccess& other);
void setFile( const QString& name, bool bWantToWrite=false );
bool isValid() const;
......@@ -48,9 +51,9 @@ public:
bool isHidden() const;
QString readLink() const;
QDateTime created() const;
//QDateTime created() const;
QDateTime lastModified() const;
QDateTime lastRead() const;
//QDateTime lastRead() const;
QString fileName() const; // Just the name-part of the path, without parent directories
QString filePath() const; // The path-string that was used during construction
......@@ -83,34 +86,32 @@ public:
void addPath( const QString& txt );
QString getStatusText();
FileAccess* parent() const; // !=0 for listDir-results, but only valid if the parent was not yet destroyed.
void setSharedName( const QString& name ); // might reduce memory consumption
void setUdsEntry( const KIO::UDSEntry& e );
KUrl m_url;
bool m_bLocal;
bool m_bValidData;
void setFile( const QFileInfo& fi, FileAccess* pParent );
class Data;
Data* d();
const Data* d() const;
Data* m_pData;
FileAccess* m_pParent;
QString m_filePath; // might be absolute or relative if m_pParent!=0
qint64 m_size;
QDateTime m_modificationTime;
QDateTime m_accessTime;
QDateTime m_creationTime;
bool m_bReadable;
bool m_bWritable;
bool m_bExecutable;
bool m_bExists;
bool m_bFile;
bool m_bDir;
bool m_bSymLink;
bool m_bHidden;
long m_fileType; // for testing only
QString m_linkTarget;
QString m_user;
QString m_group;
QString m_name;
QString m_path;
QString m_absoluteFilePath;
QString m_localCopy;
QString m_statusText; // Might contain an error string, when the last operation didn't succeed.
bool m_bSymLink : 1;
bool m_bFile : 1;
bool m_bDir : 1;
bool m_bExists : 1;
bool m_bWritable : 1;
bool m_bHidden : 1;
bool m_bUseData : 1;
friend class FileAccessJobHandler;
This diff is collapsed.
This diff is collapsed.
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