silence dbus-send output
[harmattan/cameraplus] / declarative / videoresolutionmodel.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 VIDEO_RESOLUTION_MODEL_H
24 #define VIDEO_RESOLUTION_MODEL_H
25
26 #include <QAbstractListModel>
27
28 class QtCamVideoSettings;
29 class QtCamVideoResolution;
30
31 class VideoResolutionModel : public QAbstractListModel {
32   Q_OBJECT
33
34   Q_PROPERTY(QString aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged);
35   Q_PROPERTY(int count READ count NOTIFY countChanged);
36
37 public:
38
39   enum ResolutionRoles {
40     IdRole = Qt::UserRole + 1,
41     NameRole,
42     CaptureRole,
43     PreviewRole,
44     FpsRole,
45     NightFpsRole,
46     ResolutionRole,
47     AspectRatioRole,
48   };
49
50   VideoResolutionModel(QtCamVideoSettings *settings, QObject *parent = 0);
51   ~VideoResolutionModel();
52
53   int rowCount(const QModelIndex& parent = QModelIndex()) const;
54
55   QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
56
57   QString aspectRatio() const;
58   void setAspectRatio(const QString& aspectRatio);
59
60   int count() const;
61
62 signals:
63   void aspectRatioChanged();
64   void countChanged();
65
66 private:
67   QString m_aspectRatio;
68
69   QtCamVideoSettings *m_settings;
70
71   QList<QtCamVideoResolution> m_resolutions;
72
73 #if defined(QT5)
74   QHash<int, QByteArray> roleNames() const;
75   void setRoleNames(const QHash<int, QByteArray>& roles);
76   QHash<int, QByteArray> m_roles;
77 #endif
78 };
79
80 #endif /* VIDEO_RESOLUTION_MODEL_H */