MauiKit Controls

fmh.h
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#pragma once
21
22#include <QHash>
23#include <QVariant>
24#include <QString>
25#include <QUrl>
26#include <QVector>
27
28#include "mauikit_export.h"
29
30/**
31 * @brief A set of helpers for managing the key-value model data type. And other functionality helpers.
32 */
33namespace FMH
34{
35/**
36 * @brief Whether the platform running is Android.
37 */
38bool MAUIKIT_EXPORT isAndroid();
39
40/**
41 * @brief Whether the platform running is Window.
42 */
43bool MAUIKIT_EXPORT isWindows();
44
45/**
46 * @brief Whether the platform running is GNU/Linux.
47
48 */
49bool MAUIKIT_EXPORT isLinux();
50
51/**
52 * @brief Whether the platform running is Mac.
53 */
54bool MAUIKIT_EXPORT isMac();
55
56/**
57 * @brief Whether the platform running is IOS.
58 */
59bool MAUIKIT_EXPORT isIOS();
60
61/**
62 * @brief The MODEL_KEY enum values.
63 */
64enum MODEL_KEY : int {
65 ICON,
66 LABEL,
67 PATH,
68 URL,
69 TYPE,
70 GROUP,
71 OWNER,
72 SUFFIX,
73 NAME,
74 DATE,
75 SIZE,
76 MODIFIED,
77 MIME,
78 TAG,
79 PERMISSIONS,
80 THUMBNAIL,
81 THUMBNAIL_1,
82 THUMBNAIL_2,
83 THUMBNAIL_3,
84 HIDDEN,
85 ICONSIZE,
86 DETAILVIEW,
87 SHOWTHUMBNAIL,
88 SHOWTERMINAL,
89 COUNT,
90 SORTBY,
91 USER,
92 PASSWORD,
93 SERVER,
94 FOLDERSFIRST,
95 VIEWTYPE,
96 ADDDATE,
97 FAV,
98 FAVORITE,
99 COLOR,
100 RATE,
101 FORMAT,
102 PLACE,
103 LOCATION,
104 ALBUM,
105 ARTIST,
106 TRACK,
107 DURATION,
108 ARTWORK,
109 PLAYLIST,
110 LYRICS,
111 WIKI,
112 MOOD,
113 SOURCETYPE,
114 GENRE,
115 NOTE,
116 COMMENT,
117 CONTEXT,
118 SOURCE,
119 TITLE,
120 ID,
121 PARENT_ID,
122 RELEASEDATE,
123 LICENSE,
124 DESCRIPTION,
125 BOOKMARK,
126 ACCOUNT,
127 ACCOUNTTYPE,
128 VERSION,
129 DOMAIN_M,
130 CATEGORY,
131 CONTENT,
132 PIN,
133 IMG,
134 PREVIEW,
135 LINK,
136 STAMP,
137 BOOK,
138 N,
139 PHOTO,
140 GENDER,
141 ADR,
142 ADR_2,
143 ADR_3,
144 EMAIL,
145 EMAIL_2,
146 EMAIL_3,
147 LANG,
148 NICKNAME,
149 ORG,
150 PROFILE,
151 TZ,
152 TEL,
153 TEL_2,
154 TEL_3,
155 IM,
156 CITY,
157 STATE,
158 COUNTRY,
159 PACKAGE_ARCH,
160 PACKAGE_TYPE,
161 GPG_FINGERPRINT,
162 GPG_SIGNATURE,
163 PACKAGE_NAME,
164 PRICE,
165 REPOSITORY,
166 TAGS,
167 WAY,
168 PIC,
169 SMALL_PIC,
170 CHANGED,
171 COMMENTS,
172 CREATED,
173 DETAIL_PAGE,
174 DETAILS,
175 TOTAL_DOWNLOADS,
176 GHNS_EXCLUDED,
177 LANGUAGE,
178 PERSON_ID,
179 SCORE,
180 SUMMARY,
181 TYPE_ID,
182 TYPE_NAME,
183 XDG_TYPE,
184 SYMLINK,
185 IS_SYMLINK,
186 IS_DIR,
187 IS_FILE,
188 IS_REMOTE,
189 EXECUTABLE,
190 READABLE,
191 WRITABLE,
192 LAST_READ,
193 VALUE,
194 KEY,
195 MAC,
196 LOT,
197 APP,
198 URI,
199 DEVICE,
200 LASTSYNC,
201 UDI,
202 LATITUDE,
203 LONGITUDE,
204 MESSAGE,
205 AUTHOR,
206 BRANCH,
207 UPDATABLE
208};
209
210/**
211 * @brief The mapping of the FMH::MODEL_KEY enum values to its string representation.
212 * For example, `FMH::MODEL_KEY::LABEL` is mapped to`"label"`.
213 * @code
214 * QString keyName = FMH::MODEL_NAME[FMH::MODEL_KEY::LABEL]; //resulting in "label"
215 * @endcode
216 *
217 * @note All the string representations of the FMH::MODEL_KEY are always lower cased, and with no special character division.
218 */
219static const QHash<MODEL_KEY, QString> MODEL_NAME = {{MODEL_KEY::ICON, QStringLiteral("icon")},
220 {MODEL_KEY::LABEL, QStringLiteral("label")},
221 {MODEL_KEY::PATH, QStringLiteral("path")},
222 {MODEL_KEY::URL, QStringLiteral("url")},
223 {MODEL_KEY::TYPE, QStringLiteral("type")},
224 {MODEL_KEY::GROUP, QStringLiteral("group")},
225 {MODEL_KEY::OWNER, QStringLiteral("owner")},
226 {MODEL_KEY::SUFFIX, QStringLiteral("suffix")},
227 {MODEL_KEY::NAME, QStringLiteral("name")},
228 {MODEL_KEY::DATE, QStringLiteral("date")},
229 {MODEL_KEY::MODIFIED, QStringLiteral("modified")},
230 {MODEL_KEY::MIME, QStringLiteral("mime")},
231 {MODEL_KEY::SIZE, QStringLiteral("size")},
232 {MODEL_KEY::TAG, QStringLiteral("tag")},
233 {MODEL_KEY::PERMISSIONS, QStringLiteral("permissions")},
234 {MODEL_KEY::THUMBNAIL, QStringLiteral("thumbnail")},
235 {MODEL_KEY::THUMBNAIL_1, QStringLiteral("thumbnail_1")},
236 {MODEL_KEY::THUMBNAIL_2, QStringLiteral("thumbnail_2")},
237 {MODEL_KEY::THUMBNAIL_3, QStringLiteral("thumbnail_3")},
238 {MODEL_KEY::ICONSIZE, QStringLiteral("iconsize")},
239 {MODEL_KEY::HIDDEN, QStringLiteral("hidden")},
240 {MODEL_KEY::DETAILVIEW, QStringLiteral("detailview")},
241 {MODEL_KEY::SHOWTERMINAL, QStringLiteral("showterminal")},
242 {MODEL_KEY::SHOWTHUMBNAIL, QStringLiteral("showthumbnail")},
243 {MODEL_KEY::COUNT, QStringLiteral("count")},
244 {MODEL_KEY::SORTBY, QStringLiteral("sortby")},
245 {MODEL_KEY::USER, QStringLiteral("user")},
246 {MODEL_KEY::PASSWORD, QStringLiteral("password")},
247 {MODEL_KEY::SERVER, QStringLiteral("server")},
248 {MODEL_KEY::FOLDERSFIRST, QStringLiteral("foldersfirst")},
249 {MODEL_KEY::VIEWTYPE, QStringLiteral("viewtype")},
250 {MODEL_KEY::ADDDATE, QStringLiteral("adddate")},
251 {MODEL_KEY::FAV, QStringLiteral("fav")},
252 {MODEL_KEY::FAVORITE, QStringLiteral("favorite")},
253 {MODEL_KEY::COLOR, QStringLiteral("color")},
254 {MODEL_KEY::RATE, QStringLiteral("rate")},
255 {MODEL_KEY::FORMAT, QStringLiteral("format")},
256 {MODEL_KEY::PLACE, QStringLiteral("place")},
257 {MODEL_KEY::LOCATION, QStringLiteral("location")},
258 {MODEL_KEY::ALBUM, QStringLiteral("album")},
259 {MODEL_KEY::DURATION, QStringLiteral("duration")},
260 {MODEL_KEY::RELEASEDATE, QStringLiteral("releasedate")},
261 {MODEL_KEY::ARTIST, QStringLiteral("artist")},
262 {MODEL_KEY::LYRICS, QStringLiteral("lyrics")},
263 {MODEL_KEY::TRACK, QStringLiteral("track")},
264 {MODEL_KEY::GENRE, QStringLiteral("genre")},
265 {MODEL_KEY::WIKI, QStringLiteral("wiki")},
266 {MODEL_KEY::CONTEXT, QStringLiteral("context")},
267 {MODEL_KEY::SOURCETYPE, QStringLiteral("sourcetype")},
268 {MODEL_KEY::ARTWORK, QStringLiteral("artwork")},
269 {MODEL_KEY::NOTE, QStringLiteral("note")},
270 {MODEL_KEY::MOOD, QStringLiteral("mood")},
271 {MODEL_KEY::COMMENT, QStringLiteral("comment")},
272 {MODEL_KEY::PLAYLIST, QStringLiteral("playlist")},
273 {MODEL_KEY::SOURCE, QStringLiteral("source")},
274 {MODEL_KEY::TITLE, QStringLiteral("title")},
275 {MODEL_KEY::ID, QStringLiteral("id")},
276 {MODEL_KEY::PERSON_ID, QStringLiteral("personid")},
277 {MODEL_KEY::PARENT_ID, QStringLiteral("parentid")},
278 {MODEL_KEY::LICENSE, QStringLiteral("license")},
279 {MODEL_KEY::DESCRIPTION, QStringLiteral("description")},
280 {MODEL_KEY::BOOKMARK, QStringLiteral("bookmark")},
281 {MODEL_KEY::ACCOUNT, QStringLiteral("account")},
282 {MODEL_KEY::ACCOUNTTYPE, QStringLiteral("accounttype")},
283 {MODEL_KEY::VERSION, QStringLiteral("version")},
284 {MODEL_KEY::DOMAIN_M, QStringLiteral("domain")},
285 {MODEL_KEY::CATEGORY, QStringLiteral("category")},
286 {MODEL_KEY::CONTENT, QStringLiteral("content")},
287 {MODEL_KEY::PIN, QStringLiteral("pin")},
288 {MODEL_KEY::IMG, QStringLiteral("img")},
289 {MODEL_KEY::PREVIEW, QStringLiteral("preview")},
290 {MODEL_KEY::LINK, QStringLiteral("link")},
291 {MODEL_KEY::STAMP, QStringLiteral("stamp")},
292 {MODEL_KEY::BOOK, QStringLiteral("book")},
293
294 /** ccdav keys **/
295 {MODEL_KEY::N, QStringLiteral("n")},
296 {MODEL_KEY::IM, QStringLiteral("im")},
297 {MODEL_KEY::PHOTO, QStringLiteral("photo")},
298 {MODEL_KEY::GENDER, QStringLiteral("gender")},
299 {MODEL_KEY::ADR, QStringLiteral("adr")},
300 {MODEL_KEY::ADR_2, QStringLiteral("adr2")},
301 {MODEL_KEY::ADR_3, QStringLiteral("adr3")},
302 {MODEL_KEY::EMAIL, QStringLiteral("email")},
303 {MODEL_KEY::EMAIL_2, QStringLiteral("email2")},
304 {MODEL_KEY::EMAIL_3, QStringLiteral("email3")},
305 {MODEL_KEY::LANG, QStringLiteral("lang")},
306 {MODEL_KEY::NICKNAME, QStringLiteral("nickname")},
307 {MODEL_KEY::ORG, QStringLiteral("org")},
308 {MODEL_KEY::PROFILE, QStringLiteral("profile")},
309 {MODEL_KEY::TZ, QStringLiteral("tz")},
310 {MODEL_KEY::TEL, QStringLiteral("tel")},
311 {MODEL_KEY::TEL_2, QStringLiteral("tel2")},
312 {MODEL_KEY::TEL_3, QStringLiteral("tel3")},
313
314 {MODEL_KEY::CITY, QStringLiteral("city")},
315 {MODEL_KEY::STATE, QStringLiteral("state")},
316 {MODEL_KEY::COUNTRY, QStringLiteral("country")},
317
318 // opendesktop keys
319 {MODEL_KEY::PACKAGE_ARCH, QStringLiteral("packagearch")},
320 {MODEL_KEY::PACKAGE_TYPE, QStringLiteral("packagetype")},
321 {MODEL_KEY::GPG_FINGERPRINT, QStringLiteral("gpgfingerprint")},
322 {MODEL_KEY::GPG_SIGNATURE, QStringLiteral("gpgsignature")},
323 {MODEL_KEY::PACKAGE_NAME, QStringLiteral("packagename")},
324 {MODEL_KEY::PRICE, QStringLiteral("price")},
325 {MODEL_KEY::REPOSITORY, QStringLiteral("repository")},
326 {MODEL_KEY::TAGS, QStringLiteral("tags")},
327 {MODEL_KEY::WAY, QStringLiteral("way")},
328 {MODEL_KEY::PIC, QStringLiteral("pic")},
329 {MODEL_KEY::SMALL_PIC, QStringLiteral("smallpic")},
330 {MODEL_KEY::CHANGED, QStringLiteral("changed")},
331 {MODEL_KEY::COMMENTS, QStringLiteral("comments")},
332 {MODEL_KEY::CREATED, QStringLiteral("created")},
333 {MODEL_KEY::DETAIL_PAGE, QStringLiteral("detailpage")},
334 {MODEL_KEY::DETAILS, QStringLiteral("details")},
335 {MODEL_KEY::TOTAL_DOWNLOADS, QStringLiteral("totaldownloads")},
336 {MODEL_KEY::GHNS_EXCLUDED, QStringLiteral("ghnsexcluded")},
337 {MODEL_KEY::LANGUAGE, QStringLiteral("language")},
338 {MODEL_KEY::SCORE, QStringLiteral("score")},
339 {MODEL_KEY::SUMMARY, QStringLiteral("summary")},
340 {MODEL_KEY::TYPE_ID, QStringLiteral("typeid")},
341 {MODEL_KEY::TYPE_NAME, QStringLiteral("typename")},
342 {MODEL_KEY::XDG_TYPE, QStringLiteral("xdgtype")},
343
344 // file props
345 {MODEL_KEY::SYMLINK, QStringLiteral("symlink")},
346 {MODEL_KEY::IS_SYMLINK, QStringLiteral("issymlink")},
347 {MODEL_KEY::LAST_READ, QStringLiteral("lastread")},
348 {MODEL_KEY::READABLE, QStringLiteral("readable")},
349 {MODEL_KEY::WRITABLE, QStringLiteral("writeable")},
350 {MODEL_KEY::IS_DIR, QStringLiteral("isdir")},
351 {MODEL_KEY::IS_FILE, QStringLiteral("isfile")},
352 {MODEL_KEY::IS_REMOTE, QStringLiteral("isremote")},
353 {MODEL_KEY::EXECUTABLE, QStringLiteral("executable")},
354 {MODEL_KEY::VALUE, QStringLiteral("value")},
355 {MODEL_KEY::KEY, QStringLiteral("key")},
356
357 {MODEL_KEY::MAC, QStringLiteral("mac")},
358 {MODEL_KEY::LOT, QStringLiteral("lot")},
359 {MODEL_KEY::APP, QStringLiteral("app")},
360 {MODEL_KEY::URI, QStringLiteral("uri")},
361 {MODEL_KEY::DEVICE, QStringLiteral("device")},
362 {MODEL_KEY::UDI, QStringLiteral("udi")},
363 {MODEL_KEY::LASTSYNC, QStringLiteral("lastsync")},
364 {MODEL_KEY::LATITUDE, QStringLiteral("latitude")},
365 {MODEL_KEY::BRANCH, QStringLiteral("branch")},
366 {MODEL_KEY::MESSAGE, QStringLiteral("message")},
367 {MODEL_KEY::AUTHOR, QStringLiteral("author")},
368 {MODEL_KEY::UPDATABLE, QStringLiteral("updatable")},
369 {MODEL_KEY::LONGITUDE, QStringLiteral("lastsync")}};
370
371/**
372 * @brief The mapping of a string text into a FMH::MODEL_KEY.
373 * For example, `"label"` is mapped to `FMH::MODEL_KEY::LABEL`.
374 * @code
375 * FMH::MODEL_KEY key = FMH::MODEL_NAME_KEY["label"]; //resulting in FMH::MODEL_KEY::LABEL
376 * @endcode
377 */
378static const QHash<QString, MODEL_KEY> MODEL_NAME_KEY = {{MODEL_NAME[MODEL_KEY::ICON], MODEL_KEY::ICON},
379 {MODEL_NAME[MODEL_KEY::LABEL], MODEL_KEY::LABEL},
380 {MODEL_NAME[MODEL_KEY::PATH], MODEL_KEY::PATH},
381 {MODEL_NAME[MODEL_KEY::URL], MODEL_KEY::URL},
382 {MODEL_NAME[MODEL_KEY::TYPE], MODEL_KEY::TYPE},
383 {MODEL_NAME[MODEL_KEY::GROUP], MODEL_KEY::GROUP},
384 {MODEL_NAME[MODEL_KEY::OWNER], MODEL_KEY::OWNER},
385 {MODEL_NAME[MODEL_KEY::SUFFIX], MODEL_KEY::SUFFIX},
386 {MODEL_NAME[MODEL_KEY::NAME], MODEL_KEY::NAME},
387 {MODEL_NAME[MODEL_KEY::DATE], MODEL_KEY::DATE},
388 {MODEL_NAME[MODEL_KEY::MODIFIED], MODEL_KEY::MODIFIED},
389 {MODEL_NAME[MODEL_KEY::MIME], MODEL_KEY::MIME},
390 {MODEL_NAME[MODEL_KEY::SIZE], MODEL_KEY::SIZE},
391 {MODEL_NAME[MODEL_KEY::TAG], MODEL_KEY::TAG},
392 {MODEL_NAME[MODEL_KEY::PERMISSIONS], MODEL_KEY::PERMISSIONS},
393 {MODEL_NAME[MODEL_KEY::THUMBNAIL], MODEL_KEY::THUMBNAIL},
394 {MODEL_NAME[MODEL_KEY::THUMBNAIL_1], MODEL_KEY::THUMBNAIL_1},
395 {MODEL_NAME[MODEL_KEY::THUMBNAIL_2], MODEL_KEY::THUMBNAIL_2},
396 {MODEL_NAME[MODEL_KEY::THUMBNAIL_3], MODEL_KEY::THUMBNAIL_3},
397 {MODEL_NAME[MODEL_KEY::ICONSIZE], MODEL_KEY::ICONSIZE},
398 {MODEL_NAME[MODEL_KEY::HIDDEN], MODEL_KEY::HIDDEN},
399 {MODEL_NAME[MODEL_KEY::DETAILVIEW], MODEL_KEY::DETAILVIEW},
400 {MODEL_NAME[MODEL_KEY::SHOWTERMINAL], MODEL_KEY::SHOWTERMINAL},
401 {MODEL_NAME[MODEL_KEY::SHOWTHUMBNAIL], MODEL_KEY::SHOWTHUMBNAIL},
402 {MODEL_NAME[MODEL_KEY::COUNT], MODEL_KEY::COUNT},
403 {MODEL_NAME[MODEL_KEY::SORTBY], MODEL_KEY::SORTBY},
404 {MODEL_NAME[MODEL_KEY::USER], MODEL_KEY::USER},
405 {MODEL_NAME[MODEL_KEY::PASSWORD], MODEL_KEY::PASSWORD},
406 {MODEL_NAME[MODEL_KEY::SERVER], MODEL_KEY::SERVER},
407 {MODEL_NAME[MODEL_KEY::VIEWTYPE], MODEL_KEY::VIEWTYPE},
408 {MODEL_NAME[MODEL_KEY::ADDDATE], MODEL_KEY::ADDDATE},
409 {MODEL_NAME[MODEL_KEY::FAV], MODEL_KEY::FAV},
410 {MODEL_NAME[MODEL_KEY::FAVORITE], MODEL_KEY::FAVORITE},
411 {MODEL_NAME[MODEL_KEY::COLOR], MODEL_KEY::COLOR},
412 {MODEL_NAME[MODEL_KEY::RATE], MODEL_KEY::RATE},
413 {MODEL_NAME[MODEL_KEY::FORMAT], MODEL_KEY::FORMAT},
414 {MODEL_NAME[MODEL_KEY::PLACE], MODEL_KEY::PLACE},
415 {MODEL_NAME[MODEL_KEY::LOCATION], MODEL_KEY::LOCATION},
416 {MODEL_NAME[MODEL_KEY::ALBUM], MODEL_KEY::ALBUM},
417 {MODEL_NAME[MODEL_KEY::ARTIST], MODEL_KEY::ARTIST},
418 {MODEL_NAME[MODEL_KEY::DURATION], MODEL_KEY::DURATION},
419 {MODEL_NAME[MODEL_KEY::TRACK], MODEL_KEY::TRACK},
420 {MODEL_NAME[MODEL_KEY::GENRE], MODEL_KEY::GENRE},
421 {MODEL_NAME[MODEL_KEY::LYRICS], MODEL_KEY::LYRICS},
422 {MODEL_NAME[MODEL_KEY::RELEASEDATE], MODEL_KEY::RELEASEDATE},
423 {MODEL_NAME[MODEL_KEY::FORMAT], MODEL_KEY::FORMAT},
424 {MODEL_NAME[MODEL_KEY::WIKI], MODEL_KEY::WIKI},
425 {MODEL_NAME[MODEL_KEY::SOURCETYPE], MODEL_KEY::SOURCETYPE},
426 {MODEL_NAME[MODEL_KEY::ARTWORK], MODEL_KEY::ARTWORK},
427 {MODEL_NAME[MODEL_KEY::NOTE], MODEL_KEY::NOTE},
428 {MODEL_NAME[MODEL_KEY::MOOD], MODEL_KEY::MOOD},
429 {MODEL_NAME[MODEL_KEY::COMMENT], MODEL_KEY::COMMENT},
430 {MODEL_NAME[MODEL_KEY::CONTEXT], MODEL_KEY::CONTEXT},
431 {MODEL_NAME[MODEL_KEY::SOURCE], MODEL_KEY::SOURCE},
432 {MODEL_NAME[MODEL_KEY::PLAYLIST], MODEL_KEY::PLAYLIST},
433 {MODEL_NAME[MODEL_KEY::TITLE], MODEL_KEY::TITLE},
434 {MODEL_NAME[MODEL_KEY::ID], MODEL_KEY::ID},
435 {MODEL_NAME[MODEL_KEY::PARENT_ID], MODEL_KEY::PARENT_ID},
436 {MODEL_NAME[MODEL_KEY::LICENSE], MODEL_KEY::LICENSE},
437 {MODEL_NAME[MODEL_KEY::DESCRIPTION], MODEL_KEY::DESCRIPTION},
438 {MODEL_NAME[MODEL_KEY::BOOKMARK], MODEL_KEY::BOOKMARK},
439 {MODEL_NAME[MODEL_KEY::ACCOUNT], MODEL_KEY::ACCOUNT},
440 {MODEL_NAME[MODEL_KEY::ACCOUNTTYPE], MODEL_KEY::ACCOUNTTYPE},
441 {MODEL_NAME[MODEL_KEY::VERSION], MODEL_KEY::VERSION},
442 {MODEL_NAME[MODEL_KEY::DOMAIN_M], MODEL_KEY::DOMAIN_M},
443 {MODEL_NAME[MODEL_KEY::CATEGORY], MODEL_KEY::CATEGORY},
444 {MODEL_NAME[MODEL_KEY::CONTENT], MODEL_KEY::CONTENT},
445 {MODEL_NAME[MODEL_KEY::PIN], MODEL_KEY::PIN},
446 {MODEL_NAME[MODEL_KEY::IMG], MODEL_KEY::IMG},
447 {MODEL_NAME[MODEL_KEY::PREVIEW], MODEL_KEY::PREVIEW},
448 {MODEL_NAME[MODEL_KEY::LINK], MODEL_KEY::LINK},
449 {MODEL_NAME[MODEL_KEY::STAMP], MODEL_KEY::STAMP},
450 {MODEL_NAME[MODEL_KEY::BOOK], MODEL_KEY::BOOK},
451
452 /** ccdav keys **/
453 {MODEL_NAME[MODEL_KEY::N], MODEL_KEY::N},
454 {MODEL_NAME[MODEL_KEY::IM], MODEL_KEY::IM},
455 {MODEL_NAME[MODEL_KEY::PHOTO], MODEL_KEY::PHOTO},
456 {MODEL_NAME[MODEL_KEY::GENDER], MODEL_KEY::GENDER},
457 {MODEL_NAME[MODEL_KEY::ADR], MODEL_KEY::ADR},
458 {MODEL_NAME[MODEL_KEY::ADR_2], MODEL_KEY::ADR_2},
459 {MODEL_NAME[MODEL_KEY::ADR_3], MODEL_KEY::ADR_3},
460 {MODEL_NAME[MODEL_KEY::EMAIL], MODEL_KEY::EMAIL},
461 {MODEL_NAME[MODEL_KEY::EMAIL_2], MODEL_KEY::EMAIL_2},
462 {MODEL_NAME[MODEL_KEY::EMAIL_3], MODEL_KEY::EMAIL_3},
463 {MODEL_NAME[MODEL_KEY::LANG], MODEL_KEY::LANG},
464 {MODEL_NAME[MODEL_KEY::NICKNAME], MODEL_KEY::NICKNAME},
465 {MODEL_NAME[MODEL_KEY::ORG], MODEL_KEY::ORG},
466 {MODEL_NAME[MODEL_KEY::PROFILE], MODEL_KEY::PROFILE},
467 {MODEL_NAME[MODEL_KEY::TZ], MODEL_KEY::TZ},
468 {MODEL_NAME[MODEL_KEY::TEL], MODEL_KEY::TEL},
469 {MODEL_NAME[MODEL_KEY::TEL_2], MODEL_KEY::TEL_2},
470 {MODEL_NAME[MODEL_KEY::TEL_3], MODEL_KEY::TEL_3},
471
472 {MODEL_NAME[MODEL_KEY::CITY], MODEL_KEY::CITY},
473 {MODEL_NAME[MODEL_KEY::STATE], MODEL_KEY::STATE},
474 {MODEL_NAME[MODEL_KEY::COUNTRY], MODEL_KEY::COUNTRY},
475
476 // opendesktop store keys
477 {MODEL_NAME[MODEL_KEY::PACKAGE_ARCH], MODEL_KEY::PACKAGE_ARCH},
478 {MODEL_NAME[MODEL_KEY::PACKAGE_TYPE], MODEL_KEY::PACKAGE_TYPE},
479 {MODEL_NAME[MODEL_KEY::GPG_FINGERPRINT], MODEL_KEY::GPG_FINGERPRINT},
480 {MODEL_NAME[MODEL_KEY::GPG_SIGNATURE], MODEL_KEY::GPG_SIGNATURE},
481 {MODEL_NAME[MODEL_KEY::PACKAGE_NAME], MODEL_KEY::PACKAGE_NAME},
482 {MODEL_NAME[MODEL_KEY::PRICE], MODEL_KEY::PRICE},
483 {MODEL_NAME[MODEL_KEY::REPOSITORY], MODEL_KEY::REPOSITORY},
484 {MODEL_NAME[MODEL_KEY::TAGS], MODEL_KEY::TAGS},
485 {MODEL_NAME[MODEL_KEY::WAY], MODEL_KEY::WAY},
486 {MODEL_NAME[MODEL_KEY::PIC], MODEL_KEY::PIC},
487 {MODEL_NAME[MODEL_KEY::SMALL_PIC], MODEL_KEY::SMALL_PIC},
488 {MODEL_NAME[MODEL_KEY::CHANGED], MODEL_KEY::CHANGED},
489 {MODEL_NAME[MODEL_KEY::COMMENTS], MODEL_KEY::COMMENTS},
490 {MODEL_NAME[MODEL_KEY::CREATED], MODEL_KEY::CREATED},
491 {MODEL_NAME[MODEL_KEY::DETAIL_PAGE], MODEL_KEY::DETAIL_PAGE},
492 {MODEL_NAME[MODEL_KEY::DETAILS], MODEL_KEY::DETAILS},
493 {MODEL_NAME[MODEL_KEY::TOTAL_DOWNLOADS], MODEL_KEY::TOTAL_DOWNLOADS},
494 {MODEL_NAME[MODEL_KEY::GHNS_EXCLUDED], MODEL_KEY::GHNS_EXCLUDED},
495 {MODEL_NAME[MODEL_KEY::LANGUAGE], MODEL_KEY::LANGUAGE},
496 {MODEL_NAME[MODEL_KEY::PERSON_ID], MODEL_KEY::PERSON_ID},
497 {MODEL_NAME[MODEL_KEY::SCORE], MODEL_KEY::SCORE},
498 {MODEL_NAME[MODEL_KEY::SUMMARY], MODEL_KEY::SUMMARY},
499 {MODEL_NAME[MODEL_KEY::TYPE_ID], MODEL_KEY::TYPE_ID},
500 {MODEL_NAME[MODEL_KEY::TYPE_NAME], MODEL_KEY::TYPE_NAME},
501 {MODEL_NAME[MODEL_KEY::XDG_TYPE], MODEL_KEY::XDG_TYPE},
502
503 // file props
504 {MODEL_NAME[MODEL_KEY::SYMLINK], MODEL_KEY::SYMLINK},
505 {MODEL_NAME[MODEL_KEY::IS_SYMLINK], MODEL_KEY::IS_SYMLINK},
506 {MODEL_NAME[MODEL_KEY::LAST_READ], MODEL_KEY::LAST_READ},
507 {MODEL_NAME[MODEL_KEY::READABLE], MODEL_KEY::READABLE},
508 {MODEL_NAME[MODEL_KEY::WRITABLE], MODEL_KEY::WRITABLE},
509 {MODEL_NAME[MODEL_KEY::IS_DIR], MODEL_KEY::IS_DIR},
510 {MODEL_NAME[MODEL_KEY::IS_FILE], MODEL_KEY::IS_FILE},
511 {MODEL_NAME[MODEL_KEY::IS_REMOTE], MODEL_KEY::IS_REMOTE},
512 {MODEL_NAME[MODEL_KEY::EXECUTABLE], MODEL_KEY::EXECUTABLE},
513 {MODEL_NAME[MODEL_KEY::VALUE], MODEL_KEY::VALUE},
514 {MODEL_NAME[MODEL_KEY::KEY], MODEL_KEY::KEY},
515
516 {MODEL_NAME[MODEL_KEY::MAC], MODEL_KEY::MAC},
517 {MODEL_NAME[MODEL_KEY::LOT], MODEL_KEY::LOT},
518 {MODEL_NAME[MODEL_KEY::APP], MODEL_KEY::APP},
519 {MODEL_NAME[MODEL_KEY::URI], MODEL_KEY::URI},
520 {MODEL_NAME[MODEL_KEY::DEVICE], MODEL_KEY::DEVICE},
521 {MODEL_NAME[MODEL_KEY::UDI], MODEL_KEY::UDI},
522 {MODEL_NAME[MODEL_KEY::LASTSYNC], MODEL_KEY::LASTSYNC},
523 {MODEL_NAME[MODEL_KEY::LATITUDE], MODEL_KEY::LATITUDE},
524 {MODEL_NAME[MODEL_KEY::LONGITUDE], MODEL_KEY::LONGITUDE},
525 {MODEL_NAME[MODEL_KEY::MESSAGE], MODEL_KEY::MESSAGE},
526 {MODEL_NAME[MODEL_KEY::AUTHOR], MODEL_KEY::AUTHOR},
527 {MODEL_NAME[MODEL_KEY::UPDATABLE], MODEL_KEY::UPDATABLE},
528 {MODEL_NAME[MODEL_KEY::BRANCH], MODEL_KEY::BRANCH}};
529 /**
530 * @brief The key-value pair model structure, where the values are strings. This is just a tydef to `QHash<MODEL_KEY, QString>`.
531 */
533
534/**
535 * @brief An alias for a container of multiple FMH::MODEL key-value pairs.
536 */
538
539/**
540 * @brief Given a FMH::MODEL, this function will extract all the FMH::MODEL_KEY values used as the keys/roles.
541 * @param model the given key-value pair model
542 * @return A list of keys/roles in the given model
543 */
544const QVector<int> MAUIKIT_EXPORT modelRoles(const MODEL &model);
545
546/**
547 * @brief Extracts a value associated with that given FMH::MODEL_KEY key in a map.
548 * @param map the map with the data
549 * @param key the key to look for in the map
550 * @return if found, the string value is returned, otherwise an empty string.
551 */
552const QString MAUIKIT_EXPORT mapValue(const QVariantMap &map, const MODEL_KEY &key);
553
554/**
555 * @brief Converts a FMH::MODEL object to a QVariantMap.
556 * This is basically doing a convertion from `QHash<MODEL_KEY, QString>` to a `QMap<QString, QString>`.
557 * @param model the data model to convert
558 * @return a new QVariantMap
559 */
560const QVariantMap MAUIKIT_EXPORT toMap(const MODEL &model);
561
562/**
563 * @brief Converts a QVariantMap to a FMH::MODEl.
564 * @note For this to be successful, the original map keys should be mappable in the FMH::MODEL_NAME.
565 * @param map the map to be converted
566 * @return the resulting FMH::MODEL if all the keys in the original map were successfully mapped.
567 */
568const MODEL MAUIKIT_EXPORT toModel(const QVariantMap &map);
569
570/**
571 * @brief Creates a FMH::MODEL_LIST from a QVariantList
572 * @param list
573 * @note For this to be successful, the original map keys - in the list - should be mappable in the FMH::MODEL_NAME.
574 * @return the resulting FMH::MODEL_LIST
575 */
576const MODEL_LIST MAUIKIT_EXPORT toModelList(const QVariantList &list);
577
578/**
579 * @brief Creates a QVariantList from a MODEL_LIST
580 * @param list
581 * @return
582 */
583const QVariantList MAUIKIT_EXPORT toMapList(const MODEL_LIST &list);
584
585/**
586 * @brief Creates a new MODEL from another by filtering in the given array of MODEL_KEY
587 * @param model the source model used to filter
588 * @param keys the keys of the values to be filtered-in
589 * @return a new FMH::MODEL with the values filtered from the original model source
590 */
591const MODEL MAUIKIT_EXPORT filterModel(const MODEL &model, const QVector<MODEL_KEY> &keys);
592
593/**
594 * @brief Extracts from a MODEL_LIST the values from a given MODEL::KEY into a QStringList
595 * @param list the source list of model pairs
596 * @param key the keys to use to extract the values
597 * @return a list of the values extracted
598 */
599const QStringList MAUIKIT_EXPORT modelToList(const MODEL_LIST &list, const MODEL_KEY &key);
600
601/**
602 * @brief Checks if a local file exists.
603 * @param path the URL must represent a local file path, by using the scheme file://
604 * @return whether the files exists
605 */
606bool MAUIKIT_EXPORT fileExists(const QUrl &path);
607}
A set of helpers for managing the key-value model data type.
Definition fmh.cpp:7
const FMH::MODEL filterModel(const FMH::MODEL &model, const QVector< FMH::MODEL_KEY > &keys)
Creates a new MODEL from another by filtering in the given array of MODEL_KEY.
Definition fmh.cpp:64
static const QHash< QString, MODEL_KEY > MODEL_NAME_KEY
The mapping of a string text into a FMH::MODEL_KEY.
Definition fmh.h:378
const QVariantList toMapList(const FMH::MODEL_LIST &list)
Creates a QVariantList from a MODEL_LIST.
Definition fmh.cpp:55
const QString mapValue(const QVariantMap &map, const FMH::MODEL_KEY &key)
Extracts a value associated with that given FMH::MODEL_KEY key in a map.
Definition fmh.cpp:17
bool isLinux()
Whether the platform running is GNU/Linux.
Definition fmh.cpp:104
const QVector< int > modelRoles(const FMH::MODEL &model)
Given a FMH::MODEL, this function will extract all the FMH::MODEL_KEY values used as the keys/roles.
Definition fmh.cpp:8
const FMH::MODEL_LIST toModelList(const QVariantList &list)
Creates a FMH::MODEL_LIST from a QVariantList.
Definition fmh.cpp:46
bool isIOS()
Whether the platform running is IOS.
Definition fmh.cpp:124
const QStringList modelToList(const FMH::MODEL_LIST &list, const FMH::MODEL_KEY &key)
Extracts from a MODEL_LIST the values from a given MODEL::KEY into a QStringList.
Definition fmh.cpp:74
QVector< MODEL > MODEL_LIST
An alias for a container of multiple FMH::MODEL key-value pairs.
Definition fmh.h:537
bool fileExists(const QUrl &path)
Checks if a local file exists.
Definition fmh.cpp:133
static const QHash< MODEL_KEY, QString > MODEL_NAME
The mapping of the FMH::MODEL_KEY enum values to its string representation.
Definition fmh.h:219
QHash< MODEL_KEY, QString > MODEL
The key-value pair model structure, where the values are strings.
Definition fmh.h:532
MODEL_KEY
The MODEL_KEY enum values.
Definition fmh.h:64
bool isWindows()
Whether the platform running is Window.
Definition fmh.cpp:93
const FMH::MODEL toModel(const QVariantMap &map)
Converts a QVariantMap to a FMH::MODEl.
Definition fmh.cpp:34
const QVariantMap toMap(const FMH::MODEL &model)
Converts a FMH::MODEL object to a QVariantMap.
Definition fmh.cpp:22
bool isMac()
Whether the platform running is Mac.
Definition fmh.cpp:113
bool isAndroid()
Whether the platform running is Android.
Definition fmh.cpp:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:42:41 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.