File indexing completed on 2023-10-03 04:07:40
0001 /** 0002 * Copyright (C) 2004 Scott Wheeler <wheeler@kde.org> 0003 * 0004 * This program is free software; you can redistribute it and/or modify it under 0005 * the terms of the GNU General Public License as published by the Free Software 0006 * Foundation; either version 2 of the License, or (at your option) any later 0007 * version. 0008 * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. 0012 * 0013 * You should have received a copy of the GNU General Public License along with 0014 * this program. If not, see <http://www.gnu.org/licenses/>. 0015 */ 0016 0017 #ifndef JUK_FILEHANDLE_H 0018 #define JUK_FILEHANDLE_H 0019 0020 #include <QExplicitlySharedDataPointer> 0021 #include <QVector> 0022 #include <QMetaType> 0023 #include <QStringList> 0024 0025 class QString; 0026 class QFileInfo; 0027 class QDateTime; 0028 class QDataStream; 0029 0030 class CoverInfo; 0031 class Tag; 0032 class CacheDataStream; 0033 0034 /** 0035 * A value based, explicitly shared wrapper around file related information 0036 * used in JuK's playlists. 0037 */ 0038 0039 class FileHandle 0040 { 0041 public: 0042 FileHandle(); 0043 FileHandle(const FileHandle &f); 0044 explicit FileHandle(const QFileInfo &info); 0045 explicit FileHandle(const QString &path); 0046 FileHandle(const QString &path, CacheDataStream &s); 0047 0048 // manually declared so its definition can be delayed until .cpp 0049 ~FileHandle(); 0050 0051 /** 0052 * Forces the FileHandle to reread its information from the disk. 0053 */ 0054 void refresh(); 0055 void setFile(const QString &path); 0056 0057 Tag *tag() const; 0058 CoverInfo *coverInfo() const; 0059 QString absFilePath() const; 0060 const QFileInfo &fileInfo() const; 0061 0062 bool isNull() const; 0063 bool current() const; 0064 const QDateTime &lastModified() const; 0065 0066 void read(CacheDataStream &s); 0067 0068 FileHandle &operator=(const FileHandle &f); 0069 bool operator==(const FileHandle &f) const; 0070 bool operator!=(const FileHandle &f) const; 0071 0072 static QStringList properties(); 0073 QString property(const QString &name) const; 0074 0075 private: 0076 class FileHandlePrivate; 0077 QExplicitlySharedDataPointer<FileHandlePrivate> d; 0078 }; 0079 0080 typedef QVector<FileHandle> FileHandleList; 0081 0082 Q_DECLARE_METATYPE(FileHandle); 0083 Q_DECLARE_METATYPE(FileHandleList); 0084 0085 QDataStream &operator<<(QDataStream &s, const FileHandle &f); 0086 CacheDataStream &operator>>(CacheDataStream &s, FileHandle &f); 0087 0088 #endif 0089 0090 // vim: set et sw=4 tw=0 sta: