summaryrefslogtreecommitdiff
path: root/ui/gridView.h
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gridView.h')
-rw-r--r--ui/gridView.h194
1 files changed, 135 insertions, 59 deletions
diff --git a/ui/gridView.h b/ui/gridView.h
index 8603bbd2..c7728b06 100644
--- a/ui/gridView.h
+++ b/ui/gridView.h
@@ -1,7 +1,7 @@
#ifndef GRIDVIEW_H_INCLUDED
#define GRIDVIEW_H_INCLUDED
-#include "../structures.h"
+#include "../fileHierarchy.h"
namespace FreeFileSync
@@ -10,23 +10,18 @@ namespace FreeFileSync
class GridView
{
public:
- GridView(FolderComparison& results);
+ //direct data access via row number
+ const FileSystemObject* getObject(unsigned int row) const; //returns NULL if object is not found; logarithmic complexity
+ FileSystemObject* getObject(unsigned int row); //
+ unsigned int rowsOnView() const; //only the currently visible elements
+ unsigned int rowsTotal() const; //total number of rows available
- const FileCompareLine& operator[] (unsigned row) const;
- FileCompareLine& operator[] (unsigned row);
+ //get references to FileSystemObject: no NULL-check needed! Everything's bound.
+ void getAllFileRef(const std::set<unsigned int>& guiRows, std::vector<FileSystemObject*>& output);
- unsigned int elementsOnView() const; //only the currently visible elements
-
- bool refGridIsEmpty() const;
-
- //convert view references to FolderCompRef
- void viewRefToFolderRef(const std::set<int>& viewRef, FolderCompRef& output);
-
- const FolderPair getFolderPair(const unsigned int row) const;
-
- struct StatusInfo
+ struct StatusCmpResult
{
- StatusInfo();
+ StatusCmpResult();
bool existsLeftOnly;
bool existsRightOnly;
@@ -36,6 +31,29 @@ namespace FreeFileSync
bool existsEqual;
bool existsConflict;
+ unsigned int filesOnLeftView;
+ unsigned int foldersOnLeftView;
+ unsigned int filesOnRightView;
+ unsigned int foldersOnRightView;
+
+ wxULongLong filesizeLeftView;
+ wxULongLong filesizeRightView;
+ };
+
+ //comparison results view
+ StatusCmpResult updateCmpResult(bool hideFiltered,
+ bool leftOnlyFilesActive,
+ bool rightOnlyFilesActive,
+ bool leftNewerFilesActive,
+ bool rightNewerFilesActive,
+ bool differentFilesActive,
+ bool equalFilesActive,
+ bool conflictFilesActive);
+
+ struct StatusSyncPreview
+ {
+ StatusSyncPreview();
+
bool existsSyncCreateLeft;
bool existsSyncCreateRight;
bool existsSyncDeleteLeft;
@@ -43,41 +61,34 @@ namespace FreeFileSync
bool existsSyncDirLeft;
bool existsSyncDirRight;
bool existsSyncDirNone;
+ bool existsConflict;
unsigned int filesOnLeftView;
unsigned int foldersOnLeftView;
unsigned int filesOnRightView;
unsigned int foldersOnRightView;
- unsigned int objectsTotal;
-
wxULongLong filesizeLeftView;
wxULongLong filesizeRightView;
};
- StatusInfo update(const bool hideFiltered, const bool syncPreviewActive);
-
- void clearView(); //clear all references on compare results table: needed if there is a mismatch between references and actual data
-
- //UI View Filter settings
- //compare result
- bool leftOnlyFilesActive;
- bool rightOnlyFilesActive;
- bool leftNewerFilesActive;
- bool rightNewerFilesActive;
- bool differentFilesActive;
- bool equalFilesActive;
- bool conflictFilesActive;
- //sync preview
- bool syncCreateLeftActive;
- bool syncCreateRightActive;
- bool syncDeleteLeftActive;
- bool syncDeleteRightActive;
- bool syncDirLeftActive;
- bool syncDirRightActive;
- bool syncDirNoneActive;
-
- void resetSettings();
+ //synchronization preview
+ StatusSyncPreview updateSyncPreview(bool hideFiltered,
+ bool syncCreateLeftActive,
+ bool syncCreateRightActive,
+ bool syncDeleteLeftActive,
+ bool syncDeleteRightActive,
+ bool syncDirOverwLeftActive,
+ bool syncDirOverwRightActive,
+ bool syncDirNoneActive,
+ bool conflictFilesActive);
+
+
+
+ FolderComparison& getDataTentative(); //get data for operation that does NOT add or reorder rows! (deletion is okay)
+ void setData(FolderComparison& newData); //set data, taking ownership: warning std::swap() is used!!!
+ void removeInvalidRows(); //remove rows that have been deleted meanwhile: call after manual deletion and synchronization!
+ void clearAllRows(); //clears everything
//sorting...
enum SortType
@@ -91,55 +102,120 @@ namespace FreeFileSync
SORT_BY_SYNC_DIRECTION
};
- void sortView(const SortType type, const bool onLeft, const bool ascending);
+ void sortView(const SortType type, const bool onLeft, const bool ascending); //always call this method for sorting, never sort externally!
private:
- template <bool syncPreviewActive>
- StatusInfo update_sub(const bool hideFiltered);
+ class SerializeHierarchy;
struct RefIndex
{
+ RefIndex(unsigned int folderInd, FileSystemObject::ObjectID id) :
+ folderIndex(folderInd),
+ objId(id) {}
unsigned int folderIndex;
- unsigned int rowIndex;
+ FileSystemObject::ObjectID objId;
};
- std::vector<RefIndex> refView;
- FolderComparison& folderCmp;
+ FileSystemObject* getReferencedRow(const RefIndex ref); //returns NULL if not found
+ const FileSystemObject* getReferencedRow(const RefIndex ref) const; //returns NULL if not found
+ bool isInvalidRow(const RefIndex& ref) const;
+
+
+ std::vector<RefIndex> viewRef; //partial view on sortedRef
+ // |
+ // | (update...)
+ // \|/
+ std::vector<RefIndex> sortedRef; //equivalent to folerCmp, but may be sorted
+ // |
+ // | (setData)
+ // \|/
+ FolderComparison folderCmp; //actual comparison data: owned by GridView!
+
+
+ //sorting classes
+ template <bool ascending>
+ class SortByDirectory;
+
+ template <bool ascending, SelectedSide side>
+ class SortByRelName;
+
+ template <bool ascending, SelectedSide side>
+ class SortByFileName;
+
+ template <bool ascending, SelectedSide side>
+ class SortByFileSize;
+
+ template <bool ascending, SelectedSide side>
+ class SortByDate;
+
+ template <bool ascending>
+ class SortByCmpResult;
+
+ template <bool ascending>
+ class SortBySyncDirection;
};
+
+
+
+
+
+
+
+
//############################################################################
//inline implementation
+
inline
- const FileCompareLine& GridView::operator[] (unsigned row) const
+ const FileSystemObject* GridView::getObject(unsigned int row) const
{
- const unsigned int folderInd = refView[row].folderIndex;
- const unsigned int rowInd = refView[row].rowIndex;
-
- return folderCmp[folderInd].fileCmp[rowInd];
+ if (row < rowsOnView())
+ return getReferencedRow(viewRef[row]);
+ else
+ return NULL;
}
inline
- FileCompareLine& GridView::operator[] (unsigned row)
+ FileSystemObject* GridView::getObject(unsigned int row)
{
//code re-use of const method: see Meyers Effective C++
- return const_cast<FileCompareLine&>(static_cast<const GridView&>(*this).operator[](row));
+ return const_cast<FileSystemObject*>(static_cast<const GridView&>(*this).getObject(row));
}
inline
- unsigned int GridView::elementsOnView() const
+ unsigned int GridView::rowsOnView() const
{
- return refView.size();
+ return viewRef.size();
}
inline
- const FolderPair GridView::getFolderPair(const unsigned int row) const
+ FolderComparison& GridView::getDataTentative()
{
- const unsigned int folderInd = refView[row].folderIndex;
- const FolderCompareLine& folderCmpLine = folderCmp[folderInd];
- return folderCmpLine.syncPair;
+ return folderCmp;
+ }
+
+ inline
+ unsigned int GridView::rowsTotal() const //total number of rows available
+ {
+ return sortedRef.size();
+ }
+
+
+ inline
+ const FreeFileSync::FileSystemObject* GridView::getReferencedRow(const RefIndex ref) const
+ {
+ return folderCmp[ref.folderIndex].retrieveById(ref.objId);
+ }
+
+
+ inline
+ FreeFileSync::FileSystemObject* GridView::getReferencedRow(const RefIndex ref)
+ {
+ //code re-use of const method: see Meyers Effective C++
+ return const_cast<FileSystemObject*>(static_cast<const GridView&>(*this).getReferencedRow(ref));
}
}
bgstack15