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