Messagelib

compositememento.h
1 /*
2  SPDX-FileCopyrightText: 2023 Daniel Vr├ítil <dvratil@kde.org>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "cryptobodypartmemento.h"
10 
11 #include <memory>
12 #include <type_traits>
13 
14 namespace MimeTreeParser
15 {
16 
17 class CompositeMemento : public CryptoBodyPartMemento
18 {
19  Q_OBJECT
20 public:
21  explicit CompositeMemento() = default;
22  ~CompositeMemento() override;
23 
24  bool start() override;
25  void exec() override;
26 
27  void addMemento(CryptoBodyPartMemento *memento);
28 
29  QVector<CryptoBodyPartMemento *> mementos() const
30  {
31  return mMementos;
32  }
33 
34  auto size() const
35  {
36  return mMementos.size();
37  }
38 
39  template<typename T>
40  T *memento() const
41  {
42  auto it = std::find_if(mMementos.begin(), mMementos.end(), [](auto *memento) {
43  return qobject_cast<std::decay_t<T> *>(memento) != nullptr;
44  });
45  if (it != mMementos.cend()) {
46  return static_cast<T *>(*it);
47  }
48 
49  return nullptr;
50  }
51 
52 private Q_SLOTS:
53  void subMementoFinished();
54 
55 private:
57  int mRunningMementos = 0;
58 };
59 
60 } // namespace
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
Q_SCRIPTABLE Q_NOREPLY void start()
int size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.