| 1 | /* |
| 2 | This file is part of the Nepomuk KDE project. |
| 3 | SPDX-FileCopyrightText: 2010 Sebastian Trueg <trueg@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef BALOO_TIMELINE_TOOLS_H_ |
| 9 | #define BALOO_TIMELINE_TOOLS_H_ |
| 10 | |
| 11 | class QString; |
| 12 | |
| 13 | #include <QDate> |
| 14 | #include <QUrl> |
| 15 | |
| 16 | namespace Baloo |
| 17 | { |
| 18 | /** |
| 19 | * The hierarchy in timeline:/ looks as follows: |
| 20 | * |
| 21 | * / |
| 22 | * |- /today |
| 23 | * | |
| 24 | * |- /calendar |
| 25 | * | |- /calendar/2010 |
| 26 | * | |- /calendar/2010/january |
| 27 | * | |- /calendar/2010/january/2010-01-01 |
| 28 | * | |- /calendar/2009 |
| 29 | * | |
| 30 | * |- /months |
| 31 | * | |- /month/2010 |
| 32 | * | |- /months/2010/january |
| 33 | * | |
| 34 | * |- /weeks |
| 35 | */ |
| 36 | enum TimelineFolderType { |
| 37 | NoFolder = 0, /// nothing |
| 38 | RootFolder, /// the root folder |
| 39 | CalendarFolder, /// the calendar folder listing all months |
| 40 | MonthFolder, /// a folder listing a month's days (m_date contains the month) |
| 41 | DayFolder, /// a folder listing a day (m_date); optionally m_filename is set |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * Parse a timeline URL like timeline:/today and return the type of folder it |
| 46 | * represents. If DayFolder is returned \p date is set to the date that should be listed. |
| 47 | * Otherwise it is an invalid date. \p filename is optionally set to the name of the file |
| 48 | * in the folder. |
| 49 | */ |
| 50 | TimelineFolderType parseTimelineUrl(const QUrl& url, QDate* date, QString* filename = nullptr); |
| 51 | |
| 52 | /** |
| 53 | * Remove any double slashes, remove any trailing slashes, and |
| 54 | * add an initial slash after the scheme. |
| 55 | */ |
| 56 | QUrl canonicalizeTimelineUrl(const QUrl& url); |
| 57 | |
| 58 | } |
| 59 | |
| 60 | #endif |
| 61 | |