File indexing completed on 2025-01-05 03:53:53

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-04-09
0007  * Description : Collection location abstraction
0008  *
0009  * SPDX-FileCopyrightText: 2007-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_COLLECTION_LOCATION_H
0016 #define DIGIKAM_COLLECTION_LOCATION_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 #include <QHash>
0022 
0023 // Local includes
0024 
0025 #include "digikam_export.h"
0026 #include "coredbalbuminfo.h"
0027 
0028 namespace Digikam
0029 {
0030 
0031 class DIGIKAM_DATABASE_EXPORT CollectionLocation
0032 {
0033 
0034 public:
0035 
0036     enum Status
0037     {
0038         /**
0039          * An invalid status. A location has this status if it is not valid,
0040          * and it had this status before its creation (for oldStatus information)
0041          */
0042         LocationNull,
0043 
0044         /**
0045          * The location if available. This is the most common status.
0046          */
0047         LocationAvailable,
0048 
0049         /**
0050          * The location is explicitly hidden. This gives no information if
0051          * the location was available were it not hidden.
0052          */
0053         LocationHidden,
0054 
0055         /**
0056          * The location is currently not available. (Harddisk unplugged, CD not in drive,
0057          * network fs not mounted etc.) It may become available any time.
0058          */
0059         LocationUnavailable,
0060 
0061         /**
0062          * An invalid status. A location object acquires this status if it has been deleted.
0063          * The object then does no longer point to an existing location.
0064          */
0065         LocationDeleted
0066     };
0067 
0068 public:
0069 
0070     enum Type
0071     {
0072         /**
0073          * The location is undefined.
0074          * Keep values constant.
0075          */
0076         Undefined       = 0,
0077 
0078         /**
0079          * The location is located on a storage device that is built-in
0080          * without frequent removal: Hard-disk inside the machine.
0081          */
0082         VolumeHardWired = 1,
0083 
0084         /**
0085          * The location is located on a storage device that can be removed
0086          * from the local machine, and is expected to be removed.
0087          * USB stick, USB hard-disk, CD, DVD
0088          */
0089         VolumeRemovable = 2,
0090 
0091         /**
0092          * The location is available via a network file system.
0093          * The availability depends on the network connection.
0094          */
0095         Network         = 3
0096     };
0097 
0098 public:
0099 
0100     enum CaseSensitivity
0101     {
0102         /**
0103          * The location has an unknown case sensitivity.
0104          */
0105         UnknownCaseSensitivity,
0106 
0107         /**
0108          * The location is case insensitive.
0109          */
0110         CaseInsensitive,
0111 
0112         /**
0113          * The location is case sensitive.
0114          */
0115         CaseSensitive
0116     };
0117 
0118 public:
0119 
0120     CollectionLocation();
0121 
0122     /**
0123      * The id uniquely identifying this collection
0124      */
0125     int                 id()                  const;
0126 
0127     /**
0128      * Return as Qt case sensitivity enum of location.
0129      * For unknown, it is assumed to be Qt::CaseSensitive.
0130      */
0131     Qt::CaseSensitivity asQtCaseSensitivity() const;
0132 
0133     /**
0134      * The case sensitivity of location. See above for possible values.
0135      */
0136     CaseSensitivity     caseSensitivity()     const;
0137 
0138     /**
0139      * The current status. See above for possible values.
0140      */
0141     Status              status()              const;
0142 
0143     /**
0144      * The type of location. See above for possible values.
0145      */
0146     Type                type()                const;
0147 
0148     /**
0149      * The current file system path leading to this album root.
0150      * Only guaranteed to be valid for location with status Available.
0151      */
0152     QString             albumRootPath()       const;
0153 
0154     /**
0155      * A user-visible, optional label.
0156      */
0157     QString             label()               const;
0158 
0159     bool isAvailable()                        const
0160     {
0161         return (m_status == LocationAvailable);
0162     }
0163 
0164     bool isNull()                             const
0165     {
0166         return (m_status == LocationNull);
0167     }
0168 
0169     uint hash()                               const
0170     {
0171         return ::qHash(m_id);
0172     }
0173 
0174 public:
0175 
0176     QString         identifier;
0177 
0178 protected:
0179 
0180     int             m_id;
0181     QString         m_label;
0182     Status          m_status;
0183     Type            m_type;
0184     QString         m_path;
0185     CaseSensitivity m_caseSensitivity;
0186 
0187 };
0188 
0189 inline uint qHash(const CollectionLocation& loc)
0190 {
0191     return loc.hash();
0192 }
0193 
0194 } // namespace Digikam
0195 
0196 #endif // DIGIKAM_COLLECTION_LOCATION_H