Debian Codegraph @

src/Library/LibraryData.cpp

raw symbols SCIP
1 /*
2 * Copyright 2014 Mihai Niculescu <[email protected]>
3 *
4 * This file is part of EqualX Project (https://launchpad.net/equalx/)
5 *
6 * EqualX is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * EqualX is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <QDateTime>
21 #include <QFileInfo>
22
23 #include "Library/LibraryData.h"
24
25 //______________LibraryModelData_____________________________
26
27 LibraryModelData::LibraryModelData()
28 : id(0),
29 idparent(0),
30 name(""),
31 type(TypeFolder)
32 {
33 created = QDateTime::currentMSecsSinceEpoch();
34
35 }
36
37 LibraryModelData::LibraryModelData(const LibraryModelData &other)
38 {
39 id = other.id;
40 idparent = other.idparent;
41 name = QString(other.name);
42 type = (LibraryModelData::Type)other.type;
43 created = other.created;
44 }
45
46 LibraryModelData::~LibraryModelData()
47 {
48 }
49
50 bool LibraryModelData::isFolder() const
51 {
52 return (type==TypeFolder);
53 }
54
55 bool LibraryModelData::isBookmark() const
56 {
57 return (type==TypeBookmark);
58 }
59
60 bool LibraryModelData::isHistory() const
61 {
62 return (type==TypeHistory);
63 }
64
65 bool LibraryModelData::isValid() const
66 {
67 return (id>0);
68 }
69
70 QDebug operator<<(QDebug dbg, const LibraryModelData &data)
71 {
72 QString output = QString("LibraryModelData( id:%1 idparent:%2 name:[%3] type:%4 created:%5 )").arg(data.id).arg(data.idparent).arg(data.name).arg(data.type).arg(data.created);
73 dbg.nospace() << output;
74
75 return dbg.maybeSpace();
76 }
77
78
79
80 //______________History Row_____________________________
81
82 HistoryRow::HistoryRow()
83 : id(0),
84 title(""),
85 filePath("")
86 {
87 created = QDateTime::currentMSecsSinceEpoch();
88
89 }
90
91 HistoryRow::HistoryRow(const HistoryRow &other)
92 : id(other.id),
93 title(other.title),
94 filePath(other.filePath),
95 created(other.created)
96 {
97
98 }
99
100 HistoryRow::~HistoryRow()
101 {
102 }
103
104 LibraryModelData HistoryRow::basicData() const
105 {
106 LibraryModelData basic;
107 basic.id = id;
108 basic.idparent=0;
109 basic.name= filePath;
110 basic.type= LibraryModelData::TypeHistory;
111 basic.created= created;
112
113 return basic;
114 }
115
116 //_______________Bookmark Row______________________________
117
118 Bookmark::Bookmark()
119 : id(0),
120 idparent(0),
121 title(""),
122 description(""),
123 filePath(""),
124 dirPath("")
125 {
126 created = QDateTime::currentMSecsSinceEpoch();
127 modified= created;
128 }
129
130 Bookmark::Bookmark(const Bookmark& other)
131 : id(other.id),
132 idparent(other.idparent),
133 title(other.title),
134 description(other.description),
135 filePath(other.filePath),
136 dirPath(other.dirPath),
137 created(other.created),
138 modified(other.modified)
139 {
140
141 }
142
143 Bookmark::Bookmark(const LibraryModelData &data)
144 : id(data.id),
145 idparent(data.idparent),
146 title(""),
147 description(""),
148 filePath(data.name),
149 dirPath(""),
150 created(data.created),
151 modified(data.created)
152 {
153
154 }
155
156 Bookmark::~Bookmark()
157 { }
158
159 LibraryModelData Bookmark::basicData() const
160 {
161 LibraryModelData basic;
162 basic.id = id;
163 basic.idparent=idparent;
164 basic.name= filePath;
165 basic.type= LibraryModelData::TypeBookmark;
166 basic.created= created;
167
168 return basic;
169 }
170
171 bool Bookmark::isValid() const
172 {
173 return (id>0);
174 }
175
176 QString Bookmark::fileExt() const
177 {
178 QFileInfo finfo(filePath);
179 return finfo.completeSuffix();
180 }
181
182 void Bookmark::clear()
183 {
184 id = 0;
185 idparent=0;
186 title= "";
187 description="";
188 dirPath="";
189 filePath="";
190
191 }
192
193 //_______________Bookmark Folder Row______________________________
194
195 BookmarkFolder::BookmarkFolder()
196 : id(0),
197 idparent(0),
198 name(""),
199 description(""),
200 dirPath("")
201 {
202 created = QDateTime::currentMSecsSinceEpoch();
203 }
204
205 BookmarkFolder::BookmarkFolder(const BookmarkFolder& other)
206 : id(other.id),
207 idparent(other.idparent),
208 name(other.name),
209 description(other.description),
210 dirPath(other.dirPath),
211 created(other.created)
212 {
213 }
214
215 BookmarkFolder::BookmarkFolder(const LibraryModelData &data)
216 : id(data.id),
217 idparent(data.idparent),
218 name(data.name),
219 description(""),
220 dirPath(""),
221 created(data.created)
222 {
223
224 }
225
226 BookmarkFolder::~BookmarkFolder()
227 { }
228
229 LibraryModelData BookmarkFolder::basicData() const
230 {
231 LibraryModelData basic;
232 basic.id = id;
233 basic.idparent=idparent;
234 basic.name= name;
235 basic.type= LibraryModelData::TypeFolder;
236 basic.created= created;
237
238 return basic;
239 }
240
241 bool BookmarkFolder::isValid() const
242 {
243 return (id>0);
244 }