~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/digikam/cameradragobject.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ============================================================
2
 
 *
3
 
 * This file is a part of digiKam project
4
 
 * http://www.digikam.org
5
 
 *
6
 
 * Date        : 2003-02-18
7
 
 * Description : drag and drop camera management 
8
 
 * 
9
 
 * Copyright (C) 2003-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
 
 *
12
 
 * This program is free software; you can redistribute it
13
 
 * and/or modify it under the terms of the GNU General
14
 
 * Public License as published by the Free Software Foundation;
15
 
 * either version 2, or (at your option)
16
 
 * any later version.
17
 
 * 
18
 
 * This program is distributed in the hope that it will be useful,
19
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
 * GNU General Public License for more details.
22
 
 * 
23
 
 * ============================================================ */
24
 
 
25
 
// Qt includes.
26
 
 
27
 
#include <qmime.h>
28
 
#include <qstring.h>
29
 
#include <qdatetime.h>
30
 
#include <qcstring.h>
31
 
#include <qwidget.h>
32
 
#include <qdatastream.h>
33
 
 
34
 
// Local includes.
35
 
 
36
 
#include "cameratype.h"
37
 
#include "cameradragobject.h"
38
 
 
39
 
namespace Digikam
40
 
{
41
 
 
42
 
CameraDragObject::CameraDragObject(const CameraType& ctype, QWidget *dragSource)
43
 
                : QStoredDrag("camera/unknown", dragSource)
44
 
{
45
 
    setCameraType(ctype);
46
 
}
47
 
 
48
 
CameraDragObject::~CameraDragObject()
49
 
{
50
 
}
51
 
 
52
 
void CameraDragObject::setCameraType(const CameraType& ctype)
53
 
{
54
 
    QByteArray byteArray;
55
 
    QDataStream ds(byteArray, IO_WriteOnly);
56
 
 
57
 
    ds << ctype.title();
58
 
    ds << ctype.model();
59
 
    ds << ctype.port();
60
 
    ds << ctype.path();
61
 
    ds << ctype.lastAccess();
62
 
    
63
 
    setEncodedData(byteArray);    
64
 
}
65
 
 
66
 
bool CameraDragObject::canDecode(const QMimeSource* e)
67
 
{
68
 
    return e->provides("camera/unknown");
69
 
}
70
 
 
71
 
bool CameraDragObject::decode(const QMimeSource* e, CameraType& ctype)
72
 
{
73
 
    QByteArray payload = e->encodedData("camera/unknown");
74
 
    if (payload.size()) 
75
 
    {
76
 
        QString   title, model, port, path;
77
 
        QDateTime lastAccess;
78
 
 
79
 
        QDataStream ds(payload, IO_ReadOnly);
80
 
        ds >> title;
81
 
        ds >> model;
82
 
        ds >> port;
83
 
        ds >> path;
84
 
        ds >> lastAccess;
85
 
 
86
 
        ctype = CameraType(title, model, port, path, lastAccess);
87
 
        
88
 
        return true;
89
 
    }
90
 
    else
91
 
        return false;
92
 
}
93
 
 
94
 
}  // namespace Digikam