KIO

krecentdocument.h
1/* -*- c++ -*-
2 SPDX-FileCopyrightText: 2000 Daniel M. Duley <mosfet@kde.org>
3 SPDX-FileCopyrightText: 2022 Méven Car <meven.car@kdemail.net>
4
5 SPDX-License-Identifier: BSD-2-Clause
6*/
7
8#ifndef __KRECENTDOCUMENT_H
9#define __KRECENTDOCUMENT_H
10
11#include "kiocore_export.h"
12
13#include <QDateTime>
14#include <QString>
15#include <QUrl>
16
17/**
18 * @class KRecentDocument krecentdocument.h <KRecentDocument>
19 *
20 * Manage the "Recent Document Menu" entries displayed by
21 * applications such as Kicker and Konqueror.
22 *
23 * These entries are automatically generated .desktop files pointing
24 * to the current application and document. You should call the
25 * static add() method whenever the user opens or saves a new
26 * document if you want it to show up in the menu.
27 *
28 * It also stores history following xdg specification.
29 * Ref: https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec
30 * This allows cross-framework file history sharing.
31 * I.e Gtk Apps can access files recently opened by KDE Apps.
32 *
33 * You don't have to worry about this if you are using
34 * QFileDialog to open and save documents, as the KDE implementation
35 * (KFileWidget) already calls this class. User defined limits on the maximum
36 * number of documents to save, etc... are all automatically handled.
37 *
38 * @author Daniel M. Duley <mosfet@kde.org>
39 * @author Méven Car <meven.car@kdemail.net>
40 */
41class KIOCORE_EXPORT KRecentDocument
42{
43public:
44 /*
45 * Usage group for a file to bookmark in recently-used.xbel file
46 *
47 * from spec https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec/#appendixb:registeredgroupnames
48 * @since 5.93
49 */
50 enum RecentDocumentGroup {
51 Development, // A bookmark related to a development environment
52 Office, // A bookmark related to an office type document or folder
53 Database, // A bookmark related to a database application; Office; relates to Development
54 Email, // A bookmark related to an email application relates to Office
55 Presentation, // A bookmark related to a presentation application relates to Office
56 Spreadsheet, // A bookmark related to a spreadsheet application relates to Office
57 WordProcessor, // A bookmark related to a word processing application relates to Office
58 Graphics, // A bookmark related to a graphical application
59 TextEditor, // A bookmark related to a text editor
60 Viewer, // A bookmark related to any kind of file viewer
61 Archive, // A bookmark related to an archive file
62 Multimedia, // A bookmark related to a multimedia file or application
63 Audio, // A bookmark related to an audio file or application relates to Multimedia
64 Video, // A bookmark related to a video file or application relates to Multimedia
65 Photo, // A bookmark related to a digital photography file or application relates to Multimedia; Graphics; Viewer
66 Application, // Special bookmark for application launchers
67 };
68
70
71 /**
72 *
73 * Return a list of recent URLs. This includes all the URLs from
74 * recentDocuments() as well as URLs from other applications conforming to
75 * the XDG desktop-bookmark-spec (e. g. the GTK file dialog).
76 *
77 * @since 5.93
78 */
79 static QList<QUrl> recentUrls();
80
81 /**
82 * Add a new item to the Recent Document menu.
83 *
84 * @param url The url to add.
85 */
86 static void add(const QUrl &url);
87 /// @since 5.93
88 static void add(const QUrl &url, KRecentDocument::RecentDocumentGroups groups);
89
90 /**
91 * Add a new item to the Recent Document menu, specifying the application to open it with.
92 * The above add() method uses QCoreApplication::applicationName() for the app name,
93 * which isn't always flexible enough.
94 * This method is used when an application launches another one to open a document.
95 *
96 * @param url The url to add.
97 * @param desktopEntryName The desktopEntryName of the service to use for opening this document.
98 */
99 static void add(const QUrl &url, const QString &desktopEntryName);
100 /// @since 5.93
101 static void add(const QUrl &url, const QString &desktopEntryName, KRecentDocument::RecentDocumentGroups groups);
102
103 static bool clearEntriesOldestEntries(int maxEntries);
104
105 /// @since 6.6
106 static void removeFile(const QUrl &url);
107 /// @since 6.6
108 static void removeApplication(const QString &desktopEntryName);
109 /**
110 * Remove bookmarks whose modification date is after since parameter.
111 *
112 * @since 6.6
113 */
114 static void removeBookmarksModifiedSince(const QDateTime &since);
115 /**
116 * Clear the recent document menu of all entries.
117 */
118 static void clear();
119
120 /**
121 * Returns the maximum amount of recent document entries allowed.
122 */
123 static int maximumItems();
124};
125
126#endif
Manage the "Recent Document Menu" entries displayed by applications such as Kicker and Konqueror.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:11:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.