Source /tmp/session_bus_address.user before invoking dbus-send in postinst script
[harmattan/cameraplus] / src / fileindex.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include "fileindex.h"
22 #include "settings.h"
23
24 FileIndex::FileIndex(Settings *settings) :
25   m_settings(settings) {
26
27 }
28
29 FileIndex::~FileIndex() {
30
31 }
32
33 SingleFileIndex::SingleFileIndex(Settings *settings) :
34   FileIndex(settings) {
35
36 }
37
38 QString SingleFileIndex::stamp(const Type& type) {
39   Q_UNUSED(type);
40
41   return m_settings->fileNamingStamp("stamp");
42 }
43
44 void SingleFileIndex::setStamp(const Type& type, const QString& stamp) {
45   Q_UNUSED(type);
46
47   m_settings->setFileNamingStamp("stamp", stamp);
48 }
49
50 int SingleFileIndex::counter(const Type& type) {
51   Q_UNUSED(type);
52
53   return m_settings->fileNamingCounter("counter");
54 }
55
56 void SingleFileIndex::setCounter(const Type& type, int counter) {
57   Q_UNUSED(type);
58
59   m_settings->setFileNamingCounter("counter", counter);
60 }
61
62 MultiFileIndex::MultiFileIndex(Settings *settings) :
63   FileIndex(settings) {
64
65 }
66
67 QString MultiFileIndex::stamp(const Type& type) {
68   switch (type) {
69   case Image:
70     return m_settings->fileNamingStamp("imageStamp");
71   case Video:
72     return m_settings->fileNamingStamp("videoStamp");
73   }
74 }
75
76 void MultiFileIndex::setStamp(const Type& type, const QString& stamp) {
77   switch (type) {
78   case Image:
79     m_settings->setFileNamingStamp("imageStamp", stamp);
80     break;
81   case Video:
82     m_settings->setFileNamingStamp("videoStamp", stamp);
83     break;
84   }
85 }
86
87 int MultiFileIndex::counter(const Type& type) {
88   switch (type) {
89   case Image:
90     return m_settings->fileNamingCounter("imageCounter");
91   case Video:
92     return m_settings->fileNamingCounter("videoCounter");
93   }
94 }
95
96 void MultiFileIndex::setCounter(const Type& type, int counter) {
97   switch (type) {
98   case Image:
99     m_settings->setFileNamingCounter("imageCounter", counter);
100     break;
101   case Video:
102     m_settings->setFileNamingCounter("videoCounter", counter);
103     break;
104   }
105 }