digiKam
dtrash.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2015-07-27
7  * Description : Special digiKam trash implementation
8  *
9  * Copyright (C) 2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_DTRASH_H
25 #define DIGIKAM_DTRASH_H
26 
27 // Qt includes
28 
29 #include <QObject>
30 #include <QFileInfo>
31 
32 // Local includes
33 
34 #include "dtrashiteminfo.h"
35 
36 namespace Digikam
37 {
38 
39 class DTrash
40 {
41 
42 public:
43 
44  const static QString TRASH_FOLDER;
45  const static QString FILES_FOLDER;
46  const static QString INFO_FOLDER;
47  const static QString INFO_FILE_EXTENSION;
48  const static QString PATH_JSON_KEY;
49  const static QString DELETIONTIMESTAMP_JSON_KEY;
50  const static QString IMAGEID_JSON_KEY;
51 
52 public:
53 
59  static bool deleteImage(const QString& imagePath, const QDateTime& deleteTime);
60 
66  static bool deleteDirRecursivley(const QString& dirToDelete, const QDateTime& deleteTime);
67 
74  static void extractJsonForItem(const QString& collPath, const QString& baseName, DTrashItemInfo& itemInfo);
75 
76 private:
77 
83  static bool prepareCollectionTrash(const QString& collectionPath);
84 
96  static QString createJsonRecordForFile(qlonglong imageId,
97  const QString& imagePath,
98  const QDateTime& deleteTime,
99  const QString& collectionPath);
100 
114  static QString getAvialableJsonFilePathInTrash(const QString& collectionPath,
115  const QString& baseName, int version = 0);
116 
117 private:
118 
119  DTrash();
120 };
121 
122 } // namespace Digikam
123 
124 #endif // DIGIKAM_DTRASH_H
Definition: dtrashiteminfo.h:36
Definition: dtrash.h:40
static const QString TRASH_FOLDER
Definition: dtrash.h:44
static const QString INFO_FILE_EXTENSION
Definition: dtrash.h:47
static const QString INFO_FOLDER
Definition: dtrash.h:46
static const QString FILES_FOLDER
Definition: dtrash.h:45
static void extractJsonForItem(const QString &collPath, const QString &baseName, DTrashItemInfo &itemInfo)
Extracts the data from json file and gives it to DTrashItemInfo.
Definition: dtrash.cpp:131
static const QString PATH_JSON_KEY
Definition: dtrash.h:48
static const QString DELETIONTIMESTAMP_JSON_KEY
Definition: dtrash.h:49
static bool deleteDirRecursivley(const QString &dirToDelete, const QDateTime &deleteTime)
Deletes a whole folder from the collection.
Definition: dtrash.cpp:108
static const QString IMAGEID_JSON_KEY
Definition: dtrash.h:50
static bool deleteImage(const QString &imagePath, const QDateTime &deleteTime)
Deletes image to the trash of a particular collection.
Definition: dtrash.cpp:59
Definition: datefolderview.cpp:43