File: kipiimageinfoshared.cpp

package info (click to toggle)
libkf5kipi 4%3A22.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 668 kB
  • sloc: cpp: 4,761; makefile: 5
file content (95 lines) | stat: -rw-r--r-- 2,296 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
    SPDX-FileCopyrightText: 2009-2010 Michael G. Hansen <mike at mghansen dot de>
    SPDX-FileCopyrightText: 2011-2018 Gilles Caulier <caulier dot gilles at gmail dot com>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "kipiimageinfoshared.h"

// Qt includes

#include <QFileInfo>
#include <QStringList>
#include <QDebug>

namespace KXMLKipiCmd
{

class KipiImageInfoShared::Private
{
public:

    Private()
    {
    }

    QDateTime dateTime;
};

KipiImageInfoShared::KipiImageInfoShared(Interface* const interface, const QUrl& url)
    : ImageInfoShared(interface, url),
      d(new Private())
{
}

KipiImageInfoShared::~KipiImageInfoShared()
{
    delete d;
}

QMap<QString, QVariant> KipiImageInfoShared::attributes()
{
    qDebug() << "QMap<QString,QVariant> attributes()";

    QMap<QString, QVariant> res;

    // Comment attribute
    res[QString::fromLatin1("comment")] = QString::fromLatin1("Image located at \"%1\"").arg(_url.url());

    // Date attribute
    if (!d->dateTime.isValid())
    {
        if ( ! _url.isLocalFile() )
        {
            qFatal("KIPI::ImageInfoShared::time does not yet support non local files, please fix\n");
            d->dateTime = QDateTime();
        }
        else
        {
            // File creation date only
            d->dateTime = QFileInfo( _url.toLocalFile() ).lastModified();
        }
    }

    res[QString::fromLatin1("date")] = d->dateTime;

    return res;
}
void KipiImageInfoShared::clearAttributes()
{
    qDebug() << "void KipiImageInfoShared::clearAttributes()";
}

void KipiImageInfoShared::addAttributes(const QMap<QString, QVariant>& attributes)
{
    qDebug() << "void KipiImageInfoShared::addAttributes()";

    QMap<QString, QVariant>::const_iterator it = attributes.constBegin();

    while (it != attributes.constEnd())
    {
        QString key = it.key();
        QString val = it.value().toString();
        qDebug() << QString::fromLatin1("attribute( \"%1\" ), value( \"%2\" )").arg(key).arg(val);
        ++it;
    }
}

void KipiImageInfoShared::delAttributes(const QStringList& attributes)
{
    qDebug() << "void KipiImageInfoShared::delAttributes()";
    qDebug() << QString::fromLatin1("attributes : \"%1\"").arg(attributes.join(QString::fromLatin1(", ")));
}

} // namespace KXMLKipiCmd