~elopio/gallery-app/revert_workaround-1302706-click_toolbar_button_failure

« back to all changes in this revision

Viewing changes to src/photoeditor/photo-caches.h

  • Committer: Leo Arias
  • Date: 2015-05-15 08:05:23 UTC
  • mfrom: (954.1.241 gallery-app)
  • Revision ID: leo.arias@canonical.com-20150515080523-i2of3vr8h7dioj59
Now the toolbar object is not needed at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors:
 
17
 * Charles Lindsay <chaz@yorba.org>
 
18
 */
 
19
 
 
20
#ifndef GALLERY_PHOTO_CACHES_H_
 
21
#define GALLERY_PHOTO_CACHES_H_
 
22
 
 
23
#include <QFile>
 
24
#include <QFileInfo>
 
25
#include <QString>
 
26
 
 
27
/*!
 
28
 * \brief The PhotoCaches class
 
29
 *
 
30
 * An abstraction around the various files we keep in addition to the photo
 
31
 * file itself: the original, the pristine version of the file without any
 
32
 * applied edits; and the enhanced, a version of the original with auto-enhance
 
33
 * applied to it (necessary because of how slow auto-enhance is).
 
34
 */
 
35
class PhotoCaches
 
36
{
 
37
public:
 
38
    static const QString ORIGINAL_DIR;
 
39
    static const QString ENHANCED_DIR;
 
40
 
 
41
    PhotoCaches(); // FIXME: remove this class and only deal with a stack of temporary rollback files
 
42
    PhotoCaches(const QFileInfo& file);
 
43
 
 
44
    bool hasCachedOriginal() const;
 
45
    bool hasCachedEnhanced() const;
 
46
 
 
47
    const QFileInfo& originalFile() const;
 
48
    const QFileInfo& enhancedFile() const;
 
49
    const QFileInfo& pristineFile() const;
 
50
 
 
51
    bool cacheOriginal();
 
52
    bool restoreOriginal();
 
53
    bool cacheEnhancedFromOriginal();
 
54
    bool overwriteFromCache(bool preferEnhanced);
 
55
 
 
56
    void discardCachedOriginal();
 
57
    void discardCachedEnhanced();
 
58
    void discardAll();
 
59
 
 
60
private:
 
61
    static bool remove(const QFileInfo& file) {
 
62
        return QFile::remove(file.filePath());
 
63
    }
 
64
    static bool rename(const QFileInfo& oldName, const QFileInfo& newName) {
 
65
        return QFile::rename(oldName.filePath(), newName.filePath());
 
66
    }
 
67
    static bool copy(const QFileInfo& oldName, const QFileInfo& newName) {
 
68
        return QFile::copy(oldName.filePath(), newName.filePath());
 
69
    }
 
70
 
 
71
    QFileInfo m_file;
 
72
    QFileInfo m_originalFile;
 
73
    QFileInfo m_enhancedFile;
 
74
};
 
75
 
 
76
#endif