"Fossies" - the Fresh Open Source Software Archive

Member "digikam-6.3.0/core/utilities/geolocation/geoiface/items/gpsitemcontainer.h" (4 Sep 2019, 5354 Bytes) of package /linux/misc/digikam-6.3.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gpsitemcontainer.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.2.0_vs_6.3.0.

    1 /* ============================================================
    2  *
    3  * This file is a part of digiKam project
    4  * https://www.digikam.org
    5  *
    6  * Date        : 2010-03-21
    7  * Description : A container to hold GPS information about an item.
    8  *
    9  * Copyright (C) 2010-2019 by Gilles Caulier <caulier dot gilles at gmail dot com>
   10  * Copyright (C) 2010-2014 by Michael G. Hansen <mike at mghansen dot de>
   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 #ifndef DIGIKAM_GPS_ITEM_CONTAINER_H
   26 #define DIGIKAM_GPS_ITEM_CONTAINER_H
   27 
   28 // Qt includes
   29 
   30 #include <QVariant>
   31 #include <QDateTime>
   32 #include <QUrl>
   33 
   34 // Local includes
   35 
   36 #include "geoifacetypes.h"
   37 #include "digikam_export.h"
   38 #include "gpsdatacontainer.h"
   39 #include "rginfo.h"
   40 
   41 namespace Digikam
   42 {
   43 
   44 enum Type
   45 {
   46     TypeChild    = 1,
   47     TypeSpacer   = 2,
   48     TypeNewChild = 4
   49 };
   50 
   51 typedef struct TagData
   52 {
   53     QString tagName;
   54     QString tipName;
   55     Type    tagType;
   56 
   57 } TagData;
   58 
   59 class SaveProperties
   60 {
   61 public:
   62 
   63     explicit SaveProperties()
   64     {
   65         shouldRemoveCoordinates = false;
   66         shouldRemoveAltitude    = false;
   67         shouldWriteCoordinates  = false;
   68         shouldWriteAltitude     = false;
   69         altitude                = 0.0;
   70         latitude                = 0.0;
   71         longitude               = 0.0;
   72     }
   73 
   74     bool  shouldRemoveCoordinates;
   75     bool  shouldRemoveAltitude;
   76     bool  shouldWriteCoordinates;
   77     bool  shouldWriteAltitude;
   78     qreal altitude;
   79     qreal latitude;
   80     qreal longitude;
   81 };
   82 
   83 class GPSItemModel;
   84 class DMetadata;
   85 
   86 class DIGIKAM_EXPORT GPSItemContainer
   87 {
   88 public:
   89 
   90     static const int RoleCoordinates         = Qt::UserRole + 1;
   91 
   92     static const int ColumnThumbnail         = 0;
   93     static const int ColumnFilename          = 1;
   94     static const int ColumnDateTime          = 2;
   95     static const int ColumnLatitude          = 3;
   96     static const int ColumnLongitude         = 4;
   97     static const int ColumnAltitude          = 5;
   98     static const int ColumnAccuracy          = 6;
   99     static const int ColumnTags              = 7;
  100     static const int ColumnStatus            = 8;
  101     static const int ColumnDOP               = 9;
  102     static const int ColumnFixType           = 10;
  103     static const int ColumnNSatellites       = 11;
  104     static const int ColumnSpeed             = 12;
  105 
  106     static const int ColumnGPSItemContainerCount = 13;
  107 
  108 public:
  109 
  110     explicit GPSItemContainer(const QUrl& url);
  111     virtual ~GPSItemContainer();
  112 
  113     /// @name Loading and saving
  114     //@{
  115     virtual QString saveChanges();
  116     virtual bool loadImageData();
  117     //@}
  118 
  119     bool isDirty()       const;
  120     QUrl url()           const;
  121     QDateTime dateTime() const;
  122 
  123     /// @name Functions used by the model
  124     //@{
  125     static void setHeaderData(GPSItemModel* const model);
  126     bool lessThan(const GPSItemContainer* const otherItem, const int column) const;
  127     //@}
  128 
  129     /// @name GPS related functions
  130     //@{
  131     void setCoordinates(const GeoCoordinates& newCoordinates);
  132     GeoCoordinates coordinates() const;
  133     GPSDataContainer gpsData() const;
  134     void setGPSData(const GPSDataContainer& container);
  135     void restoreGPSData(const GPSDataContainer& container);
  136     //@}
  137 
  138     /// @name Tag related functions
  139     //@{
  140     /**
  141      * The tags added in reverse geocoding process are stored in each image, before they end up in external tag model. This function adds them.
  142      * @param externalTagList A list containing tags.
  143      */
  144     void setTagList(const QList<QList<TagData> >& externalTagList);
  145 
  146     /**
  147      * @return Returns true is the current image has been modified and not saved.
  148      */
  149     bool isTagListDirty() const;
  150 
  151     /**
  152      * Returns the tag list of the current image.
  153      */
  154     QList<QList<TagData> > getTagList() const;
  155 
  156     /**
  157      * Replaces the current tag list with the one contained in tagList.
  158      */
  159     void restoreRGTagList(const QList<QList<TagData> >& tagList);
  160 
  161     /**
  162      * Writes the current tags to XMP metadata.
  163      */
  164     void writeTagsToXmp(const bool writeXmpTags) { m_writeXmpTags = writeXmpTags; }
  165     //@}
  166 
  167 protected:
  168 
  169     // these are only to be called by the GPSItemModel
  170     QVariant data(const int column, const int role) const;
  171     void setModel(GPSItemModel* const model);
  172     void emitDataChanged();
  173     DMetadata* getMetadataForFile() const;
  174     SaveProperties saveProperties() const;
  175 
  176 protected:
  177 
  178     GPSItemModel*          m_model;
  179 
  180     QUrl                   m_url;
  181     QDateTime              m_dateTime;
  182 
  183     bool                   m_dirty;
  184     GPSDataContainer       m_gpsData;
  185     GPSDataContainer       m_savedState;
  186 
  187     bool                   m_tagListDirty;
  188     QList<QList<TagData> > m_tagList;
  189     QList<QList<TagData> > m_savedTagList;
  190     bool                   m_writeXmpTags;
  191 
  192     friend class GPSItemModel;
  193 };
  194 
  195 } // namespace Digikam
  196 
  197 #endif // DIGIKAM_GPS_ITEM_CONTAINER_H