Mailcommon

folderrequester.h
1/*
2 * SPDX-FileCopyrightText: 2004 Carsten Burghardt <burghardt@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#pragma once
8
9#include "mailcommon_export.h"
10
11#include <Akonadi/Collection>
12
13#include <QWidget>
14
15class QKeyEvent;
16
17class KJob;
18namespace Akonadi
19{
20class AccountActivitiesAbstract;
21}
22
23namespace MailCommon
24{
25/**
26 * A widget that contains a QLineEdit which shows the current folder
27 * and a button that fires a FolderSelectionDialog
28 * The dialog is set to disable readonly folders by default
29 * Search folders are excluded
30 *
31 * @todo This should be cleaned up and go into libakonadi. This includes:
32 * - s/Folder/Collection/g
33 * - Use Akonadi::CollectionDialog instead of MailCommon::FolderSelectionDialog
34 * - merge that into CollectionDialog
35 * - or allow to replace the built-in dialog by your own
36 * - Allow to pass in an existing ETM, to remove the Kernel dependency
37 */
38class FolderRequesterPrivate;
39class MAILCOMMON_EXPORT FolderRequester : public QWidget
40{
41 Q_OBJECT
42
43public:
44 /**
45 * Constructor
46 * @param parent the parent widget
47 */
48 explicit FolderRequester(QWidget *parent = nullptr);
49 ~FolderRequester() override;
50
51 /**
52 * Returns the selected collection.
53 */
54 [[nodiscard]] Akonadi::Collection collection() const;
55
56 /**
57 * Presets the folder to the collection @p collection.
58 * Disable fetchcollection when not necessary @p fetchCollection
59 */
60 void setCollection(const Akonadi::Collection &collection, bool fetchCollection = true);
61
62 /**
63 * Returns @c true if there's a valid collection set on this widget.
64 */
65 [[nodiscard]] bool hasCollection() const;
66
67 /**
68 * Sets if readonly folders should be disabled.
69 * Be aware that if you disable this the user can also select the
70 * 'Local Folders' folder which has no valid folder associated
71 */
72 void setMustBeReadWrite(bool readwrite);
73
74 void setShowOutbox(bool show);
75
76 void setNotAllowToCreateNewFolder(bool notCreateNewFolder);
77
78 void setSelectFolderTitleDialog(const QString &title);
79
80 void setAccountActivities(Akonadi::AccountActivitiesAbstract *accountActivities);
81protected Q_SLOTS:
82 /**
83 * Opens the folder dialog.
84 */
85 void slotOpenDialog();
86
87 /**
88 * Updates the information we have about the current folder.
89 */
90 void slotCollectionsReceived(KJob *);
91
92Q_SIGNALS:
93 /**
94 * Emitted when the folder changed.
95 */
96 void folderChanged(const Akonadi::Collection &);
97 void invalidFolder();
98
99protected:
100 /** Capture space key to open the dialog */
101 void keyPressEvent(QKeyEvent *e) override;
102 void setCollectionFullPath(const Akonadi::Collection &col);
103
104protected:
105 std::unique_ptr<FolderRequesterPrivate> const d;
106};
107}
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:18:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.