Add a new data member for the class specific private pointer instead of the mess...
authorMohammed Sameer <msameer@foolab.org>
Sat, 1 Sep 2012 09:15:41 +0000 (12:15 +0300)
committerMohammed Sameer <msameer@foolab.org>
Thu, 6 Sep 2012 16:10:10 +0000 (19:10 +0300)
lib/qtcamimagemode.cpp
lib/qtcamimagemode.h
lib/qtcamvideomode.cpp
lib/qtcamvideomode.h

index 029f528..06ca23c 100644 (file)
@@ -18,10 +18,10 @@ public:
   QtCamImageSettings settings;
 };
 
-QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *d, QObject *parent) :
-  QtCamMode(new QtCamImageModePrivate(d), "mode-image", "image-done", parent) {
+QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *dev, QObject *parent) :
+  QtCamMode(new QtCamImageModePrivate(dev), "mode-image", "image-done", parent) {
 
-  d_ptr = (QtCamImageModePrivate *)QtCamMode::d_ptr;
+  d = (QtCamImageModePrivate *)d_ptr;
 
   QString name = d_ptr->dev->conf->imageEncodingProfileName();
   QString path = d_ptr->dev->conf->imageEncodingProfilePath();
@@ -35,7 +35,7 @@ QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *d, QObject *parent) :
 }
 
 QtCamImageMode::~QtCamImageMode() {
-
+  d = 0;
 }
 
 bool QtCamImageMode::canCapture() {
@@ -43,12 +43,12 @@ bool QtCamImageMode::canCapture() {
 }
 
 void QtCamImageMode::applySettings() {
-  d_ptr->setCaps("image-capture-caps", d_ptr->settings.captureResolution(),
-                d_ptr->settings.frameRate());
-  d_ptr->setCaps("viewfinder-caps", d_ptr->settings.viewfinderResolution(),
-                d_ptr->settings.frameRate());
+  d_ptr->setCaps("image-capture-caps", d->settings.captureResolution(),
+                d->settings.frameRate());
+  d_ptr->setCaps("viewfinder-caps", d->settings.viewfinderResolution(),
+                d->settings.frameRate());
 
-  setPreviewSize(d_ptr->settings.previewResolution());
+  setPreviewSize(d->settings.previewResolution());
 }
 
 void QtCamImageMode::start() {
@@ -73,7 +73,7 @@ bool QtCamImageMode::capture(const QString& fileName) {
 }
 
 bool QtCamImageMode::setSettings(const QtCamImageSettings& settings) {
-  d_ptr->settings = settings;
+  d->settings = settings;
 
   if (!d_ptr->dev->q_ptr->isIdle()) {
     return false;
index 483c7a5..4a17750 100644 (file)
@@ -14,7 +14,7 @@ class QtCamImageMode : public QtCamMode {
   Q_OBJECT
 
 public:
-  QtCamImageMode(QtCamDevicePrivate *d, QObject *parent = 0);
+  QtCamImageMode(QtCamDevicePrivate *dev, QObject *parent = 0);
   ~QtCamImageMode();
 
   virtual bool canCapture();
@@ -31,7 +31,7 @@ protected:
   virtual void stop();
 
 private:
-  QtCamImageModePrivate *d_ptr;
+  QtCamImageModePrivate *d;
 };
 
 #endif /* QT_CAM_IMAGE_MODE_H */
index 864383a..6edc03f 100644 (file)
@@ -25,10 +25,10 @@ public:
   QtCamVideoSettings settings;
 };
 
-QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent) :
-  QtCamMode(new QtCamVideoModePrivate(d), "mode-video", "video-done", parent) {
+QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *dev, QObject *parent) :
+  QtCamMode(new QtCamVideoModePrivate(dev), "mode-video", "video-done", parent) {
 
-  d_ptr = (QtCamVideoModePrivate *)QtCamMode::d_ptr;
+  d = (QtCamVideoModePrivate *)QtCamMode::d_ptr;
 
   QString name = d_ptr->dev->conf->videoEncodingProfileName();
   QString path = d_ptr->dev->conf->videoEncodingProfilePath();
@@ -45,7 +45,7 @@ QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent) :
 }
 
 QtCamVideoMode::~QtCamVideoMode() {
-
+  d = 0;
 }
 
 bool QtCamVideoMode::canCapture() {
@@ -53,13 +53,13 @@ bool QtCamVideoMode::canCapture() {
 }
 
 void QtCamVideoMode::applySettings() {
-  d_ptr->setCaps("viewfinder-caps", d_ptr->settings.captureResolution(),
-         d_ptr->settings.frameRate());
+  d_ptr->setCaps("viewfinder-caps", d->settings.captureResolution(),
+         d->settings.frameRate());
 
-  d_ptr->setCaps("video-capture-caps", d_ptr->settings.captureResolution(),
-         d_ptr->settings.frameRate());
+  d_ptr->setCaps("video-capture-caps", d->settings.captureResolution(),
+         d->settings.frameRate());
 
-  setPreviewSize(d_ptr->settings.previewResolution());
+  setPreviewSize(d->settings.previewResolution());
 }
 
 void QtCamVideoMode::start() {
@@ -100,7 +100,7 @@ void QtCamVideoMode::stopRecording() {
 }
 
 bool QtCamVideoMode::setSettings(const QtCamVideoSettings& settings) {
-  d_ptr->settings = settings;
+  d->settings = settings;
 
   if (isRecording()) {
     return false;
index 6b32767..5b900fc 100644 (file)
@@ -16,7 +16,7 @@ class QtCamVideoMode : public QtCamMode {
   Q_PROPERTY(bool recording READ isRecording NOTIFY recordingStateChanged);
 
 public:
-  QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent = 0);
+  QtCamVideoMode(QtCamDevicePrivate *dev, QObject *parent = 0);
   ~QtCamVideoMode();
 
   virtual bool canCapture();
@@ -40,9 +40,8 @@ protected:
   virtual void stop();
 
 private:
-  Q_PRIVATE_SLOT(d_ptr, void _d_idleStateChanged(bool));
-
-  QtCamVideoModePrivate *d_ptr;
+  QtCamVideoModePrivate *d;
+  Q_PRIVATE_SLOT(d, void _d_idleStateChanged(bool));
 };
 
 #endif /* QT_CAM_VIDEO_MODE_H */