LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
progressmanager.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QIcon>
12 #include <util/models/itemsmodel.h>
13 #include <interfaces/ijobholder.h>
14 #include "xpcconfig.h"
15 
16 namespace LC::Util
17 {
18  class ProgressManager;
19 
21  {
22  ProgressManager& Manager_;
23  QPersistentModelIndex Index_;
24  public:
25  explicit ProgressModelRow (ProgressManager&, const QModelIndex&);
26  ~ProgressModelRow ();
27 
28  void Disengage ();
29 
30  void SetDone (qint64);
31  void SetTotal (qint64);
32  void ChangeTotalBy (qint64 delta);
33  void SetState (ProcessState state, QString customText = {});
34 
35  void SetCustomData (const QVariant&);
36 
37  void operator++ ();
38  };
39 
40  class UTIL_XPC_API ProgressManager : public QObject
41  {
42  friend class ProgressModelRow;
43  public:
44  constexpr static auto CustomDataRole = MaxValue<JobHolderProcessRole> + 1;
45 
46  constexpr static auto MaxRole = CustomDataRole;
47  private:
48  struct Item
49  {
56 
58 
60  };
61  RoledItemsModel<Item> Model_;
62  public:
63  explicit ProgressManager (QObject *parent = nullptr);
64 
65  void SetGlobalData (const QVariant& data, int role);
66 
67  QAbstractItemModel& GetModel ();
68  IJobHolderRepresentationHandler_ptr CreateDefaultHandler ();
69 
70  struct Initializers
71  {
73  qint64 Total_ = 0;
74  QString CustomStateText_ {};
75  QIcon Icon_ {};
76  QVariant CustomData_ {};
77  };
78 
79  [[nodiscard]] std::unique_ptr<ProgressModelRow> AddRow (RowInfo);
80  [[nodiscard]] std::unique_ptr<ProgressModelRow> AddRow (RowInfo, Initializers);
81 
82  QVariant GetCustomData (const QModelIndex&) const;
83  };
84 }
class UTIL_XDG_API Item
Definition: itemsfinder.h:19
std::unique_ptr< IJobHolderRepresentationHandler > IJobHolderRepresentationHandler_ptr
Definition: ijobholder.h:172
constexpr int MaxValue< JobHolderProcessRole >
Definition: ijobholder.h:114
ProcessState
Definition: ijobholder.h:71
#define UTIL_XPC_API
Definition: xpcconfig.h:16