Source /tmp/session_bus_address.user before invoking dbus-send in postinst script
[harmattan/cameraplus] / src / filenaming.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef FILE_NAMING_H
24 #define FILE_NAMING_H
25
26 #include <QObject>
27 #if defined(QT4)
28 #include <QDeclarativeParserStatus>
29 #elif defined(QT5)
30 #include <QQmlParserStatus>
31 #endif
32 #include "fileindex.h"
33
34 class Settings;
35
36 #if defined(QT4)
37 class FileNaming : public QObject, public QDeclarativeParserStatus {
38 #elif defined(QT5)
39 class FileNaming : public QObject, public QQmlParserStatus {
40 #endif
41
42   Q_OBJECT
43
44   Q_PROPERTY(QString imageSuffix READ imageSuffix WRITE setImageSuffix NOTIFY imageSuffixChanged);
45   Q_PROPERTY(QString videoSuffix READ videoSuffix WRITE setVideoSuffix NOTIFY videoSuffixChanged);
46   Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged);
47   Q_PROPERTY(QString videoPath READ videoPath WRITE setVideoPath NOTIFY videoPathChanged);
48   Q_PROPERTY(QString temporaryVideoPath READ temporaryVideoPath WRITE setTemporaryVideoPath NOTIFY temporaryVideoPathChanged);
49   Q_PROPERTY(Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged);
50
51 public:
52   FileNaming(QObject *parent = 0);
53   ~FileNaming();
54
55   QString imageSuffix() const;
56   void setImageSuffix(const QString& suffix);
57
58   QString videoSuffix() const;
59   void setVideoSuffix(const QString& suffix);
60
61   Q_INVOKABLE QString imageFileName();
62   Q_INVOKABLE QString videoFileName();
63   Q_INVOKABLE QString temporaryVideoFileName();
64
65   QString imagePath() const;
66   void setImagePath(const QString& path);
67
68   QString videoPath() const;
69   void setVideoPath(const QString& path);
70
71   QString temporaryVideoPath() const;
72   void setTemporaryVideoPath(const QString& path);
73
74   Settings *settings() const;
75   void setSettings(Settings *settings);
76
77   virtual void classBegin();
78   virtual void componentComplete();
79
80 signals:
81   void imageSuffixChanged();
82   void videoSuffixChanged();
83   void imagePathChanged();
84   void videoPathChanged();
85   void temporaryVideoPathChanged();
86   void settingsChanged();
87
88 private:
89   typedef enum {
90     Image = FileIndex::Image,
91     Video = FileIndex::Video,
92   } Type;
93
94   QString fileName(const QString& path, const QString& suffix, const Type& type);
95   QString canonicalPath(const QString& path);
96   QString temporaryPath();
97
98   QString m_imageSuffix;
99   QString m_videoSuffix;
100   QString m_imagePath;
101   QString m_videoPath;
102   QString m_temporaryVideoPath;
103
104   Settings *m_settings;
105   FileIndex *m_index;
106 };
107
108 #endif /* FILE_NAMING_H */