OpenMW
components/contentselector/model/esmfile.hpp
Go to the documentation of this file.
00001 #ifndef ESMFILE_HPP
00002 #define ESMFILE_HPP
00003 
00004 #include <QDateTime>
00005 #include <QStringList>
00006 
00007 #include "modelitem.hpp"
00008 
00009 class QMimeData;
00010 
00011 namespace ContentSelectorModel
00012 {
00013     class EsmFile : public ModelItem
00014     {
00015         Q_OBJECT
00016         Q_PROPERTY(QString filename READ fileName)
00017 
00018     public:
00019 
00020         enum FileProperty
00021         {
00022             FileProperty_FileName       = 0,
00023             FileProperty_Author         = 1,
00024             FileProperty_Format         = 2,
00025             FileProperty_DateModified   = 3,
00026             FileProperty_FilePath       = 4,
00027             FileProperty_Description    = 5,
00028             FileProperty_GameFile       = 6
00029         };
00030 
00031         EsmFile(QString fileName = QString(), ModelItem *parent = 0);
00032      //   EsmFile(const EsmFile &);
00033 
00034         ~EsmFile()
00035         {}
00036 
00037         void setFileProperty (const FileProperty prop, const QString &value);
00038 
00039         void setFileName(const QString &fileName);
00040         void setAuthor(const QString &author);
00041         void setSize(const int size);
00042         void setDate(const QDateTime &modified);
00043         void setFormat(const int format);
00044         void setFilePath(const QString &path);
00045         void setGameFiles(const QStringList &gameFiles);
00046         void setDescription(const QString &description);
00047 
00048         inline void addGameFile (const QString &name) {mGameFiles.append(name); }
00049         QVariant fileProperty (const FileProperty prop) const;
00050 
00051         inline QString fileName() const             { return mFileName; }
00052         inline QString author() const               { return mAuthor; }
00053         inline QDateTime modified() const           { return mModified; }
00054         inline float format() const                 { return mFormat; }
00055         inline QString filePath() const                 { return mPath; }
00056         inline const QStringList &gameFiles() const { return mGameFiles; }
00057         inline QString description() const          { return mDescription; }
00058         inline QString toolTip() const              { return sToolTip.arg(mAuthor)
00059                                                              .arg(mFormat)
00060                                                              .arg(mPath)
00061                                                              .arg(mDescription)
00062                                                              .arg(mGameFiles.join(", "));
00063                                                     }
00064 
00065         inline bool isGameFile() const              { return (mGameFiles.size() == 0); }
00066         QByteArray encodedData() const;
00067 
00068     public:
00069         static int sPropertyCount;
00070         static QString sToolTip;
00071 
00072     private:
00073 
00074         QString mFileName;
00075         QString mAuthor;
00076         QDateTime mModified;
00077         int mFormat;
00078         QString mPath;
00079         QStringList mGameFiles;
00080         QString mDescription;
00081         QString mToolTip;
00082 
00083     };
00084 }
00085 
00086 #endif