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

KDE's Doxygen guidelines are available online.