nextcloud-desktop/src/mirall/syncfileitem.h

80 lines
1.6 KiB
C
Raw Normal View History

2013-01-15 23:41:52 +04:00
#ifndef SYNCFILEITEM_H
#define SYNCFILEITEM_H
#include <QVector>
#include <QString>
2013-05-16 15:54:22 +04:00
#include <QMetaType>
2013-01-15 23:41:52 +04:00
#include <csync.h>
namespace Mirall {
// FIXME: Unhack this.
class SyncFileItem {
public:
typedef enum {
None = 0,
Up,
Down } Direction;
typedef enum {
UnknownType,
File,
Directory,
SoftLink
} Type;
2013-01-15 23:41:52 +04:00
SyncFileItem() {}
friend bool operator==(const SyncFileItem& item1, const SyncFileItem& item2) {
return item1._file == item2._file;
}
friend bool operator<(const SyncFileItem& item1, const SyncFileItem& item2) {
// Delete at the end:
if (item1._instruction == CSYNC_INSTRUCTION_REMOVE && item2._instruction != CSYNC_INSTRUCTION_REMOVE)
return false;
if (item1._instruction != CSYNC_INSTRUCTION_REMOVE && item2._instruction == CSYNC_INSTRUCTION_REMOVE)
return true;
// Sort by destination
return item1.destination() < item2.destination();
2013-01-15 23:41:52 +04:00
}
QString destination() const {
return _instruction == CSYNC_INSTRUCTION_RENAME ? _renameTarget : _file;
}
bool isEmpty() const {
return _file.isEmpty();
}
2013-01-15 23:41:52 +04:00
// variables
QString _file;
QString _renameTarget;
QByteArray _originalFile; // as it is in the csync tree
2013-01-15 23:41:52 +04:00
csync_instructions_e _instruction;
Direction _dir;
bool _isDirectory;
time_t _modtime;
QByteArray _etag;
QString _errorString;
QString _errorDetail;
int _httpCode;
Type _type;
2013-01-15 23:41:52 +04:00
};
2013-01-15 23:41:52 +04:00
typedef QVector<SyncFileItem> SyncFileItemVector;
}
2013-05-16 15:54:22 +04:00
Q_DECLARE_METATYPE(Mirall::SyncFileItem);
2013-01-15 23:41:52 +04:00
#endif // SYNCFILEITEM_H