swift
dbloadoverviewcomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_DBLOADOVERVIEWCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_DBLOADOVERVIEWCOMPONENT_H
8 
9 #include <QFrame>
10 #include <QScopedPointer>
11 
12 #include "gui/loadindicator.h"
13 #include "gui/swiftguiexport.h"
14 #include "misc/digestsignal.h"
16 
17 namespace Ui
18 {
19  class CDbLoadOverviewComponent;
20 }
21 namespace swift::gui::components
22 {
27  {
28  Q_OBJECT
29 
30  public:
32  explicit CDbLoadOverviewComponent(QWidget *parent = nullptr);
33 
35  virtual ~CDbLoadOverviewComponent() override;
36 
38  void display();
39 
41  void showVisibleDbRefreshButtons(bool visible);
42 
44  void showVisibleSharedRefreshButtons(bool visible);
45 
47  void showVisibleLoadAllButtons(bool shared, bool db, bool disk);
48 
50  void loadAllFromDb();
51 
53  void loadAllFromShared();
54 
56  void loadAllFromResourceFiles();
57 
59  bool isLoadInProgress() const { return m_loadInProgress; }
60 
61  protected:
63  virtual void resizeEvent(QResizeEvent *event) override;
64 
65  private:
66  QScopedPointer<Ui::CDbLoadOverviewComponent> ui;
67  swift::misc::CDigestSignal m_dsTriggerGuiUpdate { this, &CDbLoadOverviewComponent::setGuiValues,
68  std::chrono::milliseconds(2500), 5 };
69  qint64 m_sharedLastCheck = -1;
70  bool m_sharedValueCheckInProgress = false;
72  const QString m_imgOk = ":/diagona/icons/diagona/icons/tick.png";
73  const QString m_imgFailed = ":/diagona/icons/diagona/icons/cross-script.png";
74 
76  void triggerLoadingFromDb(swift::misc::network::CEntityFlags::Entity entities);
77 
79  void triggerLoadingFromSharedFiles(swift::misc::network::CEntityFlags::Entity entities);
80 
82  bool isInitialized() const;
83 
85  void refreshDbPressed();
86 
88  void refreshSharedPressed();
89 
91  void setGuiValues();
92 
94  void setSharedUrlValues();
95 
97  void dataLoaded(swift::misc::network::CEntityFlags::Entity entities,
98  swift::misc::network::CEntityFlags::ReadState state, int number, const QUrl &url);
99 
101  void loadInfoObjects();
102 
104  void adjustTextWidth();
105 
107  static QString formattedTimestamp(const QDateTime &dateTime);
108 
110  static QString cacheTimestampForEntity(swift::misc::network::CEntityFlags::Entity entity);
111 
113  static QString cacheCountForEntity(swift::misc::network::CEntityFlags::Entity entity);
114 
116  static QString dbTimestampForEntity(swift::misc::network::CEntityFlags::Entity entity);
117 
119  static QString dbCountForEntity(swift::misc::network::CEntityFlags::Entity entity);
120 
122  static QString sharedFileTimestampForEntity(swift::misc::network::CEntityFlags::Entity entity);
123 
125  static QString sharedCountForEntity(swift::misc::network::CEntityFlags::Entity entity);
126 
128  static void admitCaches();
129  };
130 } // namespace swift::gui::components
131 #endif // SWIFT_GUI_COMPONENTS_DBLOADOVERVIEWCOMPONENT_H
Enable widget class for load indicator.
bool isLoadInProgress() const
Is loading in progress.
Receive 1..n signals, collect them over time, and resend afer n milliseconds.
Definition: digestsignal.h:18
High level reusable GUI components.
Definition: aboutdialog.cpp:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.