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

« back to all changes in this revision

Viewing changes to src/photo/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(const QFileInfo& file);
42
 
 
43
 
    bool hasCachedOriginal() const;
44
 
    bool hasCachedEnhanced() const;
45
 
 
46
 
    const QFileInfo& originalFile() const;
47
 
    const QFileInfo& enhancedFile() const;
48
 
    const QFileInfo& pristineFile() const;
49
 
 
50
 
    bool cacheOriginal();
51
 
    bool restoreOriginal();
52
 
    bool cacheEnhancedFromOriginal();
53
 
    bool overwriteFromCache(bool preferEnhanced);
54
 
 
55
 
    void discardCachedOriginal();
56
 
    void discardCachedEnhanced();
57
 
    void discardAll();
58
 
 
59
 
private:
60
 
    static bool remove(const QFileInfo& file) {
61
 
        return QFile::remove(file.filePath());
62
 
    }
63
 
    static bool rename(const QFileInfo& oldName, const QFileInfo& newName) {
64
 
        return QFile::rename(oldName.filePath(), newName.filePath());
65
 
    }
66
 
    static bool copy(const QFileInfo& oldName, const QFileInfo& newName) {
67
 
        return QFile::copy(oldName.filePath(), newName.filePath());
68
 
    }
69
 
 
70
 
    QFileInfo m_file;
71
 
    QFileInfo m_originalFile;
72
 
    QFileInfo m_enhancedFile;
73
 
};
74
 
 
75
 
#endif