Warning, file /utilities/krusader/app/Synchronizer/synchronizerfileitem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2006 Csaba Karai <krusader@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2006-2022 Krusader Krew <https://krusader.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef SYNCHRONIZERFILEITEM_H 0009 #define SYNCHRONIZERFILEITEM_H 0010 0011 // QtCore 0012 #include <QString> 0013 0014 #include <KIO/Global> 0015 0016 typedef enum { 0017 TT_EQUALS = 0, // the files are equals -> do nothing 0018 TT_DIFFERS = 1, // the files are differents -> don't know what to do 0019 TT_COPY_TO_LEFT = 2, // the right file is newer -> copy from right to left 0020 TT_COPY_TO_RIGHT = 3, // the left file is newer -> copy from left to right 0021 TT_DELETE = 4, // the left file is single -> delete it 0022 TT_UNKNOWN = 5, // (5-9) the type of the task is not yet known 0023 TT_MAX = 10 // the maximum number of task types 0024 } TaskType; 0025 0026 #define SWAP(A, B, TYPE) \ 0027 { \ 0028 TYPE TMP = A; \ 0029 A = B; \ 0030 B = TMP; \ 0031 } 0032 #define REVERSE_TASK(A, asym) \ 0033 { \ 0034 switch (A) { \ 0035 case TT_COPY_TO_LEFT: \ 0036 if (asym) \ 0037 A = !m_existsRight ? TT_DELETE : TT_COPY_TO_LEFT; \ 0038 else \ 0039 A = TT_COPY_TO_RIGHT; \ 0040 break; \ 0041 case TT_COPY_TO_RIGHT: \ 0042 case TT_DELETE: \ 0043 A = TT_COPY_TO_LEFT; \ 0044 default: \ 0045 break; \ 0046 } \ 0047 }; 0048 0049 class SynchronizerFileItem 0050 { 0051 private: 0052 QString m_leftName; // the left file name 0053 QString m_rightName; // the right file name 0054 QString m_leftDirectory; // the left relative directory path from the base 0055 QString m_rightDirectory; // the left relative directory path from the base 0056 bool m_marked; // flag, indicates to show the file 0057 bool m_existsLeft; // flag, the file exists in the left directory 0058 bool m_existsRight; // flag, the file exists in the right directory 0059 KIO::filesize_t m_leftSize; // the file size at the left directory 0060 KIO::filesize_t m_rightSize; // the file size at the right directory 0061 time_t m_leftDate; // the file date at the left directory 0062 time_t m_rightDate; // the file date at the left directory 0063 QString m_leftLink; // the left file's symbolic link destination 0064 QString m_rightLink; // the right file's symbolic link destination 0065 QString m_leftOwner; // the left file's owner 0066 QString m_rightOwner; // the right file's owner 0067 QString m_leftGroup; // the left file's group 0068 QString m_rightGroup; // the right file's group 0069 mode_t m_leftMode; // mode for left 0070 mode_t m_rightMode; // mode for right 0071 QString m_leftACL; // ACL of the left file 0072 QString m_rightACL; // ACL of the right file 0073 TaskType m_task; // the task with the file 0074 bool m_isDir; // flag, indicates that the file is a directory 0075 SynchronizerFileItem *m_parent; // pointer to the parent directory item or 0 0076 void *m_userData; // user data 0077 bool m_overWrite; // overwrite flag 0078 QString m_destination; // the destination URL at rename 0079 bool m_temporary; // flag indicates temporary directory 0080 TaskType m_originalTask; // the original task type 0081 0082 public: 0083 SynchronizerFileItem(const QString &leftNam, 0084 const QString &rightNam, 0085 const QString &leftDir, 0086 const QString &rightDir, 0087 bool mark, 0088 bool exL, 0089 bool exR, 0090 KIO::filesize_t leftSize, 0091 KIO::filesize_t rightSize, 0092 time_t leftDate, 0093 time_t rightDate, 0094 const QString &leftLink, 0095 const QString &rightLink, 0096 const QString &leftOwner, 0097 const QString &rightOwner, 0098 const QString &leftGroup, 0099 const QString &rightGroup, 0100 mode_t leftMode, 0101 mode_t rightMode, 0102 const QString &leftACL, 0103 const QString &rightACL, 0104 TaskType tsk, 0105 bool isDir, 0106 bool tmp, 0107 SynchronizerFileItem *parent) 0108 : m_leftName(leftNam) 0109 , m_rightName(rightNam) 0110 , m_leftDirectory(leftDir) 0111 , m_rightDirectory(rightDir) 0112 , m_marked(mark) 0113 , m_existsLeft(exL) 0114 , m_existsRight(exR) 0115 , m_leftSize(leftSize) 0116 , m_rightSize(rightSize) 0117 , m_leftDate(leftDate) 0118 , m_rightDate(rightDate) 0119 , m_leftLink(leftLink) 0120 , m_rightLink(rightLink) 0121 , m_leftOwner(leftOwner) 0122 , m_rightOwner(rightOwner) 0123 , m_leftGroup(leftGroup) 0124 , m_rightGroup(rightGroup) 0125 , m_leftMode(leftMode) 0126 , m_rightMode(rightMode) 0127 , m_leftACL(leftACL) 0128 , m_rightACL(rightACL) 0129 , m_task(tsk) 0130 , m_isDir(isDir) 0131 , m_parent(parent) 0132 , m_userData(nullptr) 0133 , m_overWrite(false) 0134 , m_destination(QString()) 0135 , m_temporary(tmp) 0136 , m_originalTask(tsk) 0137 { 0138 } 0139 0140 inline bool isMarked() 0141 { 0142 return m_marked; 0143 } 0144 inline void setMarked(bool flag) 0145 { 0146 m_marked = flag; 0147 } 0148 inline const QString &leftName() 0149 { 0150 return m_leftName; 0151 } 0152 inline const QString &rightName() 0153 { 0154 return m_rightName; 0155 } 0156 inline const QString &leftDirectory() 0157 { 0158 return m_leftDirectory; 0159 } 0160 inline const QString &rightDirectory() 0161 { 0162 return m_rightDirectory; 0163 } 0164 inline bool existsInLeft() 0165 { 0166 return m_existsLeft; 0167 } 0168 inline bool existsInRight() 0169 { 0170 return m_existsRight; 0171 } 0172 inline bool overWrite() 0173 { 0174 return m_overWrite; 0175 } 0176 inline KIO::filesize_t leftSize() 0177 { 0178 return m_leftSize; 0179 } 0180 inline KIO::filesize_t rightSize() 0181 { 0182 return m_rightSize; 0183 } 0184 inline time_t leftDate() 0185 { 0186 return m_leftDate; 0187 } 0188 inline time_t rightDate() 0189 { 0190 return m_rightDate; 0191 } 0192 inline const QString &leftLink() 0193 { 0194 return m_leftLink; 0195 } 0196 inline const QString &rightLink() 0197 { 0198 return m_rightLink; 0199 } 0200 inline const QString &leftOwner() 0201 { 0202 return m_leftOwner; 0203 } 0204 inline const QString &rightOwner() 0205 { 0206 return m_rightOwner; 0207 } 0208 inline const QString &leftGroup() 0209 { 0210 return m_leftGroup; 0211 } 0212 inline const QString &rightGroup() 0213 { 0214 return m_rightGroup; 0215 } 0216 inline mode_t leftMode() 0217 { 0218 return m_leftMode; 0219 } 0220 inline mode_t rightMode() 0221 { 0222 return m_rightMode; 0223 } 0224 inline const QString &leftACL() 0225 { 0226 return m_leftACL; 0227 } 0228 inline const QString &rightACL() 0229 { 0230 return m_rightACL; 0231 } 0232 inline TaskType task() 0233 { 0234 return m_task; 0235 } 0236 inline void compareContentResult(bool res) 0237 { 0238 if (res == true) 0239 m_task = m_originalTask = TT_EQUALS; 0240 else if (m_originalTask >= TT_UNKNOWN) 0241 m_task = m_originalTask = (TaskType)(m_originalTask - TT_UNKNOWN); 0242 } 0243 inline bool isDir() 0244 { 0245 return m_isDir; 0246 } 0247 inline SynchronizerFileItem *parent() 0248 { 0249 return m_parent; 0250 } 0251 inline void *userData() 0252 { 0253 return m_userData; 0254 } 0255 inline void setUserData(void *ud) 0256 { 0257 m_userData = ud; 0258 } 0259 inline void setOverWrite() 0260 { 0261 m_overWrite = true; 0262 } 0263 inline const QString &destination() 0264 { 0265 return m_destination; 0266 } 0267 inline void setDestination(QString d) 0268 { 0269 m_destination = d; 0270 } 0271 inline bool isTemporary() 0272 { 0273 return m_temporary; 0274 } 0275 inline void setPermanent() 0276 { 0277 m_temporary = false; 0278 } 0279 inline TaskType originalTask() 0280 { 0281 return m_originalTask; 0282 } 0283 inline void restoreOriginalTask() 0284 { 0285 m_task = m_originalTask; 0286 } 0287 inline void setTask(TaskType t) 0288 { 0289 m_task = t; 0290 } 0291 inline void swap(bool asym = false) 0292 { 0293 SWAP(m_existsLeft, m_existsRight, bool); 0294 SWAP(m_leftName, m_rightName, QString); 0295 SWAP(m_leftDirectory, m_rightDirectory, QString); 0296 SWAP(m_leftSize, m_rightSize, KIO::filesize_t); 0297 SWAP(m_leftDate, m_rightDate, time_t); 0298 SWAP(m_leftLink, m_rightLink, QString); 0299 SWAP(m_leftOwner, m_rightOwner, QString); 0300 SWAP(m_leftGroup, m_rightGroup, QString); 0301 SWAP(m_leftACL, m_rightACL, QString); 0302 REVERSE_TASK(m_originalTask, asym); 0303 REVERSE_TASK(m_task, asym); 0304 } 0305 }; 0306 0307 #endif /* __SYNCHRONIZER_FILE_ITEM_H__ */