Changelog for 0.0.8
[harmattan/cameraplus] / declarative / videoresolutionmodel.cpp
index 60ba7bf..1cd0981 100644 (file)
 VideoResolutionModel::VideoResolutionModel(QtCamVideoSettings *settings, QObject *parent) :
   QAbstractListModel(parent), m_settings(settings) {
 
-  m_roles[IdRole] = "resolutionId";
-  m_roles[NameRole] = "resolutionName";
-  m_roles[CaptureRole] = "captureResolution";
-  m_roles[PreviewRole] = "previewResolution";
-  m_roles[FpsRole] = "frameRate";
-  m_roles[NightFpsRole] = "nightFrameRate";
-  m_roles[ResolutionRole] = "resolution";
-  m_roles[AspectRatioRole] = "resolutionAspectRatio";
+  QHash<int, QByteArray> roles;
+  roles[IdRole] = "resolutionId";
+  roles[NameRole] = "resolutionName";
+  roles[CaptureRole] = "captureResolution";
+  roles[PreviewRole] = "previewResolution";
+  roles[FpsRole] = "frameRate";
+  roles[NightFpsRole] = "nightFrameRate";
+  roles[ResolutionRole] = "resolution";
+  roles[AspectRatioRole] = "resolutionAspectRatio";
+
+  setRoleNames(roles);
 
   m_resolutions = m_settings->resolutions(m_aspectRatio);
 }
@@ -95,16 +98,27 @@ void VideoResolutionModel::setAspectRatio(const QString& aspectRatio) {
 
     m_aspectRatio = aspectRatio;
 
-    emit aspectRatioChanged();
-
     beginResetModel();
 
     m_resolutions = m_settings->resolutions(m_aspectRatio);
 
     endResetModel();
+
+    emit aspectRatioChanged();
+    emit countChanged();
   }
 }
 
+int VideoResolutionModel::count() const {
+  return rowCount();
+}
+
+#if defined(QT5)
 QHash<int, QByteArray> VideoResolutionModel::roleNames() const {
   return m_roles;
 }
+
+void VideoResolutionModel::setRoleNames(const QHash<int, QByteArray>& roles) {
+  m_roles = roles;
+}
+#endif