• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • graphics API Reference
  • KDE Home
  • Contact Us
 

digikam

  • extragear
  • graphics
  • digikam
  • core
  • libs
  • metadataengine
  • containers
captionvalues.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-07-13
7  * Description : caption values container
8  *
9  * Copyright (C) 2009-2019 by Gilles Caulier <caulier dot gilles at gmail 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)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #include "captionvalues.h"
25 
26 namespace Digikam
27 {
28 
29 CaptionValues::CaptionValues()
30 {
31 }
32 
33 CaptionValues::~CaptionValues()
34 {
35 }
36 
37 bool CaptionValues::operator==(const CaptionValues& val) const
38 {
39  bool b1 = (author == val.author);
40  bool b2 = (caption == val.caption);
41  bool b3 = (date == val.date);
42 
43  return (b1 && b2 && b3);
44 }
45 
46 QDebug operator<<(QDebug dbg, const CaptionValues& val)
47 {
48  dbg.nospace() << "CaptionValues::caption: "
49  << val.caption << ", ";
50  dbg.nospace() << "CaptionValues::author: "
51  << val.author << ", ";
52  dbg.nospace() << "CaptionValues::date: "
53  << val.date;
54  return dbg.space();
55 }
56 
57 // --------------------------------------------------------------------
58 
59 CaptionsMap::CaptionsMap()
60 {
61 }
62 
63 CaptionsMap::~CaptionsMap()
64 {
65 }
66 
67 void CaptionsMap::setData(const MetaEngine::AltLangMap& comments,
68  const MetaEngine::AltLangMap& authors,
69  const QString& commonAuthor,
70  const MetaEngine::AltLangMap& dates)
71 {
72  fromAltLangMap(comments);
73  setAuthorsList(authors, commonAuthor);
74  setDatesList(dates);
75 }
76 
77 MetaEngine::AltLangMap CaptionsMap::toAltLangMap() const
78 {
79  MetaEngine::AltLangMap map;
80 
81  for (CaptionsMap::const_iterator it = constBegin() ; it != constEnd() ; ++it)
82  {
83  map.insert(it.key(), (*it).caption);
84  }
85 
86  return map;
87 }
88 
89 void CaptionsMap::fromAltLangMap(const MetaEngine::AltLangMap& map)
90 {
91  clear();
92 
93  for (MetaEngine::AltLangMap::const_iterator it = map.constBegin() ; it != map.constEnd() ; ++it)
94  {
95  CaptionValues val;
96  val.caption = it.value();
97  insert(it.key(), val);
98  }
99 }
100 
101 MetaEngine::AltLangMap CaptionsMap::authorsList() const
102 {
103  MetaEngine::AltLangMap map;
104 
105  for (CaptionsMap::const_iterator it = constBegin() ; it != constEnd() ; ++it)
106  {
107  map.insert(it.key(), (*it).author);
108  }
109 
110  return map;
111 }
112 
113 void CaptionsMap::setAuthorsList(const MetaEngine::AltLangMap& map, const QString& commonAuthor)
114 {
115  for (CaptionsMap::iterator it = begin() ; it != end() ; ++it)
116  {
117  MetaEngine::AltLangMap::const_iterator authorIt = map.find(it.key());
118 
119  if (authorIt != map.constEnd())
120  {
121  (*it).author = authorIt.value();
122  }
123  else if (!commonAuthor.isNull())
124  {
125  (*it).author = commonAuthor;
126  }
127  }
128 }
129 
130 MetaEngine::AltLangMap CaptionsMap::datesList() const
131 {
132  MetaEngine::AltLangMap map;
133 
134  for (CaptionsMap::const_iterator it = constBegin() ; it != constEnd() ; ++it)
135  {
136  map.insert(it.key(), (*it).date.toString(Qt::ISODate));
137  }
138 
139  return map;
140 }
141 
142 void CaptionsMap::setDatesList(const MetaEngine::AltLangMap& map)
143 {
144  for (MetaEngine::AltLangMap::const_iterator it = map.constBegin() ; it != map.constEnd() ; ++it)
145  {
146  CaptionsMap::iterator val = find(it.key());
147 
148  if (val != end())
149  {
150  (*val).date = QDateTime::fromString(it.value(), Qt::ISODate);
151  }
152  }
153 }
154 
155 } // namespace Digikam
QMap< QString, CaptionValues >::constBegin
const_iterator constBegin() const
QMap
Digikam::operator<<
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:796
QDebug::nospace
QDebug & nospace()
Digikam::CaptionsMap::datesList
MetaEngine::AltLangMap datesList() const
Definition: captionvalues.cpp:130
QMap< QString, CaptionValues >::clear
void clear()
Digikam::CaptionValues::CaptionValues
CaptionValues()
Definition: captionvalues.cpp:29
Digikam::CaptionsMap::setAuthorsList
void setAuthorsList(const MetaEngine::AltLangMap &map, const QString &commonAuthor=QString())
Sets the author for the comments in the specified languages.
Definition: captionvalues.cpp:113
QString::isNull
bool isNull() const
Digikam::CaptionsMap::fromAltLangMap
void fromAltLangMap(const MetaEngine::AltLangMap &map)
Definition: captionvalues.cpp:89
Digikam::CaptionsMap::setDatesList
void setDatesList(const MetaEngine::AltLangMap &map)
Definition: captionvalues.cpp:142
QMap< QString, CaptionValues >::constEnd
const_iterator constEnd() const
QMap::const_iterator
Digikam::CaptionValues::date
QDateTime date
Definition: captionvalues.h:53
Digikam::CaptionsMap::setData
void setData(const MetaEngine::AltLangMap &comments, const MetaEngine::AltLangMap &authors, const QString &commonAuthor, const MetaEngine::AltLangMap &dates)
Definition: captionvalues.cpp:67
QString
Digikam::CaptionsMap::authorsList
MetaEngine::AltLangMap authorsList() const
Definition: captionvalues.cpp:101
QMap< QString, CaptionValues >::end
iterator end()
QMap< QString, CaptionValues >::begin
iterator begin()
Digikam::CaptionsMap::CaptionsMap
CaptionsMap()
Definition: captionvalues.cpp:59
QDebug::space
QDebug & space()
QDateTime::fromString
QDateTime fromString(const QString &string, Qt::DateFormat format)
QDebug
Digikam::CaptionsMap::~CaptionsMap
~CaptionsMap()
Definition: captionvalues.cpp:63
Digikam::CaptionValues::~CaptionValues
~CaptionValues()
Definition: captionvalues.cpp:33
QMap::insert
iterator insert(const Key &key, const T &value)
Digikam::CaptionValues::operator==
bool operator==(const CaptionValues &val) const
Definition: captionvalues.cpp:37
Digikam::CaptionValues::caption
QString caption
Definition: captionvalues.h:51
captionvalues.h
QMap::find
iterator find(const Key &key)
Digikam::CaptionValues
Definition: captionvalues.h:42
Digikam::CaptionsMap::toAltLangMap
MetaEngine::AltLangMap toAltLangMap() const
Definition: captionvalues.cpp:77
Digikam::CaptionValues::author
QString author
Definition: captionvalues.h:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Wed Dec 11 2019 07:34:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages
-->

graphics API Reference

Skip menu "graphics API Reference"
  • digikam
  • KDiagram
  •     KChart
  •     KGantt
  • KPhotoAlbum
  •   AndroidRemoteControl
  • Krita
  •   libs
  •     KritaBasicFlakes
  •     brush
  •     KritaUndo2
  •     KritaFlake
  •     image
  •     KritaPlugin
  •     Krita
  •     KritaOdf
  •     KritaPigment
  •     KritaStore
  •     ui
  •     KritaWidgets
  •     KritaWidgetUtils
  •   plugins
  •     Assitants
  •     Extensions
  •     Filters
  •         KritaText
  •         KritaTextLayout
  •     Generators
  •     Formats
  •             src
  •     PaintOps
  •       libpaintop
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal