camerauis/cameraxui/cxengine/src/cxestillimagesymbian.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QString>
       
    19 #include <QPixmap>
       
    20 
       
    21 #include "cxeimagedataitem.h"
       
    22 #include "cxestillimagesymbian.h"
       
    23 #include "cxutils.h"
       
    24 
       
    25 // Static initialization
       
    26 int CxeStillImageSymbian::mNextId = CxeStillImage::INVALID_ID + 1;
       
    27 
       
    28 /*!
       
    29 * Constructor.
       
    30 */
       
    31 CxeStillImageSymbian::CxeStillImageSymbian()
       
    32   : mSnapshot(),
       
    33     mDataItem(NULL),
       
    34     mSaved(false),
       
    35     mId(++mNextId)
       
    36 {
       
    37 }
       
    38 
       
    39 /*!
       
    40 * Destructor.
       
    41 */
       
    42 CxeStillImageSymbian::~CxeStillImageSymbian()
       
    43 {
       
    44     // Not owned.
       
    45     mDataItem = NULL;
       
    46 }
       
    47 
       
    48 /*!
       
    49 * Get the contained data item.
       
    50 * @return Image data item.
       
    51 */
       
    52 CxeImageDataItem *CxeStillImageSymbian::dataItem()
       
    53 {
       
    54     return mDataItem;
       
    55 }
       
    56 
       
    57 /*!
       
    58 * Get the filename of this image.
       
    59 * @return The filename.
       
    60 */
       
    61 QString CxeStillImageSymbian::filename() const
       
    62 {
       
    63     return mFilename;
       
    64 }
       
    65 
       
    66 /*!
       
    67 * Get snapshot for this image.
       
    68 * @return Snapshot for this image if set. Null pixmap otherwise.
       
    69 */
       
    70 QPixmap CxeStillImageSymbian::snapshot() const
       
    71 {
       
    72     return mSnapshot;
       
    73 }
       
    74 
       
    75 /*!
       
    76 * Image saved status.
       
    77 * @return Is this image saved.
       
    78 */
       
    79 bool CxeStillImageSymbian::saved() const
       
    80 {
       
    81     return mSaved;
       
    82 }
       
    83 
       
    84 /*!
       
    85 * Set the unique id of this image.
       
    86 * Usable in one application run context.
       
    87 */
       
    88 int CxeStillImageSymbian::id() const
       
    89 {
       
    90     return mId;
       
    91 }
       
    92 
       
    93 /*!
       
    94 * Set snapshot for this image.
       
    95 * @param pixmap The snapshot.
       
    96 */
       
    97 void CxeStillImageSymbian::setSnapshot(QPixmap pixmap)
       
    98 {
       
    99     mSnapshot = pixmap;
       
   100 }
       
   101 
       
   102 /*!
       
   103 * Set the filename of this image.
       
   104 * @param filename The filename.
       
   105 */
       
   106 void CxeStillImageSymbian::setFilename(const QString &filename)
       
   107 {
       
   108     mFilename = filename;
       
   109 }
       
   110 
       
   111 /*!
       
   112 * Set this image as saved.
       
   113 * @param saved Is this item saved or not.
       
   114 */
       
   115 void CxeStillImageSymbian::setSaved(bool saved)
       
   116 {
       
   117     mSaved = saved;
       
   118 }
       
   119 
       
   120 /*!
       
   121 * Set the contained image data item.
       
   122 * @param dataItem Image data item to store. Ownership not taken.
       
   123 */
       
   124 void CxeStillImageSymbian::setDataItem(CxeImageDataItem *dataItem)
       
   125 {
       
   126     // Disconnect from old data item if it exists.
       
   127     if (mDataItem) {
       
   128         disconnect(mDataItem, 0, this, 0);
       
   129     }
       
   130 
       
   131     // Set the new item.
       
   132     mDataItem = dataItem;
       
   133 
       
   134     // Connnect to the new item's saved signal.
       
   135     if (mDataItem) {
       
   136         bool ok = connect(mDataItem, SIGNAL(imageSaved(CxeError::Id, const QString&, int)),
       
   137                           this, SLOT(imageDataSaved(CxeError::Id)), Qt::UniqueConnection);
       
   138         CX_ASSERT_ALWAYS(ok);
       
   139     }
       
   140 }
       
   141 
       
   142 /*!
       
   143 * Slot to handle saving the data item has finished.
       
   144 */
       
   145 void CxeStillImageSymbian::imageDataSaved(CxeError::Id status)
       
   146 {
       
   147     setSaved(status == CxeError::None);
       
   148 }
       
   149 
       
   150 // end of file