Hydra 0.20
hydra.src/desktop/FileEntry.h
00001 
00002 /*
00003  * Copyright (c) 2010 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_HYDRADESKTOP_FILEENTRY_H__
00009 #define __INCLUDED_HYDRADESKTOP_FILEENTRY_H__
00010 
00011 #include <QString>
00012 #include <QDateTime>
00013 
00014 #include <hydra/Records.h>
00015 #include <desktop/FileItemCache.h>
00016 
00017 namespace desktop
00018 {
00019   class FileEntry;
00020 }
00021 
00022 /**
00023  * An individual FileEntry
00024  * This contains a filename, record info (demand loaded) and file info.
00025  *
00026  * @author Aleksander Demko
00027  */ 
00028 class desktop::FileEntry
00029 {
00030   public:
00031     FileEntry(const QString &_fullfilename);
00032 
00033     bool operator < (const FileEntry &rhs) const { return dm_fullfilename < rhs.dm_fullfilename; }
00034 
00035     const QString & fullfilename(void) const { return dm_fullfilename; }
00036     const QString & justname(void) const { return dm_justname; }
00037 
00038     // have any meta data (hash/item)
00039     // may trigger a load
00040     bool containsRecord(bool *needsBigRead = 0) const;
00041 
00042     // may trigger a load
00043     const QString & recordHash(void) const;
00044     // may trigger a load
00045     hydra::FileItemRecord & recordItem(void) const;
00046 
00047     /// the last modified time of the disk file
00048     QDateTime fileLastModified(void) const;
00049     /// file's size on disk
00050     qint64 fileSize(void) const;
00051 
00052     // future image* info stuff?
00053 
00054     /// gets the rotate code, might have to load exif or tag info to determine this
00055     /// always returns >= 0
00056     int rotateCode(void);
00057     /// same as rotateCode, but always does a reload from tags/exif
00058     int reloadRotateCode(void);
00059 
00060   private:
00061     void loadRecord(bool *needsBigRead = 0) const;
00062     void loadFile(void) const;
00063 
00064   private:
00065     mutable bool dm_recordloaded;
00066 
00067     QString dm_fullfilename, dm_justname;
00068     mutable QString dm_hash;
00069 
00070     //mutable hydra::FileItemCache::cache_ptr dm_item;  // demand loaded, may be null
00071     mutable hydra::FileItemRecord dm_item;  // demand loaded, may be null
00072 
00073     mutable QDateTime dm_fileLastModified;
00074     mutable qint64 dm_fileSize;
00075 
00076     int dm_rotateCode; // -1 initially, which means not loaded
00077 };
00078 
00079 #endif
00080 
 All Classes Namespaces Functions Variables