~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/photivointegration/xmpmm.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of kipi-plugins project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2012-07-01
 
7
 * Description : Integration of the Photivo RAW-Processor.
 
8
 *
 
9
 * Copyright (C) 2012 by Dominic Lyons <domlyons at googlemail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option) any later version.
 
15
 * 
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * ============================================================ */
 
22
 
 
23
// KDE includes
 
24
 
 
25
#include <kdebug.h>
 
26
 
 
27
// local includes
 
28
 
 
29
#include "xmpmm.h"
 
30
 
 
31
namespace KIPIPhotivoIntegrationPlugin
 
32
{
 
33
 
 
34
// public /////////////////////////////////////////////////////////////////////
 
35
 
 
36
void XmpMM::load(const KPMetadata& meta)
 
37
{
 
38
    // Check if XMP is available at all
 
39
    if (meta.hasXmp())
 
40
    {
 
41
        KExiv2::MetaDataMap mmMap = meta.getXmpTagsDataList(QStringList("xmpMM"));
 
42
        kDebug() << "mmMap.size():" << mmMap.size();
 
43
 
 
44
        loadIDs(mmMap);
 
45
        loadHistory(mmMap);
 
46
        //TODO: loadDerivedFrom()
 
47
    }
 
48
}
 
49
 
 
50
// ----------------------------------------------------------------------------
 
51
 
 
52
QString XmpMM::pureID (const QString& id) const
 
53
{
 
54
    int split = id.lastIndexOf (':');
 
55
 
 
56
    if (split < 0) //no ':' found => no prefix
 
57
        return id;
 
58
 
 
59
    else           //split prefix and id after last ':'
 
60
        return id.mid(split + 1);
 
61
}
 
62
 
 
63
// private ////////////////////////////////////////////////////////////////////
 
64
 
 
65
void XmpMM::loadHistory(const KExiv2::MetaDataMap& mmMap)
 
66
{
 
67
    // KPMetadata/KExiv2 can't tell how many elements an array has, 
 
68
    // so we try to access the next element in a loop until we fail.
 
69
    int i = 0;
 
70
    while (mmMap.contains(QString("Xmp.xmpMM.History[%1]").arg(++i)))
 
71
    {
 
72
        XmpMMHistory hist;
 
73
        QString      node  = QString("Xmp.xmpMM.History[%1]/stEvt:").arg(i);
 
74
 
 
75
        // Missing key/value pairs will result as an empty string
 
76
        hist.action     = mmMap[node + "action"];
 
77
        hist.instanceID = mmMap[node + "instanceID"];
 
78
        hist.when       = mmMap[node + "when"];
 
79
        history.push_back(hist);
 
80
    }
 
81
    kDebug() << "history.size():" << history.size();
 
82
}
 
83
 
 
84
// ----------------------------------------------------------------------------
 
85
 
 
86
void XmpMM::loadIDs(const KExiv2::MetaDataMap& mmMap)
 
87
{
 
88
    // Missing key/value pairs will result as an empty string
 
89
    documentID         = mmMap["Xmp.xmpMM.DocumentID"];
 
90
    instanceID         = mmMap["Xmp.xmpMM.InstanceID"];
 
91
    originalDocumentID = mmMap["Xmp.xmpMM.OriginalDocumentID"];
 
92
}
 
93
 
 
94
} // namespace KIPIPhotivoIntegrationPlugin