~ubuntu-branches/ubuntu/feisty/digikam/feisty

« back to all changes in this revision

Viewing changes to digikam/cameradragobject.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2005-03-10 02:39:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050310023902-023nymfst5mg696c
Tags: 0.7.2-2
* debian/TODO: clean
* digikam manpage: better --detect-camera description

Show diffs side-by-side

added added

removed removed

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