| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef LIBRARYDATA_H |
| 21 |
#define LIBRARYDATA_H |
| 22 |
|
| 23 |
#include <QDebug> |
| 24 |
#include <QDataStream> |
| 25 |
#include <QMetaType> |
| 26 |
#include <QVariant> |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class LibraryModelData |
| 31 |
{ |
| 32 |
public: |
| 33 |
enum Type |
| 34 |
{ |
| 35 |
TypeUndefined, |
| 36 |
TypeFolder, |
| 37 |
TypeHistory, |
| 38 |
TypeBookmark |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
LibraryModelData(); |
| 43 |
LibraryModelData(const LibraryModelData& other); |
| 44 |
virtual ~LibraryModelData(); |
| 45 |
|
| 46 |
bool isFolder() const; |
| 47 |
bool isBookmark() const; |
| 48 |
bool isHistory() const; |
| 49 |
bool isValid() const; |
| 50 |
|
| 51 |
operator QVariant() const |
| 52 |
{ |
| 53 |
return QVariant::fromValue(*this); |
| 54 |
} |
| 55 |
|
| 56 |
int id; |
| 57 |
int idparent; |
| 58 |
QString name; |
| 59 |
LibraryModelData::Type type; |
| 60 |
qint64 created; |
| 61 |
}; |
| 62 |
Q_DECLARE_METATYPE(LibraryModelData) |
| 63 |
|
| 64 |
typedef QList<LibraryModelData> LibraryRowsList; |
| 65 |
|
| 66 |
inline QDataStream& operator<<(QDataStream& out, const LibraryModelData& object) |
| 67 |
{ |
| 68 |
out << object.id; |
| 69 |
out << object.idparent; |
| 70 |
out << object.name; |
| 71 |
out << (quint32)object.type; |
| 72 |
out << object.created; |
| 73 |
|
| 74 |
return out; |
| 75 |
} |
| 76 |
|
| 77 |
inline QDataStream& operator>>(QDataStream& in, LibraryModelData& object) |
| 78 |
{ |
| 79 |
in >> object.id; |
| 80 |
in >> object.idparent; |
| 81 |
in >> object.name; |
| 82 |
quint32 typeIntVal; |
| 83 |
|
| 84 |
in >> typeIntVal; |
| 85 |
object.type= (LibraryModelData::Type)typeIntVal; |
| 86 |
|
| 87 |
in >> object.created; |
| 88 |
return in; |
| 89 |
} |
| 90 |
|
| 91 |
QDebug operator<<(QDebug dbg, const LibraryModelData &data); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
class HistoryRow |
| 99 |
{ |
| 100 |
public: |
| 101 |
HistoryRow(); |
| 102 |
HistoryRow(const HistoryRow& other); |
| 103 |
virtual ~HistoryRow(); |
| 104 |
|
| 105 |
LibraryModelData basicData() const; |
| 106 |
|
| 107 |
int id; |
| 108 |
QString title; |
| 109 |
QString filePath; |
| 110 |
qint64 created; |
| 111 |
}; |
| 112 |
Q_DECLARE_METATYPE(HistoryRow) |
| 113 |
|
| 114 |
|
| 115 |
class Bookmark |
| 116 |
{ |
| 117 |
public: |
| 118 |
Bookmark(); |
| 119 |
Bookmark(const Bookmark& other); |
| 120 |
Bookmark(const LibraryModelData& data); |
| 121 |
virtual ~Bookmark(); |
| 122 |
|
| 123 |
LibraryModelData basicData() const; |
| 124 |
|
| 125 |
bool isValid() const; |
| 126 |
QString fileExt() const; |
| 127 |
void clear(); |
| 128 |
|
| 129 |
int id; |
| 130 |
int idparent; |
| 131 |
QString title; |
| 132 |
QString description; |
| 133 |
QString filePath; |
| 134 |
QString dirPath; |
| 135 |
qint64 created; |
| 136 |
qint64 modified; |
| 137 |
}; |
| 138 |
Q_DECLARE_METATYPE(Bookmark) |
| 139 |
|
| 140 |
class BookmarkFolder |
| 141 |
{ |
| 142 |
public: |
| 143 |
BookmarkFolder(); |
| 144 |
BookmarkFolder(const BookmarkFolder& other); |
| 145 |
BookmarkFolder(const LibraryModelData& data); |
| 146 |
virtual ~BookmarkFolder(); |
| 147 |
|
| 148 |
LibraryModelData basicData() const; |
| 149 |
|
| 150 |
bool isValid() const; |
| 151 |
|
| 152 |
int id; |
| 153 |
int idparent; |
| 154 |
QString name; |
| 155 |
QString description; |
| 156 |
QString dirPath; |
| 157 |
qint64 created; |
| 158 |
qint64 modified; |
| 159 |
}; |
| 160 |
Q_DECLARE_METATYPE(BookmarkFolder) |
| 161 |
|
| 162 |
|
| 163 |
#endif |